FD.io VPP  v17.10-9-gd594711
Vector Packet Processing
client.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 /*
16  * client.h: dhcp client
17  */
18 
19 #ifndef included_dhcp_client_h
20 #define included_dhcp_client_h
21 
22 #include <vnet/ip/ip.h>
23 #include <vnet/dhcp/dhcp4_packet.h>
24 
25 #define foreach_dhcp_client_state \
26 _(DHCP_DISCOVER) \
27 _(DHCP_REQUEST) \
28 _(DHCP_BOUND)
29 
30 typedef enum {
31 #define _(a) a,
33 #undef _
35 
36 typedef struct {
38 
39  /* the interface in question */
41 
42  /* State machine retry counter */
44 
45  /* Send next pkt at this time */
48 
49  /* DHCP transaction ID, a random number */
51 
52  /* leased address, other learned info DHCP */
53  ip4_address_t leased_address; /* from your_ip_address field */
55  u32 subnet_mask_width; /* option 1 */
56  ip4_address_t router_address; /* option 3 */
57  u32 lease_renewal_interval; /* option 51 */
58  u32 lease_lifetime; /* option 59 */
59 
60  /* Requested data (option 55) */
62 
64 
65  /* hostname and software client identifiers */
67  u8 * client_identifier; /* software version, e.g. vpe 1.0*/
68 
69  /* Information used for event callback */
74 
75 typedef struct {
76  /* DHCP client pool */
80 
81  /* convenience */
85 
86 typedef struct {
87  int is_add;
89 
90  /* vectors, consumed by dhcp client code */
93 
94  /* Bytes containing requested option numbers */
96 
97  /* Information used for event callback */
102 
104 
105 #define EVENT_DHCP_CLIENT_WAKEUP 1
106 
107 int dhcp_client_for_us (u32 bi0,
108  vlib_buffer_t * b0,
109  ip4_header_t * ip0,
110  udp_header_t * u0,
111  dhcp_header_t * dh0);
112 
114  u32 sw_if_index,
115  u8 * hostname,
116  u8 * client_id,
117  u32 is_add,
118  u32 client_index,
119  void *event_callback,
120  u32 pid);
121 
122 #endif /* included_dhcp_client_h */
dhcp_client_main_t dhcp_client_main
Definition: client.h:103
u32 retry_count
Definition: client.h:43
f64 next_transmit
Definition: client.h:46
u32 transaction_id
Definition: client.h:50
u8 * hostname
Definition: client.h:66
dhcp_client_t * clients
Definition: client.h:77
u32 lease_lifetime
Definition: client.h:58
u8 * l2_rewrite
Definition: client.h:63
#define foreach_dhcp_client_state
Definition: client.h:25
u32 client_index
Definition: client.h:70
dhcp_client_state_t
Definition: client.h:30
vlib_main_t * vlib_main
Definition: client.h:82
int dhcp_client_for_us(u32 bi0, vlib_buffer_t *b0, ip4_header_t *ip0, udp_header_t *u0, dhcp_header_t *dh0)
Definition: client.c:141
u32 subnet_mask_width
Definition: client.h:55
vlib_main_t * vm
Definition: buffer.c:283
dhcp_client_state_t state
Definition: client.h:37
u8 * option_55_data
Definition: client.h:61
unsigned int u32
Definition: types.h:88
u32 lease_renewal_interval
Definition: client.h:57
u32 sw_if_index
Definition: client.h:40
u64 uword
Definition: types.h:112
f64 lease_expires
Definition: client.h:47
double f64
Definition: types.h:142
unsigned char u8
Definition: types.h:56
ip4_address_t dhcp_server
Definition: client.h:54
uword * client_by_sw_if_index
Definition: client.h:78
void * event_callback
Definition: client.h:72
ip4_address_t router_address
Definition: client.h:56
vnet_main_t * vnet_main
Definition: client.h:83
int dhcp_client_config(vlib_main_t *vm, u32 sw_if_index, u8 *hostname, u8 *client_id, u32 is_add, u32 client_index, void *event_callback, u32 pid)
Definition: client.c:937
ip4_address_t leased_address
Definition: client.h:53
u8 * client_identifier
Definition: client.h:67