blob: f15a03a91b19c836dab5e0c21bcdf4b1f45d895f [file] [log] [blame]
Harald Welte33cb71a2011-05-21 18:54:32 +02001#ifndef _OSMOCORE_SOCKET_H
2#define _OSMOCORE_SOCKET_H
3
Harald Welteba6988b2011-08-17 12:46:48 +02004/*! \defgroup socket Socket convenience functions
5 * @{
6 */
7
Harald Weltebd598e32011-08-16 23:26:52 +02008/*! \file socket.h
9 * \brief Osmocom socket convenience functions
10 */
11
Harald Welte33cb71a2011-05-21 18:54:32 +020012#include <stdint.h>
Harald Weltee4764422011-05-22 12:25:57 +020013
14struct sockaddr;
Holger Hans Peter Freyther58d31532012-03-16 09:18:12 +010015struct osmo_fd;
Harald Welte33cb71a2011-05-21 18:54:32 +020016
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020017/* flags for osmo_sock_init. */
18#define OSMO_SOCK_F_CONNECT (1 << 0)
19#define OSMO_SOCK_F_BIND (1 << 1)
20#define OSMO_SOCK_F_NONBLOCK (1 << 2)
21
Harald Welte33cb71a2011-05-21 18:54:32 +020022int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020023 const char *host, uint16_t port, unsigned int flags);
Harald Welte33cb71a2011-05-21 18:54:32 +020024
Harald Welte68b15742011-05-22 21:47:29 +020025int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020026 const char *host, uint16_t port, unsigned int flags);
Harald Welte68b15742011-05-22 21:47:29 +020027
Harald Welte33cb71a2011-05-21 18:54:32 +020028int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020029 uint8_t proto, unsigned int flags);
Harald Welte33cb71a2011-05-21 18:54:32 +020030
Harald Weltee4764422011-05-22 12:25:57 +020031int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen);
Harald Welte33cb71a2011-05-21 18:54:32 +020032
Sylvain Munautdca7d2c2012-04-18 21:53:23 +020033/*! @} */
Harald Welteba6988b2011-08-17 12:46:48 +020034
Harald Welte33cb71a2011-05-21 18:54:32 +020035#endif /* _OSMOCORE_SOCKET_H */