2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2009, 2010 Daniel Borkmann.
5 * Subject to the GPL, version 2.
9 #include <netinet/in.h> /* for ntohs() */
13 #include "dissector_eth.h"
18 uint16_t ar_hrd
; /* format of hardware address */
19 uint16_t ar_pro
; /* format of protocol address */
20 uint8_t ar_hln
; /* length of hardware address */
21 uint8_t ar_pln
; /* length of protocol address */
22 uint16_t ar_op
; /* ARP opcode (command) */
23 uint8_t ar_sha
[6]; /* sender hardware address */
24 uint8_t ar_sip
[4]; /* sender IP address */
25 uint8_t ar_tha
[6]; /* target hardware address */
26 uint8_t ar_tip
[4]; /* target IP address */
29 #define ARPOP_REQUEST 1 /* ARP request */
30 #define ARPOP_REPLY 2 /* ARP reply */
31 #define ARPOP_RREQUEST 3 /* RARP request */
32 #define ARPOP_RREPLY 4 /* RARP reply */
33 #define ARPOP_InREQUEST 8 /* InARP request */
34 #define ARPOP_InREPLY 9 /* InARP reply */
35 #define ARPOP_NAK 10 /* (ATM)ARP NAK */
37 static void arp(struct pkt_buff
*pkt
)
40 struct arphdr
*arp
= (struct arphdr
*) pkt_pull(pkt
, sizeof(*arp
));
45 switch (ntohs(arp
->ar_op
)) {
47 opcode
= "ARP request";
53 opcode
= "RARP request";
56 opcode
= "RARP reply";
59 opcode
= "InARP request";
62 opcode
= "InARP reply";
65 opcode
= "(ATM) ARP NAK";
73 tprintf("Format HA (%u), ", ntohs(arp
->ar_hrd
));
74 tprintf("Format Proto (%u), ", ntohs(arp
->ar_pro
));
75 tprintf("HA Len (%u), ", ntohs(arp
->ar_hln
));
76 tprintf("Proto Len (%u), ", ntohs(arp
->ar_pln
));
77 tprintf("Opcode (%u => %s)", ntohs(arp
->ar_op
), opcode
);
81 static void arp_less(struct pkt_buff
*pkt
)
84 struct arphdr
*arp
= (struct arphdr
*) pkt_pull(pkt
, sizeof(*arp
));
89 switch (ntohs(arp
->ar_op
)) {
91 opcode
= "ARP request";
97 opcode
= "RARP request";
100 opcode
= "RARP reply";
102 case ARPOP_InREQUEST
:
103 opcode
= "InARP request";
106 opcode
= "InARP reply";
109 opcode
= "(ATM) ARP NAK";
116 tprintf(" Op %s", opcode
);
119 struct protocol arp_ops
= {
122 .print_less
= arp_less
,
125 EXPORT_SYMBOL(arp_ops
);