Connect to hard-coded peer and exchange route info. Buggy and incomplete.
[trust_router.git] / include / tr_trp.h
index f96f211..87f4ce0 100644 (file)
@@ -1,56 +1,27 @@
 #ifndef TR_TRP_H
 #define TR_TRP_H
 
+#include <event2/event.h>
 #include <talloc.h>
+#include <pthread.h>
 
+#include <trp_internal.h>
 #include <tr_config.h>
 #include <tr_event.h>
-#include <trust_router/tr_dh.h>
-
-#define TRP_PORT 12310
-
-typedef struct trp_req {
-  int msg;
-} TRP_REQ;
-
-typedef struct trp_resp {
-  int msg;
-} TRP_RESP;
-
-typedef struct trps_instance TRPS_INSTANCE;
-
-typedef int (TRPS_REQ_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
-typedef void (TRPS_RESP_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
-typedef int (trps_auth_func)(gss_name_t client_name, TR_NAME *display_name, void *cookie);
-
-
-/* TRP Client Instance Data */
-typedef struct trpc_instance {
-  DH *client_dh;                       /* Client's DH struct with priv and pub keys */
-} TRPC_INSTANCE;
-
-/* TRP Server Instance Data */
-struct trps_instance {
-  char *hostname;
-  unsigned int port;
-  TRPS_REQ_FUNC *req_handler;
-  trps_auth_func *auth_handler;
-  void *cookie;
-  struct tr_rp_client *rp_gss;         /* Client matching GSS name, TBD -- FIX ME (??) */
-};
 
+typedef struct tr_trps_events {
+  struct tr_socket_event *listen_ev;
+  struct event *mq_ev;
+  struct event *connect_ev;
+  struct event *update_ev;
+  struct event *sweep_ev;
+} TR_TRPS_EVENTS;
 
 /* prototypes */
-TRPC_INSTANCE *trpc_create (TALLOC_CTX *mem_ctx);
-void trpc_destroy (TRPC_INSTANCE *trpc);
-int trpc_open_connection (TRPC_INSTANCE *trpc, char *server, unsigned int port, gss_ctx_id_t *gssctx);
-int trpc_send_msg (TRPC_INSTANCE *trpc, int conn, gss_ctx_id_t gssctx, const char *msg_content,
-                   int *resp_handler(), void *cookie);
-
-TRPS_INSTANCE *trps_create (TALLOC_CTX *mem_ctx);
-void trps_destroy (TRPS_INSTANCE *trps);
-int tr_trps_event_init(struct event_base *base, TRPS_INSTANCE *trps, TR_CFG_MGR *cfg_mgr,
-                       struct tr_socket_event *trps_ev);
-int trps_accept(TRPS_INSTANCE *trps, int listen);
-
+TR_TRPS_EVENTS *tr_trps_events_new(TALLOC_CTX *mem_ctx);
+TRP_RC tr_trps_event_init(struct event_base *base, TRPS_INSTANCE *trps, TR_CFG_MGR *cfg_mgr,
+                       TR_TRPS_EVENTS *trps_ev);
+TRPC_INSTANCE *tr_trpc_initiate(TRPS_INSTANCE *trps, TRP_PEER *peer);
+void tr_config_changed(TR_CFG *new_cfg, void *cookie);
+TRP_RC tr_connect_to_peers(TRPS_INSTANCE *trps);
 #endif /* TR_TRP_H */