Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decode IP header from samples of MPLS-encapsulated packets #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/sflowtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,26 @@ static void decodeLinkLayer(SFSample *sample)
sample->s.gotIPV6 = YES;
sample->s.offsetToIPV6 = (ptr - start);
}

if(type_len == 0x8847) {
/* MPLS unicast - 4 bytes */
ptr += 4;
/* look at first byte of possible IP header.... */
if((*ptr >> 4) == 4) {
/* IPV4 - check again that we have enough header bytes */
if((end - ptr) < sizeof(struct myiphdr)) return;
if((*ptr & 15) < 5) return; /* not IP (hdr len must be 5 quads or more) */
/* survived all the tests - store the offset to the start of the ip header */
sample->s.gotIPV4 = YES;
sample->s.offsetToIPV4 = (ptr - start);
}
else if((*ptr >> 4) == 6) {
/* IPV6 */
/* survived all the tests - store the offset to the start of the ip6 header */
sample->s.gotIPV6 = YES;
sample->s.offsetToIPV6 = (ptr - start);
}
}
}

/*_________________---------------------------__________________
Expand Down