]>
git.ipfire.org Git - thirdparty/bird.git/blob - lib/socket.h
2 * BIRD Socket Interface
4 * (c) 1998 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
9 #ifndef _BIRD_SOCKET_H_
10 #define _BIRD_SOCKET_H_
12 #include "lib/resource.h"
14 typedef struct birdsock
{
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 */
24 byte
*rbuf
, *rpos
; /* NULL=allocate automatically */
26 void (*rx_hook
)(struct birdsock
*); /* NULL=receiving turned off */
28 byte
*tbuf
, *tpos
; /* NULL=allocate automatically */
29 byte
*ttx
; /* Internal */
31 void (*tx_hook
)(struct birdsock
*);
33 void (*err_hook
)(struct birdsock
*, int);
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 */
42 * Socket types SA SP DA DP IF SendTo (?=may, -=must not, *=must)
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 /* ? ? * * * - */