Commit 342f09eb authored by Jonathon Duerig's avatar Jonathon Duerig

Space-ified all of these files. No other edits this time.

parent ce7c9a95
......@@ -88,13 +88,13 @@ static void logPrefix(int flags, struct timeval const * timestamp)
timeptr = &now;
}
fprintf(logFile, "%f ", (double)(timeptr->tv_sec) +
((timeptr->tv_usec)/1000)/1000.0);
((timeptr->tv_usec)/1000)/1000.0);
}
fprintf(logFile, ": ");
}
void logWrite(int flags, struct timeval const * timestamp,
char const * format, ...)
char const * format, ...)
{
va_list va;
va_start(va, format);
......
......@@ -44,7 +44,7 @@ void logCleanup(void);
// act just like a normal printf call. This is where you actually
// write your message. It will be written to the logging file.
void logWrite(int flags, struct timeval const * timestamp,
char const * format, ...);
char const * format, ...);
enum LOG_TYPE
{
......
......@@ -103,8 +103,8 @@ int replace_sender_by_stub_port(unsigned long ip, unsigned short stub_port,
snddb[index].pending.is_pending = 0;
if (snddb[index].sockfd != -1)
{
FD_CLR(snddb[index].sockfd, read_fds);
close(snddb[index].sockfd);
FD_CLR(snddb[index].sockfd, read_fds);
close(snddb[index].sockfd);
}
if (sockfd > maxfd)
{
......@@ -298,7 +298,7 @@ void reconnect_receiver(int index)
// int send_buf_size = 0;
// int int_size = sizeof(send_buf_size);
// getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &send_buf_size,
// (socklen_t*)&int_size);
// (socklen_t*)&int_size);
// fprintf(stderr, "Socket buffer size: %d\n", send_buf_size);
struct sockaddr_in source_addr;
......
......@@ -2,7 +2,7 @@
#include "log.h"
/* tcpdump header (ether.h) defines ETHER_HDRLEN) */
#ifndef ETHER_HDRLEN
#ifndef ETHER_HDRLEN
#define ETHER_HDRLEN 14
#endif
......@@ -21,20 +21,20 @@ u_int16_t handle_IP(u_char *args,const struct pcap_pkthdr* pkthdr,const u_char*
* against negative integers quite easily, and fail in subtle ways.
*/
struct my_ip {
u_int8_t ip_vhl; /* header length, version */
#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
u_int8_t ip_tos; /* type of service */
u_int16_t ip_len; /* total length */
u_int16_t ip_id; /* identification */
u_int16_t ip_off; /* fragment offset field */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
u_int8_t ip_ttl; /* time to live */
u_int8_t ip_p; /* protocol */
u_int16_t ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
u_int8_t ip_vhl; /* header length, version */
#define IP_V(ip) (((ip)->ip_vhl & 0xf0) >> 4)
#define IP_HL(ip) ((ip)->ip_vhl & 0x0f)
u_int8_t ip_tos; /* type of service */
u_int16_t ip_len; /* total length */
u_int16_t ip_id; /* identification */
u_int16_t ip_off; /* fragment offset field */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
u_int8_t ip_ttl; /* time to live */
u_int8_t ip_p; /* protocol */
u_int16_t ip_sum; /* checksum */
struct in_addr ip_src,ip_dst; /* source and dest address */
};
......@@ -60,7 +60,7 @@ int throughputInWindow(ThroughputAckState * state, unsigned int sequence)
// Reset the state of a connection completely.
void throughputInit(ThroughputAckState * state, unsigned int sequence,
struct timeval const * firstTime)
struct timeval const * firstTime)
{
if (state->isValid == 0)
{
......@@ -105,7 +105,7 @@ void throughputProcessSend(ThroughputAckState * state, unsigned int sequence,
// Notify the throughput monitor that some bytes have been acknowledged.
void throughputProcessAck(ThroughputAckState * state, unsigned int sequence,
struct timeval const * timestamp, unsigned int pktsize)
struct timeval const * timestamp, unsigned int pktsize)
{
if (! state->isValid) {
printf("throughputProcessAck() called with invalid state\n");
......@@ -180,29 +180,29 @@ int nnmod(int num, int modulus){
//Take account of the seq wrap-arround
int in_sequence_block(unsigned long seq_start, unsigned long seq_end, unsigned long seq) {
if (seq_start < seq_end) {
if (seq_start<=seq && seq<seq_end)
if (seq_start<=seq && seq<seq_end)
return 1; //in range
else
else
return 0; //out of range
}
if (seq_start > seq_end) {
if (seq_start<=seq || seq<seq_end)
if (seq_start<=seq || seq<seq_end)
return 1; //in range
else
else
return 0; //out of range
}
//seq_start == seq_end
if (seq_start == seq)
if (seq_start == seq)
return 1; //in range
else
return 0; //out of range
return 0; //out of range
}
void init_sniff_rcvdb(void) {
int i;
for (i=0; i<CONCURRENT_RECEIVERS; i++){
sniff_rcvdb[i].start = 0;
sniff_rcvdb[i].end = 0;
......@@ -257,9 +257,9 @@ unsigned int pop_sniff_rcvdb(int path_id, u_long to_seqnum){
pre_index = sniff_rcvdb[path_id].start;
//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)
if ((sniff_rcvdb[path_id].records[to_index].seq_end==sniff_rcvdb[path_id].records[to_index].seq_start)
|| (((unsigned long)(sniff_rcvdb[path_id].records[to_index].seq_end-1)) == to_seqnum)) {
sniff_rcvdb[path_id].start = nnmod(to_index+1, SNIFF_WINSIZE); //complete pop-up
sniff_rcvdb[path_id].start = nnmod(to_index+1, SNIFF_WINSIZE); //complete pop-up
} else {
sniff_rcvdb[path_id].start = to_index; //partial pop-up
new_seqnum = to_seqnum+1; //PAW
......@@ -280,14 +280,14 @@ unsigned int pop_sniff_rcvdb(int path_id, u_long to_seqnum){
/* looking at ethernet headers */
void my_callback(u_char *args,const struct pcap_pkthdr* pkthdr,const u_char* packet){
u_int16_t type = handle_ethernet(args,pkthdr,packet);
if(type == ETHERTYPE_IP) {
if(type == ETHERTYPE_IP) {
/* handle IP packet */
handle_IP(args,pkthdr,packet);
}else if(type == ETHERTYPE_ARP) {
/* handle arp packet */
}else if(type == ETHERTYPE_REVARP){
/* handle reverse arp packet */
}else if(type == ETHERTYPE_ARP) {
/* handle arp packet */
}else if(type == ETHERTYPE_REVARP){
/* handle reverse arp packet */
}else {
/* handle_ethernet returned -1 */
}
......@@ -311,8 +311,8 @@ u_int16_t handle_IP(u_char *args, const struct pcap_pkthdr* pkthdr, const u_char
/* jump pass the ethernet header */
ip = (struct my_ip*)(packet + sizeof(struct ether_header));
length -= sizeof(struct ether_header);
caplen -= sizeof(struct ether_header);
length -= sizeof(struct ether_header);
caplen -= sizeof(struct ether_header);
/* check if we have captured enough to continue parse */
if (caplen < sizeof(struct my_ip)) {
......@@ -348,28 +348,28 @@ u_int16_t handle_IP(u_char *args, const struct pcap_pkthdr* pkthdr, const u_char
ip_src = ip->ip_src.s_addr;
ip_dst = ip->ip_dst.s_addr;
if (flag_debug){
if (flag_debug){
//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);
}
/*jump pass the ip header */
cp = (u_char *)ip + (hlen * 4);
caplen -= (hlen * 4);
length -= (hlen * 4);
caplen -= (hlen * 4);
length -= (hlen * 4);
switch (ip->ip_p) {
case IPPROTO_TCP:
if (caplen < sizeof(struct tcphdr)) {
printf("Error: truncated tcp header - %d bytes missing\n", sizeof(struct tcphdr)-caplen);
return -1;
}
printf("Error: truncated tcp header - %d bytes missing\n", sizeof(struct tcphdr)-caplen);
return -1;
}
tp = (struct tcphdr *)cp;
tcp_hlen = ((tp)->doff & 0x000f);
tcp_hlen = ((tp)->doff & 0x000f);
length -= (tcp_hlen * 4); //jump pass the tcp header
caplen -= (tcp_hlen * 4); //jump pass the tcp header
seq_start = ntohl(tp->seq);
seq_start = ntohl(tp->seq);
seq_end = ((unsigned long)(seq_start+length));
ack_bit= ((tp)->ack & 0x0001);
source_port = htons(tp->source);
......@@ -377,16 +377,16 @@ u_int16_t handle_IP(u_char *args, const struct pcap_pkthdr* pkthdr, const u_char
if (flag_standalone)
{
// If this is standalone mode, the stub_port entry will be the
// destination port requested by the command line.
path_id = find_by_stub_port(ip_dst, dest_port);
// If this is standalone mode, the stub_port entry will be the
// destination port requested by the command line.
path_id = find_by_stub_port(ip_dst, dest_port);
}
else
{
// I contacted the receiver. Therefore, my port is unique and
// the receiver's port is fixed. The destination is the
// receiver, therefore my port is the one that is of interest.
path_id = find_by_stub_port(ip_dst, source_port);
// I contacted the receiver. Therefore, my port is unique and
// the receiver's port is fixed. The destination is the
// receiver, therefore my port is the one that is of interest.
path_id = find_by_stub_port(ip_dst, source_port);
}
if (path_id != -1) { //a monitored outgoing packet
//ignore the pure outgoing ack
......@@ -394,168 +394,168 @@ u_int16_t handle_IP(u_char *args, const struct pcap_pkthdr* pkthdr, const u_char
return 0;
}
path = &(sniff_rcvdb[path_id]);
loss_records[path_id].total_counter++;
if (path->end == path->start){ //no previous packet
throughputInit(&throughput[path_id], seq_start, &(pkthdr->ts));
throughputProcessSend(&throughput[path_id], seq_start, length);
return push_sniff_rcvdb(path_id, seq_start, seq_end, &(pkthdr->ts), pkthdr->len); //new packet
} else {
throughputProcessSend(&throughput[path_id], seq_start, length);
//find the real received end index
end = nnmod(path->end-1, SNIFF_WINSIZE);
//if the packet has no payload
if (seq_end == seq_start) {
if ((path->records[end].seq_end==path->records[end].seq_start) && (path->records[end].seq_end==seq_end)) {
//the last packet also has no payload and has the same seqnum, pure resent
loss_records[path_id].loss_counter++;
fprintf(loss_log, "Resent: %lu\n",seq_end); //loss log
fflush(loss_log); //loss log
} else {
return push_sniff_rcvdb(path_id, seq_start, seq_end, &(pkthdr->ts), pkthdr->len); //new packet
}
} else if (seq_start >= path->records[end].seq_end) { //new packet
return push_sniff_rcvdb(path_id, seq_start, seq_end, &(pkthdr->ts), pkthdr->len);
} else { //resend
path = &(sniff_rcvdb[path_id]);
loss_records[path_id].total_counter++;
if (path->end == path->start){ //no previous packet
throughputInit(&throughput[path_id], seq_start, &(pkthdr->ts));
throughputProcessSend(&throughput[path_id], seq_start, length);
return push_sniff_rcvdb(path_id, seq_start, seq_end, &(pkthdr->ts), pkthdr->len); //new packet
} else {
throughputProcessSend(&throughput[path_id], seq_start, length);
//find the real received end index
end = nnmod(path->end-1, SNIFF_WINSIZE);
//if the packet has no payload
if (seq_end == seq_start) {
if ((path->records[end].seq_end==path->records[end].seq_start) && (path->records[end].seq_end==seq_end)) {
//the last packet also has no payload and has the same seqnum, pure resent
loss_records[path_id].loss_counter++;
fprintf(loss_log, "Resent: %lu\n",seq_end); //loss log
fflush(loss_log); //loss log
} else {
return push_sniff_rcvdb(path_id, seq_start, seq_end, &(pkthdr->ts), pkthdr->len); //new packet
}
} else if (seq_start >= path->records[end].seq_end) { //new packet
return push_sniff_rcvdb(path_id, seq_start, seq_end, &(pkthdr->ts), pkthdr->len);
} else { //resend
loss_records[path_id].loss_counter++;
if (seq_end > path->records[end].seq_end){ //partial resend
fprintf(loss_log, "Resent: %lu to %lu\n",seq_start, path->records[end].seq_end-1); //loss log
fflush(loss_log); //loss log
if (seq_end > path->records[end].seq_end){ //partial resend
fprintf(loss_log, "Resent: %lu to %lu\n",seq_start, path->records[end].seq_end-1); //loss log
fflush(loss_log); //loss log
tmpuint = pkthdr->len - (path->records[end].seq_end-seq_start);
return push_sniff_rcvdb(path_id, path->records[end].seq_end, seq_end, &(pkthdr->ts), tmpuint);
}
fprintf(loss_log, "Resent: %lu to %lu\n",seq_start, seq_end-1); //loss log
fflush(loss_log); //loss log
} // if has payload and resent
}
}
fprintf(loss_log, "Resent: %lu to %lu\n",seq_start, seq_end-1); //loss log
fflush(loss_log); //loss log
} // if has payload and resent
}
} else {
if (flag_standalone)
{
// If this is standalone mode, and the packet is incoming,
// then the source_port will be the remote port requested on
// the command line.
path_id = find_by_stub_port(ip_src, source_port);
}
else
{
// I contacted the receiver, so my port is unique and their
// port is the same every time. This means that if a packet is
// coming from them, the destination port is the one of
// interest.
path_id = find_by_stub_port(ip_src, dest_port);
}
if (path_id != -1) { //a monitored incoming packet
if (ack_bit == 1) { //has an acknowledgement
if (flag_standalone)
{
// If this is standalone mode, and the packet is incoming,
// then the source_port will be the remote port requested on
// the command line.
path_id = find_by_stub_port(ip_src, source_port);
}
else
{
// I contacted the receiver, so my port is unique and their
// port is the same every time. This means that if a packet is
// coming from them, the destination port is the one of
// interest.
path_id = find_by_stub_port(ip_src, dest_port);
}
if (path_id != -1) { //a monitored incoming packet
if (ack_bit == 1) { //has an acknowledgement
ack_seq = ntohl(tp->ack_seq);
acked_size = 0;
record_id = search_sniff_rcvdb(path_id, (unsigned long)(ack_seq-1));
record_id = search_sniff_rcvdb(path_id, (unsigned long)(ack_seq-1));
/* Note: we use the in-flight widnow to igore the duplicate Acks in the delay estimation
* because TCP don't use them to calculate the sample RTT in the RTT estimation */
if (record_id != -1) { //new ack received
if (record_id != -1) { //new ack received
int delay = 0;
struct tcp_info info;
int info_size = sizeof(info);
int error = 0;
if (is_live)
{
error = getsockopt(rcvdb[path_id].sockfd,
SOL_TCP, TCP_INFO, &info,
&info_size);
if (error == -1)
{
perror("getsockopt() TCP_INFO");
clean_exit(1);
}
if ((info.tcpi_snd_cwnd < info.tcpi_snd_ssthresh
|| ((unsigned int)(tp->window)
<< info.tcpi_rcv_wscale)
<= (info.tcpi_unacked * 1448))
&& bandwidth_method == BANDWIDTH_BUFFER)
{
// We are in slow start. This means that even if the
// socket buffer is full, we are still not sending
// at the ABW rate.
buffer_full[path_id] = 0;
last_through[path_id] = INT_MAX;
logWrite(DELAY_DETAIL, NULL, "Buffer Clear");
}
logWrite(DELAY_DETAIL, NULL, "receive_window: %u, unacked: %u",
(unsigned int)(tp->window)
<< info.tcpi_rcv_wscale,
info.tcpi_unacked * 1448);
}
struct tcp_info info;
int info_size = sizeof(info);
int error = 0;
if (is_live)
{
error = getsockopt(rcvdb[path_id].sockfd,
SOL_TCP, TCP_INFO, &info,
&info_size);
if (error == -1)
{
perror("getsockopt() TCP_INFO");
clean_exit(1);
}
if ((info.tcpi_snd_cwnd < info.tcpi_snd_ssthresh
|| ((unsigned int)(tp->window)
<< info.tcpi_rcv_wscale)
<= (info.tcpi_unacked * 1448))
&& bandwidth_method == BANDWIDTH_BUFFER)
{
// We are in slow start. This means that even if the
// socket buffer is full, we are still not sending
// at the ABW rate.
buffer_full[path_id] = 0;
last_through[path_id] = INT_MAX;
logWrite(DELAY_DETAIL, NULL, "Buffer Clear");
}
logWrite(DELAY_DETAIL, NULL, "receive_window: %u, unacked: %u",
(unsigned int)(tp->window)
<< info.tcpi_rcv_wscale,
info.tcpi_unacked * 1448);
}
msecs = floor((pkthdr->ts.tv_usec-sniff_rcvdb[path_id].records[record_id].captime.tv_usec)/1000.0+0.5);
delay = (pkthdr->ts.tv_sec-sniff_rcvdb[path_id].records[record_id].captime.tv_sec)*1000 + msecs;
if (delay != 0)
{
delays[path_id] += delay;
(delay_count[path_id])++;
if (delay < base_rtt[path_id])
{
base_rtt[path_id] = delay;
}
logWrite(DELAY_DETAIL, NULL, "delay: %d, max_delay: %d",
delay, max_delay[path_id]);
if (delay > max_delay[path_id])
{
max_delay[path_id] = delay + delay/10 + 1;
}
if (is_live && delay_count[path_id] > 0
&& bandwidth_method == BANDWIDTH_VEGAS)
{
int bandwidth = 0;
bandwidth = (info.tcpi_unacked/*tcpi_snd_cwnd*/
* info.tcpi_snd_mss * 8)
/ base_rtt[path_id];
if (bandwidth > max_throughput[path_id])
{
max_throughput[path_id] = bandwidth;
}
logWrite(DELAY_DETAIL, NULL,
"Kernel RTT: %lu, Kernel Losses: %lu, "
"Receive Window: %lu, Kernel packets out: %lu",
info.tcpi_rtt, info.tcpi_lost, tp->window,
info.tcpi_unacked);
logWrite(DELAY_DETAIL, NULL,
"Tput: %lu, cwnd: %lu, snd_MSS: %lu bytes, "
"Base RTT: %lu",
bandwidth, info.tcpi_snd_cwnd, info.tcpi_snd_mss,
base_rtt[path_id]);
}
else if (bandwidth_method == BANDWIDTH_MAX)
{
int goodput = 0;
goodput = throughputTick(&throughput[path_id]);
logWrite(DELAY_DETAIL, NULL, "Goodput: %d", goodput);
if (goodput > max_throughput[path_id])
{
max_throughput[path_id] = goodput;
}
}
// append_delay_sample(path_id, delay, &(pkthdr->ts));
logWrite(DELAY_DETAIL, &(pkthdr->ts),
"Delay: %lu, Sum: %lu, Count: %lu", delay,
delays[path_id], delay_count[path_id]);
}
if (delay != 0)
{
delays[path_id] += delay;
(delay_count[path_id])++;
if (delay < base_rtt[path_id])
{
base_rtt[path_id] = delay;
}
logWrite(DELAY_DETAIL, NULL, "delay: %d, max_delay: %d",
delay, max_delay[path_id]);
if (delay > max_delay[path_id])
{
max_delay[path_id] = delay + delay/10 + 1;
}
if (is_live && delay_count[path_id] > 0
&& bandwidth_method == BANDWIDTH_VEGAS)
{
int bandwidth = 0;
bandwidth = (info.tcpi_unacked/*tcpi_snd_cwnd*/
* info.tcpi_snd_mss * 8)
/ base_rtt[path_id];
if (bandwidth > max_throughput[path_id])
{
max_throughput[path_id] = bandwidth;
}
logWrite(DELAY_DETAIL, NULL,
"Kernel RTT: %lu, Kernel Losses: %lu, "
"Receive Window: %lu, Kernel packets out: %lu",
info.tcpi_rtt, info.tcpi_lost, tp->window,
info.tcpi_unacked);
logWrite(DELAY_DETAIL, NULL,
"Tput: %lu, cwnd: %lu, snd_MSS: %lu bytes, "
"Base RTT: %lu",
bandwidth, info.tcpi_snd_cwnd, info.tcpi_snd_mss,
base_rtt[path_id]);
}
else if (bandwidth_method == BANDWIDTH_MAX)
{
int goodput = 0;
goodput = throughputTick(&throughput[path_id]);
logWrite(DELAY_DETAIL, NULL, "Goodput: %d", goodput);
if (goodput > max_throughput[path_id])
{
max_throughput[path_id] = goodput;
}
}
// append_delay_sample(path_id, delay, &(pkthdr->ts));
logWrite(DELAY_DETAIL, &(pkthdr->ts),
"Delay: %lu, Sum: %lu, Count: %lu", delay,
delays[path_id], delay_count[path_id]);
}
acked_size = pop_sniff_rcvdb(path_id, (unsigned long)(ack_seq-1)); //advance the sniff window base
} //ack in rcvdb
} //ack in rcvdb
throughputProcessAck(&throughput[path_id], ack_seq, &(pkthdr->ts), acked_size);
} //has ack
} //if incoming
} //has ack
} //if incoming
} //if outgoing
if (flag_debug) {
printf("TCP start_seq:%lu end_seq:%lu length:%d\n", seq_start, seq_end, length);
printf("TCP ack_seq:%lu ack_flag:%d hlen:%d\n", ack_seq, ack_bit, tcp_hlen);
printf("TCP start_seq:%lu end_seq:%lu length:%d\n", seq_start, seq_end, length);
printf("TCP ack_seq:%lu ack_flag:%d hlen:%d\n", ack_seq, ack_bit, tcp_hlen);
}
break;
case IPPROTO_UDP:
......@@ -605,13 +605,13 @@ u_int16_t handle_ethernet (u_char *args,const struct pcap_pkthdr* pkthdr,const u
/* check to see if we have an ip packet */
if (ether_type == ETHERTYPE_IP){
fprintf(stdout,"(IP)");
fprintf(stdout,"(IP)");
}else if (ether_type == ETHERTYPE_ARP){
fprintf(stdout,"(ARP)");
fprintf(stdout,"(ARP)");
}else if (eptr->ether_type == ETHERTYPE_REVARP){
fprintf(stdout,"(RARP)");
fprintf(stdout,"(RARP)");
}else {
fprintf(stdout,"(?)");
fprintf(stdout,"(?)");
}
fprintf(stdout," %d\n",length); //total ethernet packet length
} //if
......@@ -627,8 +627,8 @@ void init_pcap(int to_ms, unsigned short port, char * device) {
if (is_live)
{
logWrite(MAIN_LOOP, NULL,
"Initializing pcap live interface with device %s, and port %d",
device, port);
"Initializing pcap live interface with device %s, and port %d",
device, port);
// We are running using live data. device refers to the network
// device.
struct bpf_program fp; /* hold compiled program */
......@@ -642,30 +642,30 @@ void init_pcap(int to_ms, unsigned short port, char * device) {
//addr.s_addr = netp;
sprintf(string_filter, "port %d and tcp", port);
/* open device for reading.
/* open device for reading.
* NOTE: We use non-promiscuous */
descr = pcap_open_live(device, BUFSIZ, 0, to_ms, errbuf);
if(descr == NULL) {
printf("Error: pcap_open_live(): %s\n",errbuf);
exit(1);
if(descr == NULL) {
printf("Error: pcap_open_live(): %s\n",errbuf);
exit(1);
}
// Lets try and compile the program, optimized
// Lets try and compile the program, optimized
if(pcap_compile(descr, &fp, string_filter, 1, maskp) == -1) {
fprintf(stderr,"Error: calling pcap_compile\n");
exit(1);
fprintf(stderr,"Error: calling pcap_compile\n");
exit(1);
}
// set the compiled program as the filter
// set the compiled program as the filter
if(pcap_setfilter(descr,&fp) == -1) {
fprintf(stderr,"Error: setting filter\n");
exit(1);
fprintf(stderr,"Error: setting filter\n");
exit(1);
}
/*
if (pcap_setnonblock(descr, 1, errbuf) == -1){
printf("Error: pcap_setnonblock(): %s\n",errbuf);
exit(1);
}
if (pcap_setnonblock(descr, 1, errbuf) == -1){
printf("Error: pcap_setnonblock(): %s\n",errbuf);
exit(1);
}
*/