本文整理汇总了C++中PacketHdr::getIntegerInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketHdr::getIntegerInfo方法的具体用法?C++ PacketHdr::getIntegerInfo怎么用?C++ PacketHdr::getIntegerInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketHdr
的用法示例。
在下文中一共展示了PacketHdr::getIntegerInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void *interface4(void *arg){
printf("Starting interface4 thread\n");
struct cShared *sh = (struct cShared *)arg;
cout<<"This is interface4!"<<endl;
Packet *recvPacket;
PacketHdr *hdr;
char type;
int cid;
int hid;
int hopnum;
int interface;
while(1){
// sleep(0.4);
recvPacket = sh->recv_port4->receivePacket();
if(recvPacket!=NULL){
hdr = recvPacket->accessHeader();
type = hdr->getOctet(0);
//receive update packet: [type+cid+#hops]
if(type==(char)0X02){
int k=0;
struct routing_Table *temp=new routing_Table;
struct routing_Table *ptr=NULL;
cid=hdr->getIntegerInfo(1);
hopnum=hdr->getIntegerInfo(5);
temp->CID=cid;
temp->interf=4;
temp->hopNum=hopnum;
temp->nextrow=NULL;
temp->previous=NULL;
// updated in 0903 start
// time_t t=time(0);
int t=0;
// updated in 0903 end
temp->TtoE=t+TTL;
ptr=sh->rtable;
//update the routing table
while(ptr!=NULL){
if(ptr->CID==temp->CID){
k=1;
if(ptr->hopNum >= temp->hopNum){
ptr->interf=4;
ptr->hopNum=temp->hopNum;
ptr->TtoE=temp->TtoE;
//broadcast updated packet
hdr->setIntegerInfo(hopnum+1,5);
sh->send_port2->sendPacket(recvPacket);
sh->send_port3->sendPacket(recvPacket);
sh->send_port1->sendPacket(recvPacket);
}
else if(ptr->hopNum==temp->hopNum&&ptr->interf==temp->interf){
ptr->TtoE=temp->TtoE;
}
}
ptr=ptr->nextrow;
}
if(k==0){
temp->nextrow=sh->rtable;
sh->rtable->previous=temp;
sh->rtable=temp;
//broadcast updated packet
hdr->setIntegerInfo(hopnum+1,5);
sh->send_port2->sendPacket(recvPacket);
sh->send_port3->sendPacket(recvPacket);
sh->send_port1->sendPacket(recvPacket);
}
//}
//delete ptr;
}
//receive response packet: [type+cid+hid+payload]
else if(type==(char)0x01){
int k=0;
struct pending_Table *ptr=NULL;
ptr=sh->ptable;
cid=hdr->getIntegerInfo(1);
hid=hdr->getIntegerInfo(5);
//find the path in pending table
while(ptr!=NULL){
if(ptr->rCID==cid && ptr->HID==hid){
interface=ptr->interf;
k=1;
//decided which interface should send the packet
switch(interface){
case 1:
sh->send_port1->sendPacket(recvPacket);
break;
case 2:
//.........这里部分代码省略.........