]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/router/osrf_router.h
New function: client_sock_fd(). It returns the socket fd used
[OpenSRF.git] / src / router / osrf_router.h
1 #ifndef OSRF_ROUTER_H
2 #define OSRF_ROUTER_H
3
4 #include <sys/select.h>
5 #include <signal.h>
6 #include <stdio.h>
7
8 #include "opensrf/utils.h"
9 #include "opensrf/log.h"
10 #include "opensrf/osrf_list.h"
11 #include "opensrf/osrf_hash.h"
12
13 #include "opensrf/string_array.h"
14 #include "opensrf/transport_client.h"
15 #include "opensrf/transport_message.h"
16
17 #include "opensrf/osrf_message.h"
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /* a router maintains a list of server classes */
24 struct _osrfRouterStruct {
25
26         osrfHash* classes;    /**< our list of server classes */
27         char* domain;         /**< Domain name of Jabber server. */
28         char* name;           /**< Router's username for the Jabber logon. */
29         char* resource;       /**< Router's resource name for the Jabber logon. */
30         char* password;       /**< Router's password for the Jabber logon. */
31         int port;             /**< Jabber's port number. */
32         sig_atomic_t stop;    /**< To be set by signal handler to interrupt main loop */
33
34         osrfStringArray* trustedClients;
35         osrfStringArray* trustedServers;
36
37         transport_client* connection;
38 };
39
40 typedef struct _osrfRouterStruct osrfRouter;
41
42 /**
43   Allocates a new router.  
44   @param domain The jabber domain to connect to
45   @param name The login name for the router
46   @param resource The login resource for the router
47   @param password The login password for the new router
48   @param port The port to connect to the jabber server on
49   @param trustedClients The array of client domains that we allow to send requests through us
50   @param trustedServers The array of server domains that we allow to register, etc. with ust.
51   @return The allocated router or NULL on memory error
52   */
53 osrfRouter* osrfNewRouter( const char* domain, const char* name, const char* resource, 
54         const char* password, int port, osrfStringArray* trustedClients,
55         osrfStringArray* trustedServers );
56
57 /**
58   Connects the given router to the network
59   */
60 int osrfRouterConnect( osrfRouter* router );
61
62 /**
63   Waits for incoming data to route
64   If this function returns, then the router's connection to the jabber server
65   has failed.
66   */
67 void osrfRouterRun( osrfRouter* router );
68
69 void router_stop( osrfRouter* router );
70
71 /**
72   Frees a router
73   */
74 void osrfRouterFree( osrfRouter* router );
75
76 /**
77   Handles connects, disconnects, etc.
78   */
79 //int osrfRouterHandeStatusMessage( osrfRouter* router, transport_message* msg );
80
81 /**
82   Handles REQUEST messages 
83   */
84 //int osrfRouterHandleRequestMessage( osrfRouter* router, transport_message* msg );
85
86 #ifdef __cplusplus
87 }
88 #endif
89
90 #endif
91