Skip to content
Snippets Groups Projects
Commit 4fabc806 authored by Mark Spencer's avatar Mark Spencer
Browse files

Make ACL be what SIP is going to need (bug #2358, just first part)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5155 65c4cc65-6c06-0410-ace0-fbb531ad65f3
parent 98a3c16b
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,7 @@ struct ast_netsock {
int sockfd;
int *ioref;
struct io_context *ioc;
void *data;
};
......@@ -317,25 +318,25 @@ struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, struct i
if (setsockopt(netsocket, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))
ast_log(LOG_WARNING, "Unable to set TOS to %d\n", tos);
/* Establish I/O callback for socket read */
ioref = ast_io_add(ioc, netsocket, callback, AST_IO_IN, data);
if (!ioref) {
ast_log(LOG_WARNING, "Out of memory!\n");
close(netsocket);
return NULL;
}
ns = malloc(sizeof(struct ast_netsock));
if (ns) {
/* Establish I/O callback for socket read */
ioref = ast_io_add(ioc, netsocket, callback, AST_IO_IN, ns);
if (!ioref) {
ast_log(LOG_WARNING, "Out of memory!\n");
close(netsocket);
free(ns);
return NULL;
}
ASTOBJ_INIT(ns);
ns->ioref = ioref;
ns->ioc = ioc;
ns->sockfd = netsocket;
ns->data = data;
memcpy(&ns->bindaddr, bindaddr, sizeof(ns->bindaddr));
ASTOBJ_CONTAINER_LINK(list, ns);
} else {
ast_log(LOG_WARNING, "Out of memory!\n");
ast_io_remove(ioc, ioref);
close(netsocket);
}
return ns;
......@@ -362,6 +363,16 @@ int ast_netsock_release(struct ast_netsock_list *list)
return 0;
}
const struct sockaddr_in *ast_netsock_boundaddr(struct ast_netsock *ns)
{
return &(ns->bindaddr);
}
void *ast_netsock_data(struct ast_netsock *ns)
{
return ns->data;
}
struct ast_netsock *ast_netsock_bind(struct ast_netsock_list *list, struct io_context *ioc, const char *bindinfo, int defaultport, int tos, ast_io_cb callback, void *data)
{
struct sockaddr_in sin;
......
......@@ -50,6 +50,8 @@ extern struct ast_netsock *ast_netsock_bindaddr(struct ast_netsock_list *list, s
extern int ast_netsock_free(struct ast_netsock_list *list, struct ast_netsock *netsock);
extern int ast_netsock_release(struct ast_netsock_list *list);
extern int ast_netsock_sockfd(struct ast_netsock *ns);
extern const struct sockaddr_in *ast_netsock_boundaddr(struct ast_netsock *ns);
extern void *ast_netsock_data(struct ast_netsock *ns);
extern int ast_find_ourip(struct in_addr *ourip, struct sockaddr_in bindaddr);
/*! Compares the source address and port of two sockaddr_in */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment