Working with pcap I declare the rtp struct and when I try to point to this area of the packet I found that depending on my declaration, it works in a different way.
I wrote this:
struct udphdr *udp;
struct rtphdr *rtp, *rtp2;
udp = (struct udphdr*) (packet + sizeof(struct ether_header) + (ip->ip_hl*4));
rtp = (struct rtphdr*) (packet + sizeof(struct ether_header) + (ip->ip_hl*4) + sizeof(struct udphdr));
rtp2 = (struct rtphdr*) (udp + sizeof(struct udphdr));
printf("UPD header: %p\n",udp);
printf("RTP header 1: %p\n",rtp);
printf("RTP header 2: %p\n",rtp2);
And the output is:
UDP header: 0x7fcea3802222
RTP header 1: 0x7fcea380222a
RTP header 2: 0x7fcea3802262
Why with the first declaration it adds the 8 Bytes of the UDP header (0x2a - 0x22 = 0x8) and with the other it a lot more.
Thanks