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.
13 #include <netinet/in.h> /* for ntohs() */
15 #include "proto_struct.h"
16 #include "dissector_eth.h"
21 uint16_t ar_hrd
; /* format of hardware address */
22 uint16_t ar_pro
; /* format of protocol address */
23 uint8_t ar_hln
; /* length of hardware address */
24 uint8_t ar_pln
; /* length of protocol address */
25 uint16_t ar_op
; /* ARP opcode (command) */
26 uint8_t ar_sha
[6]; /* sender hardware address */
27 uint8_t ar_sip
[4]; /* sender IP address */
28 uint8_t ar_tha
[6]; /* target hardware address */
29 uint8_t ar_tip
[4]; /* target IP address */
32 #define ARPOP_REQUEST 1 /* ARP request */
33 #define ARPOP_REPLY 2 /* ARP reply */
34 #define ARPOP_RREQUEST 3 /* RARP request */
35 #define ARPOP_RREPLY 4 /* RARP reply */
36 #define ARPOP_InREQUEST 8 /* InARP request */
37 #define ARPOP_InREPLY 9 /* InARP reply */
38 #define ARPOP_NAK 10 /* (ATM)ARP NAK */
40 static inline void arp(struct pkt_buff
*pkt
)
43 struct arphdr
*arp
= (struct arphdr
*) pkt_pull(pkt
, sizeof(*arp
));
48 switch (ntohs(arp
->ar_op
)) {
50 opcode
= "ARP request";
56 opcode
= "RARP request";
59 opcode
= "RARP reply";
62 opcode
= "InARP request";
65 opcode
= "InARP reply";
68 opcode
= "(ATM) ARP NAK";
76 tprintf("Format HA (%u), ", ntohs(arp
->ar_hrd
));
77 tprintf("Format Proto (%u), ", ntohs(arp
->ar_pro
));
78 tprintf("HA Len (%u), ", ntohs(arp
->ar_hln
));
79 tprintf("Proto Len (%u), ", ntohs(arp
->ar_pln
));
80 tprintf("Opcode (%u => %s)", ntohs(arp
->ar_op
), opcode
);
84 static inline void arp_less(struct pkt_buff
*pkt
)
87 struct arphdr
*arp
= (struct arphdr
*) pkt_pull(pkt
, sizeof(*arp
));
92 switch (ntohs(arp
->ar_op
)) {
94 opcode
= "ARP request";
100 opcode
= "RARP request";
103 opcode
= "RARP reply";
105 case ARPOP_InREQUEST
:
106 opcode
= "InARP request";
109 opcode
= "InARP reply";
112 opcode
= "(ATM) ARP NAK";
119 tprintf(" Op %s", opcode
);
122 struct protocol arp_ops
= {
125 .print_less
= arp_less
,
128 #endif /* PROTO_ARP_H */