anchor.diff:  -endif.
   
   %% api
  --export([handle/1,
  -         handle_datagram/1,
  -         unpack/2,
  +-export([handle/2,
  +         handle_datagram/2,
  +         unpack/3,
            pack/1]).
   
   -opaque endpoint() :: {endpoint, list( endpoint_option())}.
  
positive.code: %% {messages, ppspp_messages()}
  %% ].
  
  -spec unpack(binary(), endpoint()) -> datagram().
  unpack(Raw_Datagram, _Endpoint) ->
      {Channel, Maybe_Messages} = ppspp_channel:unpack_with_rest(Raw_Datagram),
      ?DEBUG("dgram: received on channel ~p~n",
             [ppspp_channel:channel_to_string(Channel)]),
      Parsed_Messages = ppspp_message:unpack(Maybe_Messages),
      Parsed_Datagram = orddict:from_list([Channel, {messages, Parsed_Messages}]),
      {datagram, Parsed_Datagram}.
  
  
negative.code: %% @spec handle_datagram() -> ok
  %% @end
  -spec handle({udp, inet:socket(), inet:ip_address(), inet:port_number(),
                binary()}, ppspp_options:options()) -> ok.
  
  handle(_Packet = {udp, Socket, Peer_IP_Address, Peer_Port, Maybe_Datagram},
         Swarm_Options) ->
      Channel = ppspp_channel:unpack_channel(Maybe_Datagram),
      Endpoint = build_endpoint(udp, Socket, Peer_IP_Address, Peer_Port, Channel),
      Datagram = unpack(Maybe_Datagram, Endpoint, Swarm_Options),
      ?DEBUG("dgram: got valid datagram ~p~n", [Datagram]),
      % NB usually called from spawned process, so return values are ignored
      handle_datagram(Datagram, Swarm_Options).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %% @doc Extract PPSPP channel ID from header of datagram
  