Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

dnshandler.h

Go to the documentation of this file.
00001 
00002 /*
00003 ** Copyright (C) 2004 Russell Leighton
00004 **
00005 ** This program is free software; you can redistribute it and/or modify
00006 ** it under the terms of the GNU General Public License as published by
00007 ** the Free Software Foundation; either version 2 of the License, or
00008 ** (at your option) any later version.
00009 **
00010 ** This program is distributed in the hope that it will be useful,
00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 ** GNU General Public License for more details.
00014 **
00015 ** You should have received a copy of the GNU General Public License
00016 ** along with this program; if not, write to the Free Software
00017 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 */
00019 
00020 
00021 
00022 
00023 #ifndef __AWHANDLER_DNS__
00024 #define __AWHANDLER_DNS__
00025 
00026 #include "sysnet.h" 
00027 #include "monitor.h"
00028 #include "wire.h"
00029 
00031 /*\@{*/
00032 
00083 /*
00084 Changes:
00085 
00086 03/04/04  Russell Leighton
00087 Port to handler
00088 
00089 04/16/02  Russell Leighton
00090 Made stateful.
00091 
00092 03/08/02 Russell Leighton
00093 Added triptime: support
00094 
00095 */
00096 
00100 typedef struct {
00101 
00102   aw_event_sig_t
00103    service,
00104    noservice,
00105    triptime;
00106 
00107   u_int32_t
00108    statefull;            /* if non-zero then service/noservice events will be statefull,
00109                             meaning you only get events on transitions from service <-> noservice
00110                           */
00111 
00112 } aw_dnshandler_events_t;
00113 
00117 typedef enum {
00118 
00119   AW_DNSHANDLER_IDLE,               /* not doing anything */
00120   AW_DNSHANDLER_WAIT_READ,          /* waiting on a read() */
00121   AW_DNSHANDLER_DONE_READ           /* done read */
00122 
00123 } aw_dnshandler_state_cd_t;
00124 
00125 
00129 typedef struct {
00130 
00131   aw_dnshandler_state_cd_t
00132    state_cd;
00133 
00134   aw_event_t
00135    *current_event;
00136 
00137   int32_t
00138    sfd;
00139 
00140   /* marks start of connection */
00141   aw_timestamp_t
00142    starttime;
00143 
00144   /* how many times have I tried */
00145   u_int32_t
00146    tries;
00147 
00148   /* 1 if last handler could check service, -1 if noservice */
00149   int32_t
00150    service;
00151 
00152 } aw_dnshandler_state_t;
00153 
00157 typedef struct {
00158 
00159   aw_handler_t 
00160     handler_header;
00161 
00162   aw_dnshandler_state_t
00163    state;
00164 
00165   aw_dnshandler_events_t
00166    events;
00167 
00168   struct sockaddr_in
00169     whereto_addr;
00170 
00171   /* used for timeout callbacks */
00172   aw_address_t
00173    timeout_event_id;
00174 
00175   /* sched for timeout alarm */
00176   aw_alarm_sched_t
00177    timeout_sched;
00178 
00179 
00180   /* number of times to try before giving up , if 0 then try only 1 time */
00181   u_int32_t
00182    maxretries;
00183 
00184   byte_t
00185    *host;
00186 
00187 } aw_dnshandler_t ;
00188 
00201 aw_dnshandler_t *aw_create_dnshandler(const aw_dnshandler_events_t *events,
00202                                       const byte_t *hostname,
00203                                       aw_timestamp_t timeout,
00204                                       u_int32_t maxretries,
00205                                       int32_t (*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00206                                       int32_t (*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00207                                       const aw_alarm_sched_t *sched,
00208                                       aw_logger_t *logger
00209                                       );
00210 
00215 void aw_free_dnshandler(aw_dnshandler_t *p);
00216 
00220 aw_handler_t *aw_wire_dnshandler(aw_wire_mkhandler_args_t *args);
00221 
00222 /*\@}*/
00223 #endif
Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)