~ubuntu-branches/ubuntu/utopic/binkd/utopic-proposed

« back to all changes in this revision

Viewing changes to rfc2553.h

  • Committer: Package Import Robot
  • Author(s): Marco d'Itri
  • Date: 2014-07-21 03:18:57 UTC
  • mfrom: (1.2.5)
  • Revision ID: package-import@ubuntu.com-20140721031857-86q9nft3k63gwoki
Tags: 1.0.2-1
* New upstream release. (Closes: #686869)
* binkd.logrotate: use the correct log file. (Closes: #710776)
* Stop checking inetd.conf in the init script. (Closes: #739707)
* Added a systemd unit file.
* Switched /var/log/binkd/ to mode 750.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ######################################################################
 
2
 
 
3
   RFC 2553 Emulation - Provides emulation for RFC 2553 getaddrinfo,
 
4
                        freeaddrinfo and getnameinfo
 
5
   
 
6
   These functions are necessary to write portable protocol independent
 
7
   networking. They transparently support IPv4, IPv6 and probably many 
 
8
   other protocols too. This implementation is needed when the host does 
 
9
   not support these standards. It implements a simple wrapper that 
 
10
   basically supports only IPv4. 
 
11
 
 
12
   Perfect emulation is not provided, but it is passable..
 
13
   
 
14
   Originally written by Jason Gunthorpe <jgg@debian.org> and placed into
 
15
   the Public Domain, do with it what you will.
 
16
  
 
17
   ##################################################################### */
 
18
 
 
19
/*
 
20
 * $Id: rfc2553.h,v 2.2 2012/01/07 13:52:23 green Exp $
 
21
 *
 
22
 * $Log: rfc2553.h,v $
 
23
 * Revision 2.2  2012/01/07 13:52:23  green
 
24
 * Removed C++ comments (bad style, I know)
 
25
 *
 
26
 * Revision 2.1  2012/01/03 17:25:32  green
 
27
 * Implemented IPv6 support
 
28
 * - replace (almost) all getXbyY function calls with getaddrinfo/getnameinfo (RFC2553) calls
 
29
 * - Add compatibility layer for target systems not supporting RFC2553 calls in rfc2553.[ch]
 
30
 * - Add support for multiple listen sockets -- one for IPv4 and one for IPv6 (use V6ONLY)
 
31
 * - For WIN32 platform add configuration parameter IPV6 (mutually exclusive with BINKD9X)
 
32
 * - On WIN32 platform use Winsock2 API if IPV6 support is requested
 
33
 * - config: node IP address literal + port supported: [<ipv6 address>]:<port>
 
34
 *
 
35
 */
 
36
 
 
37
#ifndef RFC2553EMU_H
 
38
#define RFC2553EMU_H
 
39
 
 
40
#include "iphdr.h"
 
41
 
 
42
/* Autosense getaddrinfo */
 
43
#if defined(AI_PASSIVE) && defined(EAI_NONAME)
 
44
#define HAVE_GETADDRINFO
 
45
#endif
 
46
 
 
47
/* Autosense getnameinfo */
 
48
#if defined(NI_NUMERICHOST)
 
49
#define HAVE_GETNAMEINFO
 
50
#endif
 
51
 
 
52
/* getaddrinfo support? */
 
53
#ifndef HAVE_GETADDRINFO
 
54
  /* Renamed to advoid type clashing.. (for debugging) */
 
55
  struct addrinfo_emu
 
56
  {   
 
57
     int     ai_flags;     /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
 
58
     int     ai_family;    /* PF_xxx */
 
59
     int     ai_socktype;  /* SOCK_xxx */
 
60
     int     ai_protocol;  /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
 
61
     size_t  ai_addrlen;   /* length of ai_addr */
 
62
     char   *ai_canonname; /* canonical name for nodename */
 
63
     struct sockaddr  *ai_addr; /* binary address */
 
64
     struct addrinfo_emu  *ai_next; /* next structure in linked list */
 
65
  };
 
66
  #define addrinfo addrinfo_emu
 
67
 
 
68
  int getaddrinfo(const char *nodename, const char *servname,
 
69
                  const struct addrinfo *hints,
 
70
                  struct addrinfo **res);
 
71
  void freeaddrinfo(struct addrinfo *ai);
 
72
  char * gai_strerror(int ecode);
 
73
 
 
74
  #ifndef AI_PASSIVE
 
75
  #define AI_PASSIVE (1<<1)
 
76
  #endif
 
77
  
 
78
  #ifndef EAI_NONAME
 
79
  #define EAI_NONAME     -1
 
80
  #define EAI_AGAIN      -2
 
81
  #define EAI_FAIL       -3
 
82
  #define EAI_NODATA     -4
 
83
  #define EAI_FAMILY     -5
 
84
  #define EAI_SOCKTYPE   -6
 
85
  #define EAI_SERVICE    -7
 
86
  #define EAI_ADDRFAMILY -8
 
87
  #define EAI_MEMORY     -9
 
88
  #define EAI_SYSTEM     -10
 
89
  #define EAI_UNKNOWN    -11
 
90
  #endif
 
91
 
 
92
  /* If we don't have getaddrinfo then we probably don't have 
 
93
     sockaddr_storage either (same RFC) so we definately will not be
 
94
     doing any IPv6 stuff. Do not use the members of this structure to
 
95
     retain portability, cast to a sockaddr. */
 
96
  #define sockaddr_storage sockaddr_in
 
97
#endif
 
98
 
 
99
/* getnameinfo support (glibc2.0 has getaddrinfo only) */
 
100
#ifndef HAVE_GETNAMEINFO
 
101
 
 
102
  int getnameinfo(const struct sockaddr *sa, socklen_t salen,
 
103
                  char *host, size_t hostlen,
 
104
                  char *serv, size_t servlen,
 
105
                  int flags);
 
106
 
 
107
  #ifndef NI_MAXHOST
 
108
  #define NI_MAXHOST 1025
 
109
  #define NI_MAXSERV 32
 
110
  #endif
 
111
 
 
112
  #ifndef NI_NUMERICHOST
 
113
  #define NI_NUMERICHOST (1<<0)
 
114
  #define NI_NUMERICSERV (1<<1)
 
115
/*  #define NI_NOFQDN (1<<2) */
 
116
  #define NI_NAMEREQD (1<<3)
 
117
  #define NI_DATAGRAM (1<<4)
 
118
  #endif
 
119
 
 
120
  #define sockaddr_storage sockaddr_in
 
121
#endif
 
122
 
 
123
/* Glibc 2.0.7 misses this one */
 
124
#ifndef AI_NUMERICHOST
 
125
#define AI_NUMERICHOST 0
 
126
#endif
 
127
 
 
128
/* Win32 doesn't support these */
 
129
#ifndef AI_NUMERICSERV
 
130
#define AI_NUMERICSERV 0
 
131
#endif
 
132
 
 
133
/* Win32 doesn't support these */
 
134
#ifndef NI_NUMERICSERV
 
135
#define NI_NUMERICSERV 0
 
136
#endif
 
137
 
 
138
 
 
139
#endif