-bin_PROGRAMS= tr/tr
+bin_PROGRAMS= tr/tr tpq/tpqc tpq/tpqs
AM_CPPFLAGS=-I$(srcdir)/include
-SUBDIRS = gsscon .
+SUBDIRS = gsscon
tr_tr_SOURCES = tr/tr_main.c \
tpq/tpqs.c \
+tpq/tpq_common.c \
common/tr_config.c
tr_tr_LDADD = gsscon/libgsscon.la
+tpq_tpqc_SOURCES = tpq/example/tpqc_main.c \
+tpq/tpqc.c \
+tpq/tpq_common.c
+
+tpq_tpqc_LDADD = gsscon/libgsscon.la
+
+tpq_tpqs_SOURCES = tpq/example/tpqs_main.c \
+tpq/tpqs.c \
+tpq/tpq_common.c
+
+tpq_tpqs_LDADD = gsscon/libgsscon.la
+
typedef struct tpq_req {
struct tpq_req *next_req;
int conn;
- TPQ_NAME realm;
- TPQ_NAME coi;
+ TPQ_NAME *realm;
+ TPQ_NAME *coi;
void *resp_func;
void *cookie;
} TPQ_REQ;
typedef struct tpq_resp {
- TPQ_NAME realm;
- TPQ_NAME coi;
+ TPQ_NAME *realm;
+ TPQ_NAME *coi;
/* Address of AAA Server */
/* Credentials */
/* Trust Path Used */
typedef struct tpqs_instance {
int req_count;
+ void *req_handler;
+ void *cookie;
} TPQS_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 (TPQC_RESP_FUNC)(TPQC_INSTANCE *, TPQ_RESP *, void *);
+typedef int (TPQS_REQ_FUNC)(TPQS_INSTANCE *, TPQ_REQ *, TPQ_RESP *, void *);
TPQ_NAME *tpq_dup_name (TPQ_NAME *from);
void tpqc_destroy (TPQC_INSTANCE *tpqc);
TPQS_INSTANCE *tpqs_create ();
-int tpqs_start (TPQS_INSTANCE *tpqs);
+int tpqs_start (TPQS_INSTANCE *tpqs, TPQS_REQ_FUNC *req_handler, void *cookie);
void tpqs_destroy (TPQS_INSTANCE *tpqs);
#endif
*
*/
-#include <stdio,h>
+#include <stdio.h>
+
#include <tpq.h>
static int tpqc_response_received = 0;
-void tpqc_print_usage (char *name)
+void tpqc_print_usage (const char *name)
{
printf("Usage: %s <server> <realm> <coi>\n", name);
}
char *coi = NULL;
void *cookie = NULL;
int conn = 0;
+ int rc;
/* Parse command-line arguments */
if (argc != 4)
tpqc_print_usage(argv[0]);
/* TBD -- validity checking, dealing with quotes, etc. */
- server = argv[1];
- realm = argv[2];
- coi = argv[3];
+ server = (char *)argv[1];
+ realm = (char *)argv[2];
+ coi = (char *)argv[3];
/* Create a TPQ client instance */
tpqc = tpqc_create();
/* Set-up TPQ connection */
if (-1 == (conn = tpqc_open_connection(tpqc, server))) {
/* Handle error */
- print("Error in tpqc_open_connection.\n");
+ printf("Error in tpqc_open_connection.\n");
return 1;
};
/* Send a TPQ request */
- if (rc = tpqc_send_request(tpqc, conn, realm, coi, tpqc_resp_handler, NULL)) {
+ if (rc = tpqc_send_request(tpqc, conn, realm, coi, &tpqc_resp_handler, NULL)) {
/* Handle error */
printf("Error in tpqc_send_request, rc = &d.\n", rc);
return 1;
while (!tpqc_response_received);
/* Clean-up the TPQ client instance, and exit */
- tpqc_release(tpqc);
+ tpqc_destroy(tpqc);
return 0;
}
*
*/
-#include <stdio,h>
+#include <stdio.h>
+
#include <tpq.h>
-int tpqc_req_handler (TPQS_INSTANCE * tpqs,
+int tpqs_req_handler (TPQS_INSTANCE * tpqs,
TPQ_REQ *req,
TPQ_RESP *resp,
- void *cookie);
+ void *cookie)
{
printf("Request received! Realm = %s, COI = %s\n", req->realm->buf, req->coi->buf);
if (tpqs)
printf("Unexpected arguments, ignored.\n");
/* Create a TPQ server instance */
- tpqc = tpqc_create();
+ tpqs = tpqs_create();
/* Start-up the server, won't return unless there is an error. */
+ tpqs_start(tpqs, &tpqs_req_handler , NULL);
/* Clean-up the TPQ server instance */
- tpqs_release(tpqs);
+ tpqs_destroy(tpqs);
return 1;
}
*
*/
+#include <stdlib.h>
+#include <string.h>
+
#include <tpq.h>
+TPQ_NAME *tpq_new_name (char *name)
+{
+ TPQ_NAME *new;
+
+ if (new = malloc(sizeof(TPQ_NAME))) {
+ new->len = strlen(name);
+ if (new->buf = malloc(new->len+1)) {
+ strcpy(new->buf, name);
+ }
+ }
+ return new;
+}
+
TPQ_NAME *tpq_dup_name (TPQ_NAME *from)
{
- TPQ_NAME to;
+ TPQ_NAME *to;
- to.len = from->len;
- to.buf = malloc(to.len+1);
- strncpy(from->buf, to.buf, to.len);
- to.buf[to.len] = 0; /* NULL terminate for debugging printf()s */
+ if (to = malloc(sizeof(TPQ_NAME))) {
+ to->len = from->len;
+ if (to->buf = malloc(to->len+1)) {
+ strncpy(to->buf, from->buf, to->len);
+ to->buf[to->len] = 0; /* NULL terminate for debugging printf()s */
+ }
+ }
- return &to;
+ return to;
}
err = gsscon_connect(server, TPQ_PORT, &conn);
if (!err)
- err = fsscon_active_authenticate(conn, NULL, "trustquery", &gssContext);
+ err = gsscon_active_authenticate(conn, NULL, "trustquery", &gssContext);
if (!err)
return conn;
return tpqs;
}
-int tpqs_start (TPQS_INSTANCE *tpqs)
+int tpqs_start (TPQS_INSTANCE *tpqs,
+ TPQS_REQ_FUNC *req_handler,
+ void *cookie)
{
return 1;
#include <trust_router.h>
+int tpqs_req_handler (TPQS_INSTANCE * tpqs,
+ TPQ_REQ *req,
+ TPQ_RESP *resp,
+ void *cookie)
+{
+ printf("Request received! Realm = %s, COI = %s\n", req->realm->buf, req->coi->buf);
+ if (tpqs)
+ tpqs->req_count++;
+
+ if ((NULL == (resp->realm = tpq_dup_name(req->realm))) ||
+ (NULL == (resp->coi = tpq_dup_name(req->coi)))) {
+ printf ("Error in tpq_dup_name, not responding.\n");
+ return 1;
+ }
+
+ return 0;
+}
+
int main (int argc, const char *argv[])
{
TPQS_INSTANCE *tpqs = 0;
return 1;
}
- /* start the trust path query server, runs in its own thread */
- if (0 != (err = tpqs_start(tpqs))) {
+ /* start the trust path query server, won't return unless there is an error. */
+ if (0 != (err = tpqs_start(tpqs, &tpqs_req_handler, NULL))) {
printf ("Error starting Trust Path Query Server, err = %d.\n", err);
return err;
}
- /* start the trust router protocol engine -- TBD */
- while (1);
-
tpqs_destroy(tpqs);
return 0;
}