2007-09-02 17:26:51 +02:00
|
|
|
/****************************************************************************
|
2009-12-15 00:32:23 +01:00
|
|
|
* include/arpa/inet.h
|
2007-09-02 17:26:51 +02:00
|
|
|
*
|
2020-04-11 19:17:55 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-09-02 17:26:51 +02:00
|
|
|
*
|
2020-04-11 19:17:55 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-09-02 17:26:51 +02:00
|
|
|
*
|
2020-04-11 19:17:55 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-09-02 17:26:51 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2012-07-17 05:58:11 +02:00
|
|
|
#ifndef __INCLUDE_ARPA_INET_H
|
|
|
|
#define __INCLUDE_ARPA_INET_H
|
2007-09-02 17:26:51 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2009-12-15 00:32:23 +01:00
|
|
|
|
2007-09-02 17:26:51 +02:00
|
|
|
#include <sys/types.h>
|
2009-12-15 00:32:23 +01:00
|
|
|
#include <stdint.h>
|
2007-09-02 17:26:51 +02:00
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Type Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/* This macro to convert a 16/32-bit constant values quantity from host byte
|
2007-11-23 22:16:43 +01:00
|
|
|
* order to network byte order. The 16-bit version of this macro is required
|
2007-09-02 17:26:51 +02:00
|
|
|
* for uIP:
|
|
|
|
*
|
|
|
|
* Author Adam Dunkels <adam@dunkels.com>
|
|
|
|
* Copyright (c) 2001-2003, Adam Dunkels.
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_ENDIAN_BIG
|
|
|
|
# define HTONS(ns) (ns)
|
|
|
|
# define HTONL(nl) (nl)
|
|
|
|
#else
|
|
|
|
# define HTONS(ns) \
|
2009-03-08 00:27:38 +01:00
|
|
|
(unsigned short) \
|
|
|
|
(((((unsigned short)(ns)) & 0x00ff) << 8) | \
|
|
|
|
((((unsigned short)(ns)) >> 8) & 0x00ff))
|
2007-09-17 00:12:04 +02:00
|
|
|
# define HTONL(nl) \
|
2009-03-08 00:27:38 +01:00
|
|
|
(unsigned long) \
|
2012-01-06 20:29:37 +01:00
|
|
|
(((((unsigned long)(nl)) & 0x000000ffUL) << 24) | \
|
|
|
|
((((unsigned long)(nl)) & 0x0000ff00UL) << 8) | \
|
|
|
|
((((unsigned long)(nl)) & 0x00ff0000UL) >> 8) | \
|
|
|
|
((((unsigned long)(nl)) & 0xff000000UL) >> 24))
|
2007-09-02 17:26:51 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define NTOHS(hs) HTONS(hs)
|
2009-12-19 23:05:12 +01:00
|
|
|
#define NTOHL(hl) HTONL(hl)
|
2007-09-02 17:26:51 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
2014-07-05 03:13:08 +02:00
|
|
|
extern "C"
|
|
|
|
{
|
2007-09-02 17:26:51 +02:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2018-08-19 16:24:30 +02:00
|
|
|
/* Functions to convert between host and network byte ordering.
|
|
|
|
*
|
|
|
|
* REVISIT: Since network order is defined as big-endian, the following
|
|
|
|
* functions are equivalent to functions declared in endian.h:
|
|
|
|
*
|
|
|
|
* htonl htobe32
|
|
|
|
* htons htobe16
|
|
|
|
* ntohl be32toh
|
|
|
|
* ntohs be16toh
|
|
|
|
*/
|
2007-09-02 17:26:51 +02:00
|
|
|
|
2014-07-05 03:13:08 +02:00
|
|
|
uint32_t ntohl(uint32_t nl);
|
|
|
|
uint16_t ntohs(uint16_t ns);
|
|
|
|
uint32_t htonl(uint32_t hl);
|
|
|
|
uint16_t htons(uint16_t hs);
|
2007-09-02 17:26:51 +02:00
|
|
|
|
|
|
|
/* Functions to manipulate address representations */
|
|
|
|
|
2014-07-05 03:13:08 +02:00
|
|
|
int inet_aton(FAR const char *cp, FAR struct in_addr *inp);
|
|
|
|
in_addr_t inet_addr(FAR const char *cp);
|
|
|
|
in_addr_t inet_network(FAR const char *cp);
|
2007-12-28 23:10:14 +01:00
|
|
|
|
2014-07-05 03:13:08 +02:00
|
|
|
FAR char *inet_ntoa(struct in_addr in);
|
|
|
|
in_addr_t inet_lnaof(struct in_addr in);
|
|
|
|
in_addr_t inet_netof(struct in_addr in);
|
2007-12-28 23:10:14 +01:00
|
|
|
|
2014-07-05 03:13:08 +02:00
|
|
|
struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host);
|
2007-12-28 23:10:14 +01:00
|
|
|
|
2014-07-05 03:13:08 +02:00
|
|
|
int inet_pton(int af, FAR const char *src, FAR void *dst);
|
2020-04-11 19:43:37 +02:00
|
|
|
const char *inet_ntop(int af, FAR const void *src, FAR char *dst,
|
|
|
|
socklen_t size);
|
2007-09-02 17:26:51 +02:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-07-17 05:58:11 +02:00
|
|
|
#endif /* __INCLUDE_ARPA_INET_H */
|