2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-25 19:47:42 +00:00
bind/lib/omapi/listener.c

308 lines
8.5 KiB
C
Raw Normal View History

checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
* Copyright (C) 1996, 1997, 1998, 1999 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
1999-10-27 22:24:32 +00:00
/*
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
* Subroutines that support the generic listener object.
1999-10-27 22:24:32 +00:00
*/
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
#include <stddef.h> /* NULL */
#include <string.h> /* memset */
#include <unistd.h> /* close */
1999-10-27 22:24:32 +00:00
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
#include <isc/assertions.h>
2000-01-04 20:04:42 +00:00
#include <isc/bufferlist.h>
#include <isc/mem.h>
1999-10-27 22:24:32 +00:00
2000-01-04 20:04:42 +00:00
#include <omapi/private.h>
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
typedef struct omapi_listener_object {
OMAPI_OBJECT_PREAMBLE;
2000-01-04 20:04:42 +00:00
isc_task_t *task;
isc_socket_t *socket; /* Connection socket. */
isc_sockaddr_t address;
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
} omapi_listener_object_t;
2000-01-04 20:04:42 +00:00
/*
* Reader callback for a listener object. Accept an incoming connection.
*/
static void
omapi_listener_accept(isc_task_t *task, isc_event_t *event) {
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
isc_result_t result;
2000-01-04 20:04:42 +00:00
isc_buffer_t *ibuffer, *obuffer;
2000-01-06 03:36:32 +00:00
isc_task_t *connection_task = NULL;
2000-01-04 20:04:42 +00:00
isc_socket_newconnev_t *incoming;
2000-01-06 03:36:32 +00:00
omapi_connection_object_t *connection = NULL;
2000-01-04 20:04:42 +00:00
omapi_object_t *listener;
1999-10-27 22:24:32 +00:00
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
2000-01-04 20:04:42 +00:00
* XXXDCL What are the meaningful things the listen/accept function
* can do if it fails to process an incoming connection because one
* of the functions it calls fails?
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
*/
1999-10-27 22:24:32 +00:00
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
2000-01-04 20:04:42 +00:00
* Set up another listen task for the socket.
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
*/
2000-01-04 20:04:42 +00:00
isc_socket_accept(event->sender, task, omapi_listener_accept,
event->arg);
1999-10-27 22:24:32 +00:00
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
2000-01-04 20:04:42 +00:00
* Check for the validity of new connection event.
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
*/
2000-01-04 20:04:42 +00:00
incoming = (isc_socket_newconnev_t *)event;
if (incoming->result != ISC_R_SUCCESS)
/*
* The result is probably ISC_R_UNEXPECTED; what can really be
* done about this other than just flunking out of here?
*/
return;
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
2000-01-04 20:04:42 +00:00
* The new connection is good to go. Allocate the buffers for it and
2000-01-06 03:36:32 +00:00
* prepare its own task.
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
*/
2000-01-06 03:36:32 +00:00
if (isc_task_create(omapi_taskmgr, NULL, 0, &connection_task) !=
2000-01-04 20:04:42 +00:00
ISC_R_SUCCESS)
return;
ibuffer = NULL;
result = isc_buffer_allocate(omapi_mctx, &ibuffer, OMAPI_BUFFER_SIZE,
ISC_BUFFERTYPE_BINARY);
if (result != ISC_R_SUCCESS)
return;
obuffer = NULL;
result = isc_buffer_allocate(omapi_mctx, &obuffer, OMAPI_BUFFER_SIZE,
ISC_BUFFERTYPE_BINARY);
if (result != ISC_R_SUCCESS)
return;
1999-10-27 22:24:32 +00:00
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
2000-01-04 20:04:42 +00:00
* Create a new connection object.
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
*/
2000-01-06 03:36:32 +00:00
result = omapi_object_new((omapi_object_t **)&connection,
omapi_type_connection, sizeof(*connection));
if (result != ISC_R_SUCCESS) {
/* XXXDCL cleanup */
2000-01-04 20:04:42 +00:00
isc_buffer_free(&obuffer);
2000-01-06 03:36:32 +00:00
isc_buffer_free(&ibuffer);
2000-01-04 20:04:42 +00:00
return;
1999-10-27 22:24:32 +00:00
}
2000-01-06 03:36:32 +00:00
connection->task = connection_task;
2000-01-04 20:04:42 +00:00
connection->state = omapi_connection_connected;
connection->socket = incoming->newsocket;
1999-10-27 22:24:32 +00:00
2000-01-04 20:04:42 +00:00
ISC_LIST_INIT(connection->input_buffers);
ISC_LIST_APPEND(connection->input_buffers, ibuffer, link);
ISC_LIST_INIT(connection->output_buffers);
ISC_LIST_APPEND(connection->output_buffers, obuffer, link);
1999-10-27 22:24:32 +00:00
2000-01-04 20:04:42 +00:00
/*
* Point the connection's listener member at the listener object.
* XXXDCL but why is this needed?
*/
listener = event->arg;
OBJECT_REF(&connection->listener, listener, "omapi_listener_accept");
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
2000-01-04 20:04:42 +00:00
/*
* Notify the listener object that a connection was made.
*/
result = omapi_signal(listener, "connect", connection);
if (result != ISC_R_SUCCESS)
/*XXXDCL then what?!*/
;
/*
* Lose our reference to the connection, so it'll be gc'd when it's
* reaped.
* XXXDCL ... um, hmm? this object only has one reference, so it
* is going to be reaped right here! unless omapi_signal added
* a reference ...
*/
OBJECT_DEREF(&connection, "omapi_listener_accept");
return;
1999-10-27 22:24:32 +00:00
}
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
isc_result_t
2000-01-04 20:04:42 +00:00
omapi_listener_listen(omapi_object_t *caller, int port, int max) {
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
isc_result_t result;
2000-01-04 20:04:42 +00:00
isc_task_t *task;
1999-10-27 22:24:32 +00:00
omapi_listener_object_t *listener;
2000-01-04 20:04:42 +00:00
struct in_addr inaddr;
1999-10-27 22:24:32 +00:00
2000-01-04 20:04:42 +00:00
task = NULL;
result = isc_task_create(omapi_taskmgr, NULL, 0, &task);
if (result != ISC_R_SUCCESS)
return (result);
#if 0 /*XXXDCL*/
result = isc_task_onshutdown(task, omapi_listener_shutdown, NULL);
if (result != ISC_R_SUCCESS)
return (result);
#endif
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
* Get the handle.
*/
2000-01-04 20:04:42 +00:00
listener = isc_mem_get(omapi_mctx, sizeof(*listener));
if (listener == NULL)
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
return (ISC_R_NOMEMORY);
2000-01-04 20:04:42 +00:00
memset(listener, 0, sizeof(*listener));
listener->object_size = sizeof(*listener);
listener->refcnt = 1;
listener->task = task;
listener->type = omapi_type_listener;
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
2000-01-04 20:04:42 +00:00
* Tie the listener object to the calling object.
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
*/
2000-01-04 20:04:42 +00:00
OBJECT_REF(&caller->outer, listener, "omapi_protocol_listen");
OBJECT_REF(&listener->inner, caller, "omapi_protocol_listen");
/*
* Create a socket on which to listen.
*/
listener->socket = NULL;
result = isc_socket_create(omapi_socketmgr, PF_INET,
isc_sockettype_tcp, &listener->socket);
if (result != ISC_R_SUCCESS) {
/* XXXDCL this call and later will not free the listener
* because it has two refcnts, one for existing plus one
* for the tie to h->outer. This does not seem right to me.
*/
OBJECT_DEREF(&listener, "omapi_listen");
return (result);
1999-10-27 22:24:32 +00:00
}
2000-01-04 20:04:42 +00:00
/*
* Set up the address on which we will listen.
*/
inaddr.s_addr = INADDR_ANY;
isc_sockaddr_fromin(&listener->address, &inaddr, port);
/*
* Try to bind to the wildcard address using the port number
* we were given.
*/
result = isc_socket_bind(listener->socket, &listener->address);
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
if (result != ISC_R_SUCCESS) {
2000-01-04 20:04:42 +00:00
OBJECT_DEREF(&listener, "omapi_listen");
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
return (result);
1999-10-27 22:24:32 +00:00
}
2000-01-04 20:04:42 +00:00
/*
* Now tell the kernel to listen for connections.
*/
result = isc_socket_listen(listener->socket, max);
if (result != ISC_R_SUCCESS) {
OBJECT_DEREF(&listener, "omapi_listen");
return (result);
}
1999-10-27 22:24:32 +00:00
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
2000-01-04 20:04:42 +00:00
* Queue up the first accept event. The listener object
* will be passed to omapi_listener_accept() when it is called.
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
*/
2000-01-04 20:04:42 +00:00
result = isc_socket_accept(listener->socket, task,
omapi_listener_accept, listener);
if (result != ISC_R_SUCCESS)
OBJECT_DEREF(&listener, "omapi_listen");
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
return (result);
1999-10-27 22:24:32 +00:00
}
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
isc_result_t
2000-01-04 20:04:42 +00:00
omapi_listener_setvalue(omapi_object_t *listener, omapi_object_t *id,
omapi_data_string_t *name, omapi_typed_data_t *value)
1999-10-27 22:24:32 +00:00
{
2000-01-04 20:04:42 +00:00
/*
* Nothing meaningful can be set in a listener object; just
* continue the call through the object chain.
*/
REQUIRE(listener != NULL && listener->type == omapi_type_listener);
PASS_SETVALUE(listener);
1999-10-27 22:24:32 +00:00
}
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
isc_result_t
2000-01-04 20:04:42 +00:00
omapi_listener_getvalue(omapi_object_t *listener, omapi_object_t *id,
omapi_data_string_t *name, omapi_value_t **value)
1999-10-27 22:24:32 +00:00
{
2000-01-04 20:04:42 +00:00
/*
* Nothing meaningful can be fetched from a listener object; just
* continue the call through the object chain.
*/
REQUIRE(listener != NULL && listener->type == omapi_type_listener);
1999-10-27 22:24:32 +00:00
2000-01-04 20:04:42 +00:00
PASS_GETVALUE(listener);
1999-10-27 22:24:32 +00:00
}
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
void
2000-01-04 20:04:42 +00:00
omapi_listener_destroy(omapi_object_t *object, const char *name) {
omapi_listener_object_t *listener;
1999-10-27 22:24:32 +00:00
2000-01-04 20:04:42 +00:00
REQUIRE(object != NULL && object->type == omapi_type_listener);
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
(void)name; /* Unused. */
2000-01-04 20:04:42 +00:00
listener = (omapi_listener_object_t *)object;
if (listener->socket != NULL) {
#if 0 /*XXXDCL*/
isc_socket_cancel(listener->socket, NULL, ISC_SOCKCANCEL_ALL);
isc_socket_shutdown(listener->socket, ISC_SOCKSHUT_ALL);
#else
isc_task_shutdown(listener->task);
#endif
listener->socket = NULL;
1999-10-27 22:24:32 +00:00
}
}
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
isc_result_t
2000-01-04 20:04:42 +00:00
omapi_listener_signalhandler(omapi_object_t *listener, const char *name,
va_list ap)
1999-10-27 22:24:32 +00:00
{
2000-01-04 20:04:42 +00:00
REQUIRE(listener != NULL && listener->type == omapi_type_listener);
1999-10-27 22:24:32 +00:00
2000-01-04 20:04:42 +00:00
/*
* This function is reached when omapi_listener_accept does
* an omapi_signal of "connect" on the listener object. Nothing
* need be done here, but the object that originally requested
* the listen needs to signalled that a connection was made.
*
* In the normal instance, the pass-through is to an object of type
* omapi_type_protocol_listener, so the signal_handler that
* is getting called is omapi_protocol_listener_signal.
*/
PASS_SIGNAL(listener);
1999-10-27 22:24:32 +00:00
}
checkpoint conversion to ISC (doc/dev/coding.html) style. * no spaces around " -> " in indirect postfix expression. * no space between function name and open parenthesis. * no space between array name and open bracket. * use NULL not 0 for pointers. * explicitly compare pointers to NULL. * explicitly compare integers to 0. * Do not cast NULL. * return type of function declaration on line by itself. * open brace of function definition follows close parenthesis if parameters all fit on one line. * comment-only lines start with /* on line by itself, and end with */ on line by itself. * variable names in structures separated from their types in a column. * name the parameters in function prototypes. * ifndef multiple header file inclusion. and other BIND9 conventions not in coding.html: * private structures defined in relevant source module, not private header. * RCS /* $Id: $ */ comments. * Principal Author (Ted Lemon) comments. * Updated ISC copyrights. * Parenthesize value of return(). * Parenthesize argument of sizeof(). * "unsigned int foo" not "unsigned foo". * ISC_LANG_(BEGIN|END)DECLS in header files. * header files included directly by source/header file that needs them. * ... and others I am probably forgetting. and conversion to some libisc.a modules: * use isc/int.h for isc_uintXX_t types, not u_intXX_t. * use isc/assertions.h for REQUIRE() and INSIST(). * use isc/error.h for UNEXPECTED_ERROR. * use isc/boolean.h for isc_boolean_t flags instead of int flags. * use isc/net.h for networking types. * use isc/netdb.h for gethostby*. STILL TO COME ... * more isc_boolean_t. * isc/time.h to replace struct timeval. * isc/socket.h to replace socket/listen/select/etc. * isc/mem.h to replace malloc/free. * namespace overhaul & omapi/compatibility.h. Please collect all your belongings but stand clear of the doors until this train has come to a complete stop.
1999-11-02 04:01:34 +00:00
/*
* Write all the published values associated with the object through the
* specified connection.
*/
isc_result_t
2000-01-04 20:04:42 +00:00
omapi_listener_stuffvalues(omapi_object_t *connection, omapi_object_t *id,
omapi_object_t *listener)
1999-10-27 22:24:32 +00:00
{
2000-01-04 20:04:42 +00:00
REQUIRE(listener != NULL && listener->type == omapi_type_listener);
1999-10-27 22:24:32 +00:00
2000-01-04 20:04:42 +00:00
PASS_STUFFVALUES(listener);
1999-10-27 22:24:32 +00:00
}