Annotation of embedaddon/bird2/sysdep/unix/unix.h, revision 1.1.1.1
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: #include <signal.h>
14:
15: struct pool;
16: struct iface;
17: struct birdsock;
18: struct rfile;
19:
20: /* main.c */
21:
22: extern char *bird_name;
23: void async_config(void);
24: void async_dump(void);
25: void async_shutdown(void);
26: void cmd_check_config(char *name);
27: void cmd_reconfig(char *name, int type, uint timeout);
28: void cmd_reconfig_confirm(void);
29: void cmd_reconfig_undo(void);
30: void cmd_reconfig_status(void);
31: void cmd_shutdown(void);
32: void cmd_graceful_restart(void);
33:
34: #define UNIX_DEFAULT_CONFIGURE_TIMEOUT 300
35:
36: #define UNIX_DEFAULT_LATENCY_LIMIT (1 S_)
37: #define UNIX_DEFAULT_WATCHDOG_WARNING (5 S_)
38:
39: /* io.c */
40:
41: #define ERR(c) do { s->err = c; return -1; } while (0)
42: #define ERR2(c) do { s->err = c; goto err; } while (0)
43: #define ERR_MSG(c) do { errno = 0; s->err = c; return -1; } while (0)
44:
45:
46: #define SOCKADDR_SIZE 32
47:
48: typedef struct sockaddr_bird {
49: struct sockaddr sa;
50: char padding[SOCKADDR_SIZE - sizeof(struct sockaddr)];
51: } sockaddr;
52:
53:
54:
55: /* This is sloppy hack, it should be detected by configure script */
56: /* Linux systems have it defined so this is definition for BSD systems */
57: #ifndef s6_addr32
58: #define s6_addr32 __u6_addr.__u6_addr32
59: #endif
60:
61:
62: static inline ip_addr ipa_from_in4(struct in_addr a)
63: { return ipa_from_u32(ntohl(a.s_addr)); }
64:
65: static inline ip_addr ipa_from_in6(struct in6_addr a)
66: { return ipa_build6(ntohl(a.s6_addr32[0]), ntohl(a.s6_addr32[1]), ntohl(a.s6_addr32[2]), ntohl(a.s6_addr32[3])); }
67:
68: static inline ip_addr ipa_from_sa4(sockaddr *sa)
69: { return ipa_from_in4(((struct sockaddr_in *) sa)->sin_addr); }
70:
71: static inline ip_addr ipa_from_sa6(sockaddr *sa)
72: { return ipa_from_in6(((struct sockaddr_in6 *) sa)->sin6_addr); }
73:
74: static inline ip_addr ipa_from_sa(sockaddr *sa)
75: {
76: switch (sa->sa.sa_family)
77: {
78: case AF_INET: return ipa_from_sa4(sa);
79: case AF_INET6: return ipa_from_sa6(sa);
80: default: return IPA_NONE;
81: }
82: }
83:
84: static inline struct in_addr ipa_to_in4(ip_addr a)
85: { return (struct in_addr) { htonl(ipa_to_u32(a)) }; }
86:
87: static inline struct in_addr ip4_to_in4(ip4_addr a)
88: { return (struct in_addr) { htonl(ip4_to_u32(a)) }; }
89:
90: static inline struct in6_addr ipa_to_in6(ip_addr a)
91: { return (struct in6_addr) { .s6_addr32 = { htonl(_I0(a)), htonl(_I1(a)), htonl(_I2(a)), htonl(_I3(a)) } }; }
92:
93: void sockaddr_fill(sockaddr *sa, int af, ip_addr a, struct iface *ifa, uint port);
94: int sockaddr_read(sockaddr *sa, int af, ip_addr *a, struct iface **ifa, uint *port);
95:
96:
97: #ifndef SUN_LEN
98: #define SUN_LEN(ptr) ((size_t) (((struct sockaddr_un *) 0)->sun_path) + strlen ((ptr)->sun_path))
99: #endif
100:
101: extern volatile sig_atomic_t async_config_flag;
102: extern volatile sig_atomic_t async_dump_flag;
103: extern volatile sig_atomic_t async_shutdown_flag;
104:
105: void io_init(void);
106: void io_loop(void);
107: void io_log_dump(void);
108: int sk_open_unix(struct birdsock *s, char *name);
109: struct rfile *rf_open(struct pool *, char *name, char *mode);
110: void *rf_file(struct rfile *f);
111: int rf_fileno(struct rfile *f);
112: void test_old_bird(char *path);
113:
114: /* krt.c bits */
115:
116: void krt_io_init(void);
117:
118: /* log.c */
119:
120: void main_thread_init(void);
121: void log_init_debug(char *); /* Initialize debug dump to given file (NULL=stderr, ""=off) */
122: void log_switch(int initial, list *l, char *);
123:
124: struct log_config {
125: node n;
126: uint mask; /* Classes to log */
127: void *fh; /* FILE to log to, NULL=syslog */
128: struct rfile *rf; /* Resource for log file */
129: char *filename; /* Log filename */
130: char *backup; /* Secondary filename (for log rotation) */
131: off_t pos; /* Position/size of current log */
132: off_t limit; /* Log size limit */
133: int terminal_flag;
134: };
135:
136: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>