]> git.ipfire.org Git - thirdparty/bird.git/blob - lib/socket.h
Added declarations of all our socket functions.
[thirdparty/bird.git] / lib / socket.h
1 /*
2 * BIRD Socket Interface
3 *
4 * (c) 1998 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_SOCKET_H_
10 #define _BIRD_SOCKET_H_
11
12 #include "lib/resource.h"
13
14 typedef struct birdsock {
15 resource r;
16 int type; /* Socket type */
17 void *data; /* User data */
18 ip_addr saddr, daddr; /* IPA_NONE = unspecified */
19 unsigned sport, dport; /* 0 = unspecified (for IP: protocol type) */
20 int tos; /* TOS and priority, -1 = default */
21 int ttl; /* Time To Live, -1 = default */
22 struct iface *iface; /* Bound to interface */
23
24 byte *rbuf, *rpos; /* NULL=allocate automatically */
25 unsigned rbsize;
26 void (*rx_hook)(struct birdsock *); /* NULL=receiving turned off */
27
28 byte *tbuf, *tpos; /* NULL=allocate automatically */
29 byte *ttx; /* Internal */
30 unsigned tbsize;
31 void (*tx_hook)(struct birdsock *);
32
33 void (*err_hook)(struct birdsock *, int);
34 } socket;
35
36 socket *sk_get(pool *); /* Allocate new socket */
37 int sk_open(socket *); /* Open socket */
38 int sk_send(socket *); /* Try to send queued data, > 0 if succeeded */
39 int sk_send_to(socket *, ip_addr, unsigned); /* Send queued data to given destination */
40
41 /*
42 * Socket types SA SP DA DP IF SendTo (?=may, -=must not, *=must)
43 */
44
45 #define SK_TCP_PASSIVE 0 /* ? * - - - - */
46 #define SK_TCP_ACTIVE 1 /* ? ? * * - - */
47 #define SK_UDP 2 /* ? ? - - - ? */
48 #define SK_UDP_MC 3 /* ? ? * * * - */
49 #define SK_IP 4 /* ? ? - * - ? */
50 #define SK_IP_MC 5 /* ? ? * * * - */
51
52 #endif