From 10e31def736e29719392ddfadc849b3a475d99d7 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Tue, 22 Mar 2011 22:13:10 +0100 Subject: inet: Adding inet_ntoa() Adding inet_ntoa() as it could be useful to print pxe_boot_t structure --- com32/lib/inet.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 com32/lib/inet.c (limited to 'com32/lib/inet.c') diff --git a/com32/lib/inet.c b/com32/lib/inet.c new file mode 100644 index 00000000..18891e88 --- /dev/null +++ b/com32/lib/inet.c @@ -0,0 +1,37 @@ +/* ----------------------------------------------------------------------- * + * + * Copyright 2011 Erwan Velu - All Rights Reserved + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall + * be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * ----------------------------------------------------------------------- + */ + +#include +#include +char * inet_ntoa ( in_addr_t addr ) { + static char buf[16] = {0}; + uint8_t *bytes = ( uint8_t * ) &addr; + + sprintf ( buf, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3] ); + return buf; +} -- cgit v1.2.1 From 0c8bfd91ab11a00b796f32982a30414c8bac7ec9 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 25 Apr 2011 17:15:40 -0700 Subject: com32: inet_ntoa() takes struct in_addr The standard definition for inet_ntoa() is to take struct in_addr, and not doing that causes a conflict on the lwip branch. Signed-off-by: H. Peter Anvin --- com32/lib/inet.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'com32/lib/inet.c') diff --git a/com32/lib/inet.c b/com32/lib/inet.c index 18891e88..133645ed 100644 --- a/com32/lib/inet.c +++ b/com32/lib/inet.c @@ -28,10 +28,12 @@ #include #include -char * inet_ntoa ( in_addr_t addr ) { - static char buf[16] = {0}; - uint8_t *bytes = ( uint8_t * ) &addr; - - sprintf ( buf, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3] ); - return buf; + +char *inet_ntoa(struct in_addr addr) +{ + static char buf[16]; + const uint8_t *bytes = (const uint8_t *)&addr.s_addr; + + sprintf(buf, "%u.%u.%u.%u", bytes[0], bytes[1], bytes[2], bytes[3]); + return buf; } -- cgit v1.2.1