Skip to content

Commit 97ab4ee

Browse files
NareshM1702Leela-Charumathisaniya-09GoutamD2905Suganya-Sugumar
authored
Rebase (#160)
Signed-off-by: Leela Charumathi M <LeelaCharumathi_M@comcast.com> Co-authored-by: Leela-Charumathi <156892064+Leela-Charumathi@users.noreply.github.com> Co-authored-by: saniya-09 <139232822+saniya-09@users.noreply.github.com> Co-authored-by: Goutam Damodaran <140494857+GoutamD2905@users.noreply.github.com> Co-authored-by: Suganya-Sugumar <222150366+Suganya-Sugumar@users.noreply.github.com>
1 parent e47e684 commit 97ab4ee

File tree

82 files changed

+19136
-4802
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+19136
-4802
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d
44

55
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
66

7+
#### [1.4.1](https://github.com/rdkcentral/utopia/compare/1.4.0...1.4.1)
8+
9+
- RDKCOM-5484: RDKBDEV-3327 Add API documentation for Utopia Header files [`#146`](https://github.com/rdkcentral/utopia/pull/146)
10+
- XF10-229 XF10-281 : Analyse & Add support for hotspot 6G [`#153`](https://github.com/rdkcentral/utopia/pull/153)
11+
- [RDKB-62642] Parental control is not working as expected - iptables broken with chain create error [`#141`](https://github.com/rdkcentral/utopia/pull/141)
12+
- RDKCOM-5473: RDKBACCL-1248 rdkb-cli connection was not established from bpi device via 8888 port [`#140`](https://github.com/rdkcentral/utopia/pull/140)
13+
- RDKB-61944 : [Coverity] Various issues in utopia - part2 [`#137`](https://github.com/rdkcentral/utopia/pull/137)
14+
- Merge tag '1.4.0' into develop [`e7e3d74`](https://github.com/rdkcentral/utopia/commit/e7e3d74f962a08833dbe73ad1a951d7abe87bd16)
15+
716
#### [1.4.0](https://github.com/rdkcentral/utopia/compare/1.3.1...1.4.0)
817

18+
> 4 December 2025
19+
920
- RDKB-61489: {Ignite} Router advertisement packet has been dropped via firewall at runtime. [`#139`](https://github.com/rdkcentral/utopia/pull/139)
1021
- RDKB-62206 - Rename NTP Telemetry Marker [`#133`](https://github.com/rdkcentral/utopia/pull/133)
1122
- IPV6 hotspot support for ETHWAN mode and Other Platform [`#124`](https://github.com/rdkcentral/utopia/pull/124)

source/dhcpproxy/dhcp_msg.h

Lines changed: 96 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
/**********************************************************************
2121
Copyright [2014] [Cisco Systems, Inc.]
22-
22+
2323
Licensed under the Apache License, Version 2.0 (the "License");
2424
you may not use this file except in compliance with the License.
2525
You may obtain a copy of the License at
26-
26+
2727
http://www.apache.org/licenses/LICENSE-2.0
28-
28+
2929
Unless required by applicable law or agreed to in writing, software
3030
distributed under the License is distributed on an "AS IS" BASIS,
3131
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -99,7 +99,7 @@ struct dhcp_option
9999
* @brief DHCP option code
100100
*/
101101
enum {
102-
OPTION_PAD=0,
102+
OPTION_PAD=0,
103103
OPTION_ROUTER=3,
104104
OPTION_DNS=6,
105105
OPTION_HOSTNAME=12,
@@ -152,26 +152,116 @@ enum {
152152
extern "C" {
153153
#endif
154154

155+
/**
156+
* @brief Compare two DHCP options.
157+
*
158+
* This function compares two DHCP option structures by their length and data.
159+
*
160+
* @param[in] opt1 - Pointer to the first DHCP option to compare.
161+
* @param[in] opt2 - Pointer to the second DHCP option to compare.
162+
*
163+
* @return The comparison result.
164+
* @retval 0 if two options are same.
165+
* @retval -1 if opt1 is less than opt2.
166+
* @retval 1 if opt1 is greater than opt2.
167+
*
168+
*/
155169
int compare_option(const struct dhcp_option *opt1, const struct dhcp_option *opt2);
156170

171+
/**
172+
* @brief Copy DHCP option and allocate new memory for data.
173+
*
174+
* This function performs copy of a DHCP option from src to dst.
175+
*
176+
* @param[in,out] dst - Pointer to the destination DHCP option structure.
177+
* @param[in] src - Pointer to the source DHCP option structure to copy from.
178+
*
179+
* @return None.
180+
*
181+
*/
157182
void dhcp_copy_option(struct dhcp_option *dst, const struct dhcp_option *src);
158183

184+
/**
185+
* @brief Cleanup DHCP option by freeing allocated memory.
186+
*
187+
* This function can only be used to clean up copied DHCP options. DHCP options from message parsing contain pointers to option
188+
* locations inside the DHCP message and cannot be cleaned using this function.This function does not free the option structure itself.
189+
*
190+
* @param[in,out] opt - Pointer to the DHCP option structure to cleanup.
191+
*
192+
* @return None.
193+
*
194+
*/
159195
void dhcp_cleanup_option(struct dhcp_option *opt);
160196

197+
/**
198+
* @brief Clear DHCP option info and free all associated option lists.
199+
*
200+
* This function releases all dynamically allocated option nodes and resets the structure to zero.
201+
*
202+
* @param[in,out] opt_info - Pointer to the DHCP option info structure to clear.
203+
*
204+
* @return None.
205+
*
206+
*/
161207
void dhcp_clear_option_info(struct dhcp_option_info *opt_info);
162208

209+
/**
210+
* @brief Parse a list of DHCP options from option data.
211+
*
212+
* @param[in,out] opt_info - Pointer to DHCP option info structure where parsed options will be stored.
213+
* Overload flag will be set if found.
214+
* @param[in] opt_data - Pointer to the option data buffer to parse.
215+
* @param[in] size - Size of the option data buffer in bytes.
216+
*
217+
* @return A linked list of DHCP options.
218+
*
219+
*/
163220
struct dhcp_option *dhcp_parse_options(struct dhcp_option_info *opt_info,
164221
ui8* opt_data, size_t size);
165222

223+
/**
224+
* @brief Parse DHCP message including options in option field, file field, and sname field.
225+
*
226+
* @param[out] opt_info - Pointer to DHCP option info structure where parsed options will be stored.
227+
* @param[in] msg - Pointer to the DHCP message to parse.
228+
* @param[in] size - Total size of the DHCP message in bytes.
229+
*
230+
* @return None.
231+
*
232+
*/
166233
void dhcp_parse_msg(struct dhcp_option_info *opt_info, struct dhcp_msg *msg, size_t size);
167234

235+
/**
236+
* @brief Validate DHCP message by checking message type consistency with operation type.
237+
*
238+
* @param[in] msg - Pointer to the DHCP message to validate.
239+
* @param[in] opt_info - Pointer to the DHCP option info containing parsed message type.
240+
*
241+
* @return The status of the operation.
242+
* @retval 0 if the message is valid.
243+
* @retval -1 if the message is invalid.
244+
*
245+
*/
168246
int dhcp_validate_msg(const struct dhcp_msg *msg, const struct dhcp_option_info *opt_info);
169247

248+
/**
249+
* @brief Add a single IP address option to the buffer.
250+
*
251+
* This function add a 4-byte IP address option into the provided buffer.
252+
*
253+
* @param[in] code - DHCP option code.
254+
* @param[in] ipaddr - IP address to add.
255+
* @param[out] buf - Pointer to the buffer where the option will be written.
256+
* @param[in] bufsize - Size of the buffer in bytes.
257+
*
258+
* @return The number of bytes written to the buffer.
259+
*
260+
*/
170261
size_t dhcp_add_ipaddr_option(ui8 code, struct in_addr ipaddr, ui8* buf, size_t bufsize);
171262

172263
#ifdef __cplusplus
173264
}
174265
#endif
175266

176-
#endif // _DHCP_MSG_H_
177-
267+
#endif // _DHCP_MSG_H_

source/dhcpproxy/dhcp_proxy.h

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
/**********************************************************************
2121
Copyright [2014] [Cisco Systems, Inc.]
22-
22+
2323
Licensed under the Apache License, Version 2.0 (the "License");
2424
you may not use this file except in compliance with the License.
2525
You may obtain a copy of the License at
26-
26+
2727
http://www.apache.org/licenses/LICENSE-2.0
28-
28+
2929
Unless required by applicable law or agreed to in writing, software
3030
distributed under the License is distributed on an "AS IS" BASIS,
3131
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -99,19 +99,78 @@ extern struct in_addr g_my_ip;
9999
extern "C" {
100100
#endif
101101

102+
/**
103+
* @brief Find DHCP lease associated with a DHCP message.
104+
*
105+
* This function lookup an existing DHCP lease by client identifier if present, otherwise by hardware type and chaddr.
106+
*
107+
* @param[in] msg - Pointer to the DHCP message used for lease lookup.
108+
* @param[in] opt_info - Pointer to DHCP option info containing client identifier.
109+
* @param[out] pprev - Pointer to store the previous lease in the list.
110+
*
111+
* @return DHCP lease found associated with a DHCP message.
112+
* @retval Pointer to the found DHCP lease.
113+
* @retval NULL if not found.
114+
*
115+
*/
102116
struct dhcp_lease *dhcp_find_lease(const struct dhcp_msg *msg,
103117
const struct dhcp_option_info *opt_info,
104118
struct dhcp_lease **pprev);
105119

120+
/**
121+
* @brief Process received DHCP message and update lease information.
122+
*
123+
* This function validate and process a received DHCP message, find or create/update the associated lease and persist changes.
124+
*
125+
* @param[in] recv_msg - Pointer to the received DHCP message to process.
126+
* @param[in] recv_msg_size - Size of the received DHCP message in bytes.
127+
* @param[in] opt_info - Pointer to DHCP option info containing parsed options from the message.
128+
* @param[in] recv_ifindex - Index of the interface from which the message was received.
129+
* @param[in] recv_iftype - Type of the interface from which the message was received.
130+
*
131+
* @return DHCP lease this messsage associated with
132+
* @retval Pointer to the DHCP lease associated with this message if processing success.
133+
* @retval NULL if processing fails.
134+
*
135+
*/
106136
struct dhcp_lease* dhcp_process_msg(struct dhcp_msg *recv_msg, size_t recv_msg_size,
107137
struct dhcp_option_info *opt_info,
108138
int recv_ifindex, int recv_iftype);
109139

140+
/**
141+
* @brief Relay DHCP message to the appropriate interface with modified options.
142+
*
143+
* For DHCP OFFER and ACK, this function will update Router option and DNS server option.
144+
* It will also update IP length field, UDP length field, as well as IP checksum field accordingly.
145+
* UDP checksum field will be zero out. (Not necessary in a LAN environment).
146+
*
147+
* @param[in] lease - Pointer to the DHCP lease associated with this message.
148+
* @param[in] recv_packet - Pointer to the received packet buffer including all headers.
149+
* @param[in] udp_header_offset - Offset to the UDP header in the packet buffer in bytes.
150+
* @param[in] recv_msg - Pointer to the received DHCP message.
151+
* @param[in] recv_msg_size - Size of the received DHCP message in bytes.
152+
* @param[in] opt_info - Pointer to DHCP option info containing parsed options.
153+
*
154+
* @return None.
155+
*
156+
*/
110157
void dhcp_relay_message(struct dhcp_lease *lease,
111158
void *recv_packet, int udp_header_offset,
112159
struct dhcp_msg *recv_msg, size_t recv_msg_size,
113160
struct dhcp_option_info *opt_info);
114161

162+
/**
163+
* @brief Encode DHCP option list to buffer, replacing Router and DNS Server options with proxy IP.
164+
*
165+
* This function encode a linked list of DHCP options to a buffer, forcibly replacing Router and DNS Server values with the relay agent's own IP address.
166+
*
167+
* @param[in] option_list - Pointer to the linked list of DHCP options to encode.
168+
* @param[out] buf - Pointer to the buffer where encoded options will be written.
169+
* @param[in] bufsize - Size of the buffer in bytes.
170+
*
171+
* @return The number of bytes written to the buffer.
172+
*
173+
*/
115174
ssize_t dhcp_encode_option_list(const struct dhcp_option *option_list, ui8 *buf, size_t bufsize);
116175

117176
#ifdef __cplusplus

0 commit comments

Comments
 (0)