Annotation of embedaddon/bird/sysdep/unix/unix.h, revision 1.1.1.2
1.1 misho 1: /*
2: * BIRD -- Declarations Common to Unix Port
3: *
4: * (c) 1998--2000 Martin Mares <mj@ucw.cz>
5: *
6: * Can be freely distributed and used under the terms of the GNU GPL.
7: */
8:
9: #ifndef _BIRD_UNIX_H_
10: #define _BIRD_UNIX_H_
11:
12: #include <sys/socket.h>
13:
14: struct pool;
15: struct iface;
16: struct birdsock;
1.1.1.2 ! misho 17: struct rfile;
1.1 misho 18:
19: /* main.c */
20:
21: extern char *bird_name;
22: void async_config(void);
23: void async_dump(void);
24: void async_shutdown(void);
25: void cmd_check_config(char *name);
26: void cmd_reconfig(char *name, int type, int timeout);
27: void cmd_reconfig_confirm(void);
28: void cmd_reconfig_undo(void);
29: void cmd_shutdown(void);
30:
31: #define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300
32:
33: #define UNIX_DEFAULT_LATENCY_LIMIT (1 S_)
34: #define UNIX_DEFAULT_WATCHDOG_WARNING (5 S_)
35:
36: /* io.c */
37:
38: #define ERR(c) do { s->err = c; return -1; } while (0)
39: #define ERR2(c) do { s->err = c; goto err; } while (0)
40: #define ERR_MSG(c) do { errno = 0; s->err = c; return -1; } while (0)
41:
42:
43: #define SOCKADDR_SIZE 32
44:
45: typedef struct sockaddr_bird {
46: struct sockaddr sa;
47: char padding[SOCKADDR_SIZE - sizeof(struct sockaddr)];
48: } sockaddr;
49:
50:
51: #ifdef IPV6
52: #define BIRD_AF AF_INET6
53: #define ipa_from_sa(x) ipa_from_sa6(x)
54: #else
55: #define BIRD_AF AF_INET
56: #define ipa_from_sa(x) ipa_from_sa4(x)
57: #endif
58:
59:
60: /* This is sloppy hack, it should be detected by configure script */
61: /* Linux systems have it defined so this is definition for BSD systems */
62: #ifndef s6_addr32
63: #define s6_addr32 __u6_addr.__u6_addr32
64: #endif
65:
66:
67: static inline ip_addr ipa_from_in4(struct in_addr a UNUSED6)
68: { return ipa_from_u32(ntohl(a.s_addr)); }
69:
70: static inline ip_addr ipa_from_in6(struct in6_addr a UNUSED4)
71: { return ipa_build6(ntohl(a.s6_addr32[0]), ntohl(a.s6_addr32[1]), ntohl(a.s6_addr32[2]), ntohl(a.s6_addr32[3])); }
72:
73: static inline ip_addr ipa_from_sa4(sockaddr *sa UNUSED6)
74: { return ipa_from_in4(((struct sockaddr_in *) sa)->sin_addr); }
75:
76: static inline ip_addr ipa_from_sa6(sockaddr *sa UNUSED4)
77: { return ipa_from_in6(((struct sockaddr_in6 *) sa)->sin6_addr); }
78:
79: static inline struct in_addr ipa_to_in4(ip_addr a)
80: { return (struct in_addr) { htonl(ipa_to_u32(a)) }; }
81:
82: #ifdef IPV6
83: static inline struct in6_addr ipa_to_in6(ip_addr a)
84: { return (struct in6_addr) { .s6_addr32 = { htonl(_I0(a)), htonl(_I1(a)), htonl(_I2(a)), htonl(_I3(a)) } }; }
85: #else
86: /* Temporary dummy */
87: static inline struct in6_addr ipa_to_in6(ip_addr a UNUSED)
88: { return (struct in6_addr) { .s6_addr32 = { 0, 0, 0, 0 } }; }
89: #endif
90:
91: void sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port);
92: int sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *port);
93:
94:
95: #ifndef SUN_LEN
96: #define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen ((ptr)->sun_path))
97: #endif
98:
1.1.1.2 ! misho 99: extern volatile int async_config_flag;
! 100: extern volatile int async_dump_flag;
! 101: extern volatile int async_shutdown_flag;
1.1 misho 102:
103: void io_init(void);
104: void io_loop(void);
105: void io_log_dump(void);
106: int sk_open_unix(struct birdsock *s, char *name);
1.1.1.2 ! misho 107: struct rfile *rf_open(struct pool *, char *name, char *mode);
! 108: void *rf_file(struct rfile *f);
! 109: int rf_fileno(struct rfile *f);
1.1 misho 110: void test_old_bird(char *path);
111:
112:
113: /* krt.c bits */
114:
115: void krt_io_init(void);
116:
117: /* log.c */
118:
119: void main_thread_init(void);
120: void log_init_debug(char *); /* Initialize debug dump to given file (NULL=stderr, ""=off) */
121: void log_switch(int debug, list *l, char *); /* Use l=NULL for initial switch */
122:
123: struct log_config {
124: node n;
125: uint mask; /* Classes to log */
126: void *fh; /* FILE to log to, NULL=syslog */
127: int terminal_flag;
128: };
129:
130: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>