105b432d2SOlivier Houchard /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3d915a14eSPedro F. Giffuni *
405b432d2SOlivier Houchard * Copyright (c) 2006 Olivier Houchard
505b432d2SOlivier Houchard * All rights reserved.
605b432d2SOlivier Houchard *
705b432d2SOlivier Houchard * Redistribution and use in source and binary forms, with or without
805b432d2SOlivier Houchard * modification, are permitted provided that the following conditions
905b432d2SOlivier Houchard * are met:
1005b432d2SOlivier Houchard * 1. Redistributions of source code must retain the above copyright
1105b432d2SOlivier Houchard * notice, this list of conditions and the following disclaimer.
1205b432d2SOlivier Houchard * 2. Redistributions in binary form must reproduce the above copyright
1305b432d2SOlivier Houchard * notice, this list of conditions and the following disclaimer in the
1405b432d2SOlivier Houchard * documentation and/or other materials provided with the distribution.
1505b432d2SOlivier Houchard *
1605b432d2SOlivier Houchard * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
1705b432d2SOlivier Houchard * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
1805b432d2SOlivier Houchard * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1905b432d2SOlivier Houchard * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2005b432d2SOlivier Houchard * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2105b432d2SOlivier Houchard * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2205b432d2SOlivier Houchard * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2305b432d2SOlivier Houchard * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2405b432d2SOlivier Houchard * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2505b432d2SOlivier Houchard * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2605b432d2SOlivier Houchard * POSSIBILITY OF SUCH DAMAGE.
2705b432d2SOlivier Houchard */
2805b432d2SOlivier Houchard
2905b432d2SOlivier Houchard #include <sys/endian.h>
30ffdd7037SCraig Rodrigues #define _BYTEORDER_FUNC_DEFINED
31ffdd7037SCraig Rodrigues #include <arpa/inet.h>
3205b432d2SOlivier Houchard
3305b432d2SOlivier Houchard uint32_t
htonl(uint32_t hl)3405b432d2SOlivier Houchard htonl(uint32_t hl)
3505b432d2SOlivier Houchard {
3605b432d2SOlivier Houchard
3705b432d2SOlivier Houchard return (__htonl(hl));
3805b432d2SOlivier Houchard }
3905b432d2SOlivier Houchard
4005b432d2SOlivier Houchard uint16_t
htons(uint16_t hs)4105b432d2SOlivier Houchard htons(uint16_t hs)
4205b432d2SOlivier Houchard {
4305b432d2SOlivier Houchard
4405b432d2SOlivier Houchard return (__htons(hs));
4505b432d2SOlivier Houchard }
4605b432d2SOlivier Houchard
4705b432d2SOlivier Houchard uint32_t
ntohl(uint32_t nl)4805b432d2SOlivier Houchard ntohl(uint32_t nl)
4905b432d2SOlivier Houchard {
5005b432d2SOlivier Houchard
5105b432d2SOlivier Houchard return (__ntohl(nl));
5205b432d2SOlivier Houchard }
5305b432d2SOlivier Houchard
5405b432d2SOlivier Houchard uint16_t
ntohs(uint16_t ns)5505b432d2SOlivier Houchard ntohs(uint16_t ns)
5605b432d2SOlivier Houchard {
5705b432d2SOlivier Houchard
5805b432d2SOlivier Houchard return (__ntohs(ns));
5905b432d2SOlivier Houchard }
60