Revision 05476c4d sysdep/unix/unix.h

View differences:

sysdep/unix/unix.h
12 12
#include <sys/socket.h>
13 13

  
14 14
struct pool;
15
struct iface;
16
struct birdsock;
15 17

  
16 18
/* main.c */
17 19

  
......
27 29

  
28 30
#define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300
29 31

  
32

  
30 33
/* io.c */
31 34

  
32
volatile int async_config_flag;
33
volatile int async_dump_flag;
34
volatile int async_shutdown_flag;
35
#define ERR(c) do { s->err = c; return -1; } while (0)
36
#define ERR2(c) do { s->err = c; goto err; } while (0)
37
#define ERR_MSG(c) do { errno = 0; s->err = c; return -1; } while (0)
38

  
39

  
40
#define SOCKADDR_SIZE 32
41

  
42
typedef struct sockaddr_bird {
43
  struct sockaddr sa;
44
  char padding[SOCKADDR_SIZE - sizeof(struct sockaddr)];
45
} sockaddr;
46

  
35 47

  
36 48
#ifdef IPV6
37
#define BIRD_PF PF_INET6
38 49
#define BIRD_AF AF_INET6
39
typedef struct sockaddr_in6 sockaddr;
40
static inline int sa_family_check(sockaddr *sa) { return sa->sin6_family == AF_INET6; }
50
#define _MI6(x1,x2,x3,x4) _MI(x1, x2, x3, x4)
51
#define ipa_is_link_local(x) ipa_has_link_scope(x)
52
#define ipa_from_sa(x) ipa_from_sa6(x)
53
#define ipa_from_u32(x) _MI6(0,0,0xffff,x)
54
#define ipa_to_u32(x) _I3(x)
41 55
#else
42
#define BIRD_PF PF_INET
43 56
#define BIRD_AF AF_INET
44
typedef struct sockaddr_in sockaddr;
45
static inline int sa_family_check(sockaddr *sa) { return sa->sin_family == AF_INET; }
57
#define _I0(X) 0
58
#define _I1(X) 0
59
#define _I2(X) 0
60
#define _I3(X) 0
61
#define _MI6(x1,x2,x3,x4) IPA_NONE
62
#define ipa_is_link_local(x) 0
63
#define ipa_from_sa(x) ipa_from_sa4(x)
46 64
#endif
47 65

  
66

  
67
/* This is sloppy hack, it should be detected by configure script */
68
/* Linux systems have it defined so this is definition for BSD systems */
69
#ifndef s6_addr32
70
#define s6_addr32 __u6_addr.__u6_addr32
71
#endif
72

  
73

  
74
static inline ip_addr ipa_from_in4(struct in_addr a)
75
{ return ipa_from_u32(ntohl(a.s_addr)); }
76

  
77
static inline ip_addr ipa_from_in6(struct in6_addr a)
78
{ return _MI6(ntohl(a.s6_addr32[0]), ntohl(a.s6_addr32[1]), ntohl(a.s6_addr32[2]), ntohl(a.s6_addr32[3])); }
79

  
80
static inline ip_addr ipa_from_sa4(sockaddr *sa)
81
{ return ipa_from_in4(((struct sockaddr_in *) sa)->sin_addr); }
82

  
83
static inline ip_addr ipa_from_sa6(sockaddr *sa)
84
{ return ipa_from_in6(((struct sockaddr_in6 *) sa)->sin6_addr); }
85

  
86
static inline struct in_addr ipa_to_in4(ip_addr a)
87
{ return (struct in_addr) { htonl(ipa_to_u32(a)) }; }
88

  
89
static inline struct in6_addr ipa_to_in6(ip_addr a)
90
{ return (struct in6_addr) { .s6_addr32 = { htonl(_I0(a)), htonl(_I1(a)), htonl(_I2(a)), htonl(_I3(a)) } }; }
91

  
92
void sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port);
93
int sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *port);
94

  
95

  
48 96
#ifndef SUN_LEN
49 97
#define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen ((ptr)->sun_path))
50 98
#endif
51 99

  
52
struct birdsock;
53
struct iface;
100
volatile int async_config_flag;
101
volatile int async_dump_flag;
102
volatile int async_shutdown_flag;
54 103

  
55 104
void io_init(void);
56 105
void io_loop(void);
57
void fill_in_sockaddr(sockaddr *sa, ip_addr a, struct iface *ifa, unsigned port);
58
void get_sockaddr(sockaddr *sa, ip_addr *a, struct iface **ifa, unsigned *port, int check);
59
void sk_open_unix(struct birdsock *s, char *name);
106
int sk_open_unix(struct birdsock *s, char *name);
60 107
void *tracked_fopen(struct pool *, char *name, char *mode);
61 108
void test_old_bird(char *path);
62 109

  

Also available in: Unified diff