void frame_escape_exampe(void* arg, struct modtest_result* result) { char buf[] = { 0x7E, 0x00, 0x02, 0x23, 0x11, 0xCB }; const char escbuf[] = { 0x7E, 0x00, 0x02, 0x23, 0x7D, 0x31, 0xCB }; struct sk_buff* skb = NULL; //pr_debug("bufsize %lu", sizeof(buf) ); skb = dev_alloc_skb(sizeof(buf) ); skb_put(skb, sizeof(buf) ); memcpy(skb->data, buf, sizeof(buf) ); print_hex_dump_bytes("skb: ", DUMP_PREFIX_NONE, skb->data, skb->len); frame_escape(skb); print_hex_dump_bytes("skb: ", DUMP_PREFIX_NONE, skb->data, skb->len); print_hex_dump_bytes("esc: ", DUMP_PREFIX_NONE, escbuf, sizeof(escbuf)); //FAIL_IF_ERROR(err); FAIL_IF_NOT_EQ(sizeof(escbuf), skb->len); FAIL_IF_NOT_EQ(0, memcmp(escbuf, skb->data, sizeof(escbuf)) ); TEST_SUCCESS(); }
int ppp_complt(u_char *frame, int frame_size, struct framehdr *fh, struct msidhash *mh, struct radiushash *rh, FILE *output){ //返回获得的IP数据包个数 int ipnum = 0, start = 0, end = 0; _Int16 *protocol = 0, *size = 0; u_char t[2]; while(start < frame_size){ if((end = flag_find(frame, frame_size, start+1)) == -1) break; start+=1; if(start != end){ frame_escape((frame+start),end-start); protocol = (_Int16 *)(frame+start+2); switch(*protocol){ // case IPV4: // //是IP协议说明是数据帧,进行解封装处理 // start+=4; // t[0] = frame[start+2]; t[1] = frame[start+3]; // size = (_Int16 *)t; // *size = short_displace(*size); // fwrite(size, 1, sizeof(_Int16), output); // fwrite((frame+start), 1, *size, output); // ipnum++; // break; case IPCP: start+=4; IPCP_handler((frame+start), fh, mh, rh); break; default: break; } start = end; } } return ipnum; }