-
Notifications
You must be signed in to change notification settings - Fork 0
/
arphdr.h
59 lines (54 loc) · 1.39 KB
/
arphdr.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <cstdint>
#include <arpa/inet.h>
#include "mac.h"
#include "ip.h"
#pragma pack(push, 1)
struct ArpHdr final {
uint16_t hrd_;
uint16_t pro_;
uint8_t hln_;
uint8_t pln_;
uint16_t op_;
Mac smac_;
Ip sip_;
Mac tmac_;
Ip tip_;
uint16_t hrd() { return ntohs(hrd_); }
uint16_t pro() { return ntohs(pro_); }
uint8_t hln() { return hln_;}
uint8_t pln() { return pln_;}
uint16_t op() { return ntohs(op_); }
Mac smac() { return smac_; }
Ip sip() { return ntohl(sip_); }
Mac tmac() { return tmac_; }
Ip tip() { return ntohl(tip_); }
// HardwareType(hrd_)
enum: uint16_t {
NETROM = 0, // from KA9Q: NET/ROM pseudo
ETHER = 1, // Ethernet 10Mbps
EETHER = 2, // Experimental Ethernet
AX25 = 3, // AX.25 Level 2
PRONET = 4, // PROnet token ring
CHAOS = 5, // Chaosnet
IEEE802 = 6, // IEEE 802.2 Ethernet/TR/TB
ARCNET = 7, // ARCnet
APPLETLK = 8, // APPLEtalk
LANSTAR = 9, // Lanstar
DLCI = 15, // Frame Relay DLCI
ATM = 19, // ATM
METRICOM = 23, // Metricom STRIP (new IANA id)
IPSEC = 31 // IPsec tunnel
};
// Operation(op_)
enum: uint16_t {
Request = 1, // req to resolve address
Reply = 2, // resp to previous request
RevRequest = 3, // req protocol address given hardware
RevReply = 4, // resp giving protocol address
InvRequest = 8, // req to identify peer
InvReply = 9 // resp identifying peer
};
};
typedef ArpHdr *PArpHdr;
#pragma pack(pop)