-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patharp.c
90 lines (76 loc) · 1.89 KB
/
arp.c
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <stdint.h>
#include <assert.h>
#include <rte_ether.h>
#include <rte_ip.h>
#include <rte_arp.h>
#include <rte_table_hash.h>
#include <rte_jhash.h>
#include <rte_rwlock.h>
#include "config.h"
//enum arp_hrd_format {
// arp_hrd_ethernet = 1,
//};
//
struct arp_queue_entry {
uint32_t ip; /* target ip address */
int nif_out; /* output interface number */
uint32_t ts_out; /* last sent timestamp */
TAILQ_ENTRY(arp_queue_entry) link;
};
//static void *arp_table;
static TAILQ_HEAD(, arp_queue_entry) list;
static rte_rwlock_t lock;
static int
process_request(struct arp_hdr *arph)
{
return 0;
}
int
arp_input(struct rte_mbuf *m)
{
struct arp_hdr *arph;
int rc;
arph = rte_pktmbuf_mtod(m, struct arp_hdr *);
if (ust_ip_addr != rte_be_to_cpu_32(arph->arp_data.arp_tip)) {
goto out;
}
switch (rte_be_to_cpu_16(arph->arp_op)) {
default:
rc = -EINVAL;
break;
case ARP_OP_REQUEST:
rc = process_request(arph);
break;
case ARP_OP_REPLY:
break;
}
out:
rte_pktmbuf_free(m);
return rc;
}
int
arp_output(struct rte_mbuf *mbuf)
{
return 0;
}
int
arp_init()
{
//const struct rte_table_ops *ops = &rte_table_hash_key8_ext_ops;
//struct rte_table_hash_key8_ext_params hash_params = {
// .n_entries = 1 << 10,
// .n_entries_ext = 1 << 4,
// //.f_hash = pipeline_test_hash,
// //.seed = 0,
// //.signature_offset = APP_METADATA_OFFSET(1),
// //.key_offset = APP_METADATA_OFFSET(32),
// .key_mask = NULL,
//};
//uint32_t aa = rte_jhash_1word(0x1234, 0);
//assert(!arp_table);
//arp_table = ops->f_create(&hash_params, 0, 1);
//if (arp_table != NULL)
// return -1;
rte_rwlock_init(&lock);
return 0;
}