1 /* Copyright (C) 2006 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
2 /** \file net.h exported symbols from net.c */
4 /* Userland defines for Linux DCCP support. */
7 #define SOL_DCCP 269 /**< Linux socket level. */
10 /** The maximum length of the host component in an URL. */
11 #define MAX_HOSTLEN 256
13 /* Opaque, only known to net.c. */
16 struct flowopts
*flowopt_new(void);
17 void flowopt_add(struct flowopts
*fo
, int level
, int opt
,
18 const char *name
, const void *val
, int len
);
19 void flowopt_cleanup(struct flowopts
*fo
);
22 * Functions to parse and validate (parts of) URLs.
24 char *parse_cidr(const char *cidr
,
25 char *addr
, ssize_t addrlen
, int32_t *netmask
);
26 char *parse_url(const char *url
,
27 char *host
, ssize_t hostlen
, int32_t *port
);
28 char *format_url(const char *url
, int default_port
);
29 const char *stringify_port(int port
, const char *transport
);
31 int lookup_address(unsigned l4type
, bool passive
, const char *host
,
32 int port_number
, struct addrinfo
**result
);
35 * Generic socket creation (passive and active sockets).
37 int makesock(unsigned l4type
, bool passive
, const char *host
,
38 uint16_t port_number
, struct flowopts
*fo
);
40 int makesock_addrinfo(unsigned l4type
, bool passive
, struct addrinfo
*ai
,
43 static inline int para_connect(unsigned l4type
, const char *host
, uint16_t port
)
45 return makesock(l4type
, false, host
, port
, NULL
);
48 void extract_v4_addr(const struct sockaddr_storage
*ss
, struct in_addr
*ia
);
49 bool sockaddr_equal(const struct sockaddr
*sa1
, const struct sockaddr
*sa2
);
52 * Functions to support listening sockets.
54 /** How many pending connections queue of a listening server will hold. */
57 int para_listen(unsigned l4type
, const char *addr
, uint16_t port
);
58 int para_listen_simple(unsigned l4type
, uint16_t port
);
60 /** Pretty-printing of IPv4/6 socket addresses */
61 char *remote_name(int sockfd
);
64 * Determining maximum payload (packet) size
66 int generic_max_transport_msg_size(int sockfd
);
68 int recv_bin_buffer(int fd
, char *buf
, size_t size
);
69 int recv_buffer(int fd
, char *buf
, size_t size
);
71 int para_accept(int fd
, void *addr
, socklen_t size
, int *new_fd
);
72 int create_local_socket(const char *name
);
73 int connect_local_socket(const char *name
);
74 int recv_cred_buffer(int, char *, size_t);
75 ssize_t
send_cred_buffer(int, char*);
78 * Functions and definitions to support \p IPPROTO_DCCP
80 /** Hardcoded maximum number of separate CCID modules compiled into a host. */
81 #define DCCP_MAX_HOST_CCIDS 20
82 int dccp_available_ccids(uint8_t **ccid_array
);