tid: implement GSS name callback
[trust_router.git] / include / trust_router / tid.h
index a6e510a..bf4d9c9 100644 (file)
 
 #include <trust_router/tr_name.h>
 #include <trust_router/tr_versioning.h>
+#include <gssapi.h>
 
 #define TID_PORT       12309
 
-typedef struct gss_ctx_id_struct *gss_ctx_id_t;
 
-typedef struct tid_req {
-  struct tid_req *next_req;
-  int conn;
-  TR_NAME *rp_realm;
-  TR_NAME *realm;
-  TR_NAME *comm;
-  TR_NAME *orig_coi;
-  DH *tidc_dh;                 /* Client's public dh information */
-  void *resp_func;
-  void *cookie;
-} TID_REQ;
+
+typedef enum tid_rc {
+  TID_SUCCESS = 0,
+  TID_ERROR
+} TID_RC;
 
 typedef struct tid_srvr_blk {
   struct tid_srvr_blk *next;
-  in_addr_t aaa_server_addr;
+  struct in_addr aaa_server_addr;
+  TR_NAME *key_name;
   DH *aaa_server_dh;           /* AAA server's public dh information */
 } TID_SRVR_BLK;
   
-
 typedef struct tid_resp {
-  TR_NAME *result;
+  TID_RC result;
+  TR_NAME *err_msg;
   TR_NAME *rp_realm;
   TR_NAME *realm;
   TR_NAME *comm;
@@ -74,30 +69,62 @@ typedef struct tid_resp {
   /* TBD -- Trust Path Used */
 } TID_RESP;
 
-typedef struct tidc_instance {
+typedef struct tidc_instance TIDC_INSTANCE;
+typedef struct tids_instance TIDS_INSTANCE;
+typedef struct tid_req TID_REQ;
+
+typedef void (TIDC_RESP_FUNC)(TIDC_INSTANCE *, TID_REQ *, TID_RESP *, void *);
+
+struct tid_req {
+  struct tid_req *next_req;
+  int resp_sent;
+  int conn;
+  gss_ctx_id_t gssctx;
+  int resp_rcvd;
+  TR_NAME *rp_realm;
+  TR_NAME *realm;
+  TR_NAME *comm;
+  TR_NAME *orig_coi;
+  DH *tidc_dh;                 /* Client's public dh information */
+  TIDC_RESP_FUNC *resp_func;
+  void *cookie;
+};
+
+struct tidc_instance {
   TID_REQ *req_list;
-  char *priv_key;
-  int priv_len;
-  DH *priv_dh;                 /* Client's DH struct with priv and pub keys */
-} TIDC_INSTANCE;
+  // TBD -- Do we still need a separate private key */
+  // char *priv_key;
+  // int priv_len;
+  DH *client_dh;                       /* Client's DH struct with priv and pub keys */
+};
+
+typedef int (TIDS_REQ_FUNC)(TIDS_INSTANCE *, TID_REQ *, TID_RESP **, void *);
+typedef int (tids_auth_func)(gss_name_t client_name, TR_NAME *display_name, void *cookie);
+
 
-typedef struct tids_instance {
+struct tids_instance {
   int req_count;
   char *priv_key;
-  void *req_handler;
+  char *ipaddr;
+  TIDS_REQ_FUNC *req_handler;
+  tids_auth_func *auth_handler;
   void *cookie;
-} TIDS_INSTANCE;
+};
 
-typedef void (TIDC_RESP_FUNC)(TIDC_INSTANCE *, TID_RESP *, void *);
-typedef int (TIDS_REQ_FUNC)(TIDS_INSTANCE *, TID_REQ *, TID_RESP *, void *);
+TR_EXPORT TID_REQ *tid_dup_req (TID_REQ *orig_req);
 
 TR_EXPORT TIDC_INSTANCE *tidc_create (void);
 TR_EXPORT int tidc_open_connection (TIDC_INSTANCE *tidc, char *server, gss_ctx_id_t *gssctx);
 TR_EXPORT int tidc_send_request (TIDC_INSTANCE *tidc, int conn, gss_ctx_id_t gssctx, char *rp_realm, char *realm, char *coi, TIDC_RESP_FUNC *resp_handler, void *cookie);
+TR_EXPORT int tidc_fwd_request (TIDC_INSTANCE *tidc, TID_REQ *req, TIDC_RESP_FUNC *resp_handler, void *cookie);
 TR_EXPORT void tidc_destroy (TIDC_INSTANCE *tidc);
 
-TR_EXPORT TIDS_INSTANCE *tids_create ();
-TR_EXPORT int tids_start (TIDS_INSTANCE *tids, TIDS_REQ_FUNC *req_handler, void *cookie);
+TR_EXPORT TIDS_INSTANCE *tids_create (void);
+TR_EXPORT int tids_start (TIDS_INSTANCE *tids, TIDS_REQ_FUNC *req_handler,
+                         tids_auth_func *auth_handler,
+                         void *cookie);
+TR_EXPORT int tids_send_response (TIDS_INSTANCE *tids, TID_REQ *req, TID_RESP *resp);
+TR_EXPORT int tids_send_err_response (TIDS_INSTANCE *tids, TID_REQ *req, const char *err_msg);
 TR_EXPORT void tids_destroy (TIDS_INSTANCE *tids);
 
 #endif