Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 1 | #ifndef _OSMOCORE_SOCKET_H |
| 2 | #define _OSMOCORE_SOCKET_H |
| 3 | |
Harald Welte | ba6988b | 2011-08-17 12:46:48 +0200 | [diff] [blame] | 4 | /*! \defgroup socket Socket convenience functions |
| 5 | * @{ |
| 6 | */ |
| 7 | |
Harald Welte | bd598e3 | 2011-08-16 23:26:52 +0200 | [diff] [blame] | 8 | /*! \file socket.h |
| 9 | * \brief Osmocom socket convenience functions |
| 10 | */ |
| 11 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 12 | #include <stdint.h> |
Harald Welte | e476442 | 2011-05-22 12:25:57 +0200 | [diff] [blame] | 13 | |
| 14 | struct sockaddr; |
Holger Hans Peter Freyther | 58d3153 | 2012-03-16 09:18:12 +0100 | [diff] [blame] | 15 | struct osmo_fd; |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 16 | |
Pablo Neira Ayuso | 0849c9a | 2011-06-09 15:04:30 +0200 | [diff] [blame] | 17 | /* 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 Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 22 | int osmo_sock_init(uint16_t family, uint16_t type, uint8_t proto, |
Pablo Neira Ayuso | 0849c9a | 2011-06-09 15:04:30 +0200 | [diff] [blame] | 23 | const char *host, uint16_t port, unsigned int flags); |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 24 | |
Harald Welte | 68b1574 | 2011-05-22 21:47:29 +0200 | [diff] [blame] | 25 | int osmo_sock_init_ofd(struct osmo_fd *ofd, int family, int type, int proto, |
Pablo Neira Ayuso | 0849c9a | 2011-06-09 15:04:30 +0200 | [diff] [blame] | 26 | const char *host, uint16_t port, unsigned int flags); |
Harald Welte | 68b1574 | 2011-05-22 21:47:29 +0200 | [diff] [blame] | 27 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 28 | int osmo_sock_init_sa(struct sockaddr *ss, uint16_t type, |
Pablo Neira Ayuso | 0849c9a | 2011-06-09 15:04:30 +0200 | [diff] [blame] | 29 | uint8_t proto, unsigned int flags); |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 30 | |
Harald Welte | e476442 | 2011-05-22 12:25:57 +0200 | [diff] [blame] | 31 | int osmo_sockaddr_is_local(struct sockaddr *addr, unsigned int addrlen); |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 32 | |
Sylvain Munaut | dca7d2c | 2012-04-18 21:53:23 +0200 | [diff] [blame] | 33 | /*! @} */ |
Harald Welte | ba6988b | 2011-08-17 12:46:48 +0200 | [diff] [blame] | 34 | |
Harald Welte | 33cb71a | 2011-05-21 18:54:32 +0200 | [diff] [blame] | 35 | #endif /* _OSMOCORE_SOCKET_H */ |