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