source: mainline/uspace/lib/c/include/inet/addr.h@ edf0d27

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since edf0d27 was a2e3ee6, checked in by Martin Decky <martin@…>, 13 years ago

use new network address infrastructure (towards IPv6 support)

  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*
2 * Copyright (c) 2013 Jiri Svoboda
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 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libc
30 * @{
31 */
32/** @file
33 */
34
35#ifndef LIBC_INET_ADDR_H_
36#define LIBC_INET_ADDR_H_
37
38#include <stdint.h>
39#include <net/in.h>
40
41#define INET_ADDR_SIZE 16
42
43/** Node address */
44typedef struct {
45 uint16_t family;
46 uint8_t addr[INET_ADDR_SIZE];
47} inet_addr_t;
48
49/** Network address */
50typedef struct {
51 /** Address family */
52 uint16_t family;
53
54 /** Address */
55 uint8_t addr[INET_ADDR_SIZE];
56
57 /** Number of valid bits */
58 uint8_t prefix;
59} inet_naddr_t;
60
61extern int inet_addr_family(const char *, uint16_t *);
62
63extern int inet_addr_parse(const char *, inet_addr_t *);
64extern int inet_naddr_parse(const char *, inet_naddr_t *);
65
66extern int inet_addr_format(inet_addr_t *, char **);
67extern int inet_naddr_format(inet_naddr_t *, char **);
68
69extern int inet_addr_pack(inet_addr_t *, uint32_t *);
70extern int inet_naddr_pack(inet_naddr_t *, uint32_t *, uint8_t *);
71
72extern void inet_addr_unpack(uint32_t, inet_addr_t *);
73extern void inet_naddr_unpack(uint32_t, uint8_t, inet_naddr_t *);
74
75extern int inet_addr_sockaddr_in(inet_addr_t *, sockaddr_in_t *);
76extern void inet_naddr_addr(inet_naddr_t *, inet_addr_t *);
77
78extern void inet_addr(inet_addr_t *, uint8_t, uint8_t, uint8_t, uint8_t);
79extern void inet_naddr(inet_naddr_t *, uint8_t, uint8_t, uint8_t, uint8_t,
80 uint8_t);
81
82extern void inet_addr_any(inet_addr_t *);
83extern void inet_naddr_any(inet_naddr_t *);
84
85extern int inet_addr_compare(inet_addr_t *, inet_addr_t *);
86extern int inet_addr_is_any(inet_addr_t *);
87
88#endif
89
90/** @}
91 */
Note: See TracBrowser for help on using the repository browser.