From 4c0d54fc0eeb00cf48d59eabb79dedea56b0cc0d Mon Sep 17 00:00:00 2001 From: Junxing Zhang Date: Wed, 11 Jan 2006 23:05:51 +0000 Subject: [PATCH] stub files for Plab --- pelab/stub/Makefile | 2 +- pelab/stub/stub-pcap.c | 5 +++-- pelab/stub/stubd.c | 6 +++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pelab/stub/Makefile b/pelab/stub/Makefile index 3e23ea77b..b5f746e65 100644 --- a/pelab/stub/Makefile +++ b/pelab/stub/Makefile @@ -2,7 +2,7 @@ all: stubd stub-monitor stubd: stubd.o stub-pcap.o stub.h gcc -g -Wall -lm -lpcap stubd.o stub-pcap.o -o stubd -monitor-stub: monitor-stub.c stub.h +stub-monitor: stub-monitor.c stub.h gcc -g -Wall stub-monitor.c -o stub-monitor stubd.o: stubd.c stub.h gcc -g -Wall -c stubd.c diff --git a/pelab/stub/stub-pcap.c b/pelab/stub/stub-pcap.c index 4386d5988..d15b0e938 100644 --- a/pelab/stub/stub-pcap.c +++ b/pelab/stub/stub-pcap.c @@ -103,6 +103,7 @@ int search_sniff_rcvdb(int path_id, u_long seqnum) { void pop_sniff_rcvdb(int path_id, u_long to_seqnum){ int to_index = search_sniff_rcvdb(path_id, to_seqnum); if (to_index != -1) { + //if the packet has no payload or the last sent seqnum equals the pop number if ((sniff_rcvdb[path_id].records[to_index].seq_end==sniff_rcvdb[path_id].records[to_index].seq_start) || (sniff_rcvdb[path_id].records[to_index].seq_end-1 == to_seqnum)) { sniff_rcvdb[path_id].start = (to_index+1)%SNIFF_WINSIZE; //complete pop-up @@ -181,7 +182,7 @@ u_int16_t handle_IP(u_char *args, const struct pcap_pkthdr* pkthdr, const u_char ip_dst = ip->ip_dst.s_addr; if (flag_debug){ - //For an unknown reason, inet_ntoa returns the same string if called twice in one fprintf + //Note:inet_ntoa returns the same string if called twice in one line due to static string buffer fprintf(stdout,"IP src:%s ", inet_ntoa(ip->ip_src)); fprintf(stdout,"dst:%s hlen:%d version:%d len:%d\n",inet_ntoa(ip->ip_dst),hlen,version,len); } @@ -327,7 +328,7 @@ void init_pcap(int to_ms) { char string_filter[128]; //struct in_addr addr; - dev = "eth0"; //"vnet"; + dev = "vnet"; //"eth0"; /* ask pcap for the network address and mask of the device */ pcap_lookupnet(dev,&netp,&maskp,errbuf); diff --git a/pelab/stub/stubd.c b/pelab/stub/stubd.c index 319472339..bfb8df934 100644 --- a/pelab/stub/stubd.c +++ b/pelab/stub/stubd.c @@ -232,7 +232,11 @@ int receive_monitor(int sockfd) { memcpy(&tmpulong, nextptr, SIZEOF_LONG); destnum = ntohl(tmpulong); - //receive dest addrs + //return success if no dest addr is given + if (destnum == 0){ + return 1; + } + //otherwise, receive dest addrs if (recv_all(sockfd, buf, destnum*SIZEOF_LONG)==0) { return 0; } -- GitLab