Internal changes to reflect merge of tpq and tid protocols.
authorMargaret Wasserman <mrw@debian.(none)>
Wed, 23 Jan 2013 11:42:12 +0000 (06:42 -0500)
committerMargaret Wasserman <mrw@debian.(none)>
Wed, 23 Jan 2013 11:42:12 +0000 (06:42 -0500)
common/tr_msg.c
include/tid.h [moved from include/tpq.h with 71% similarity]
include/tidr.h [deleted file]
include/tr.h
include/tr_msg.h
tid/example/tidc_main.c
tid/example/tids_main.c
tid/tidc.c
tid/tids.c
tr/tr_main.c

index d866933..42c725b 100644 (file)
@@ -37,7 +37,8 @@
 #include <jansson.h>
 
 #include <tr_msg.h>
-#include <tpq.h>
+#include <tid.h>
+
 static json_t *tr_msg_encode_dh(DH *dh)
 {
   json_t *jdh = NULL;
@@ -67,7 +68,7 @@ static DH *tr_msg_decode_dh(json_t *jdh)
   return dh;
 }
 
-json_t *tr_msg_encode_tpqreq(TPQ_REQ *req)
+json_t *tr_msg_encode_tidreq(TID_REQ *req)
 {
   json_t *jreq = NULL;
   json_t *jstr = NULL;
@@ -86,19 +87,19 @@ json_t *tr_msg_encode_tpqreq(TPQ_REQ *req)
   jstr = json_string(req->coi->buf);
   json_object_set_new(jreq, "community", jstr);
 
-  json_object_set_new(jreq, "dh_info", tr_msg_encode_dh(req->tpqc_dh));
+  json_object_set_new(jreq, "dh_info", tr_msg_encode_dh(req->tidc_dh));
   
   return jreq;
 }
 
-TPQ_REQ *tr_msg_decode_tpqreq(json_t *jreq)
+TID_REQ *tr_msg_decode_tidreq(json_t *jreq)
 {
-  TPQ_REQ *req = NULL;
+  TID_REQ *req = NULL;
 
   return req;
 }
 
-json_t *tr_msg_encode_tpqresp(TPQ_RESP *resp)
+json_t *tr_msg_encode_tidresp(TID_RESP *resp)
 {
   json_t *jresp = NULL;
 
@@ -106,38 +107,9 @@ json_t *tr_msg_encode_tpqresp(TPQ_RESP *resp)
 }
 
 
-TPQ_RESP *tr_msg_decode_tpqresp(json_t *jresp)
-{
-  TPQ_RESP *resp = NULL;
-
-  return resp;
-}
-
-json_t *tr_msg_encode_tidrreq(TIDR_REQ *req)
-{
-  json_t *jreq = NULL;
-
-  return jreq;
-
-}
-
-TIDR_REQ *tr_msg_decode_tidrreq(json_t *jreq)
-{
-  TIDR_REQ *req = NULL;
-
-  return req;
-}
-
-json_t *tr_msg_encode_tidrresp(TIDR_RESP *resp)
-{
-  json_t *jresp = NULL;
-
-  return jresp;
-}
-
-TIDR_RESP *tr_msg_decode_tidrresp(json_t *jresp)
+TID_RESP *tr_msg_decode_tidresp(json_t *jresp)
 {
-  TIDR_RESP *resp = NULL;
+  TID_RESP *resp = NULL;
 
   return resp;
 }
@@ -152,28 +124,16 @@ char *tr_msg_encode(TR_MSG *msg)
 
   switch (msg->msg_type) 
     {
-    case TPQ_REQUEST:
-      jmsg_type = json_string("TPQRequest");
-      json_object_set_new(jmsg, "msg_type", jmsg_type);
-      json_object_set_new(jmsg, "msg_body", tr_msg_encode_tpqreq(msg->tpq_req));
-      break;
-
-    case TPQ_RESPONSE:
-      jmsg_type = json_string("TPQResponse");
-      json_object_set_new(jmsg, "msg_type", jmsg_type);
-      json_object_set_new(jmsg, "msg_body", tr_msg_encode_tpqresp(msg->tpq_resp));
-      break;
-
-    case TIDR_REQUEST:
+    case TID_REQUEST:
       jmsg_type = json_string("TIDRequest");
       json_object_set_new(jmsg, "msg_type", jmsg_type);
-      json_object_set_new(jmsg, "msg_body", tr_msg_encode_tidrreq(msg->tidr_req));
+      json_object_set_new(jmsg, "msg_body", tr_msg_encode_tidreq(msg->tid_req));
       break;
 
-    case TIDR_RESPONSE:
+    case TID_RESPONSE:
       jmsg_type = json_string("TIDResponse");
       json_object_set_new(jmsg, "msg_type", jmsg_type);
-      json_object_set_new(jmsg, "msg_body", tr_msg_encode_tidrresp(msg->tidr_resp));
+      json_object_set_new(jmsg, "msg_body", tr_msg_encode_tidresp(msg->tid_resp));
       break;
 
       /* TBD -- Add TR message types */
similarity index 71%
rename from include/tpq.h
rename to include/tid.h
index 2e88399..76bca44 100644 (file)
@@ -32,8 +32,8 @@
  *
  */
 
-#ifndef TPQ_H
-#define TPQ_H
+#ifndef TID_H
+#define TID_H
 
 #include <arpa/inet.h>
 #include <openssl/dh.h>
 #include <gsscon.h>
 #include <tr_name.h>
 
-#define TPQ_PORT       12309
+#define TID_PORT       12309
 
-typedef struct tpq_req {
-  struct tpq_req *next_req;
+typedef struct tid_req {
+  struct tid_req *next_req;
   int conn;
   TR_NAME *rp_realm;
   TR_NAME *realm;
   TR_NAME *coi;
-  DH *tpqc_dh;         /* Client's public dh information */
+  DH *tidc_dh;         /* Client's public dh information */
   void *resp_func;
   void *cookie;
-} TPQ_REQ;
+} TID_REQ;
 
-typedef struct tpq_resp {
+typedef struct tid_resp {
   TR_NAME *realm;
   TR_NAME *coi;
   in_addr_t aaa_server_addr;
   DH *aaa_server_dh;           /* AAA server's public dh information */
   /* Trust Path Used */
-} TPQ_RESP;
+} TID_RESP;
 
-typedef struct tpqc_instance {
-  TPQ_REQ *req_list;
+typedef 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 */
-} TPQC_INSTANCE;
+} TIDC_INSTANCE;
 
-typedef struct tpqs_instance {
+typedef struct tids_instance {
   int req_count;
   char *priv_key;
   void *req_handler;
   void *cookie;
-} TPQS_INSTANCE;
+} TIDS_INSTANCE;
 
-typedef void (TPQC_RESP_FUNC)(TPQC_INSTANCE *, TPQ_RESP *, void *);
-typedef int (TPQS_REQ_FUNC)(TPQS_INSTANCE *, TPQ_REQ *, TPQ_RESP *, void *);
+typedef void (TIDC_RESP_FUNC)(TIDC_INSTANCE *, TID_RESP *, void *);
+typedef int (TIDS_REQ_FUNC)(TIDS_INSTANCE *, TID_REQ *, TID_RESP *, void *);
 
-TPQC_INSTANCE *tpqc_create (void);
-int tpqc_open_connection (TPQC_INSTANCE *tpqc, char *server, gss_ctx_id_t *gssctx);
-int tpqc_send_request (TPQC_INSTANCE *tpqc, int conn, gss_ctx_id_t gssctx, char *rp_realm, char *realm, char *coi, TPQC_RESP_FUNC *resp_handler, void *cookie);
-void tpqc_destroy (TPQC_INSTANCE *tpqc);
+TIDC_INSTANCE *tidc_create (void);
+int tidc_open_connection (TIDC_INSTANCE *tidc, char *server, gss_ctx_id_t *gssctx);
+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);
+void tidc_destroy (TIDC_INSTANCE *tidc);
 
-TPQS_INSTANCE *tpqs_create ();
-int tpqs_start (TPQS_INSTANCE *tpqs, TPQS_REQ_FUNC *req_handler, void *cookie);
-void tpqs_destroy (TPQS_INSTANCE *tpqs);
+TIDS_INSTANCE *tids_create ();
+int tids_start (TIDS_INSTANCE *tids, TIDS_REQ_FUNC *req_handler, void *cookie);
+void tids_destroy (TIDS_INSTANCE *tids);
 
 #endif
diff --git a/include/tidr.h b/include/tidr.h
deleted file mode 100644 (file)
index 623727b..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2012, JANET(UK)
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * 3. Neither the name of JANET(UK) nor the names of its contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef TIDR_H
-#define TIDR_H
-
-#include <gsscon.h>
-#include <tr_name.h>
-
-#define TIDR_PORT      12310
-
-typedef struct tidr_req {
-  struct tidr_req *next_req;
-  int conn;
-  TR_NAME *realm;
-  TR_NAME *coi;
-  void *resp_func;
-  void *cookie;
-} TIDR_REQ;
-
-typedef struct tidr_resp {
-  TR_NAME *realm;
-  TR_NAME *coi;
-  /* Address of AAA Server */
-  /* Credentials */
-  /* Trust Path Used */
-} TIDR_RESP;
-
-typedef struct tidrc_instance {
-  TIDR_REQ *req_list;
-} TIDRC_INSTANCE;
-
-typedef struct tidrs_instance {
-  int req_count;
-  void *req_handler;
-  void *cookie;
-} TIDRS_INSTANCE;
-
-typedef void (TIDRC_RESP_FUNC)(TIDRC_INSTANCE *, TIDR_RESP *, void *);
-typedef int (TIDRS_REQ_FUNC)(TIDRS_INSTANCE *, TIDR_REQ *, TIDR_RESP *, void *);
-
-TIDRC_INSTANCE *tidrc_create (void);
-int tidrc_open_connection (TIDRC_INSTANCE *tidrc, char *server, gss_ctx_id_t *gssctx);
-int tidrc_send_request (TIDRC_INSTANCE *tidrc, int conn, gss_ctx_id_t gssctx, char *realm, char *coi, TIDRC_RESP_FUNC *resp_handler, void *cookie);
-void tidrc_destroy (TIDRC_INSTANCE *tpqc);
-
-TIDRS_INSTANCE *tidrs_create ();
-int tidrs_start (TIDRS_INSTANCE *tidrs, TIDRS_REQ_FUNC *req_handler, void *cookie);
-void tidrs_destroy (TIDRS_INSTANCE *tidrs);
-
-#endif
index 9fee9dd..f7804d9 100644 (file)
@@ -38,8 +38,7 @@
 #include <tr_msg.h>
 #include <tr_name.h>
 #include <tr_config.h>
-#include <tpq.h>
-#include <tidr.h>
+#include <tid.h>
 
 #define TRUST_ROUTER_PORT      12308
 
index 7d8a5fa..5c0583d 100644 (file)
 #ifndef TR_MSG_H
 #define TR_MSG_H
 
-#include <tpq.h>
-#include <tidr.h>
+#include <tid.h>
 #include <jansson.h>
 
 enum msg_type {
   TR_UNKNOWN,
-  TPQ_REQUEST,
-  TPQ_RESPONSE,
-  TIDR_REQUEST,
-  TIDR_RESPONSE
+  TID_REQUEST,
+  TID_RESPONSE
 };
 
 /* Union of TR message types to hold message of any type. */
 typedef struct tr_msg {
   enum msg_type msg_type;
   union {
-    TPQ_REQ *tpq_req;
-    TPQ_RESP *tpq_resp;
-    TIDR_REQ *tidr_req;
-    TIDR_RESP *tidr_resp;
+    TID_REQ *tid_req;
+    TID_RESP *tid_resp;
   };
 } TR_MSG;
 
index 0739221..9f2943e 100644 (file)
 #include <stdio.h>
 
 #include <gsscon.h>
-#include <tpq.h>
+#include <tid.h>
 
-static int tpqc_response_received = 0;
+static int tidc_response_received = 0;
 
-void tpqc_print_usage (const char *name)
+void tidc_print_usage (const char *name)
 {
   printf("Usage: %s <server> <RP-realm> <target-realm> <community>\n", name);
 }
 
-void tpqc_resp_handler (TPQC_INSTANCE * tpqc, 
-                       TPQ_RESP *resp, 
+void tidc_resp_handler (TIDC_INSTANCE * tidc, 
+                       TID_RESP *resp, 
                        void *cookie) 
 {
   //  printf ("Response received! Realm = %s, COI = %s.\n", resp->realm->buf, 
   //     resp->coi->buf);
   printf ("Response received at handler!\n");
-  tpqc_response_received = 1;
+  tidc_response_received = 1;
   return;
 }
 
 int main (int argc, 
          const char *argv[]) 
 {
-  TPQC_INSTANCE *tpqc;
-  TPQ_REQ *treq;
+  TIDC_INSTANCE *tidc;
+  TID_REQ *treq;
   char *server = NULL;
   char *rp_realm = NULL;
   char *realm = NULL;
@@ -72,7 +72,7 @@ int main (int argc,
 
   /* Parse command-line arguments */ 
   if (argc != 5) {
-    tpqc_print_usage(argv[0]);
+    tidc_print_usage(argv[0]);
     exit(1);
   }
 
@@ -82,31 +82,31 @@ int main (int argc,
   realm = (char *)argv[3];
   coi = (char *)argv[4];
 
-  printf("TPQC Client:\nServer = %s, rp_realm = %s, target_realm = %s, community = %s\n", server, rp_realm, realm, coi);
+  printf("TIDC Client:\nServer = %s, rp_realm = %s, target_realm = %s, community = %s\n", server, rp_realm, realm, coi);
  
-  /* Create a TPQ client instance */
-  tpqc = tpqc_create();
+  /* Create a TID client instance */
+  tidc = tidc_create();
 
-  /* Set-up TPQ connection */
-  if (-1 == (conn = tpqc_open_connection(tpqc, server, &gssctx))) {
+  /* Set-up TID connection */
+  if (-1 == (conn = tidc_open_connection(tidc, server, &gssctx))) {
     /* Handle error */
-    printf("Error in tpqc_open_connection.\n");
+    printf("Error in tidc_open_connection.\n");
     return 1;
   };
 
-  /* Send a TPQ request */
-  if (0 > (rc = tpqc_send_request(tpqc, conn, gssctx, rp_realm, realm, coi, 
-                                 &tpqc_resp_handler, NULL))) {
+  /* Send a TID request */
+  if (0 > (rc = tidc_send_request(tidc, conn, gssctx, rp_realm, realm, coi, 
+                                 &tidc_resp_handler, NULL))) {
     /* Handle error */
-    printf("Error in tpqc_send_request, rc = %d.\n", rc);
+    printf("Error in tidc_send_request, rc = %d.\n", rc);
     return 1;
   }
     
   /* Wait for a response */
-  while (!tpqc_response_received);
+  while (!tidc_response_received);
 
-  /* Clean-up the TPQ client instance, and exit */
-  tpqc_destroy(tpqc);
+  /* Clean-up the TID client instance, and exit */
+  tidc_destroy(tidc);
 
   return 0;
 }
index ec56fc4..c10452f 100644 (file)
 
 #include <stdio.h>
 
-#include <tpq.h>
+#include <tid.h>
 
-int tpqs_req_handler (TPQS_INSTANCE * tpqs,
-                     TPQ_REQ *req, 
-                     TPQ_RESP *resp,
+int tids_req_handler (TIDS_INSTANCE * tids,
+                     TID_REQ *req, 
+                     TID_RESP *resp,
                      void *cookie)
 {
   printf("Request received! Realm = %s, COI = %s\n", req->realm->buf, req->coi->buf);
-  if (tpqs)
-    tpqs->req_count++;
+  if (tids)
+    tids->req_count++;
 
   if ((NULL == (resp->realm = tr_dup_name(req->realm))) ||
       (NULL == (resp->coi = tr_dup_name(req->coi)))) {
-    printf ("Error in tpq_dup_name, not responding.\n");
+    printf ("Error in tid_dup_name, not responding.\n");
     return 1;
   }
 
@@ -58,26 +58,26 @@ int tpqs_req_handler (TPQS_INSTANCE * tpqs,
 int main (int argc, 
          const char *argv[]) 
 {
-  static TPQS_INSTANCE *tpqs;
+  static TIDS_INSTANCE *tids;
   int rc = 0;
 
   /* Parse command-line arguments */ 
   if (argc != 1)
     printf("Unexpected arguments, ignored.\n");
 
-  /* Create a TPQ server instance */
-  if (NULL == (tpqs = tpqs_create())) {
-    printf("Error in tpqs_create().  Exiting.\n");
+  /* Create a TID server instance */
+  if (NULL == (tids = tids_create())) {
+    printf("Error in tids_create().  Exiting.\n");
     return 1;
   }
 
   /* Start-up the server, won't return unless there is an error. */
-  rc = tpqs_start(tpqs, &tpqs_req_handler , NULL);
+  rc = tids_start(tids, &tids_req_handler , NULL);
   
-  printf("Error in tpqs_start(), rc = %d. Exiting.\n");
+  printf("Error in tids_start(), rc = %d. Exiting.\n");
 
-  /* Clean-up the TPQ server instance */
-  tpqs_destroy(tpqs);
+  /* Clean-up the TID server instance */
+  tids_destroy(tids);
 
   return 1;
 }
index e7ab977..352baaf 100644 (file)
@@ -38,7 +38,7 @@
 
 #include <gsscon.h>
 #include <tr_dh.h>
-#include <tpq.h>
+#include <tid.h>
 #include <tr_msg.h>
 
 /* char tmp_key[32] = 
 
 int tmp_len = 32;
 
-TPQC_INSTANCE *tpqc_create ()
+TIDC_INSTANCE *tidc_create ()
 {
-  TPQC_INSTANCE *tpqc = NULL;
+  TIDC_INSTANCE *tidc = NULL;
 
-  if (tpqc = malloc(sizeof(TPQC_INSTANCE))) 
-    memset(tpqc, 0, sizeof(TPQC_INSTANCE));
+  if (tidc = malloc(sizeof(TIDC_INSTANCE))) 
+    memset(tidc, 0, sizeof(TIDC_INSTANCE));
   else
     return NULL;
 
-  if (NULL == (tpqc->priv_dh = tr_create_dh_params(NULL, 0))) {
-    free (tpqc);
+  if (NULL == (tidc->priv_dh = tr_create_dh_params(NULL, 0))) {
+    free (tidc);
     return NULL;
   }
 
-  fprintf(stderr, "TPQC DH Parameters:\n");
-  DHparams_print_fp(stdout, tpqc->priv_dh);
+  fprintf(stderr, "TIDC DH Parameters:\n");
+  DHparams_print_fp(stdout, tidc->priv_dh);
   fprintf(stderr, "\n");
 
-  return tpqc;
+  return tidc;
 }
 
-void tpqc_destroy (TPQC_INSTANCE *tpqc)
+void tidc_destroy (TIDC_INSTANCE *tidc)
 {
-  if (tpqc)
-    free(tpqc);
+  if (tidc)
+    free(tidc);
 }
 
-int tpqc_open_connection (TPQC_INSTANCE *tpqc, 
+int tidc_open_connection (TIDC_INSTANCE *tidc, 
                          char *server,
                          gss_ctx_id_t *gssctx)
 {
   int err = 0;
   int conn = -1;
 
-  err = gsscon_connect(server, TPQ_PORT, &conn);
+  err = gsscon_connect(server, TID_PORT, &conn);
 
   if (!err)
     err = gsscon_active_authenticate(conn, NULL, "trustquery", gssctx);
@@ -95,13 +95,13 @@ int tpqc_open_connection (TPQC_INSTANCE *tpqc,
     return -1;
 }
 
-int tpqc_send_request (TPQC_INSTANCE *tpqc, 
+int tidc_send_request (TIDC_INSTANCE *tidc, 
                       int conn, 
                       gss_ctx_id_t gssctx,
                       char *rp_realm,
                       char *realm, 
                       char *coi,
-                      TPQC_RESP_FUNC *resp_handler,
+                      TIDC_RESP_FUNC *resp_handler,
                       void *cookie)
 
 {
@@ -111,38 +111,38 @@ int tpqc_send_request (TPQC_INSTANCE *tpqc,
   char *resp_buf;
   size_t resp_buflen = 0;
   TR_MSG *msg;
-  TPQ_REQ *tpq_req;
+  TID_REQ *tid_req;
 
-  /* Create and populate a TPQ msg structure */
+  /* Create and populate a TID msg structure */
   if ((!(msg = malloc(sizeof(TR_MSG)))) ||
-      (!(tpq_req = malloc(sizeof(TPQ_REQ)))))
+      (!(tid_req = malloc(sizeof(TID_REQ)))))
     return -1;
 
-  memset(tpq_req, 0, sizeof(tpq_req));
+  memset(tid_req, 0, sizeof(tid_req));
 
-  msg->msg_type = TPQ_REQUEST;
+  msg->msg_type = TID_REQUEST;
 
-  msg->tpq_req = tpq_req;
+  msg->tid_req = tid_req;
 
-  tpq_req->conn = conn;
+  tid_req->conn = conn;
 
   /* TBD -- error handling */
-  tpq_req->rp_realm = tr_new_name(rp_realm);
-  tpq_req->realm = tr_new_name(realm);
-  tpq_req->coi = tr_new_name(coi);
+  tid_req->rp_realm = tr_new_name(rp_realm);
+  tid_req->realm = tr_new_name(realm);
+  tid_req->coi = tr_new_name(coi);
 
-  tpq_req->tpqc_dh = tpqc->priv_dh;
+  tid_req->tidc_dh = tidc->priv_dh;
   
-  tpq_req->resp_func = resp_handler;
-  tpq_req->cookie = cookie;
+  tid_req->resp_func = resp_handler;
+  tid_req->cookie = cookie;
 
   /* Encode the request into a json string */
   if (!(req_buf = tr_msg_encode(msg))) {
-    printf("Error encoding TPQ request.\n");
+    printf("Error encoding TID request.\n");
     return -1;
   }
 
-  printf ("Sending TPQ request:\n");
+  printf ("Sending TID request:\n");
   printf ("%s\n", req_buf);
 
   /* Send the request over the connection */
@@ -166,12 +166,12 @@ int tpqc_send_request (TPQC_INSTANCE *tpqc,
   /* Parse response -- TBD */
 
   /* Call the caller's response function */
-  (*resp_handler)(tpqc, NULL, cookie);
+  (*resp_handler)(tidc, NULL, cookie);
 
   if (msg)
     free(msg);
-  if (tpq_req)
-    free(tpq_req);
+  if (tid_req)
+    free(tid_req);
   if (req_buf)
     free(req_buf);
   if (resp_buf)
index f915379..7b7d01f 100644 (file)
@@ -41,9 +41,9 @@
 #include <jansson.h>
 
 #include <gsscon.h>
-#include <tpq.h>
+#include <tid.h>
 
-static int tpqs_listen (int port) 
+static int tids_listen (int port) 
 {
     int rc = 0;
     int conn = -1;
@@ -63,11 +63,11 @@ static int tpqs_listen (int port)
     if (0 > (rc = listen(conn, 512)))
       return rc;
     
-    fprintf (stdout, "TPQ Server listening on port %d\n", port);
+    fprintf (stdout, "TID Server listening on port %d\n", port);
     return conn; 
 }
 
-static int tpqs_auth_connection (int conn, gss_ctx_id_t *gssctx)
+static int tids_auth_connection (int conn, gss_ctx_id_t *gssctx)
 {
   int rc = 0;
   int auth, autherr = 0;
@@ -91,7 +91,7 @@ static int tpqs_auth_connection (int conn, gss_ctx_id_t *gssctx)
   return auth;
 }
 
-static int tpqs_read_request (int conn, gss_ctx_id_t *gssctx, TPQ_REQ *req)
+static int tids_read_request (int conn, gss_ctx_id_t *gssctx, TID_REQ *req)
 {
   int err;
   char *buf;
@@ -113,24 +113,24 @@ static int tpqs_read_request (int conn, gss_ctx_id_t *gssctx, TPQ_REQ *req)
   return buflen;
 }
 
-static int tpqs_handle_request (TPQ_REQ *req, TPQ_RESP *resp) 
+static int tids_handle_request (TID_REQ *req, TID_RESP *resp) 
 {
   return 0;
 }
 
-static int tpqs_send_response (int conn, gss_ctx_id_t *gssctx, TPQ_RESP *resp)
+static int tids_send_response (int conn, gss_ctx_id_t *gssctx, TID_RESP *resp)
 {
   json_t *jreq;
   int err;
   char *resp_buf;
 
-  /* Create a json TPQ response */
+  /* Create a json TID response */
   if (NULL == (jreq = json_object())) {
     fprintf(stderr,"Error creating json object.\n");
     return -1;
   }
 
-  if (0 > (err = json_object_set_new(jreq, "type", json_string("tpq_response")))) {
+  if (0 > (err = json_object_set_new(jreq, "type", json_string("tid_response")))) {
     fprintf(stderr, "Error adding type to response.\n");
     return -1;
   }
@@ -164,15 +164,15 @@ static int tpqs_send_response (int conn, gss_ctx_id_t *gssctx, TPQ_RESP *resp)
 
 }
 
-static void tpqs_handle_connection (int conn)
+static void tids_handle_connection (int conn)
 {
-  TPQ_REQ req;
-  TPQ_RESP resp;
+  TID_REQ req;
+  TID_RESP resp;
   int rc;
   gss_ctx_id_t gssctx = GSS_C_NO_CONTEXT;
 
-  if (!tpqs_auth_connection(conn, &gssctx)) {
-    fprintf(stderr, "Error authorizing TPQ Server connection, rc = %d.\n", rc);
+  if (!tids_auth_connection(conn, &gssctx)) {
+    fprintf(stderr, "Error authorizing TID Server connection, rc = %d.\n", rc);
     close(conn);
     return;
   }
@@ -181,20 +181,20 @@ static void tpqs_handle_connection (int conn)
 
   while (1) {  /* continue until an error breaks us out */
 
-    if (0 > (rc = tpqs_read_request(conn, &gssctx, &req))) {
-      fprintf(stderr, "Error from tpqs_read_request(), rc = %d.\n", rc);
+    if (0 > (rc = tids_read_request(conn, &gssctx, &req))) {
+      fprintf(stderr, "Error from tids_read_request(), rc = %d.\n", rc);
       return;
     } else if (0 == rc) {
       continue;
     }
 
-    if (0 > (rc = tpqs_handle_request(&req, &resp))) {
-      fprintf(stderr, "Error from tpqs_handle_request(), rc = %d.\n", rc);
+    if (0 > (rc = tids_handle_request(&req, &resp))) {
+      fprintf(stderr, "Error from tids_handle_request(), rc = %d.\n", rc);
       return;
     }
 
-    if (0 > (rc = tpqs_send_response(conn, &gssctx, &resp))) {
-      fprintf(stderr, "Error from tpqs_send_response(), rc = %d.\n", rc);
+    if (0 > (rc = tids_send_response(conn, &gssctx, &resp))) {
+      fprintf(stderr, "Error from tids_send_response(), rc = %d.\n", rc);
       return;
     }
   }  
@@ -202,29 +202,29 @@ static void tpqs_handle_connection (int conn)
   return;
 }
 
-TPQS_INSTANCE *tpqs_create ()
+TIDS_INSTANCE *tids_create ()
 {
-  TPQS_INSTANCE *tpqs = 0;
-  if (tpqs = malloc(sizeof(TPQS_INSTANCE)))
-    memset(tpqs, 0, sizeof(TPQS_INSTANCE));
-  return tpqs;
+  TIDS_INSTANCE *tids = 0;
+  if (tids = malloc(sizeof(TIDS_INSTANCE)))
+    memset(tids, 0, sizeof(TIDS_INSTANCE));
+  return tids;
 }
 
-int tpqs_start (TPQS_INSTANCE *tpqs, 
-               TPQS_REQ_FUNC *req_handler,
+int tids_start (TIDS_INSTANCE *tids, 
+               TIDS_REQ_FUNC *req_handler,
                void *cookie)
 {
   int listen = -1;
   int conn = -1;
   pid_t pid;
 
-  if (0 > (listen = tpqs_listen(TPQ_PORT)))
-    perror ("Error from tpqs_listen()");
+  if (0 > (listen = tids_listen(TID_PORT)))
+    perror ("Error from tids_listen()");
 
   while(1) {   /* accept incoming conns until we are stopped */
 
     if (0 > (conn = accept(listen, NULL, NULL))) {
-      perror("Error from TPQS Server accept()");
+      perror("Error from TIDS Server accept()");
       return 1;
     }
 
@@ -235,7 +235,7 @@ int tpqs_start (TPQS_INSTANCE *tpqs,
 
     if (pid == 0) {
       close(listen);
-      tpqs_handle_connection(conn);
+      tids_handle_connection(conn);
       close(conn);
       exit(0);
     } else {
@@ -246,9 +246,9 @@ int tpqs_start (TPQS_INSTANCE *tpqs,
   return 1;    /* should never get here */
 }
 
-void tpqs_destroy (TPQS_INSTANCE *tpqs)
+void tids_destroy (TIDS_INSTANCE *tids)
 {
-  free(tpqs);
+  free(tids);
 }
 
 
index 4e4ea7a..a595d38 100644 (file)
 
 #include <tr.h>
 
-int tpqs_req_handler (TPQS_INSTANCE * tpqs,
-                     TPQ_REQ *req, 
-                     TPQ_RESP *resp,
+int tids_req_handler (TIDS_INSTANCE * tids,
+                     TID_REQ *req, 
+                     TID_RESP *resp,
                      void *cookie)
 {
   printf("Request received! Realm = %s, COI = %s\n", req->realm->buf, req->coi->buf);
-  if (tpqs)
-    tpqs->req_count++;
+  if (tids)
+    tids->req_count++;
 
   if ((NULL == (resp->realm = tr_dup_name(req->realm))) ||
       (NULL == (resp->coi = tr_dup_name(req->coi)))) {
-    printf ("Error in tpq_dup_name, not responding.\n");
+    printf ("Error in tid_dup_name, not responding.\n");
     return 1;
   }
 
@@ -56,7 +56,7 @@ int tpqs_req_handler (TPQS_INSTANCE * tpqs,
 
 int main (int argc, const char *argv[])
 {
-  TPQS_INSTANCE *tpqs = 0;
+  TIDS_INSTANCE *tids = 0;
   int err;
   FILE *cfg_file = 0;
 
@@ -72,17 +72,17 @@ int main (int argc, const char *argv[])
   }
 
   /* initialize the trust path query server instance */
-  if (0 == (tpqs = tpqs_create ())) {
+  if (0 == (tids = tids_create ())) {
     printf ("Error initializing Trust Path Query Server instance.\n", err);
     return 1;
   }
 
   /* start the trust path query server, won't return unless there is an error. */
-  if (0 != (err = tpqs_start(tpqs, &tpqs_req_handler, NULL))) {
+  if (0 != (err = tids_start(tids, &tids_req_handler, NULL))) {
     printf ("Error starting Trust Path Query Server, err = %d.\n", err);
     return err;
   }
 
-  tpqs_destroy(tpqs);
+  tids_destroy(tids);
   return 0;
 }