clark, I'd suggest you this:
Code:
50 if(memcmp(ptr,"MPLS0100",8))
51 return -1;
you can either make it ..."MPLS0",5... or check for MPLS0200, too.
and
Code:
58 unsigned char* pp=ptr+68;
60 if(pp+num*82>ptr+len)
...
72 pp+=82;
This can lead you to troubles. ptr[68] and [69] keep the length of the current segment, so it is correct to increment pp in line 72 not by 82 but with the value in 68/69.
Then for the next cycle use pp as the base for other chapter calculations.