void packet_processing(const u64 time,const struct iphdr *iph,u16 ipsize,u16 rawsize){ //detect http packet struct ipoque_id_struct *src=NULL,*dst=NULL; void *flow=NULL; unsigned int protocol; u32 src_ip,dst_ip; if(iph->version == 4 && ipsize>= sizeof(struct iphdr)){ src_ip=iph->saddr; dst_ip=iph->daddr; } //TODO get_id to add func src=get_id(&src_ip); dst=get_id(&dst_ip); /// detection process // param1: ipoque_struct // param2: flow // param3: pakcet ptr // param4: packet length // param5: packet timestamp // param6: src subscriber // param7: dst sbuscriber protocol = ipoque_detection_process_packet(ipoque_struct,flow,iph,ipsize, time,src,dst); static const char *protocol_long_str[]={IPOQUE_PROTOCOL_LONG_STRING}; printf("protocol: %s\n",protocol_long_str[protocol]); }
void pkt(struct lfc *lfc, void *pdata, struct lfc_flow *lf, void *data, double ts, bool up, bool is_new, libtrace_packet_t *pkt) { struct ndpi *nd = pdata; struct flow *f = data; struct ipoque_id_struct *srcid, *dstid; uint8_t *iph; uint16_t et; uint32_t rem; uint64_t time; if (!f->ipq_flow) f->ipq_flow = mmatic_zalloc(nd->mm, ipoque_detection_get_sizeof_ipoque_flow_struct()); iph = trace_get_layer3(pkt, &et, &rem); time = ts * 1000; srcid = getid(nd, &lf->src); dstid = getid(nd, &lf->dst); f->proto = ipoque_detection_process_packet( nd->ipq, f->ipq_flow, iph, rem, time, srcid, dstid); }