Contiki-NG
uiplib.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002, Adam Dunkels.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following
12  * disclaimer in the documentation and/or other materials provided
13  * with the distribution.
14  * 3. The name of the author may not be used to endorse or promote
15  * products derived from this software without specific prior
16  * written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * This file is part of the Contiki desktop environment for the C64.
31  *
32  *
33  */
34 #ifndef UIPLIB_H_
35 #define UIPLIB_H_
36 
37 #include "net/ipv6/uip.h"
38 
39 /**
40  * \addtogroup uip
41  * @{
42  *
43  * \defgroup uip-addr-lib uIP address manipulation library
44  *
45  * A library with various IP address manipulation functions
46  * @{
47  *
48  * \file
49  * Header file for the IP address manipulation library
50  * \author
51  * Adam Dunkels <adam@sics.se>
52  */
53 
54 /**
55  * Convert a textual representation of an IP address to a numerical representation.
56  *
57  * This function takes a textual representation of an IP address in
58  * the form a.b.c.d for IPv4 or a:b:c:d:e:f:g:h for IPv6 and converts
59  * it into a numeric IP address representation that can be used by
60  * other uIP functions.
61  *
62  * \param addrstr A pointer to a string containing the IP address in
63  * textual form.
64  *
65  * \param addr A pointer to a uip_ip4addr_t that will be filled in with
66  * the numerical representation of the address.
67  *
68  * \retval 0 If the IP address could not be parsed.
69  * \retval Non-zero If the IP address was parsed.
70  */
71 #define uiplib_ipaddrconv uiplib_ip6addrconv
72 
73 int uiplib_ip4addrconv(const char *addrstr, uip_ip4addr_t *addr);
74 int uiplib_ip6addrconv(const char *addrstr, uip_ip6addr_t *addr);
75 /** @} */
76 
77 
78 /* The maxium length of an IPv6 string, including terminating null bytes
79  * fd01:0002:0003:0004:0005:0006:0007:0008 => 39 + 1 bytes */
80 #define UIPLIB_IPV6_MAX_STR_LEN 40
81 
82 /**
83  * Print an IP address using printf().
84  *
85  * \param addr A pointer to a uip_ipaddr_t that will be printed with printf().
86  */
87 void uiplib_ipaddr_print(const uip_ipaddr_t *addr);
88 
89 /**
90  * Write at most size - 1 characters of the IP address to the output string.
91  * The output is always null-terminated, unless size is 0.
92  *
93  * \param buffer A pointer to an output string with at least size bytes.
94  * \param size The max number of characters to write to the output string.
95  * \param addr A pointer to a uip_ipaddr_t that will be printed with printf().
96  */
97 int uiplib_ipaddr_snprint(char *buffer, size_t size, const uip_ipaddr_t *addr);
98 
99 #endif /* UIPLIB_H_ */
100 /**
101  * @}
102  * @}
103  */
int uiplib_ipaddr_snprint(char *buffer, size_t size, const uip_ipaddr_t *addr)
Write at most size - 1 characters of the IP address to the output string.
Definition: uiplib.c:166
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
Definition: uip-nd6.c:107
Representation of an IP address.
Definition: uip.h:95
void uiplib_ipaddr_print(const uip_ipaddr_t *addr)
Print an IP address using printf().
Definition: uiplib.c:158
Header file for the uIP TCP/IP stack.