From 10e31def736e29719392ddfadc849b3a475d99d7 Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Tue, 22 Mar 2011 22:13:10 +0100 Subject: [PATCH] inet: Adding inet_ntoa() Adding inet_ntoa() as it could be useful to print pxe_boot_t structure --- com32/include/netinet/in.h | 1 + com32/lib/Makefile | 1 + com32/lib/inet.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 com32/lib/inet.c diff --git a/com32/include/netinet/in.h b/com32/include/netinet/in.h index ccf0475..eae1162 100644 --- a/com32/include/netinet/in.h +++ b/com32/include/netinet/in.h @@ -53,4 +53,5 @@ struct in_addr { in_addr_t s_addr; }; +char * inet_ntoa (in_addr_t addr); #endif /* _NETINET_IN_H */ diff --git a/com32/lib/Makefile b/com32/lib/Makefile index 0614cf3..bf0da99 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -30,6 +30,7 @@ LIBOBJS = \ skipspace.o \ chrreplace.o \ bufprintf.o \ + inet.o \ \ lmalloc.o lstrdup.o \ \ diff --git a/com32/lib/inet.c b/com32/lib/inet.c new file mode 100644 index 0000000..18891e8 --- /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; +} -- 2.7.4