00001
00057 #ifndef __PEER_H
00058 #define __PEER_H
00059
00060
00061 #include "utils.h"
00062 #include "config.h"
00063 #include <sys/types.h>
00064
00065
00067 typedef enum {
00068 Closed = 0,
00069 Wait_Conn_Ack = 1,
00070 Wait_I_CEA = 2,
00071 Wait_Conn_Ack_Elect = 3,
00072 Wait_Returns = 4,
00073 R_Open = 5,
00074 I_Open = 6,
00075 Closing = 7
00076 } peer_state_t;
00077
00078
00080 typedef enum {
00081 Start = 101,
00082 Stop = 102,
00083 Timeout = 103,
00084 Win_Election = 104,
00085 R_Conn_CER = 105,
00086 I_Rcv_Conn_Ack = 106,
00087 I_Rcv_Conn_NAck = 107,
00088 I_Rcv_CER = 108,
00089 I_Rcv_CEA = 109,
00090 R_Rcv_CER = 110,
00091 R_Rcv_CEA = 111,
00092 I_Rcv_Non_CEA = 112,
00093 I_Rcv_DPR = 113,
00094 I_Rcv_DPA = 114,
00095 R_Rcv_DPR = 115,
00096 R_Rcv_DPA = 116,
00097 I_Rcv_DWR = 117,
00098 I_Rcv_DWA = 118,
00099 R_Rcv_DWR = 119,
00100 R_Rcv_DWA = 120,
00101 Send_Message = 121,
00102 I_Rcv_Message = 122,
00103 R_Rcv_Message = 123,
00104 I_Peer_Disc = 124,
00105 R_Peer_Disc = 125
00106 } peer_event_t;
00107
00109 typedef struct _peer_t{
00110 str fqdn;
00111 str realm;
00112 int port;
00114 app_config *applications;
00115 int applications_cnt;
00117 gen_lock_t *lock;
00119 peer_state_t state;
00120 int I_sock;
00121 int R_sock;
00123 time_t activity;
00124 int is_dynamic;
00125 int waitingDWA;
00127 str send_pipe;
00128 struct _peer_t *next;
00129 struct _peer_t *prev;
00130 } peer;
00131
00132 peer* new_peer(str fqdn,str realm,int port);
00133 void free_peer(peer *x,int locked);
00134
00135 inline void touch_peer(peer *p);
00136
00137 #endif