2014-06-16 08:13:40 +00:00
|
|
|
#pragma once
|
2011-05-21 16:54:32 +00:00
|
|
|
|
2011-08-17 10:46:48 +00:00
|
|
|
/*! \defgroup socket Socket convenience functions
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2011-08-16 21:26:52 +00:00
|
|
|
/*! \file socket.h
|
|
|
|
* \brief Osmocom socket convenience functions
|
|
|
|
*/
|
|
|
|
|
2011-05-21 16:54:32 +00:00
|
|
|
#include <stdint.h>
|
2011-05-22 10:25:57 +00:00
|
|
|
|
|
|
|
struct sockaddr;
|
2012-03-16 08:18:12 +00:00
|
|
|
struct osmo_fd;
|
2011-05-21 16:54:32 +00:00
|
|
|
|
2011-06-09 13:04:30 +00:00
|
|
|
/* flags for osmo_sock_init. */
|
2016-04-25 10:11:20 +00:00
|
|
|
/*! connect the socket to a remote peer */
|
2011-06-09 13:04:30 +00:00
|
|
|
#define OSMO_SOCK_F_CONNECT (1 << 0)
|
2016-04-25 10:11:20 +00:00
|
|
|
/*! bind the socket to a local address/port */
|
2011-06-09 13:04:30 +00:00
|
|
|
#define OSMO_SOCK_F_BIND (1 << 1)
|
2016-04-25 10:11:20 +00:00
|
|
|
/*! switch socket to non-blocking mode */
|
2011-06-09 13:04:30 +00:00
|
|
|
#define OSMO_SOCK_F_NONBLOCK (1 << 2)
|
|
|
|
|
2011-05-21 16:54:32 +00:00
|
|
|
int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto,
|
2011-06-09 13:04:30 +00:00
|
|
|
const char *host, uint16_t port, unsigned int flags);
|
2011-05-21 16:54:32 +00:00
|
|
|
|
2011-05-22 19:47:29 +00:00
|
|
|
int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto,
|
2011-06-09 13:04:30 +00:00
|
|
|
const char *host, uint16_t port, unsigned int flags);
|
2011-05-22 19:47:29 +00:00
|
|
|
|
2011-05-21 16:54:32 +00:00
|
|
|
int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type,
|
2011-06-09 13:04:30 +00:00
|
|
|
uint8_t proto, unsigned int flags);
|
2011-05-21 16:54:32 +00:00
|
|
|
|
2011-05-22 10:25:57 +00:00
|
|
|
int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen);
|
2011-05-21 16:54:32 +00:00
|
|
|
|
2014-03-24 12:02:00 +00:00
|
|
|
int osmo_sock_unix_init(uint16_t type, uint8_t proto,
|
|
|
|
const char *socket_path, unsigned int flags);
|
|
|
|
|
|
|
|
int osmo_sock_unix_init_ofd(struct osmo_fd *ofd, uint16_t type, uint8_t proto,
|
|
|
|
const char *socket_path, unsigned int flags);
|
|
|
|
|
2012-04-18 19:53:23 +00:00
|
|
|
/*! @} */
|