FD.io VPP  v19.04.4-rc0-5-ge88582fac
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 {
32 #define _(a) a,
34 #undef _
36 
37 struct dhcp_client_t_;
38 
39 /**
40  * Callback function for DHCP complete events
41  */
42 typedef void (*dhcp_event_cb_t) (u32 client_index,
43  const struct dhcp_client_t_ * client);
44 
45 typedef struct dhcp_client_t_
46 {
48 
49  /* the interface in question */
51 
52  /* State machine retry counter */
54 
55  /* Send next pkt at this time */
58 
59  /* DHCP transaction ID, a random number */
61 
62  /* leased address, other learned info DHCP */
63  ip4_address_t leased_address; /* from your_ip_address field */
65  u32 subnet_mask_width; /* option 1 */
66  ip4_address_t router_address; /* option 3 */
67  u32 lease_renewal_interval; /* option 51 */
68  u32 lease_lifetime; /* option 59 */
69 
70  /* Requested data (option 55) */
72 
74 
75  /* hostname and software client identifiers */
77  u8 *client_identifier; /* software version, e.g. vpe 1.0 */
78 
79  /* Information used for event callback */
82 
83  /* Set the broadcast Flag in the Discover/Request messages */
85  /* Interface MAC address, so we can do an rx-packet-for-us check */
88 
91 
92 typedef struct
93 {
94  /* DHCP client pool */
98 
99  /* convenience */
103 
104 typedef struct
105 {
106  int is_add;
109 
110  /* vectors, consumed by dhcp client code */
113 
114  /* Bytes containing requested option numbers */
116 
117  /* Information used for event callback */
122 
124 
125 #define EVENT_DHCP_CLIENT_WAKEUP 1
126 
127 int dhcp_client_for_us (u32 bi0,
128  vlib_buffer_t * b0,
129  ip4_header_t * ip0,
130  udp_header_t * u0, dhcp_header_t * dh0);
131 
132 /**
133  * Add/Delete DHCP clients
134  */
135 extern int dhcp_client_config (u32 is_add,
137  vlib_main_t * vm,
139  u8 * hostname,
140  u8 * client_id,
143 
144 /**
145  * callback function for clients walking the DHCP client configurations
146  *
147  * @param client The client being visitsed
148  * @param data The data passed during the call to 'walk'
149  * @return !0 to continue walking 0 to stop.
150  */
151 typedef int (*dhcp_client_walk_cb_t) (const dhcp_client_t * client,
152  void *data);
153 
154 /**
155  * Walk (visit each) DHCP client configuration
156  *
157  * @param cb The callback function invoked as each client is visited
158  * @param ctx Context data passed back to the client in the invocation of
159  * the callback.
160  */
161 extern void dhcp_client_walk (dhcp_client_walk_cb_t cb, void *ctx);
162 
163 #endif /* included_dhcp_client_h */
164 
165 /*
166  * fd.io coding-style-patch-verification: ON
167  *
168  * Local Variables:
169  * eval: (c-set-style "gnu")
170  * End:
171  */
u8 client_detect_feature_enabled
Definition: client.h:87
dhcp_client_main_t dhcp_client_main
Definition: client.c:20
u32 retry_count
Definition: client.h:53
u32 lease_lifetime
Definition: client.h:68
u8 * option_55_data
Definition: client.h:71
dhcp_client_t * clients
Definition: client.h:95
u32 sw_if_index
Definition: client.h:50
u8 data[128]
Definition: ipsec.api:248
dhcp_event_cb_t event_callback
Definition: client.h:120
dhcp_client_state_t state
Definition: client.h:47
unsigned char u8
Definition: types.h:56
u32 transaction_id
Definition: client.h:60
double f64
Definition: types.h:142
u32 lease_renewal_interval
Definition: client.h:67
dhcp_event_cb_t event_callback
Definition: client.h:89
unsigned int u32
Definition: types.h:88
#define foreach_dhcp_client_state
Definition: client.h:25
u8 set_broadcast_flag
Definition: client.h:84
ip4_address_t leased_address
Definition: client.h:63
dhcp_client_state_t
Definition: client.h:30
struct dhcp_client_t_ dhcp_client_t
vlib_main_t * vlib_main
Definition: client.h:100
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:161
long ctx[MAX_CONNS]
Definition: main.c:144
u8 * l2_rewrite
Definition: client.h:73
void(* dhcp_event_cb_t)(u32 client_index, const struct dhcp_client_t_ *client)
Callback function for DHCP complete events.
Definition: client.h:42
u8 client_hardware_address[6]
Definition: client.h:86
vlib_main_t * vm
Definition: buffer.c:312
f64 next_transmit
Definition: client.h:56
u32 client_index
Definition: client.h:80
void dhcp_client_walk(dhcp_client_walk_cb_t cb, void *ctx)
Walk (visit each) DHCP client configuration.
Definition: client.c:1062
u8 is_add
Definition: ipsec_gre.api:36
u32 subnet_mask_width
Definition: client.h:65
ip4_address_t router_address
Definition: client.h:66
u8 * client_identifier
Definition: client.h:77
int(* dhcp_client_walk_cb_t)(const dhcp_client_t *client, void *data)
callback function for clients walking the DHCP client configurations
Definition: client.h:151
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
uword * client_by_sw_if_index
Definition: client.h:96
int dhcp_client_config(u32 is_add, u32 client_index, vlib_main_t *vm, u32 sw_if_index, u8 *hostname, u8 *client_id, dhcp_event_cb_t event_callback, u8 set_broadcast_flag, u32 pid)
Add/Delete DHCP clients.
Definition: client.c:976
u8 * hostname
Definition: client.h:76
f64 lease_expires
Definition: client.h:57
vnet_main_t * vnet_main
Definition: client.h:101
ip4_address_t dhcp_server
Definition: client.h:64