Por favor, ajude-me a entender o que a última linha faz:
int PCKT_LEN = 8192;
char buffer[PCKT_LEN];
struct iphdr *ip = (struct iphdr *) buffer;
struct udphdr *udp = (struct udphdr *) (buffer + sizeof(struct iphdr));
Eu conheço esse, eu meio que entendo assim:
(struct udphdr *) -> Means cast to a udphdr "object"/instance or something like that.
Este, tenho dúvida/não entendo:
(buffer + sizeof(struct iphdr))
This one, I don't quite understand. Is it because it uses the ADDRESS being returned by buffer and then adds the actual size of the buffer until the last byte as an offset before starting to allocate udp memory range? I guess the it wants to start the address of udp right after the ip ?
Se eu fizer a última linha como abaixo, será igual? (mudei o buffer para ip )
struct udphdr *udp = (struct udphdr *) (ip + sizeof(struct iphdr));
Obrigado.
Cumprimentos,
X
(Sou um novato em CPP e comecei com ponteiros e estruturas.)