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

eventtxhandler.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 #ifndef __AWHANDLER_EVENTTX__
00023 #define __AWHANDLER_EVENTTX__
00024 
00025 #include <stdio.h>
00026 
00027 #include "monitor.h"
00028 
00029 #include "wire.h"
00030 
00032 /*\@{*/
00033 
00066 /* 
00067 Changes:
00068     4/26/03 Russell Leighton
00069     Added TCP support
00070 
00071 */
00072 
00076 typedef enum {
00077 
00078   AW_EVENTTXHANDLER_PROTOCOL_UDP,  /* udp */
00079 
00080   AW_EVENTTXHANDLER_PROTOCOL_TCP,  /* tcp */
00081 
00082   AW_EVENTTXHANDLER_PROTOCOL_MC,   /* multicast */
00083 
00084 } aw_eventtxhandler_protocol_t;
00085 
00089 typedef enum {
00090 
00091   AW_EVENTTXHANDLER_IDLE,               /* not doing anything */
00092   AW_EVENTTXHANDLER_WAIT_CONNECT,       /* waiting on a connect() */
00093   AW_EVENTTXHANDLER_WAIT_WRITE          /* waiting on a write() */
00094 
00095 } aw_eventtxhandler_state_cd_t;
00096 
00097 
00101 typedef struct {
00102 
00103   int32_t
00104    sfd;
00105 
00106   /* space to write packets, max size of a UDP packet */
00107   byte_t
00108    tx_message[0xffff]; 
00109 
00110   /* state, used in tcp handler */
00111   aw_eventtxhandler_state_cd_t
00112    state_cd;
00113 
00114   /* marks start of connection , used in tcp handler */
00115   aw_timestamp_t
00116    starttime;
00117 
00118   /* bytes read or written (depending on state_cd) , used in tcp handler */
00119   u_int32_t
00120    nbytes;
00121 
00122   /* -1 on start , used in tcp handler */
00123   int32_t
00124    data_left;
00125 
00126 } aw_eventtxhandler_state_t;
00127 
00128 
00132 typedef struct {
00133 
00134   aw_handler_t
00135    handler_header;
00136 
00137   /* ip or multicast_group */
00138   struct sockaddr_in
00139    service_addr;
00140 
00141   aw_eventtxhandler_protocol_t
00142    protocol;
00143   
00144   aw_eventtxhandler_state_t
00145    state;
00146 
00147 } aw_eventtxhandler_t;
00148 
00152 typedef struct {
00153 
00154   /* multicast inteface, defaults to NULL -> INADDR_ANY */
00155   const byte_t *mcinterface;
00156 
00157   /* non-zero if allow local multicast traffic, defaults to 0 */
00158   u_int32_t mcloopback;
00159 
00160 } aw_eventtxhandler_options_t;
00161 
00174 aw_eventtxhandler_t *aw_create_eventtxhandler(const byte_t *hostname,
00175                                               u_int32_t port,
00176                                               aw_eventtxhandler_protocol_t protocol,
00177                                               const aw_eventtxhandler_options_t *options,
00178                                               int32_t (*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00179                                               int32_t (*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00180                                               const aw_alarm_sched_t *sched,
00181                                               aw_logger_t *aware_logger);
00182 
00183 
00188 void aw_free_eventtxhandler(aw_eventtxhandler_t *h);
00189 
00190 
00194 aw_handler_t *aw_wire_eventtxhandler(aw_wire_mkhandler_args_t *args);
00195 
00196 /*\@}*/
00197 
00198 #endif
00199 
Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)