diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-03 18:47:34 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-03 18:47:34 +0000 |
commit | bcbf98b13c7ee35f9fee74dd38c855cfee7fb924 (patch) | |
tree | dbcd6ebd28fca17eb215bee29e7539dabac2336d /nuttx/lib/net/lib_inetntoa.c | |
parent | 461a420a87186bfe26e32d23768380fc97e4d275 (diff) | |
download | px4-nuttx-bcbf98b13c7ee35f9fee74dd38c855cfee7fb924.tar.gz px4-nuttx-bcbf98b13c7ee35f9fee74dd38c855cfee7fb924.tar.bz2 px4-nuttx-bcbf98b13c7ee35f9fee74dd38c855cfee7fb924.zip |
Add inet_ntop()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4366 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib/net/lib_inetntoa.c')
-rw-r--r-- | nuttx/lib/net/lib_inetntoa.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/nuttx/lib/net/lib_inetntoa.c b/nuttx/lib/net/lib_inetntoa.c index 38414dde8..f771e6b90 100644 --- a/nuttx/lib/net/lib_inetntoa.c +++ b/nuttx/lib/net/lib_inetntoa.c @@ -1,8 +1,8 @@ /**************************************************************************** * lib/net/lib_inetntoa.c * - * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -41,6 +41,8 @@ #include <stdio.h> #include <arpa/inet.h> +#ifndef CONFIG_NET_IPv6 + /**************************************************************************** * Global Functions ****************************************************************************/ @@ -59,7 +61,7 @@ #ifdef CONFIG_CAN_PASS_STRUCTS FAR char *inet_ntoa(struct in_addr in) { - static char buffer[18]; + static char buffer[INET_ADDRSTRLEN+2]; FAR char *ptr = (FAR char*)&in.s_addr; sprintf(buffer, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]); return buffer; @@ -67,10 +69,11 @@ FAR char *inet_ntoa(struct in_addr in) #else FAR char *_inet_ntoa(in_addr_t in) { - static char buffer[18]; + static char buffer[NET_ADDRSTRLEN+2]; FAR char *ptr = (FAR char*)∈ sprintf(buffer, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]); return buffer; } #endif +#endif /* !CONFIG_NET_IPv6 */ |