2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2005, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
7 * Kevin P. Fleming <kpfleming@digium.com>
9 * See http://www.asterisk.org for more information about
10 * the Asterisk project. Please do not directly contact
11 * any of the maintainers of this project for assistance;
12 * the project provides a web site, mailing lists and IRC
13 * channels for your use.
15 * This program is free software, distributed under the terms of
16 * the GNU General Public License Version 2. See the LICENSE file
17 * at the top of the source tree.
21 * \brief Network socket handling
24 #ifndef _ASTERISK_NETSOCK_H
25 #define _ASTERISK_NETSOCK_H
27 #if defined(__cplusplus) || defined(c_plusplus)
31 #include <netinet/in.h>
32 #include "asterisk/io.h"
33 #include "asterisk/astobj.h"
37 struct ast_netsock_list
;
39 struct ast_netsock_list
*ast_netsock_list_alloc(void);
41 int ast_netsock_init(struct ast_netsock_list
*list
);
43 struct ast_netsock
*ast_netsock_bind(struct ast_netsock_list
*list
, struct io_context
*ioc
,
44 const char *bindinfo
, int defaultport
, int tos
, ast_io_cb callback
, void *data
);
46 struct ast_netsock
*ast_netsock_bindaddr(struct ast_netsock_list
*list
, struct io_context
*ioc
,
47 struct sockaddr_in
*bindaddr
, int tos
, ast_io_cb callback
, void *data
);
49 int ast_netsock_free(struct ast_netsock_list
*list
, struct ast_netsock
*netsock
);
51 int ast_netsock_release(struct ast_netsock_list
*list
);
53 struct ast_netsock
*ast_netsock_find(struct ast_netsock_list
*list
,
54 struct sockaddr_in
*sa
);
56 int ast_netsock_sockfd(const struct ast_netsock
*ns
);
58 const struct sockaddr_in
*ast_netsock_boundaddr(const struct ast_netsock
*ns
);
60 void *ast_netsock_data(const struct ast_netsock
*ns
);
62 void ast_netsock_unref(struct ast_netsock
*ns
);
64 #if defined(__cplusplus) || defined(c_plusplus)
68 #endif /* _ASTERISK_NETSOCK_H */