From 271b9e41606992c8d561e858e9582102b5861d7f Mon Sep 17 00:00:00 2001 From: Margaret Wasserman Date: Sun, 7 Apr 2013 19:23:03 -0400 Subject: [PATCH] Updates to trust router handlers, added ipaddr cmd line option to tids. --- README | 3 ++- include/tr_msg.h | 1 - include/trust_router/tid.h | 3 ++- tid/example/tids_main.c | 26 +++++++++++++++++--------- tr/tr_main.c | 2 +- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/README b/README index 8a084e4..4e92fb5 100644 --- a/README +++ b/README @@ -19,7 +19,7 @@ IN PROGRESS - TR TID request & response handlers - Check idp_realm APC membership in TR - Map a COI to an APC in TR (incl config & lookup code) IN PROGRESS - TIDS integration with freeradius server (Sam) -IN PROGRESS - TIDC integration with freeradius proxy (incl default comm config) +IN PROGRESS - TIDC integration with freeradius proxy (w/default comm config) - Handle per-request community configuration in AAA proxy - Resolve TBDs for error handling and memory deallocation @@ -30,6 +30,7 @@ TO-DO FOR FULL PILOT VERSION (~2 months after beta release) - Keep single connection open between AAA proxy & TR for TID requests - Normalize/configure logging for info msgs, warnings and errors (log4c) - Clean-up gsscon API and messages +- Figure out what to do about commented-out checks in gsscon_passive.c - Handle IPv6 addresses in TID req/resp (use getaddrinfo()) - Implement rp_permitted filters (incl. general filtering mechanism) - Add constraints to TID req in TR, store and use them in AAA Server diff --git a/include/tr_msg.h b/include/tr_msg.h index bfd0da7..dd99201 100644 --- a/include/tr_msg.h +++ b/include/tr_msg.h @@ -36,7 +36,6 @@ #define TR_MSG_H #include -#include #include enum msg_type { diff --git a/include/trust_router/tid.h b/include/trust_router/tid.h index caf02e7..b76a469 100644 --- a/include/trust_router/tid.h +++ b/include/trust_router/tid.h @@ -77,7 +77,7 @@ typedef void (TIDC_RESP_FUNC)(TIDC_INSTANCE *, TID_REQ *, TID_RESP *, void *); struct tid_req { struct tid_req *next_req; int conn; - gss_ctx_id_t *gssctx; + gss_ctx_id_t gssctx; int resp_rcvd; TR_NAME *rp_realm; TR_NAME *realm; @@ -100,6 +100,7 @@ typedef int (TIDS_REQ_FUNC)(TIDS_INSTANCE *, TID_REQ *, TID_RESP **, void *); struct tids_instance { int req_count; char *priv_key; + char *ipaddr; TIDS_REQ_FUNC *req_handler; void *cookie; }; diff --git a/tid/example/tids_main.c b/tid/example/tids_main.c index 729189d..9a78ef3 100644 --- a/tid/example/tids_main.c +++ b/tid/example/tids_main.c @@ -111,10 +111,7 @@ static int tids_req_handler (TIDS_INSTANCE * tids, return -1; } - /* Hard-code the IP Address in the response. If this were a AAA server, we'd expect - * this to be set by the Trust Router before calling us. - */ - if (0 == inet_aton("127.0.0.1", &((*resp)->servers->aaa_server_addr))) { + if (0 == inet_aton(tids->ipaddr, &((*resp)->servers->aaa_server_addr))) { printf("tids_req_handler(): inet_aton() failed.\n"); return -1; } @@ -162,15 +159,24 @@ int main (int argc, { TIDS_INSTANCE *tids; int rc = 0; + char *ipaddr = NULL; /* Parse command-line arguments */ - if (argc > 2) - printf("Unexpected arguments, ignored.\n"); + if (argc > 3) + printf("Usage: %s [ []]\n", argv[0]); - /*If we have a database, open and prepare*/ if (argc >= 2) { - if (SQLITE_OK != sqlite3_open(argv[1], &db)) { - printf("Error opening database\n"); + ipaddr = (char *)argv[1]; + } else { + ipaddr = "127.0.0.1"; + } + + /* TBD -- check that input is a valid IP address? */ + + /*If we have a database, open and prepare*/ + if (argc == 3) { + if (SQLITE_OK != sqlite3_open(argv[2], &db)) { + printf("Error opening database %s\n", argv[2]); exit(1); } sqlite3_prepare_v2(db, "insert into psk_keys (keyid, key) values(?, ?)", @@ -183,6 +189,8 @@ int main (int argc, return 1; } + tids->ipaddr = ipaddr; + /* Start-up the server, won't return unless there is an error. */ rc = tids_start(tids, &tids_req_handler , NULL); diff --git a/tr/tr_main.c b/tr/tr_main.c index 36f5a89..8d49f90 100644 --- a/tr/tr_main.c +++ b/tr/tr_main.c @@ -55,7 +55,7 @@ static void tr_tidc_resp_handler (TIDC_INSTANCE *tidc, req->resp_rcvd = 1; /* TBD -- handle concatentation of multiple responses to single req */ - tids_send_response(((TR_RESP_COOKIE *)resp_cookie)->tr->tids, ((TR_RESP_COOKIE *)resp_cookie)->orig_req->conn, ((TR_RESP_COOKIE *)resp_cookie)->orig_req->gssctx, resp); + tids_send_response(((TR_RESP_COOKIE *)resp_cookie)->tr->tids, ((TR_RESP_COOKIE *)resp_cookie)->orig_req->conn, &((TR_RESP_COOKIE *)resp_cookie)->orig_req->gssctx, resp); return; } -- 2.1.4