Code:
sa = trace_get_source_address(packet, &addr);
printf("packet is type %d af_inet=%d\n", sa->sa_family, AF_INET);
if (sa->sa_family == AF_INET) {
/* ipv4 packet */
struct sockaddr_in *sa_in = (struct sockaddr_in *) sa;
printf("Source Address:%s\n", inet_ntoa(sa_in->sin_addr));
// buffer[20]= 0;
} else if (sa->sa_family == AF_INET6) {
/* ipv6 packet */
} else {
/* unknown packet */
}
sport=trace_get_source_port(packet);
printf("Source Port is: %d\n", htons(sport));
bind(sockfd, (struct sockaddr *)&sa, sizeof(struct sockaddr));
sd=trace_get_destination_address(packet, &daddr);
sd->sa_data;
struct sockaddr_in *sd_in = (struct sockaddr_in *) sd;
printf("Destination Adress:%s\n", inet_ntoa(sd_in->sin_addr));
dport=trace_get_destination_port(packet);
printf("Destination port is: %d\n", htons(&dport));
bind(sockfd_d, (struct sockaddr *)&sd, sizeof(struct sockaddr));
libtrace_tcp_t *t=trace_get_tcp(packet);
printf("Sequence No. for this packet is: %u\n", ntohl(t->seq));
while(i<count)
{i++;
/*sa_p = sa.sa_in->sin_addr;
sd_p1 = &sd;
sport_p == sport;
dport_p == dport;*/
//libtrace_tcp_t *t_p = *t;
while(i<count)
{
if(sockfd=sockfd++ && sockfd_d == sockfd_d++)
{
//x=sockfd++;
if((sport=sport++) && (dport=dport++))
{
if(t = t++)
{
count_flow++;
}
}
}
i++;
}
}
printf("No. of flows in the packet are: %d\n", count_flow);
Above is the piece of code and I am having problem:
Code:
if(sockfd=sockfd++ && sockfd_d == sockfd_d++)
if((sport=sport++) && (dport=dport++))
if(t = t++)
I have tried lots of things but all proved futile then I used this bind it works fine with the socket address but port address itself is integer. Now I dont know my code runs fine but it returns the same no. of flows as the no. of packets means something is going wrong with it. Please help somebody.