On 03/05/2013 09:35 PM, Jon Schipp wrote:
I'm a little confused on how this works. I posted this too so that it may
be referenced to in the future for those that do not have a background in CS.
I will write about this later too in documentation.

Trying to understand this:

  /* TCP Header length + TCP SYN/ECN Flag */
c16((0x8 << 12) | SYN | ECN)

Okay, so we have a 16 byte constant representing HL + rsvd + tcp[13] code flags

Nitpick: 16 Bit, not Byte.

I understand the first operation:
((0x8 << 12))  shift 12 bits to the left of 8.

Yes, the value of 8 is being shifted left by 12 positions.

Gives us 1000000000000000 which is the 2 bytes necessary for c16
$ echo -n 1000000000000000 | wc -c
16

I understand the SYN and ECN operations taken individually.
e.g. SYN = 2 (0000 0010) - The SYN bit. ECN = 64 (0100 0000) - The ECN bit

The pipe (|) used in the trafgen language is an OR operator correct?

Yep.

Presuming this
I get 1000 0000 0100 0010 as a final result. Looks right to me.

Yep. It emits hex code 80 42 or binary 1000000001000010.

Pardon in advance for what may be incorrect terminology, (corrections
accepted).
So is the flow like this (I'm interested in the details so I can
better understand)?

1.  evaluate first expression  (0x8 << 12)
2.  evaluate second expression (1 << 1)
3.  evaluate third expression ( 1 << 6 )
4. OR first and second expression
5. OR result from above(step 5) with third expression
6. Result is c16(1000000001000010)

Is this all correct?

Yep. In trafgen_parser.y you find the compile-time evaluator implementation
for this.

--
You received this message because you are subscribed to the Google Groups 
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to