I am trying to create a .pcap file after receiving the RTP pakacets. When trying to frame a fake IP header I am not able to directly specify IP address, I know that I need to use the structure below.
char src [] = "192.168.134.12"; / * Fake IP header * / hdrp- & gt; Iphdr.ip_v = 4; Hrp-> Iphdr.ip_hl = sizeof (HDR-> IPHDR) & gt; & Gt; 2; Hrp-> Iphdr.ip_len = htons (size (HDP-> iphdr) + size (HDR-> udphdr) + size file (RTP- & gt; rawdata + ASDFFARINFFST)); ** hdrp- & gt; Iphdr.ip_src = sstosin (& src); // error line hdrp-> Iphdr.ip_dst = sstosin (& src); // error line ** hdrp- & gt; Iphdr.ip_p = htons (16001); HDR-> Iphdr.ip_id = htons (i ++); HDR-> Iphdr.ip_ttl = 127; Hrp-> Iphdr.ip_sum = rtpp_in_cksum (& amp; (HDR-> IPHDR), Size (HDP-> IPHDR)); / * Fake UDP header * / ** HDRP-> Udphdr.uh_sport = sstosin (& src); // Error Line ** HDRP-> Udphdr.uh_dport = htons (6666); Hrp-> Udphdr.uh_ulen = htons (size (HDR-> udphdr) + size file (RTP-> rawdata + ASDAFARINFFST)); This structure structure in_addr {unsigned long s_addr;}
How can I specify an IP address "unsigned long sd"?
How do I assign hard codes or these IP addresses to my IP addresses ??
You can assign an array. Try the memset instead:
Something like this:
memcpy (destAddr, srcAddr, sizeof (data));
Comments
Post a Comment