BRL-CAD
bnetwork.h
Go to the documentation of this file.
1/* B N E T W O R K . H
2 * BRL-CAD
3 *
4 * Copyright (c) 2011-2023 United States Government as represented by
5 * the U.S. Army Research Laboratory.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * version 2.1 as published by the Free Software Foundation.
10 *
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this file; see the file named COPYING for more
18 * information.
19 */
20/** @addtogroup bu_bnetwork
21 *
22 * @brief
23 * BRL-CAD system compatibility wrapper header that provides declarations for
24 * native and standard system NETWORKING routines.
25 *
26 * This header is commonly used in lieu of including the following: winsock2.h
27 * (not select, fd_set), netinet/in.h, netinet/tcp.h, arpa/inet.h (htonl,
28 * ntohl, etc)
29 *
30 * The logic in this header should not rely on common.h's HAVE_* defines and
31 * should not be including the common.h header. This is intended to be a
32 * stand-alone portability header intended to be independent of build system,
33 * reusable by external projects.
34 */
35
36/** @{ */
37/** @file bnetwork.h */
38
39#ifndef BNETWORK_H
40#define BNETWORK_H
41
42#if defined(_WIN32) && !defined(__CYGWIN__)
43# ifndef _WINSOCKAPI_
44# include <winsock2.h> /* link against ws2_32 library */
45# include <ws2tcpip.h> /* provides extensions */
46# undef rad1 /* Win32 radio button 1 */
47# undef rad2 /* Win32 radio button 2 */
48# undef small /* defined as part of the Microsoft Interface Definition Language (MIDL) */
49# endif
50#else
51# include <sys/types.h>
52# include <netinet/in.h> /* sockaddr */
53# include <netinet/tcp.h> /* for TCP_NODELAY sockopt */
54# include <arpa/inet.h> /* hton/ntoh, inet_addr functions */
55# include <sys/socket.h> /* accept, connect, send, recv, ... */
56/* for c90/c99 compatibility */
57# if !defined(HAVE_DECL_HTONL) && !defined(htonl)
58extern uint32_t htonl(uint32_t);
59extern uint32_t ntohl(uint32_t);
60# endif
61#endif
62
63#endif /* BNETWORK_H */
64
65/** @} */
66
67/*
68 * Local Variables:
69 * tab-width: 8
70 * mode: C
71 * indent-tabs-mode: t
72 * c-file-style: "stroustrup"
73 * End:
74 * ex: shiftwidth=4 tabstop=8
75 */
uint32_t ntohl(uint32_t)
uint32_t htonl(uint32_t)