Commit e2316155 authored by 's avatar
Browse files

added support for POS-network packets.


git-svn-id: file:///home/svn/mapi/trunk@899 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent 45dba13f
......@@ -18,8 +18,8 @@
#include "protocols.h"
#include "mapi_errors.h"
#ifndef CHDLC_HDRLEN
#define CHDLC_HDRLEN 4
#ifndef ETHERTYPE_IP
#define ETHERTYPE_IP 0x0800 /* IP protocol */
#endif
struct topx_field {
......@@ -470,20 +470,25 @@ static int topx_process(mapidflib_function_instance_t *instance,
// struct timeval ts;
unsigned int cur_secs = 0;
struct timeval tv;
int ether_len;
int linkhdr_len;
switch (instance->hwinfo->link_type) {
case DLT_EN10MB: /* ethernet */
ether_len = sizeof(ether_header);
linkhdr_len = sizeof(ether_header);
extract_field(&field, packet + linkhdr_len,
pkt_head->wlen - linkhdr_len, data->protocol, data->field);
break;
case DLT_CHDLC:
ether_len = CHDLC_HDRLEN;
linkhdr_len = 20;
if (ntohs(*(uint16_t*)(dev_pkt + 18)) == ETHERTYPE_IP) {
extract_field(&field, dev_pkt + linkhdr_len,
pkt_head->wlen - linkhdr_len, data->protocol, data->field);
}
break;
default:
assert(0);
}
extract_field(&field, packet + ether_len, pkt_head->wlen - ether_len, data->protocol, data->field);
if(field.len==0)
return 1;
......@@ -513,7 +518,7 @@ static int topx_process(mapidflib_function_instance_t *instance,
}
//printf("---- %lf\n",(double)(pkt_head->wlen));
add_field_to_list(&field,data,(unsigned long long)(pkt_head->wlen - ether_len), data->last_rst);
add_field_to_list(&field,data,(unsigned long long)(pkt_head->wlen - linkhdr_len), data->last_rst);
tmp=data->list_head;
......
Markdown is supported
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