PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/ntp/sntp/internet.h

https://bitbucket.org/freebsd/freebsd-head/
C++ Header | 47 lines | 21 code | 12 blank | 14 comment | 1 complexity | 477d4b03e6dc06301241feb2c435e21b MD5 | raw file
 1/*  Copyright (C) 1996 N.M. Maclaren
 2    Copyright (C) 1996 The University of Cambridge
 3
 4This includes all of the 'Internet' headers and definitions used across
 5modules, including those for handling timeouts.  No changes should be needed
 6for any version of Unix with Internet (IP version 5) addressing, but would be
 7for other addressing domains.  It needs <sys/socket.h> only because AF_INET is
 8needed by gethostbyaddr and is defined there rather than in <netdb.h>, for some
 9damn-fool reason. */
10
11
12
13#include <setjmp.h>
14#include <signal.h>
15
16#include <unistd.h>
17#include <sys/types.h>
18#include <netinet/in.h>
19#include <sys/socket.h>
20
21
22
23/* It is most unclear whether these should be here or in kludges.h, as they are
24kludges to keep 32-bit address dependencies out of the main body of internet.c,
25to allow for the much heralded arrival of IP version 6.  It will be interesting
26to see whether the universal availability of 64-bit integers arrives first. */
27
28#define local_to_address(x,y) ((x)->s_addr = htonl((unsigned long)y))
29#define network_to_address(x,y) ((x)->s_addr = (y))
30
31#define NTP_PORT htons((unsigned short)123)    /* If not in /etc/services */
32#define port_to_integer(x) (ntohs((unsigned short)(x)))
33
34
35#if defined(_SS_MAXSIZE) || defined(_SS_SIZE)
36#define HAVE_IPV6
37#endif
38
39/* Defined in internet.c */
40#ifdef HAVE_IPV6
41extern void find_address (struct sockaddr_storage *address,
42    struct sockaddr_storage *anywhere,
43    int *port, char *hostname, int timespan);
44#else
45extern void find_address (struct in_addr *address, struct in_addr *anywhere,
46    int *port, char *hostname, int timespan);
47#endif