Fix issue in l3 mode when no arp reply was received
[samplevnf.git] / VNFs / DPPD-PROX / packet_utils.h
1 /*
2 // Copyright (c) 2010-2017 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 #ifndef _PACKET_UTILS_H_
17 #define _PACKET_UTILS_H_
18
19 #include "arp.h"
20 #include "quit.h"
21 #include "prox_malloc.h"
22 #include "defaults.h"
23 #include "prox_cfg.h"
24 #include "etypes.h"
25
26 #define FLAG_DST_MAC_KNOWN      1
27 #define MAX_ARP_ENTRIES 65536
28
29 #define IP4(x) x & 0xff, (x >> 8) & 0xff, (x >> 16) & 0xff, x >> 24
30
31 struct task_base;
32 struct task_args;
33 struct arp_table {
34         uint64_t arp_update_time;
35         uint64_t arp_timeout;
36         uint32_t ip;
37         struct ether_addr mac;
38 };
39 struct l3_base {
40         struct rte_ring *ctrl_plane_ring;
41         struct task_base *tmaster;
42         uint32_t flags;
43         uint32_t n_pkts;
44         uint8_t reachable_port_id;
45         uint8_t core_id;
46         uint8_t task_id;
47         struct arp_table gw;
48         struct arp_table optimized_arp_table[4];
49         struct rte_hash *ip_hash;
50         struct arp_table *arp_table;
51 };
52
53 void task_init_l3(struct task_base *tbase, struct task_args *targ);
54 void task_start_l3(struct task_base *tbase, struct task_args *targ);
55 int write_dst_mac(struct task_base *tbase, struct rte_mbuf *mbuf, uint32_t *ip_dst);
56 void task_set_gateway_ip(struct task_base *tbase, uint32_t ip);
57 void task_set_local_ip(struct task_base *tbase, uint32_t ip);
58 void handle_ctrl_plane_pkts(struct task_base *tbase, struct rte_mbuf **mbufs, uint16_t n_pkts);
59
60 #endif /* _PACKET_UTILS_H_ */