pidentd  3.0.19
About: implementation of the RFC1413 identification server (more or less complete rewrite compared to version 2)
  Fossies Dox: pidentd-3.0.19.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

sockaddr.h
Go to the documentation of this file.
1 /*
2 ** sockaddr.h - Generic sockaddr_gen to handle multiple protocols
3 **
4 ** Copyright (c) 1999 Casper Dik <Casper.Dik@Holland.Sun.COM>
5 **
6 ** This program is free software; you can redistribute it and/or
7 ** modify it as you wish - as long as you don't claim that you wrote
8 ** it.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 */
14 
15 #ifndef PIDENTD_SOCKADDR_H
16 #define PIDENTD_SOCKADDR_H
17 
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <netinet/in.h>
21 
22 #ifdef HAVE_IPV6
23 
24 struct sockaddr_gen
25 {
26  union {
27  struct sockaddr _sg_sa;
28  struct sockaddr_in _sg_sin;
29  struct sockaddr_in6 _sg_sin6;
30  } sg_addr;
31 };
32 
33 #define sg_sa sg_addr._sg_sa
34 #define sg_sin sg_addr._sg_sin
35 #define sg_family sg_sa.sa_family
36 #define sg_sin6 sg_addr._sg_sin6
37 
38 #define SGFAM(sag) ((sag).sg_family)
39 #define SGSIZE(sag) (SGFAM(sag) == AF_INET6 ? \
40  sizeof (struct in6_addr) : \
41  sizeof (struct in_addr))
42 #define SGSOCKSIZE(sag) (SGFAM(sag) == AF_INET6 ? \
43  sizeof (struct sockaddr_in6) : \
44  sizeof (struct sockaddr_in))
45 #define SGPORT(sag) (*(SGFAM(sag) == AF_INET6 ? \
46  &(sag).sg_sin6.sin6_port : \
47  &(sag).sg_sin.sin_port))
48 #define SGADDRP(sag) ((SGFAM(sag) == AF_INET6 ? \
49  (char *) &(sag).sg_sin6.sin6_addr : \
50  (char *) &(sag).sg_sin.sin_addr))
51 #else /* !HAVE_IPV6 */
52 
53 #define sockaddr_gen sockaddr_in
54 #define SGFAM(sag) AF_INET
55 #define SGSIZE(sag) sizeof(struct in_addr)
56 #define SGSOCKSIZE(sag) sizeof(struct sockaddr_in)
57 #define SGPORT(sag) ((sag).sin_port)
58 #define SGADDRP(sag) ((char *) &(sag).sin_addr)
59 
60 #endif /* HAVE_IPV6 */
61 #endif
sockaddr_gen
#define sockaddr_gen
Definition: sockaddr.h:53