Commit 7f0f98b7 authored by 's avatar
Browse files

fix in mapinicdrv: default maximum cap length is 1514 (not 1500)

fixes in mapidlib for copying link packet in modified packet



git-svn-id: file:///home/svn/mapi/trunk@196 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent f54b8b5d
......@@ -1561,7 +1561,6 @@ void PrintEapolPkt(FILE * fp, mapipacket * p,int datalink)
}
void PrintPacket(FILE *fp, mapipacket *p,int datalink) {
if(p->iph != NULL)
PrintIPPkt(stdout, p->iph->ip_proto,p);
else if(p->ah != NULL)
......
No preview for this file type
......@@ -36,13 +36,14 @@ static int anonprint_instance(mapidflib_function_instance_t *instance, flist_t *
static int anonprint_process(mapidflib_function_instance_t *instance,const unsigned char* dev_pkt,const unsigned char* link_pkt, mapid_pkthdr_t* pkt_head) {
struct pcap_pkthdr pkthdr;
mapipacket decoded_pkt;
//printf("I am anonprint_process %d\n",pkt_head->caplen);
pkthdr.caplen=pkt_head->caplen;
pkthdr.len=pkt_head->wlen;
pkthdr.ts.tv_sec=pkt_head->ts; //XXX taken from to_tcpdump, to be cross-checked
pkthdr.ts.tv_usec=pkt_head->ts;
decode_packet(instance->hwinfo->link_type,instance->hwinfo->cap_length,&pkthdr,(unsigned char *)dev_pkt,&decoded_pkt);
decode_packet(instance->hwinfo->link_type,instance->hwinfo->cap_length,&pkthdr,(unsigned char *)link_pkt,&decoded_pkt);
PrintPacket(stdout,&decoded_pkt,instance->hwinfo->link_type);
return 1;
......
......@@ -842,7 +842,7 @@ printf("========================================================================
}
if(flow->modifies==1) {
memcpy(modified_packet_buf,dev_pkt,pkt_head->caplen);
memcpy(modified_packet_buf,link_pkt,pkt_head->caplen);
memcpy(&flow->mod_pkt_head,pkt_head,sizeof(mapid_pkthdr_t));
flow->mod_pkt =&modified_packet_buf[0];
if(flow->server_mod_pkt) {
......
......@@ -157,8 +157,7 @@ process_pkts(void *buf,unsigned len, nic_instance_t *i,MAPI_UNUSED int devid, in
mhdr.caplen = rec->caplen;
mhdr.ifindex = 0;
mhdr.wlen = rec->len;
mhdr.ts = (((unsigned long long)rec->ts.tv_sec)<<32)+
((rec->ts.tv_usec*4295) & 0xffffffff);
mhdr.ts = (((unsigned long long)rec->ts.tv_sec)<<32)+((rec->ts.tv_usec*4295) & 0xffffffff);
//TODO: Need to check accuracy of timestamp. Rounding errors?
// increase counter for packets seen so far
......@@ -246,8 +245,7 @@ mapidrv_proc_loop (int devid)
// This is only for backward compatibility
mhdr.caplen = phdr.caplen;
mhdr.wlen = phdr.len;
mhdr.ts = (((unsigned long long)phdr.ts.tv_sec)<<32)+
((phdr.ts.tv_usec*4295) & 0xffffffff);
mhdr.ts = (((unsigned long long)phdr.ts.tv_sec)<<32)+((phdr.ts.tv_usec*4295) & 0xffffffff);
// increase counter for packets seen so far
i->hwinfo.pkts++;
......@@ -287,7 +285,7 @@ mapidrv_create_offline_flow (int devid, int format,int fd,char **devtype)
if(format==MFF_PCAP) {
//This should be read from the file
i->hwinfo.link_type=DLT_EN10MB;
i->hwinfo.cap_length=1500;
i->hwinfo.cap_length=1514;
i->hwinfo.devtype=MAPI_DEVICE_NIC;
i->hwinfo.devid=i->id;
i->hwinfo.pkts=0;
......
......@@ -403,9 +403,9 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
struct mapidlibflow *flow;
//fprintf(stderr,"I am COOKING\n");
precooked_data = dev_pkt;
precooked_data = link_pkt;
last_dev_pkt= dev_pkt;
last_dev_pkt= link_pkt;
last_mapid_header = pkt_head;
h.caplen=pkt_head->caplen;
......@@ -426,14 +426,14 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
callbacks=0;
eth = (ether_header*)dev_pkt;
eth = (ether_header*)link_pkt;
ether_len = sizeof(ether_header);
iph = (struct ip*)(dev_pkt + ether_len);
iph = (struct ip*)(link_pkt + ether_len);
ip_len = (iph->ip_hl & 0xf) * 4;
if(iph->ip_p != IPPROTO_TCP) // no TCP packet
return 1;
nids_mapi_next(&h, dev_pkt);
nids_mapi_next(&h, link_pkt);
//if(callbacks>1)
//fprintf(stderr,">> %d %d %d\n",callbacks,status,pkt_head->caplen);
......@@ -443,14 +443,14 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
struct tcp_stream *stream;
int from_client;
tcph = (struct tcphdr *)(dev_pkt + ether_len + ip_len);
tcph = (struct tcphdr *)(link_pkt + ether_len + ip_len);
stream= find_stream(tcph,iph,&from_client);
if(stream) {
//fprintf(stderr,"\tStream found\n");
headers = malloc(sizeof(struct headers_data));
headers->header = malloc(pkt_head->caplen); //added 100 more bytes
memcpy(headers->header,dev_pkt,pkt_head->caplen);
memcpy(headers->header,link_pkt,pkt_head->caplen);
headers->caplen = pkt_head->caplen;
headers->wlen = pkt_head->wlen;
headers->ts.tv_sec = pkt_head->ts; //XXX
......@@ -484,11 +484,11 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
int from_client;
//fprintf(stderr,"\tcheck report %d\n",flow->client_size);
tcph = (struct tcphdr *)(dev_pkt + ether_len + ip_len);
tcph = (struct tcphdr *)(link_pkt + ether_len + ip_len);
headers = malloc(sizeof(struct headers_data));
headers->header = malloc(pkt_head->caplen);
memcpy(headers->header, dev_pkt,pkt_head->caplen);
memcpy(headers->header, link_pkt,pkt_head->caplen);
headers->caplen = pkt_head->caplen;
headers->wlen = pkt_head->wlen;
headers->ts.tv_sec = pkt_head->ts; //XXX
......@@ -497,7 +497,7 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
stream= find_stream(tcph,iph,&from_client);
if(stream==NULL) {
//fprintf(stderr,"\tNULL stream %d %d\n",headers->ts.tv_sec,headers->ts.tv_usec);
create_mod_pkt(dev_pkt,flow,pkt_head);
create_mod_pkt(link_pkt,flow,pkt_head);
flist_append(flow->server_headers,0, (void *)headers);
return 1;
}
......@@ -523,7 +523,7 @@ static int cook_process(mapidflib_function_instance_t *instance,const unsigned c
if(flow->ret_client_data != NULL || flow->ret_server_data!=NULL)
{
// Set pseudoheader and new cooked packet to return to the daemon
create_mod_pkt(dev_pkt,flow,pkt_head);
create_mod_pkt(link_pkt,flow,pkt_head);
return 1;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment