Skip to content

Instantly share code, notes, and snippets.

@DanielBaulig
Created June 16, 2011 09:24
Show Gist options
  • Save DanielBaulig/1028939 to your computer and use it in GitHub Desktop.
Save DanielBaulig/1028939 to your computer and use it in GitHub Desktop.
node pcap fix issue 31
decode.ip6_header = function(raw_packet, next_header, ip, offset) {
switch (next_header) {
case 1:
ip.protocol_name = "ICMP";
ip.icmp = decode.icmp(raw_packet, offset);
break;
case 2:
ip.protocol_name = "IGMP";
ip.igmp = decode.igmp(raw_packet, offset);
break;
case 6:
ip.protocol_name = "TCP";
ip.tcp = decode.tcp(raw_packet, offset, ip);
break;
case 17:
ip.protocol_name = "UDP";
ip.udp = decode.udp(raw_packet, offset);
break;
default:
// if this is 0, undefined or null the recursion is/will get stuck!
if (raw_packet[offset+1]) {
// TODO: capture the extensions
decode.ip6_header(raw_packet, raw_packet[offset], ip, offset + raw_packet[offset+1]);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment