mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-24 22:13:52 +01:00
Add auxilary headers
This commit is contained in:
parent
419225753c
commit
4333467e02
101
sys/posix/pnet/include/arpa/inet.h
Normal file
101
sys/posix/pnet/include/arpa/inet.h
Normal file
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Freie Universität Berlin
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup pnet
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file arpa/inet.h
|
||||
* @brief Definitions for internet operations
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/arpa_inet.h.html">
|
||||
* The Open Group Base Specifications Issue 7, <arpa/inet.h>
|
||||
* </a>
|
||||
*
|
||||
* @author Freie Universität Berlin
|
||||
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef ARPA_INET_H
|
||||
#define ARPA_INET_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "net_help.h"
|
||||
#include "inet_ntop.h"
|
||||
#include "inet_pton.h"
|
||||
|
||||
typedef uint16_t in_port_t; ///< Internet port type
|
||||
typedef uint32_t in_addr_t; ///< IPv4 address type
|
||||
|
||||
#define INET_ADDRSTRLEN 16 ///< Length of the string form for IPv4.
|
||||
#define INET6_ADDRSTRLEN 46 ///< Length of the string form for IPv6.
|
||||
|
||||
/**
|
||||
* IPv4 address structure type.
|
||||
*/
|
||||
struct in_addr {
|
||||
in_addr_t s_addr; ///< an IPv4 address
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Convert values between host and network byte order.
|
||||
*
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/htonl.html">
|
||||
* The Open Group Base Specification Issue 7, htonl
|
||||
* </a>
|
||||
*
|
||||
* @param[in] hostlong A 32 bit number.
|
||||
* @return The argument value converted from host to network byte
|
||||
* order.
|
||||
*/
|
||||
#define htonl(hostlong) HTONL(hostlong)
|
||||
|
||||
/**
|
||||
* @brief Convert values between host and network byte order.
|
||||
*
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/htons.html">
|
||||
* The Open Group Base Specification Issue 7, htons
|
||||
* </a>
|
||||
*
|
||||
* @param[in] hostlong A 16 bit number.
|
||||
* @return The argument value converted from host to network byte
|
||||
* order.
|
||||
*/
|
||||
#define htons(hostshort) HTONS(hostshort)
|
||||
|
||||
/**
|
||||
* @brief Convert values between host and network byte order.
|
||||
*
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/ntohl.html">
|
||||
* The Open Group Base Specification Issue 7, ntohl
|
||||
* </a>
|
||||
*
|
||||
* @param[in] hostlong A 32-bit integer number.
|
||||
* @return The argument value converted from network to host byte
|
||||
* order.
|
||||
*/
|
||||
#define ntohl(netlong) NTOHL(netlong)
|
||||
|
||||
/**
|
||||
* @brief Convert values between host and network byte order.
|
||||
*
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/ntohs.html">
|
||||
* The Open Group Base Specification Issue 7, ntohs
|
||||
* </a>
|
||||
*
|
||||
* @param[in] hostlong A 16-bit integer number.
|
||||
* @return The argument value converted from network to host byte
|
||||
* order.
|
||||
*/
|
||||
#define ntohs(netshort) NTOHS(netshort)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* ARPA_INET_H */
|
||||
158
sys/posix/pnet/include/netinet/in.h
Normal file
158
sys/posix/pnet/include/netinet/in.h
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Freie Universität Berlin
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup pnet
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file netinet/in.h
|
||||
* @brief Main socket header
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/netinet_in.h.html">
|
||||
* The Open Group Base Specifications Issue 7, <netinet/in.h>
|
||||
* </a>
|
||||
*
|
||||
* @author Freie Universität Berlin
|
||||
* @author Martin Lenders <mlenders@inf.fu-berlin.de>
|
||||
*/
|
||||
#ifndef _NETINET_IN_H
|
||||
#define _NETINET_IN_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
#include "ipv6.h"
|
||||
#include "destiny/socket.h"
|
||||
|
||||
/**
|
||||
* IPv4 socket address type.
|
||||
*/
|
||||
struct sockaddr_in {
|
||||
sa_family_t sin_family; ///< Protocol family, always AF_INET.
|
||||
in_port_t sin_port; ///< Port number
|
||||
struct in_addr sin_addr; ///< IPv4 address
|
||||
};
|
||||
|
||||
/**
|
||||
* IPv6 address structure type.
|
||||
*/
|
||||
struct in6_addr {
|
||||
/**
|
||||
* Private RIOT-internal data, needs not to be touched by the user.
|
||||
*/
|
||||
ipv6_addr_t __in6_u;
|
||||
|
||||
/**
|
||||
* IPv6 Address represented as sequence of 8-bit numbers. Member of
|
||||
* struct in6_addr.
|
||||
*/
|
||||
#define s6_addr __in6_u.uint8
|
||||
|
||||
/**
|
||||
* IPv6 Address represented as sequence of 16-bit numbers. Member of
|
||||
* struct in6_addr.
|
||||
*/
|
||||
#define s6_addr16 __in6_u.uint16
|
||||
|
||||
/**
|
||||
* IPv6 Address represented as sequence of 32-bit numbers. Member of
|
||||
* struct in6_addr.
|
||||
*/
|
||||
#define s6_addr32 __in6_u.uint32
|
||||
};
|
||||
|
||||
/**
|
||||
* IPv6 socket address type.
|
||||
*/
|
||||
struct sockaddr_in6 {
|
||||
/**
|
||||
* Private RIOT-internal data, needs not to be touched by the user.
|
||||
*/
|
||||
sockaddr6_t __in6_a;
|
||||
|
||||
/**
|
||||
* Protocol family, always AF_INET6. Member of struct sockaddr_in6
|
||||
*/
|
||||
#define sin6_family __in6_a.sin6_family
|
||||
|
||||
/**
|
||||
* Port number. Member of struct sockaddr_in6
|
||||
*/
|
||||
#define sin6_port __in6_a.sin6_port
|
||||
|
||||
/**
|
||||
* IPv6 traffic class and flow information. Member of struct sockaddr_in6
|
||||
*/
|
||||
#define sin6_flowinfo __in6_a.sin6_flowinfo
|
||||
|
||||
/**
|
||||
* IPv6 address. Member of struct sockaddr_in6
|
||||
*/
|
||||
#define sin6_addr __in6_a.sin6_addr
|
||||
|
||||
/**
|
||||
* Set of interfaces for a scope.
|
||||
*/
|
||||
uint32_t sin6_scope_id;
|
||||
};
|
||||
|
||||
/**
|
||||
* IPv6 wildcard address.
|
||||
*/
|
||||
#define IN6ADDR_ANY_INIT {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}}
|
||||
|
||||
/**
|
||||
* IPv6 loopback address.
|
||||
*/
|
||||
#define IN6ADDR_LOOPBACK_INIT {{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1}}
|
||||
|
||||
/**
|
||||
* IPv6 socket address for the wildcard address.
|
||||
*/
|
||||
extern const struct sockaddr_in6 in6addr_any;
|
||||
|
||||
/**
|
||||
* IPv6 socket address for the loopback address.
|
||||
*/
|
||||
extern const struct sockaddr_in6 in6addr_loopback;
|
||||
|
||||
/**
|
||||
* IPv4 local host address.
|
||||
*/
|
||||
#define INADDR_ANY {(in_addr_t)0x00000000}
|
||||
|
||||
/**
|
||||
* IPv4 broadcast address.
|
||||
*/
|
||||
#define INADDR_BROADCAST {(in_addr_t)0xffffffff}
|
||||
|
||||
/**
|
||||
* Multicast hop limit option name for getsockopt() or setsockopt()
|
||||
*
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html">
|
||||
* The Open Group Base Specification Issue 7, getsockopt
|
||||
* </a>
|
||||
* @see <a href="http://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html">
|
||||
* The Open Group Base Specification Issue 7, setsockopt
|
||||
* </a>
|
||||
*/
|
||||
#define IPV6_MULTICAST_HOPS 0x12
|
||||
|
||||
/**
|
||||
* Test for IPv6 multicast address.
|
||||
*
|
||||
* @param[in] a An IPv6 address.
|
||||
* @return 1 if *a* is an multicast address, 0 if not.
|
||||
*/
|
||||
#define IN6_IS_ADDR_MULTICAST(a) (((const uint8_t *) (a))[0] == 0xff)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
#endif /* _NETINET_IN_H */
|
||||
14
sys/posix/pnet/netinet_in.c
Normal file
14
sys/posix/pnet/netinet_in.c
Normal file
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Freie Universität Berlin
|
||||
*
|
||||
* This file subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
#include <netinet/in.h>
|
||||
|
||||
const struct sockaddr_in6 in6addr_any = {{AF_INET6, 0, 0, IN6ADDR_ANY_INIT}, 0};
|
||||
const struct sockaddr_in6 in6addr_loopback = {{
|
||||
AF_INET6, 0, 0, IN6ADDR_LOOPBACK_INIT
|
||||
}, 0
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user