34#if !defined (__linux__) && !defined (__GNU__)
35#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__Darwin__) || defined(__GLIBC__)
41#include <sys/sockio.h>
42#elif defined(HAVE_GETIFADDRS)
79 memset(list, 0,
sizeof(*list));
115 const int reuseFlag = 1;
124 if (setsockopt(
netsocket, SOL_SOCKET, SO_REUSEADDR, (
char *)&reuseFlag,
sizeof reuseFlag) < 0) {
129 "Unable to bind to %s: %s\n",
185 return ns ? ns-> sockfd : -1;
Asterisk main include file. File version handling, generic pbx functions.
#define ast_calloc(num, len)
A wrapper for calloc()
Object Model for Asterisk.
#define ASTOBJ_COMPONENTS(type)
Add ASTOBJ components to a struct (with locking support).
#define ASTOBJ_CONTAINER_DESTROY(container)
Destroy a container.
#define ASTOBJ_CONTAINER_DESTROYALL(container, destructor)
Empty a container.
#define ASTOBJ_CONTAINER_LINK(container, newobj)
Add an object to a container.
#define ASTOBJ_CONTAINER_TRAVERSE(container, continue, eval)
Iterate through the objects in a container.
#define ASTOBJ_CONTAINER_INIT(container)
Initialize a container.
#define ASTOBJ_RDLOCK(object)
Lock an ASTOBJ for reading.
#define ASTOBJ_INIT(object)
Initialize an object.
#define ASTOBJ_UNLOCK(object)
Unlock a locked object.
#define ASTOBJ_UNREF(object, destructor)
Decrement the reference count on an object.
static struct ast_netsock_list * netsock
struct ast_sockaddr bindaddr
int * ast_io_add(struct io_context *ioc, int fd, ast_io_cb callback, short events, void *data)
Adds an IO context.
int(* ast_io_cb)(int *id, int fd, short events, void *cbdata)
int ast_io_remove(struct io_context *ioc, int *id)
Removes an IO context.
static char * ast_sockaddr_stringify(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() with default format.
#define ast_sockaddr_port(addr)
Get the port number of a socket address.
static void ast_sockaddr_copy(struct ast_sockaddr *dst, const struct ast_sockaddr *src)
Copies the data from one ast_sockaddr to another.
int ast_sockaddr_is_ipv6(const struct ast_sockaddr *addr)
Determine if this is an IPv6 address.
int ast_bind(int sockfd, const struct ast_sockaddr *addr)
Wrapper around bind(2) that uses struct ast_sockaddr.
int ast_set_qos(int sockfd, int tos, int cos, const char *desc)
Set type of service.
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
static void ast_netsock_destroy(struct ast_netsock *netsock)
int ast_netsock_release(struct ast_netsock_list *list)
struct ast_netsock_list * ast_netsock_list_alloc(void)
int ast_netsock_set_qos(int sockfd, int tos, int cos, const char *desc)
struct ast_netsock * ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc, const char *bindinfo, int defaultport, int tos, int cos, ast_io_cb callback, void *data)
void ast_netsock_unref(struct ast_netsock *ns)
int ast_netsock_sockfd(const struct ast_netsock *ns)
void * ast_netsock_data(const struct ast_netsock *ns)
struct ast_netsock * ast_netsock_find(struct ast_netsock_list *list, struct ast_sockaddr *addr)
const struct ast_sockaddr * ast_netsock_boundaddr(const struct ast_netsock *ns)
int ast_netsock_init(struct ast_netsock_list *list)
struct ast_netsock * ast_netsock_bindaddr(struct ast_netsock_list *list, struct io_context *ioc, struct ast_sockaddr *bindaddr, int tos, int cos, ast_io_cb callback, void *data)
ASTOBJ_CONTAINER_COMPONENTS(struct ast_netsock)
struct ast_sockaddr bindaddr
Socket address structure.
Global IO variables are now in a struct in order to be made threadsafe.
void ast_enable_packet_fragmentation(int sock)
Disable PMTU discovery on a socket.