blob: 1df28c9213b3792a603fe75a3d83a896935a075a [file] [log] [blame]
Sylvain Munaut12ba7782014-06-16 10:13:40 +02001#pragma once
Harald Welte33cb71a2011-05-21 18:54:32 +02002
Harald Welteba6988b2011-08-17 12:46:48 +02003/*! \defgroup socket Socket convenience functions
4 * @{
5 */
6
Harald Weltebd598e32011-08-16 23:26:52 +02007/*! \file socket.h
8 * \brief Osmocom socket convenience functions
9 */
10
Harald Welte33cb71a2011-05-21 18:54:32 +020011#include <stdint.h>
Harald Weltee4764422011-05-22 12:25:57 +020012
13struct sockaddr;
Holger Hans Peter Freyther58d31532012-03-16 09:18:12 +010014struct osmo_fd;
Harald Welte33cb71a2011-05-21 18:54:32 +020015
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020016/* flags for osmo_sock_init. */
17#define OSMO_SOCK_F_CONNECT (1 << 0)
18#define OSMO_SOCK_F_BIND (1 << 1)
19#define OSMO_SOCK_F_NONBLOCK (1 << 2)
20
Harald Welte33cb71a2011-05-21 18:54:32 +020021int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020022 const char *host, uint16_t port, unsigned int flags);
Harald Welte33cb71a2011-05-21 18:54:32 +020023
Harald Welte68b15742011-05-22 21:47:29 +020024int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020025 const char *host, uint16_t port, unsigned int flags);
Harald Welte68b15742011-05-22 21:47:29 +020026
Harald Welte33cb71a2011-05-21 18:54:32 +020027int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type,
Pablo Neira Ayuso0849c9a2011-06-09 15:04:30 +020028 uint8_t proto, unsigned int flags);
Harald Welte33cb71a2011-05-21 18:54:32 +020029
Harald Weltee4764422011-05-22 12:25:57 +020030int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen);
Harald Welte33cb71a2011-05-21 18:54:32 +020031
Álvaro Neira Ayuso5ade61a2014-03-24 13:02:00 +010032int osmo_sock_unix_init(uint16_t type, uint8_t proto,
33 const char *socket_path, unsigned int flags);
34
35int osmo_sock_unix_init_ofd(struct osmo_fd *ofd, uint16_t type, uint8_t proto,
36 const char *socket_path, unsigned int flags);
37
Sylvain Munautdca7d2c2012-04-18 21:53:23 +020038/*! @} */