jabberd14 1.6.2
dialback.h
Go to the documentation of this file.
00001 /*
00002  * Copyrights
00003  * 
00004  * Portions created by or assigned to Jabber.com, Inc. are 
00005  * Copyright (c) 1999-2002 Jabber.com, Inc.  All Rights Reserved.  Contact
00006  * information for Jabber.com, Inc. is available at http://www.jabber.com/.
00007  *
00008  * Portions Copyright (c) 1998-1999 Jeremie Miller.
00009  *
00010  * Portions Copyright (c) 2006-2007 Matthias Wimmer
00011  *
00012  * This file is part of jabberd14.
00013  *
00014  * This software is free software; you can redistribute it and/or
00015  * modify it under the terms of the GNU General Public License as
00016  * published by the Free Software Foundation; either version 2 of the
00017  * License, or (at your option) any later version.
00018  *
00019  * This software is distributed in the hope that it will be useful, but
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022  * General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License
00025  * along with this software; if not, write to the Free Software
00026  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00027  * 02110-1301, USA.
00028  *
00029  */
00030 
00044 #include <jabberd.h>
00045 
00047 typedef struct db_struct {
00048     instance i;         
00049     xht nscache;        
00050     xht out_connecting; 
00051     xht out_ok_db;      
00052     xht in_id;          
00053     xht in_ok_db;       
00054     xht hosts_xmpp;     
00055     xht hosts_tls;      
00056     xht hosts_auth;     
00057     char *secret;       
00058     int timeout_packets;
00059     int timeout_idle;   
00060     int timeout_auth;   
00061     xht std_ns_prefixes;
00062     xdbcache xc;        
00063 } *db, _db;
00064 
00066 typedef struct miod_struct
00067 {
00068     mio m;              
00069     int last;           
00070     int count;          
00071     db d;               
00072 } *miod, _miod;
00073 
00074 void dialback_out_packet(db d, xmlnode x, char *ip);
00075 result dialback_out_beat_packets(void *arg);
00076 
00077 void dialback_in_read(mio s, int flags, void *arg, xmlnode x, char* unused1, int unused2);
00078 void dialback_in_verify(db d, xmlnode x);
00079 
00080 int dialback_check_settings(db d, mio m, const char *server, int is_outgoing, int auth_type, int version);
00081 char *dialback_randstr(void);
00082 char *dialback_merlin(pool p, char const* secret, char const* to, char const* from, char const* challenge);
00083 void dialback_miod_hash(miod md, xht ht, jid key);
00084 miod dialback_miod_new(db d, mio m);
00085 void dialback_miod_write(miod md, xmlnode x);
00086 void dialback_miod_read(miod md, xmlnode x);
00087 char *dialback_ip_get(db d, jid host, char *ip);
00088 void dialback_ip_set(db d, jid host, char *ip);
00089 
00090 const char* dialback_get_loopcheck_token(db d);
00091 
00093 typedef struct dboq_struct
00094 {
00095     int stamp;
00096     xmlnode x;
00097     struct dboq_struct *next;
00098 } *dboq, _dboq;
00099 
00103 typedef enum {
00104     not_requested,      
00105     could_request,      
00106     want_request,       
00107     sent_request        
00108 } db_request;
00109 
00115 typedef enum {
00116     created,            
00117     connecting,         
00118     connected,          
00119     got_streamroot,     
00120     waiting_features,   
00121     got_features,       
00122     sent_db_request,    
00123     db_succeeded,       
00124     db_failed,          
00125     sasl_started,       
00126     sasl_fail,          
00127     sasl_success        
00128 } db_connection_state;
00129 
00130 /* for connecting db sockets */
00134 typedef struct {
00135     char *ip;   
00136     int stamp;  
00137     db d;       
00138     jid key;    
00139     xmlnode verifies; 
00140     pool p;     
00141     dboq q;     
00142     mio m;      
00143                 /* original comment: for that short time when we're connected and open, but haven't auth'd ourselves yet */
00144     int xmpp_version; 
00145     int settings_failed; 
00146     char *stream_id; 
00147     db_request db_state; 
00148     db_connection_state connection_state; 
00149     std::ostringstream* connect_results; 
00150     struct {
00151         int db:1;       
00152     } flags;
00153 } *dboc, _dboc;
00154 
00158 typedef struct dbic_struct {
00159     mio m;              
00160     char *id;           
00161     xmlnode results;    
00166     db d;               
00167     char *we_domain;    
00170     char *other_domain; 
00171     int xmpp_version;   
00172     time_t stamp;       
00173 } *dbic, _dbic;