net: net_utils: Move ip_to_string to lib/net_utils.c
Subsystems (2)
Am 8. November 2024 04:44:44 MEZ schrieb Adriano Cordova <[email protected]>:
Quoted 7 lines
The function
string_to_ipis already innet_utils, which is compiled unconditionally, butip_to_stringis currently only accessible if the legacy network stack is selected. This commit putsip_to_stringinnet_utils.cand removes it from the legacy network code.Signed-off-by Adriano Cordova <[email protected]>
LGTM
Would you mind resending the series as a single email thread, please (git send email 0*.patch or use patchman). This will make reviewing and merging easier.
Quoted 71 lines
---
include/net-common.h | 10 ++++++++++ lib/net_utils.c | 11 +++++++++++ net/net.c | 11 ----------- 3 files changed, 21 insertions(+), 11 deletions(-)include/net-common.h +10
-0@@ -426,6 +426,16 @@ void string_to_enetaddr(const char *addr, uint8_t *enetaddr);*/ struct in_addr string_to_ip (const char *s); +/** +* ip_to_string() - Convert a string to ip address +* +* Implemented in lib/net_utils.c (built unconditionally) +* +* @x: Input ip to parse +* @s: string containing the parsed ip address +*/ +void ip_to_string (struct in_addr x,char *s); +/* copy a filename (allow for "..." notation, limit length) */ void copy_filename (char *dst,const char *src,int size);lib/net_utils.c +11
-0@@ -152,6 +152,17 @@ out_err: }#endif +void ip_to_string (struct in_addr x,char *s) +{ + x.s_addr =ntohl (x.s_addr); +sprintf (s,"%d.%d.%d.%d" , + (int ) ((x.s_addr >>24 ) &0xff ), + (int ) ((x.s_addr >>16 ) &0xff ), + (int ) ((x.s_addr >>8 ) &0xff ), + (int ) ((x.s_addr >>0 ) &0xff ) + ); +} +void string_to_enetaddr (const char *addr,uint8_t *enetaddr) {char *end;net/net.c +0
-11@@ -1723,17 +1723,6 @@ int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len)return 1 ; } -void ip_to_string (struct in_addr x,char *s) -{ - x.s_addr =ntohl (x.s_addr); -sprintf (s,"%d.%d.%d.%d" , - (int ) ((x.s_addr >>24 ) &0xff ), - (int ) ((x.s_addr >>16 ) &0xff ), - (int ) ((x.s_addr >>8 ) &0xff ), - (int ) ((x.s_addr >>0 ) &0xff ) - ); -} -void vlan_to_string (ushort x,char *s) { x =ntohs (x);
PATCH 1/15 net: net_utils: Move ip_to_string to lib/net_utils.c
The function string_to_ip is already in net_utils, which is compiled unconditionally, but ip_to_string is currently only accessible if the legacy network stack is selected. This commit puts ip_to_string in net_utils.c and removes it from the legacy network code.
--- include/net-common.h | 10 ++++++++++ lib/net_utils.c | 11 +++++++++++ net/net.c | 11 ----------- 3 files changed, 21 insertions(+), 11 deletions(-)
include/net-common.h +10 -0
@@ -426,6 +426,16 @@ void string_to_enetaddr(const char *addr, uint8_t *enetaddr);*/ struct in_addr string_to_ip (const char *s); +/** +* ip_to_string() - Convert a string to ip address +* +* Implemented in lib/net_utils.c (built unconditionally) +* +* @x: Input ip to parse +* @s: string containing the parsed ip address +*/ +void ip_to_string (struct in_addr x,char *s); +/* copy a filename (allow for "..." notation, limit length) */ void copy_filename (char *dst,const char *src,int size);
lib/net_utils.c +11 -0
@@ -152,6 +152,17 @@ out_err: }#endif +void ip_to_string (struct in_addr x,char *s) +{ + x.s_addr =ntohl (x.s_addr); +sprintf (s,"%d.%d.%d.%d" , + (int ) ((x.s_addr >>24 ) &0xff ), + (int ) ((x.s_addr >>16 ) &0xff ), + (int ) ((x.s_addr >>8 ) &0xff ), + (int ) ((x.s_addr >>0 ) &0xff ) + ); +} +void string_to_enetaddr (const char *addr,uint8_t *enetaddr) {char *end;
net/net.c +0 -11
@@ -1723,17 +1723,6 @@ int net_parse_bootfile(struct in_addr *ipaddr, char *filename, int max_len)return 1 ; } -void ip_to_string (struct in_addr x,char *s) -{ - x.s_addr =ntohl (x.s_addr); -sprintf (s,"%d.%d.%d.%d" , - (int ) ((x.s_addr >>24 ) &0xff ), - (int ) ((x.s_addr >>16 ) &0xff ), - (int ) ((x.s_addr >>8 ) &0xff ), - (int ) ((x.s_addr >>0 ) &0xff ) - ); -} -void vlan_to_string (ushort x,char *s) { x =ntohs (x);
Signature · 1 line
2.43.0