In order to write a packet sniffer I need to be able to index through the bytes of the packet.
I have come from python, in python you can index through a list very easily eg;
variable = data[2:5]. In c++ you can't do it like that.
Here is a snippet of my code
void ethernet_frame(char raw_data[19]){
struct ethernet{
char dest_mac[6] = get_mac_addr(raw_data[:7]);
char src_mac[6] = get_mac_addr(raw_data[7:14]);
unsigned short proto = proto[14:17];
};
}
I expect that there is an alternative or perhaps a library I can use to index through the packet.
Aucun commentaire:
Enregistrer un commentaire