blob: 612b12c892814ad0b50b53bcb63332f29a7989d6 [file] [log] [blame]
Harald Welte33cb71a2011-05-21 18:54:32 +02001#ifndef _OSMOCORE_SOCKET_H
2#define _OSMOCORE_SOCKET_H
3
4#include <stdint.h>
Harald Weltee4764422011-05-22 12:25:57 +02005
6struct sockaddr;
Harald Welte33cb71a2011-05-21 18:54:32 +02007
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +02008/* flags for osmo_sock_init. */
9#define OSMO_SOCK_F_CONNECT (1 << 0)
10#define OSMO_SOCK_F_BIND (1 << 1)
11#define OSMO_SOCK_F_NONBLOCK (1 << 2)
12
Harald Welte33cb71a2011-05-21 18:54:32 +020013int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020014 const char *host, uint16_t port, unsigned int flags);
Harald Welte33cb71a2011-05-21 18:54:32 +020015
Harald Welte68b15742011-05-22 21:47:29 +020016int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020017 const char *host, uint16_t port, unsigned int flags);
Harald Welte68b15742011-05-22 21:47:29 +020018
Harald Welte33cb71a2011-05-21 18:54:32 +020019int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020020 uint8_t proto, unsigned int flags);
Harald Welte33cb71a2011-05-21 18:54:32 +020021
22/* determine if the given address is a local address */
Harald Weltee4764422011-05-22 12:25:57 +020023int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen);
Harald Welte33cb71a2011-05-21 18:54:32 +020024
25#endif /* _OSMOCORE_SOCKET_H */