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

mctxhandler.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 #ifndef __AWHANDLER_MCTX__
00022 #define __AWHANDLER_MCTX__
00023 
00024 #include "monitor.h"
00025 
00026 #include "wire.h"
00027 
00028 #include "mctxrx.h"
00029 
00093 /*
00094 
00095 Changes:
00096 
00097 
00098 */
00099 
00100 #include "monitor.h"
00101 #include "wire.h"
00102 
00106 typedef struct {
00107 
00108   aw_event_sig_t
00109    sent,                   /* could send file */
00110    error;                 /* error sending file */
00111 
00112 } aw_mctxhandler_events_t;
00113 
00117 typedef enum {
00118 
00119   AW_MCTXHANDLER_IDLE,               
00120   AW_MCTXHANDLER_WRITING,            
00121   AW_MCTXHANDLER_WAIT_RETX,          
00123 } aw_mctxhandler_state_cd_t;
00124 
00128 typedef struct {
00129 
00130   aw_mctxhandler_state_cd_t
00131    state_cd;
00132 
00133   aw_event_t
00134    *current_event;
00135 
00136   u_int32_t
00137    xtnid;
00138 
00139   aw_address_t
00140    retx_event_id,
00141    timeout_event_id;
00142 
00143   aw_timestamp_t
00144    sendfile_tstamp,   /* start of sending file */
00145    start_retx_timeout;  /* last time we sent a packet in re-transmit phase */
00146 
00147   int32_t
00148    file_fd,
00149    mc_fd,
00150    retx_fd;
00151 
00152   /* space to write packets, max size of a UDP packet */
00153   byte_t
00154    message[0xffff]; 
00155   int32_t
00156    message_size; /* how much is actually used */
00157 
00158   /* count of block writes that failed */
00159   u_int32_t
00160    nblocks_error;
00161 
00162   /* count of block writes re-sent */
00163   u_int32_t
00164   nblocks_retx;
00165 
00166   u_int32_t
00167    nblocks_written;
00168 
00169   /* current file info */
00170   aw_mctxrx_info_t
00171    info;
00172 
00173   /* bitvector indicating which blocks have not been read by clients (1), if read then 0 */
00174   aw_bitvector_t
00175    *unread_blocks;
00176 
00177 } aw_mctxhandler_state_t;
00178 
00179 
00183 typedef struct {
00184 
00185   aw_handler_t 
00186     handler_header;
00187 
00188   aw_mctxhandler_state_t
00189    state;
00190 
00191   aw_mctxhandler_events_t
00192    events;
00193 
00194   /* address of interface to send multicast packets */
00195   struct in_addr
00196    mcast_if_addr;
00197 
00198   /* non-zero if enabling IP_MULTICAST_LOOP */
00199   u_int32_t
00200    mcast_loopback;
00201 
00202   /* multicast address to send packets */
00203   struct sockaddr_in
00204    mcast_grp_addr;
00205 
00206   /* constant desired write rate in bytes per second */
00207   u_int64_t
00208    write_rate;
00209 
00210   /* calibrated delay between writes based on write_rate */
00211   struct timespec
00212    write_delay;
00213 
00214   /* max time allowed to succeed per try */
00215   aw_timestamp_t
00216    timeout;
00217 
00218   /* message size, must fit in datagram! */
00219   u_int32_t
00220    messagesize;
00221 
00222 } aw_mctxhandler_t ;
00223 
00224 
00243 aw_mctxhandler_t *aw_create_mctxhandler(const byte_t *filename,
00244                                         u_int32_t rate,
00245                                         u_int32_t messagesize,
00246                                         const byte_t *mcaddress,
00247                                         u_int32_t mcport,
00248                                         const byte_t *mcinterface,
00249                                         u_int32_t mcloopback,
00250                                         u_int32_t retxport,
00251                                         aw_timestamp_t timeout,
00252                                         const aw_mctxhandler_events_t *events,
00253                                         int32_t (*regevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00254                                         int32_t (*regmaskevent)(aw_handler_t *h, aw_address_t *eventid, u_int32_t index),
00255                                         const aw_alarm_sched_t *sched,
00256                                         aw_logger_t *logger
00257                                         );
00258 
00259 #endif
Aware 0.11.1 Copyright (C) 1998-2005 Russell Leighton (russ@elegant-software.com)