tr_constraint_set_get_match_strings
[trust_router.git] / tid / tidc.c
index e7d7caf..7f675d3 100644 (file)
@@ -33,9 +33,7 @@
  */
 
 #include <stdio.h>
-#include <stdlib.h>
 #include <jansson.h>
-#include <gsscon.h>
 
 #include <trust_router/tr_dh.h>
 #include <trust_router/tid.h>
@@ -62,41 +60,22 @@ void tidc_destroy (TIDC_INSTANCE *tidc)
     free(tidc);
 }
 
-TID_REQ *tid_dup_req (TID_REQ *orig_req) 
-{
-  TID_REQ *new_req = NULL;
-
-  if (NULL == (new_req = malloc(sizeof(TID_REQ)))) {
-    fprintf(stderr, "tid_dup_req: Can't allocated duplicate request.\n");
-    return NULL;
-  }
-
-  /* Memcpy for flat fields, not valid until names are duped. */
-  memcpy(new_req, orig_req, sizeof(TID_REQ));
-  
-  if ((NULL == (new_req->rp_realm = tr_dup_name(orig_req->rp_realm))) ||
-      (NULL == (new_req->realm = tr_dup_name(orig_req->realm))) ||
-      (NULL == (new_req->comm = tr_dup_name(orig_req->comm)))) {
-       fprintf(stderr, "tid_dup_req: Can't duplicate request (names).\n");
-  }
-
-  if (orig_req->orig_coi) {
-    if (NULL == (new_req->orig_coi = tr_dup_name(orig_req->orig_coi))) {
-      fprintf(stderr, "tid_dup_req: Can't duplicate request (orig_coi).\n");
-    }
-  }
-  
-  return new_req;
-}
-
 int tidc_open_connection (TIDC_INSTANCE *tidc, 
                          char *server,
+                         unsigned int port,
                          gss_ctx_id_t *gssctx)
 {
   int err = 0;
   int conn = -1;
+  unsigned int use_port = 0;
+
+  if (0 == port)
+    use_port = TID_PORT;
+  else 
+    use_port = port;
 
-  err = gsscon_connect(server, TID_PORT, "trustidentity", &conn, gssctx);
+  fprintf(stderr, "tidc_open_connection: Opening GSS connection to %s:%u.", server, use_port);  
+  err = gsscon_connect(server, use_port, "trustidentity", &conn, gssctx);
 
   if (!err)
     return conn;
@@ -211,7 +190,7 @@ int tidc_fwd_request (TIDC_INSTANCE *tidc,
   if (msg)
     free(msg);
   if (tid_req)
-    free(tid_req);
+    tid_req_free(tid_req);
   if (req_buf)
     free(req_buf);
   if (resp_buf)
@@ -222,7 +201,3 @@ int tidc_fwd_request (TIDC_INSTANCE *tidc,
   return 0;
 }
 
-
-
-
-