- 论坛徽章:
- 0
|
或者改成这样
- void show(struct ether_arp *a);
- int main(int argc, char *argv[])
- {
- int i;
- char buffer[65535] = {0};
- unsigned char *head;
- struct ether_arp *a;
- ..........................................
- //截包分析包头...
- head=buffer+12;
- a=(struct ether_arp *)head;
- if((*head==0x0&&(*(head+1)==0x06)) //判断协议,显示包数据
- show(a);
- }//endmain
- void show(struct ether_arp *a)
- {
- printf("header:%d\n",a->eahdr);
- printf("dest ip = %d",a->tpa);
- printf("source ip =%d",a->spa);
- printf("dest mac =%d",a->tha);
- printf("source ip =%d",a->sha);
- return;
- }
复制代码 |
|