From f1e0cb3f969c55118d3254e9c5943751728e32ef Mon Sep 17 00:00:00 2001 From: Margaret Wasserman Date: Mon, 3 Dec 2012 09:55:11 -0500 Subject: [PATCH] Fix definitions and align code, so that trust router code compiles. --- include/tpq.h | 43 +++++++++++++++++++++++++------------------ tpq/tpqc.c | 2 ++ tpq/tpqs.c | 16 ++++++++++++---- tr/tr_main.c | 3 ++- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/include/tpq.h b/include/tpq.h index 7748ae3..aa8cb45 100644 --- a/include/tpq.h +++ b/include/tpq.h @@ -37,35 +37,42 @@ #define TRUST_PATH_QUERY_PORT 12309 -typedef void (*TPQC_RESP_FUNC)(TPQC_INSTANCE *, TPQC_REQ *, TPQC_RESP *, void *); +typedef struct tpq_name { + char *buf; + int len; +} TPQ_NAME; -struct tpqc_req_t { - struct tpqc_req_t next_req; - char realm[1024]; - char coi[1024]; +typedef struct tpq_req { + struct tpq_req *next_req; + TPQ_NAME realm; + TPQ_NAME coi; int conn; - TPQC_RESP_FUNC *func -}; + void *resp_func; + void *cookie; +} TPQ_REQ; -typedef struct tpqc_req_t TPQC_REQ; +typedef struct tpq_resp { + TPQ_NAME realm; + TPQ_NAME coi; + /* Address of AAA Server */ + /* Credentials */ +} TPQ_RESP; -struct tpqc_instance_t { - TPQC_REQ *req_list -}; +typedef struct tpqc_instance { + TPQ_REQ *req_list; +} TPQC_INSTANCE; -typedef void TPQC_RESP; - -typedef struct tpqc_instance_t TPQC_INSTANCE; +typedef void (*TPQC_RESP_FUNC)(TPQC_INSTANCE *, TPQ_REQ *, TPQ_RESP *, void *); TPQC_INSTANCE *tpqc_create (void); -void tpqc_release (TPQC_INSTANCE *tpqc); int tpqc_open_connection (TPQC_INSTANCE *tpqc, char *server); -TPQC_REQ *tpqc_send_request (TPQC_INSTANCE *tpqc, int conn, char *realm, char *coi, TPQC_RESP_FUNC *resp_handler); +int tpqc_send_request (TPQC_INSTANCE *tpqc, int conn, char *realm, char *coi, TPQC_RESP_FUNC *resp_handler); +void tpqc_destroy (TPQC_INSTANCE *tpqc); typedef void TPQS_INSTANCE; -TPQS_INSTANCE *tpqs_init (); +TPQS_INSTANCE *tpqs_create (); int tpqs_start (TPQS_INSTANCE *tpqs); - +void tpqs_destroy (TPQS_INSTANCE *tpqs); #endif diff --git a/tpq/tpqc.c b/tpq/tpqc.c index 8fbdacd..085b3d6 100644 --- a/tpq/tpqc.c +++ b/tpq/tpqc.c @@ -32,6 +32,8 @@ * */ +#include + #include #include diff --git a/tpq/tpqs.c b/tpq/tpqs.c index 271dbb4..6051d73 100644 --- a/tpq/tpqs.c +++ b/tpq/tpqs.c @@ -32,13 +32,15 @@ * */ +#include + #include -TPQS_INSTANCE *tpqs_init () +TPQS_INSTANCE *tpqs_create () { - TPQS_INSTANCE *t = 0; - - return t; + TPQS_INSTANCE *tpqs = 0; + tpqs = malloc(sizeof(TPQS_INSTANCE)); + return tpqs; } int tpqs_start (TPQS_INSTANCE *tpqs) @@ -47,3 +49,9 @@ int tpqs_start (TPQS_INSTANCE *tpqs) return 1; } +void tpqs_destroy (TPQS_INSTANCE *tpqs) +{ + free(tpqs); +} + + diff --git a/tr/tr_main.c b/tr/tr_main.c index ea3a8de..bc57024 100644 --- a/tr/tr_main.c +++ b/tr/tr_main.c @@ -54,7 +54,7 @@ int main (int argc, const char *argv[]) } /* initialize the trust path query server instance */ - if (0 == (tpqs = tpqs_init ())) { + if (0 == (tpqs = tpqs_create ())) { printf ("Error initializing Trust Path Query Server instance.\n", err); return 1; } @@ -68,5 +68,6 @@ int main (int argc, const char *argv[]) /* start the trust router protocol engine -- TBD */ while (1); + tpqs_destroy(tpqs); return 0; } -- 2.1.4