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.
10 #include <netinet/in.h> /* for ntohs() */
14 #include "dissector_eth.h"
19 uint16_t ar_hrd
; /* format of hardware address */
20 uint16_t ar_pro
; /* format of protocol address */
21 uint8_t ar_hln
; /* length of hardware address */
22 uint8_t ar_pln
; /* length of protocol address */
23 uint16_t ar_op
; /* ARP opcode (command) */
24 uint8_t ar_sha
[6]; /* sender hardware address */
25 uint8_t ar_sip
[4]; /* sender IP address */
26 uint8_t ar_tha
[6]; /* target hardware address */
27 uint8_t ar_tip
[4]; /* target IP address */
30 #define ARPOP_REQUEST 1 /* ARP request */
31 #define ARPOP_REPLY 2 /* ARP reply */
32 #define ARPOP_RREQUEST 3 /* RARP request */
33 #define ARPOP_RREPLY 4 /* RARP reply */
34 #define ARPOP_InREQUEST 8 /* InARP request */
35 #define ARPOP_InREPLY 9 /* InARP reply */
36 #define ARPOP_NAK 10 /* (ATM)ARP NAK */
38 static void arp(struct pkt_buff
*pkt
)
41 struct arphdr
*arp
= (struct arphdr
*) pkt_pull(pkt
, sizeof(*arp
));
46 switch (ntohs(arp
->ar_op
)) {
48 opcode
= "ARP request";
54 opcode
= "RARP request";
57 opcode
= "RARP reply";
60 opcode
= "InARP request";
63 opcode
= "InARP reply";
66 opcode
= "(ATM) ARP NAK";
74 tprintf("Format HA (%u), ", ntohs(arp
->ar_hrd
));
75 tprintf("Format Proto (%u), ", ntohs(arp
->ar_pro
));
76 tprintf("HA Len (%u), ", ntohs(arp
->ar_hln
));
77 tprintf("Proto Len (%u), ", ntohs(arp
->ar_pln
));
78 tprintf("Opcode (%u => %s)", ntohs(arp
->ar_op
), opcode
);
82 static void arp_less(struct pkt_buff
*pkt
)
85 struct arphdr
*arp
= (struct arphdr
*) pkt_pull(pkt
, sizeof(*arp
));
90 switch (ntohs(arp
->ar_op
)) {
92 opcode
= "ARP request";
98 opcode
= "RARP request";
101 opcode
= "RARP reply";
103 case ARPOP_InREQUEST
:
104 opcode
= "InARP request";
107 opcode
= "InARP reply";
110 opcode
= "(ATM) ARP NAK";
117 tprintf(" Op %s", opcode
);
120 struct protocol arp_ops
= {
123 .print_less
= arp_less
,
126 EXPORT_SYMBOL(arp_ops
);