38#include "ace/SOCK_Dgram.h"
47#include "EoMotionControl.h"
48#include "eODeb_eoProtoParser.h"
49#include "eOtheEthLowLevelParser.h"
74#define MAX_ACQUISITION 1000000000L
94static void s_process_packet(u_char *args,
const struct pcap_pkthdr *header,
const u_char *packet);
108int main(
int argc,
char *argv[])
113 char filter_exp[260];
115 bool filterOnSrc =
false;
117 bool filterOnDst =
false;
120 char default_filter_exp[60];
124 struct pcap_pkthdr header;
125 const u_char *packet;
129 sprintf(dev,
"eth1");
130 sprintf(filter_exp,
"src host 10.0.1.104");
136 for(uint8_t i = 0; i<argc; i++)
138 if(strcmp(
"--help", argv[i]) == 0)
144 if(strcmp(
"--dev", argv[i]) == 0)
148 sprintf(dev,
"%s", argv[++i]);
153 if(strcmp(
"--filterSrcAddr", argv[i]) == 0)
158 sprintf(filtersrc,
"%s", argv[++i]);
164 if(strcmp(
"--filterDstAddr", argv[i]) == 0)
169 sprintf(filterdst,
"%s", argv[++i]);
174 if(strcmp(
"--maxacquisition", argv[i]) == 0)
178 maxacquisition = atoll(argv[++i]);
186 file = fopen(
"test.txt",
"a+");
189 printf(
"cannot open file \n");
195 if((filterOnSrc) &&(filterOnDst))
197 sprintf(filter_exp,
"src host %s and dst host %s", filtersrc, filterdst);
202 sprintf(filter_exp,
"src host %s ", filtersrc);
207 sprintf(filter_exp,
"dst host %s", filterdst);
210 sprintf(default_filter_exp,
" and not port 4444");
211 strcat(filter_exp, default_filter_exp);
213 printf(
"Debug-tool: Ethernet Low Level Praser start on interface %s\n", dev);
214 printf(
"\t\t Used filter: %s\n", filter_exp);
251 printf(
"error in inti libpacap\n");
266 printf(
"\nCapture complete.\n");
290static void s_process_packet(u_char *args,
const struct pcap_pkthdr *header,
const u_char *packet)
296 eOethLowLevParser_packetInfo_t pktInfo;
299 res = eOTheEthLowLevParser_GetUDPdatagramPayload(eo_ethLowLevParser_GetHandle(), (uint8_t*)packet, &pktInfo);
304 eODeb_eoProtoParser_RopFrameDissect(eODeb_eoProtoParser_GetHandle(), &pktInfo);
455 const eOethLowLevParser_cfg_t ethLowLevParserCfg = {0};
456 eo_ethLowLevParser_Initialise(ðLowLevParserCfg);
462 printf(
"option --help: print this help\n");
463 printf(
"option --dev: specify device where start to capture (default eth1)\n");
464 printf(
"option --filterSrcAddr: application will capture packet with source address specified here. Not mandatory\n");
465 printf(
"option --filterDstAddr: application will capture packet with dest address specified here. Not mandatory\n");
466 printf(
"option --maxacquisition: max num of captured packets. Not mandatory\n");
static void s_ethLowLevelPraser_configure(void)
static void s_process_packet(u_char *args, const struct pcap_pkthdr *header, const u_char *packet)
static void print_help(void)
const eODeb_eoProtoParser_cfg_t * deb_eoParserCfg_ptr
uint8_t wrapperPcap_loop(int32_t cnt, pcap_handler callback, uint8_t *user)
void wrapperPcap_close(void)
uint8_t wrapperPcap_init(char *dev, char *filter_expr)