Subop has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I need your help!
I'm pretty new to programming and have been trying to understand (un)pack. However, the problem I have is trying to determine the templates.
Here is a small snippet of code from ChaosReader (http://chaosreader.sourceforge.net/)
### Unpack IP data ($ip_verNihl,$ip_tos,$ip_length,$ip_ident,$ip_flagNfrag, $ip_ttl,$ip_protocol,$ip_checksum,@ip_src[0..3], @ip_dest[0..3],$ip_data) = unpack('CCnnnCCa2CCCCCCCCa*', $ether_data);
How am I supposed to know that "CCnnnCCa2CCCCCCCCa*" is the correct template when decoding IP packets? It's network data so I would think I should be using "n" or "N" all the time, but it's only used three times in the above code.
Any help is appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help with (un)pack templates
by gmargo (Hermit) on Dec 20, 2009 at 13:57 UTC | |
by AnomalousMonk (Archbishop) on Dec 20, 2009 at 15:52 UTC | |
by Subop (Acolyte) on Dec 20, 2009 at 14:01 UTC | |
by gmargo (Hermit) on Dec 20, 2009 at 14:08 UTC | |
by Subop (Acolyte) on Dec 20, 2009 at 14:23 UTC | |
by gmargo (Hermit) on Dec 20, 2009 at 14:39 UTC | |
| |
|
Re: Need help with (un)pack templates
by BrowserUk (Patriarch) on Dec 20, 2009 at 13:43 UTC | |
by Subop (Acolyte) on Dec 20, 2009 at 13:58 UTC | |
by BrowserUk (Patriarch) on Dec 20, 2009 at 14:32 UTC | |
|
Re: Need help with (un)pack templates
by planetscape (Chancellor) on Dec 20, 2009 at 22:07 UTC |