Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,19 @@ All notable changes to this project will be documented in this file. Dates are d

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

#### [1.4.1](https://github.com/rdkcentral/utopia/compare/1.4.0...1.4.1)

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

#### [1.4.0](https://github.com/rdkcentral/utopia/compare/1.3.1...1.4.0)

> 4 December 2025

- RDKB-61489: {Ignite} Router advertisement packet has been dropped via firewall at runtime. [`#139`](https://github.com/rdkcentral/utopia/pull/139)
- RDKB-62206 - Rename NTP Telemetry Marker [`#133`](https://github.com/rdkcentral/utopia/pull/133)
- IPV6 hotspot support for ETHWAN mode and Other Platform [`#124`](https://github.com/rdkcentral/utopia/pull/124)
Expand Down
102 changes: 96 additions & 6 deletions source/dhcpproxy/dhcp_msg.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in source/dhcpproxy/dhcp_msg.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'BSD-Intel' license found in local file 'source/dhcpproxy/dhcp_msg.h' (Match: rdkb/components/opensource/ccsp/Utopia/rdkb/components/opensource/ccsp/Utopia/1, 153 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/Utopia/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/dhcpproxy/dhcp_msg.h)
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
Expand All @@ -19,13 +19,13 @@

/**********************************************************************
Copyright [2014] [Cisco Systems, Inc.]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -99,7 +99,7 @@
* @brief DHCP option code
*/
enum {
OPTION_PAD=0,
OPTION_PAD=0,
OPTION_ROUTER=3,
OPTION_DNS=6,
OPTION_HOSTNAME=12,
Expand Down Expand Up @@ -152,26 +152,116 @@
extern "C" {
#endif

/**
* @brief Compare two DHCP options.
*
* This function compares two DHCP option structures by their length and data.
*
* @param[in] opt1 - Pointer to the first DHCP option to compare.
* @param[in] opt2 - Pointer to the second DHCP option to compare.
*
* @return The comparison result.
* @retval 0 if two options are same.
* @retval -1 if opt1 is less than opt2.
* @retval 1 if opt1 is greater than opt2.
*
*/
int compare_option(const struct dhcp_option *opt1, const struct dhcp_option *opt2);

/**
* @brief Copy DHCP option and allocate new memory for data.
*
* This function performs copy of a DHCP option from src to dst.
*
* @param[in,out] dst - Pointer to the destination DHCP option structure.
* @param[in] src - Pointer to the source DHCP option structure to copy from.
*
* @return None.
*
*/
void dhcp_copy_option(struct dhcp_option *dst, const struct dhcp_option *src);

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

/**
* @brief Clear DHCP option info and free all associated option lists.
*
* This function releases all dynamically allocated option nodes and resets the structure to zero.
*
* @param[in,out] opt_info - Pointer to the DHCP option info structure to clear.
*
* @return None.
*
*/
void dhcp_clear_option_info(struct dhcp_option_info *opt_info);

/**
* @brief Parse a list of DHCP options from option data.
*
* @param[in,out] opt_info - Pointer to DHCP option info structure where parsed options will be stored.
* Overload flag will be set if found.
* @param[in] opt_data - Pointer to the option data buffer to parse.
* @param[in] size - Size of the option data buffer in bytes.
*
* @return A linked list of DHCP options.
*
*/
struct dhcp_option *dhcp_parse_options(struct dhcp_option_info *opt_info,
ui8* opt_data, size_t size);

/**
* @brief Parse DHCP message including options in option field, file field, and sname field.
*
* @param[out] opt_info - Pointer to DHCP option info structure where parsed options will be stored.
* @param[in] msg - Pointer to the DHCP message to parse.
* @param[in] size - Total size of the DHCP message in bytes.
*
* @return None.
*
*/
void dhcp_parse_msg(struct dhcp_option_info *opt_info, struct dhcp_msg *msg, size_t size);

/**
* @brief Validate DHCP message by checking message type consistency with operation type.
*
* @param[in] msg - Pointer to the DHCP message to validate.
* @param[in] opt_info - Pointer to the DHCP option info containing parsed message type.
*
* @return The status of the operation.
* @retval 0 if the message is valid.
* @retval -1 if the message is invalid.
*
*/
int dhcp_validate_msg(const struct dhcp_msg *msg, const struct dhcp_option_info *opt_info);

/**
* @brief Add a single IP address option to the buffer.
*
* This function add a 4-byte IP address option into the provided buffer.
*
* @param[in] code - DHCP option code.
* @param[in] ipaddr - IP address to add.
* @param[out] buf - Pointer to the buffer where the option will be written.
* @param[in] bufsize - Size of the buffer in bytes.
*
* @return The number of bytes written to the buffer.
*
*/
size_t dhcp_add_ipaddr_option(ui8 code, struct in_addr ipaddr, ui8* buf, size_t bufsize);

#ifdef __cplusplus
}
#endif

#endif // _DHCP_MSG_H_

#endif // _DHCP_MSG_H_
65 changes: 62 additions & 3 deletions source/dhcpproxy/dhcp_proxy.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in source/dhcpproxy/dhcp_proxy.h

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'BSD-Intel' license found in local file 'source/dhcpproxy/dhcp_proxy.h' (Match: rdkb/components/opensource/ccsp/Utopia/rdkb/components/opensource/ccsp/Utopia/1, 100 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/Utopia/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/dhcpproxy/dhcp_proxy.h)
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
Expand All @@ -19,13 +19,13 @@

/**********************************************************************
Copyright [2014] [Cisco Systems, Inc.]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -99,19 +99,78 @@
extern "C" {
#endif

/**
* @brief Find DHCP lease associated with a DHCP message.
*
* This function lookup an existing DHCP lease by client identifier if present, otherwise by hardware type and chaddr.
*
* @param[in] msg - Pointer to the DHCP message used for lease lookup.
* @param[in] opt_info - Pointer to DHCP option info containing client identifier.
* @param[out] pprev - Pointer to store the previous lease in the list.
*
* @return DHCP lease found associated with a DHCP message.
* @retval Pointer to the found DHCP lease.
* @retval NULL if not found.
*
*/
struct dhcp_lease *dhcp_find_lease(const struct dhcp_msg *msg,
const struct dhcp_option_info *opt_info,
struct dhcp_lease **pprev);

/**
* @brief Process received DHCP message and update lease information.
*
* This function validate and process a received DHCP message, find or create/update the associated lease and persist changes.
*
* @param[in] recv_msg - Pointer to the received DHCP message to process.
* @param[in] recv_msg_size - Size of the received DHCP message in bytes.
* @param[in] opt_info - Pointer to DHCP option info containing parsed options from the message.
* @param[in] recv_ifindex - Index of the interface from which the message was received.
* @param[in] recv_iftype - Type of the interface from which the message was received.
*
* @return DHCP lease this messsage associated with
* @retval Pointer to the DHCP lease associated with this message if processing success.
* @retval NULL if processing fails.
*
*/
struct dhcp_lease* dhcp_process_msg(struct dhcp_msg *recv_msg, size_t recv_msg_size,
struct dhcp_option_info *opt_info,
int recv_ifindex, int recv_iftype);

/**
* @brief Relay DHCP message to the appropriate interface with modified options.
*
* For DHCP OFFER and ACK, this function will update Router option and DNS server option.
* It will also update IP length field, UDP length field, as well as IP checksum field accordingly.
* UDP checksum field will be zero out. (Not necessary in a LAN environment).
*
* @param[in] lease - Pointer to the DHCP lease associated with this message.
* @param[in] recv_packet - Pointer to the received packet buffer including all headers.
* @param[in] udp_header_offset - Offset to the UDP header in the packet buffer in bytes.
* @param[in] recv_msg - Pointer to the received DHCP message.
* @param[in] recv_msg_size - Size of the received DHCP message in bytes.
* @param[in] opt_info - Pointer to DHCP option info containing parsed options.
*
* @return None.
*
*/
void dhcp_relay_message(struct dhcp_lease *lease,
void *recv_packet, int udp_header_offset,
struct dhcp_msg *recv_msg, size_t recv_msg_size,
struct dhcp_option_info *opt_info);

/**
* @brief Encode DHCP option list to buffer, replacing Router and DNS Server options with proxy IP.
*
* 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.
*
* @param[in] option_list - Pointer to the linked list of DHCP options to encode.
* @param[out] buf - Pointer to the buffer where encoded options will be written.
* @param[in] bufsize - Size of the buffer in bytes.
*
* @return The number of bytes written to the buffer.
*
*/
ssize_t dhcp_encode_option_list(const struct dhcp_option *option_list, ui8 *buf, size_t bufsize);

#ifdef __cplusplus
Expand Down
Loading
Loading