-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathnstack_arp.h
75 lines (64 loc) · 1.39 KB
/
nstack_arp.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* @addtogroup ARP
* @{
*/
#pragma once
#include "nstack_in.h"
#include "nstack_link.h"
/**
* ARP IP protocol message.
*/
struct arp_ip {
uint16_t arp_htype; /*!< HW type */
uint16_t arp_ptype; /*!< Protocol type */
uint8_t arp_hlen; /*!< HW addr len */
uint8_t arp_plen; /*!< Proto addr len */
uint16_t arp_oper; /*!< Opcode */
mac_addr_t arp_sha; /*!< Sender HW addr */
in_addr_t arp_spa; /*!< Sender IP addr */
mac_addr_t arp_tha; /*!< Target HW addr */
in_addr_t arp_tpa; /*!< Target IP addr */
} __attribute__((packed, aligned(2)));
/**
* arp_htype
* @{
*/
#define ARP_HTYPE_ETHER 1
/**
* @}
*/
/**
* arp_oper
* @{
*/
#define ARP_OPER_REQUEST 1 /*!< Request */
#define ARP_OPER_REPLY 2 /*!< Repply */
/**
* @}
*/
/**
* ARP Cache Operations.
*/
/**
* ARP Cache entry type.
*/
enum arp_cache_entry_type {
ARP_CACHE_FREE = -2, /*!< Unused entry. */
ARP_CACHE_STATIC = -1, /*!< Static entry. */
ARP_CACHE_DYN = 0, /*!< Dynamic entry. */
};
int arp_cache_insert(in_addr_t ip_addr,
const mac_addr_t ether_addr,
enum arp_cache_entry_type type);
void arp_cache_remove(in_addr_t ip_addr);
int arp_cache_get_haddr(in_addr_t iface, in_addr_t ip_addr, mac_addr_t haddr);
/**
* @}
*/
/**
* Announce an IP address with ARP.
*/
int arp_gratuitous(int ether_handle, in_addr_t spa);
/**
* @}
*/