anchor.diff:  
   %% API
   -export([decode_addr/1, encode_addr/1,
  -         decode/1, encode/1,
  +         decode/1, decode/2, encode/1,
            decode_protocol/1, encode_protocol/1,
  +         header_checksum/1,
            addr_len/0]).
   
   -include("types.hrl").
  
positive.code:              src=SrcIP,
               dst=DestIP,
               options=Options,
               data=Data}) ->
      OptsLen = length(Options),
      Opts = not_implemented:encode_options(Options),
      RestDgram = <<Opts:OptsLen/binary, Data/binary>>,
      <<?IP_VERSION:4, HLen:4, DiffServ:8, TotLen:16,
       ID:16, Flags:3/bits, FragOff:13, TTL:8, Proto:8, HdrChkSum:16,
       SrcIP:4/binary, DestIP:4/binary, RestDgram/binary>>.
  
  addr_len() -> 4.
  
  
negative.code:           frag_offset=FragOff,
            ttl=TTL,
            proto=Protocol,
            hdr_csum=check_header_checksum(Dgram, HLen, HdrChkSum),
            src=decode_addr(SrcIP),
            dst=decode_addr(DestIP),
            options=decode_options(Opts),
            data=enet_codec:decode(Protocol, Data, DecodeOptions)};
  decode(_Dgram, _) ->
      {error, bad_packet}.
  
  expand(Pkt = #ipv4{options=Opts}) when is_list(Opts) ->
      expand(Pkt#ipv4{options=encode_options(Opts)});
  expand(Pkt = #ipv4{hlen=H, options=Opts}) when not is_integer(H), is_binary(Opts) ->
      expand(Pkt#ipv4{hlen=5 + (byte_size(Opts) div 4)});
  expand(Pkt = #ipv4{totlen=T, hlen=H, data=D})
    when not is_integer(T), is_integer(H), is_binary(D) ->
      expand(Pkt#ipv4{totlen=H + byte_size(D)});
  expand(Pkt = #ipv4{flags=Flags}) when is_list(Flags) ->
      expand(Pkt#ipv4{flags=encode_flags(Flags)});
  expand(Pkt = #ipv4{src=Src}) when not (is_binary(Src) andalso byte_size(Src) =:= 4) ->
      expand(Pkt#ipv4{src=encode_addr(Src)});
  expand(Pkt = #ipv4{dst=Dst}) when not (is_binary(Dst) andalso byte_size(Dst) =:= 4) ->
      expand(Pkt#ipv4{dst=encode_addr(Dst)});
  expand(Pkt = #ipv4{proto=P}) when not is_integer(P) ->
      expand(Pkt#ipv4{proto=encode_protocol(P)});
  expand(Pkt = #ipv4{hdr_csum=S}) when not is_integer(S) ->
      expand(Pkt#ipv4{hdr_csum=header_checksum(Pkt)});
  expand(Pkt) ->
      Pkt.
  
  encode(#ipv4{vsn=?IP_VERSION,
               hlen=HLen,
  