Message ID | 20241111210959.560738-2-adrianox@gmail.com |
---|---|
State | Superseded, archived |
Delegated to: | Heinrich Schuchardt |
Headers | show |
Series | efi_loader: efi http and ipconfig drivers | expand |
Reviewed-by tags missing for me * Heinrich On Mon, 11 Nov 2024 at 23:10, Adriano Cordova <adrianox@gmail.com> wrote: > > 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. > > Signed-off-by: Adriano Cordova <adrianox@gmail.com> > --- > > (no changes since v2) > > include/net-common.h | 10 ++++++++++ > lib/net_utils.c | 11 +++++++++++ > net/net.c | 11 ----------- > 3 files changed, 21 insertions(+), 11 deletions(-) > > diff --git a/include/net-common.h b/include/net-common.h > index 3cd0f34374..b7a519e36d 100644 > --- a/include/net-common.h > +++ b/include/net-common.h > @@ -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); > > diff --git a/lib/net_utils.c b/lib/net_utils.c > index c70fef0d99..621f6512b6 100644 > --- a/lib/net_utils.c > +++ b/lib/net_utils.c > @@ -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; > diff --git a/net/net.c b/net/net.c > index f47e9fbe33..ca35704f66 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -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); > -- > 2.43.0 >
On 11/11/24 22:09, Adriano Cordova wrote: > 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. > > Signed-off-by: Adriano Cordova <adrianox@gmail.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > --- > > (no changes since v2) > > include/net-common.h | 10 ++++++++++ > lib/net_utils.c | 11 +++++++++++ > net/net.c | 11 ----------- > 3 files changed, 21 insertions(+), 11 deletions(-) > > diff --git a/include/net-common.h b/include/net-common.h > index 3cd0f34374..b7a519e36d 100644 > --- a/include/net-common.h > +++ b/include/net-common.h > @@ -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); > > diff --git a/lib/net_utils.c b/lib/net_utils.c > index c70fef0d99..621f6512b6 100644 > --- a/lib/net_utils.c > +++ b/lib/net_utils.c > @@ -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; > diff --git a/net/net.c b/net/net.c > index f47e9fbe33..ca35704f66 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -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);
On 11/11/24 22:09, Adriano Cordova wrote: > 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. > > Signed-off-by: Adriano Cordova <adrianox@gmail.com> If patches are unchanged, please, copy the Reviewed-by, Acked-by, and Signed-off tags when resubmitting. Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de> > --- > > (no changes since v2) > > include/net-common.h | 10 ++++++++++ > lib/net_utils.c | 11 +++++++++++ > net/net.c | 11 ----------- > 3 files changed, 21 insertions(+), 11 deletions(-) > > diff --git a/include/net-common.h b/include/net-common.h > index 3cd0f34374..b7a519e36d 100644 > --- a/include/net-common.h > +++ b/include/net-common.h > @@ -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); > > diff --git a/lib/net_utils.c b/lib/net_utils.c > index c70fef0d99..621f6512b6 100644 > --- a/lib/net_utils.c > +++ b/lib/net_utils.c > @@ -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; > diff --git a/net/net.c b/net/net.c > index f47e9fbe33..ca35704f66 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -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);
diff --git a/include/net-common.h b/include/net-common.h index 3cd0f34374..b7a519e36d 100644 --- a/include/net-common.h +++ b/include/net-common.h @@ -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); diff --git a/lib/net_utils.c b/lib/net_utils.c index c70fef0d99..621f6512b6 100644 --- a/lib/net_utils.c +++ b/lib/net_utils.c @@ -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; diff --git a/net/net.c b/net/net.c index f47e9fbe33..ca35704f66 100644 --- a/net/net.c +++ b/net/net.c @@ -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);
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. Signed-off-by: Adriano Cordova <adrianox@gmail.com> --- (no changes since v2) include/net-common.h | 10 ++++++++++ lib/net_utils.c | 11 +++++++++++ net/net.c | 11 ----------- 3 files changed, 21 insertions(+), 11 deletions(-)