@@ -315,6 +315,10 @@ func (b IPv4) Flags() uint8 {
315315 return uint8 (binary .BigEndian .Uint16 (b [flagsFO :]) >> 13 )
316316}
317317
318+ func (b IPv4 ) FlagsDarwinRaw () uint8 {
319+ return uint8 (binary .BigEndian .Uint16 (b [flagsFO :]) >> 13 )
320+ }
321+
318322// More returns whether the more fragments flag is set.
319323func (b IPv4 ) More () bool {
320324 return b .Flags ()& IPv4FlagMoreFragments != 0
@@ -330,11 +334,19 @@ func (b IPv4) FragmentOffset() uint16 {
330334 return binary .BigEndian .Uint16 (b [flagsFO :]) << 3
331335}
332336
337+ func (b IPv4 ) FragmentOffsetDarwinRaw () uint16 {
338+ return binary .NativeEndian .Uint16 (b [flagsFO :]) << 3
339+ }
340+
333341// TotalLength returns the "total length" field of the IPv4 header.
334342func (b IPv4 ) TotalLength () uint16 {
335343 return binary .BigEndian .Uint16 (b [IPv4TotalLenOffset :])
336344}
337345
346+ func (b IPv4 ) TotalLengthDarwinRaw () uint16 {
347+ return binary .NativeEndian .Uint16 (b [IPv4TotalLenOffset :]) + uint16 (b .HeaderLength ())
348+ }
349+
338350// Checksum returns the checksum field of the IPv4 header.
339351func (b IPv4 ) Checksum () uint16 {
340352 return binary .BigEndian .Uint16 (b [xsum :])
@@ -428,6 +440,10 @@ func (b IPv4) SetTotalLength(totalLength uint16) {
428440 binary .BigEndian .PutUint16 (b [IPv4TotalLenOffset :], totalLength )
429441}
430442
443+ func (b IPv4 ) SetTotalLengthDarwinRaw (totalLength uint16 ) {
444+ binary .NativeEndian .PutUint16 (b [IPv4TotalLenOffset :], totalLength )
445+ }
446+
431447// SetChecksum sets the checksum field of the IPv4 header.
432448func (b IPv4 ) SetChecksum (v uint16 ) {
433449 checksum .Put (b [xsum :], v )
@@ -440,6 +456,11 @@ func (b IPv4) SetFlagsFragmentOffset(flags uint8, offset uint16) {
440456 binary .BigEndian .PutUint16 (b [flagsFO :], v )
441457}
442458
459+ func (b IPv4 ) SetFlagsFragmentOffsetDarwinRaw (flags uint8 , offset uint16 ) {
460+ v := (uint16 (flags ) << 13 ) | (offset >> 3 )
461+ binary .NativeEndian .PutUint16 (b [flagsFO :], v )
462+ }
463+
443464// SetID sets the identification field.
444465func (b IPv4 ) SetID (v uint16 ) {
445466 binary .BigEndian .PutUint16 (b [id :], v )
0 commit comments