From a0477a6737dd0012cadb88cebcc746d1c03c4fd0 Mon Sep 17 00:00:00 2001 From: Thomas Osterried Date: Sat, 12 Mar 2016 14:10:55 +0100 Subject: listen -a shows on segmented packets ok, but shows also the defragmented, packet, but garbled: bpq2: fm DL9SAU to DL9SAU-15 ctl I00+ pid=8(segment) len 4 remain 0 0000 E2 E3 E4 | ... Reason: the defragmented packet is passed to netif_rx(skb). It has skb->protocol = htons(ETH_P_IP), but still belongs to ifr.ifr_hwaddr.sa_family == AF_AX25. listen -a looks for every iface with like ifr.ifr_hwaddr.sa_family == AF_AX25 and thus gets the desegmented packet. This desegmented packet has already lost his ax25 header information (it's the IP datagram that netif_rx sees), prefixed by AX25_P_IP = 0xcc: strace: recvfrom(3, "\0\210\230r\246\202\252\340\210\230r\246\202\252\177\314\10\201\314E\0\1\1\0\32\0\0?\1!\327,\200\200\n,\200\200\1\0\0\347\300\21\6\0\1\26\23\303V.. recvfrom(3, "\314E\0\1\1\0\32\0\0?\1!\327,\200\200\n,\200\200\1\0\0\347\300\21\6\0\1\26\23\303V.. \314 == 0xcc == AX25_P_IP We can make safely make the assumption for first byte == 0xcc and length > 2, that we safeley can detect those IP frames, and then ignore it. Signed-off-by: Thomas Osterried --- listen/listen.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/listen/listen.c b/listen/listen.c index bf60281..ca933c6 100644 --- a/listen/listen.c +++ b/listen/listen.c @@ -188,6 +188,34 @@ int main(int argc, char **argv) if (sock == -1 || sigint) break; if (ifr.ifr_hwaddr.sa_family == AF_AX25) { + if (size > 2 && *buffer == 0xcc) { + /* IP packets from the ax25 de-segmenter + are seen on socket "PF_PACKET, + SOCK_PACKET, ETH_P_ALL" without + AX.25 header (just the IP-frame), + prefixed by 0xcc (AX25_P_IP). + It's unclear why in the kernel code + this happens (unsegmentet AX25 PID + AX25_P_IP have not this behavior). + We have already displayed all the + segments and like to ignore this + data. + AX.25 packets start with a kiss + byte (buffer[0]); ax25_dump() + looks for it. + There's no kiss command 0xcc + defined; kiss bytes are checked + against & 0xf (= 0x0c), which is + also not defined. + Kiss commands may have one argument. + => We can make safely make the + assumption for first byte == 0xcc + and length > 2, that we safeley can + detect those IP frames, and then + ignore it. + */ + continue; + } display_port(sa.sa_data); #ifdef NEW_AX25_STACK ax25_dump(buffer, size, dumpstyle); -- cgit v1.2.3