#include <pcap.h>
#include <stdio.h>
#include <netinet/ip.h>
#include <netinet/if_ether.h>
#include <netinet/tcp.h>
void tcp_packet_callback(unsigned char *argument,const struct pcap_pkthdr* pcap_header,const unsigned char *packet_content) {
struct tcphdr *tcpptr=(struct tcphdr *)(packet_content+14+20);
printf("----tcp protocol-----/n");
printf("source port:%d/n",ntohs(tcpptr->source));
printf("dest port:%d/n",ntohs(tcpptr->dest));
printf("sequence number:%u/n",ntohl(tcpptr->seq));
printf("acknowledgement number:%u/n",ntohl(tcpptr->ack_seq));
printf("header length:%d/n",tcpptr->doff*4);
printf("check sum:%d/n",ntohs(tcpptr->check));
printf("window size:%d/n",ntohs(tcpptr->window));
printf("urgent pointer:%d/n",ntohs(tcpptr->urg_ptr));
}