Permalink
Browse files

API change: return {pkthdr, list()}

Somehow the second element of the tagged pkthdr tuple was a tuple rather
than a proplist. I blame my keyboard: must've typed a { instead of a [ ...
and a ei_x_encode_tuple_header instead of ei_x_encode_list_header() <.<

This is a backwards incompatible change. The idea was that the tuple was
like the pkthdr struct and so was ordered and tagged with the field name.
The list is still ordered but can be used as a proplist.
  • Loading branch information...
msantos committed Mar 9, 2011
1 parent 3d82ba6 commit 89c22645298636b2aecaeeb1213ccd75561ac5fb
Showing with 10 additions and 6 deletions.
  1. +6 −3 c_src/epcap.c
  2. +4 −3 src/sniff.erl
View
@@ -228,12 +228,12 @@ epcap_response(struct pcap_pkthdr *hdr, const u_char *pkt, unsigned int datalink
IS_FALSE(ei_x_new_with_version(&msg));
IS_FALSE(ei_x_encode_list_header(&msg, 2));
- /* {pkthdr, {{time, Time}, {caplen, CapLength}, {len, ActualLength}}} */
+ /* {pkthdr, [{time, Time}, {caplen, CapLength}, {len, ActualLength}]} */
IS_FALSE(ei_x_encode_tuple_header(&msg, 2));
IS_FALSE(ei_x_encode_atom(&msg, "pkthdr"));
- /* { */
- IS_FALSE(ei_x_encode_tuple_header(&msg, 4));
+ /* [ */
+ IS_FALSE(ei_x_encode_list_header(&msg, 4));
/* {time, {MegaSec, Sec, MicroSec}} */
IS_FALSE(ei_x_encode_tuple_header(&msg, 2));
@@ -259,6 +259,9 @@ epcap_response(struct pcap_pkthdr *hdr, const u_char *pkt, unsigned int datalink
IS_FALSE(ei_x_encode_atom(&msg, "datalink"));
IS_FALSE(ei_x_encode_long(&msg, datalink));
+ /* ] */
+ IS_FALSE(ei_x_encode_empty_list(&msg));
+
/* } */
/* {packet, Packet} */
View
@@ -81,14 +81,15 @@ handle_sync_event(_Event, _From, StateName, State) ->
%% State: sniffing
%%
handle_info([
- {pkthdr, {{time, Time}, {caplen, CapLen}, {len, Len}}},
+ {pkthdr, [{time, Time}, {caplen, CapLen}, {len, Len}, {datalink, DLT}]},
{packet, Packet}
], sniffing, _) ->
[Ether, IP, Hdr, Payload] = pkt:decapsulate(Packet),
error_logger:info_report([
{time, timestamp(Time)},
- {caplen,CapLen},
- {len,Len},
+ {caplen, CapLen},
+ {len, Len},
+ {datalink, DLT},
% Source
{source_macaddr, string:join(ether_addr(Ether#ether.shost), ":")},

0 comments on commit 89c2264

Please sign in to comment.