-2

i'm trying to make a .pcap file after receiving RTP pcakets. While trying to frame a fake ip header i'm not able to assign ip address directly I know i need to use the structure as below .

char src[]="192.168.134.12";
/* Prepare fake IP header */
hdrp->iphdr.ip_v = 4;
hdrp->iphdr.ip_hl = sizeof(hdrp->iphdr) >> 2;
hdrp->iphdr.ip_len = htons(sizeof(hdrp->iphdr) + sizeof(hdrp->udphdr) + sizeof(rtp->rawdata +   AST_FRIENDLY_OFFSET));
**hdrp->iphdr.ip_src = sstosin(&src);//error line
hdrp->iphdr.ip_dst = sstosin(&src);//error line**
hdrp->iphdr.ip_p = htons(16001);
hdrp->iphdr.ip_id = htons(i++);
hdrp->iphdr.ip_ttl = 127;
hdrp->iphdr.ip_sum = rtpp_in_cksum(&(hdrp->iphdr), sizeof(hdrp->iphdr));

/* Prepare fake UDP header */
**hdrp->udphdr.uh_sport = sstosin(&src);//error line**
hdrp->udphdr.uh_dport = htons(6666);
hdrp->udphdr.uh_ulen = htons(sizeof(hdrp->udphdr) + sizeof(rtp->rawdata + AST_FRIENDLY_OFFSET));

 This is the structure
 struct in_addr{
unsigned long s_addr;}

How can i assign ip address to "unsigned long s_addr"??

how do i hard code or assign my ip address to these error lines??

Prakash GiBBs
  • 297
  • 2
  • 13
  • possible duplicate of [convert string to ipaddress](http://stackoverflow.com/questions/5328070/convert-string-to-ipaddress) – xmojmr Nov 01 '14 at 18:00

1 Answers1

0

You cant assign an array. try memset instead:

something like that:

memcpy ( destAddr, srcAddr, sizeof(data) );
antonpuz
  • 3,256
  • 4
  • 25
  • 48