Merge branch 'master' of moonshot.suchdamage.org:/srv/git/trust_router
authorMargaret Wasserman <margaret@debian.(none)>
Mon, 25 Mar 2013 22:03:54 +0000 (18:03 -0400)
committerMargaret Wasserman <margaret@debian.(none)>
Mon, 25 Mar 2013 22:03:54 +0000 (18:03 -0400)
16 files changed:
Makefile.am
common/tr_dh.c
common/tr_msg.c
common/tr_name.c
gsscon/Makefile.am
include/tr.h
include/tr_dh.h
include/tr_msg.h
include/trust_router/tid.h [moved from include/tid.h with 80% similarity]
include/trust_router/tr_name.h [moved from include/tr_name.h with 92% similarity]
include/trust_router/tr_versioning.h [new file with mode: 0644]
tid/example/tidc_main.c
tid/example/tids_main.c
tid/tidc.c
tid/tids.c
tr/tr_main.c

index 746eaf1..4e501b1 100644 (file)
@@ -1,33 +1,41 @@
-bin_PROGRAMS= tr/tr tid/example/tidc tid/example/tids common/dh_test/dh_test
+bin_PROGRAMS= tr/tr tid/example/tidc tid/example/tids common/dh_test/tr_dh_test
 AM_CPPFLAGS=-I$(srcdir)/include
+AM_CFLAGS = -Wall -Werror=missing-prototypes -Werror=strict-prototypes -Wno-parentheses
 SUBDIRS = gsscon 
+common_srcs = common/tr_name.c \
+common/tr_msg.c \
+common/tr_dh.c
+
+lib_LTLIBRARIES = libtr_tid.la
 
 tr_tr_SOURCES = tr/tr_main.c \
-tid/tidc.c \
-tid/tids.c \
-common/tr_name.c \
-common/tr_msg.c \
-common/tr_dh.c \
 common/tr_config.c 
 
-tr_tr_LDADD = gsscon/libgsscon.la
+tr_tr_LDADD = gsscon/libgsscon.la libtr_tid.la
 
-tid_example_tidc_SOURCES = tid/example/tidc_main.c \
-tid/tidc.c \
-common/tr_name.c \
-common/tr_msg.c \
-common/tr_dh.c
+tid_example_tidc_SOURCES = tid/example/tidc_main.c 
 
-tid_example_tidc_LDADD = gsscon/libgsscon.la
+tid_example_tidc_LDADD = gsscon/libgsscon.la libtr_tid.la
 
-tid_example_tids_SOURCES = tid/example/tids_main.c \
-tid/tids.c \
-common/tr_name.c \
-common/tr_msg.c \
-common/tr_dh.c
+tid_example_tids_SOURCES = tid/example/tids_main.c 
 
-tid_example_tids_LDADD = gsscon/libgsscon.la
+tid_example_tids_LDADD = gsscon/libgsscon.la libtr_tid.la
 
-common_dh_test_dh_test_SOURCES = common/tr_dh.c \
+common_dh_test_tr_dh_test_SOURCES = common/tr_dh.c \
 common/dh_test/dh_test.c
 
+libtr_tid_la_SOURCES = tid/tids.c tid/tidc.c \
+$(common_srcs)
+
+libtr_tid_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
+libtr_tid_la_LIBADD = gsscon/libgsscon.la
+libtr_tid_la_LDFLAGS = $(AM_LDFLAGS) -version-info 0 -no-undefined
+
+pkginclude_HEADERS = include/trust_router/tid.h include/trust_router/tr_name.h \
+include/trust_router/tr_versioning.h
+
+noinst_HEADERS = include/gsscon.h include/tr_config.h \
+include/tr_msg.h \
+include/tr.h \
+include/tr_dh.h
+
index a6b5867..ab3a7a4 100644 (file)
@@ -33,6 +33,7 @@
  */
 
 #include <openssl/dh.h>
+#include <tr_dh.h>
 
 unsigned char tr_2048_dhprime[2048/8] = {
   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
index d3fc712..0554d5a 100644 (file)
@@ -37,8 +37,8 @@
 #include <jansson.h>
 
 #include <tr_msg.h>
-#include <tr_name.h>
-#include <tid.h>
+#include <trust_router/tr_name.h>
+#include <trust_router/tid.h>
 
 static json_t *tr_msg_encode_dh(DH *dh)
 {
@@ -98,7 +98,7 @@ static DH *tr_msg_decode_dh(json_t *jdh)
   return dh;
 }
 
-json_t *tr_msg_encode_tidreq(TID_REQ *req)
+static json_t * tr_msg_encode_tidreq(TID_REQ *req)
 {
   json_t *jreq = NULL;
   json_t *jstr = NULL;
@@ -122,7 +122,7 @@ json_t *tr_msg_encode_tidreq(TID_REQ *req)
   return jreq;
 }
 
-TID_REQ *tr_msg_decode_tidreq(json_t *jreq)
+static TID_REQ *tr_msg_decode_tidreq(json_t *jreq)
 {
   TID_REQ *treq = NULL;
   json_error_t rc;
@@ -169,7 +169,7 @@ TID_REQ *tr_msg_decode_tidreq(json_t *jreq)
   return treq;
 }
 
-json_t *tr_msg_encode_tidresp(TID_RESP *resp)
+static json_t * tr_msg_encode_tidresp(TID_RESP *resp)
 {
   json_t *jresp = NULL;
   json_t *jstr = NULL;
@@ -201,7 +201,7 @@ json_t *tr_msg_encode_tidresp(TID_RESP *resp)
   return jresp;
 }
 
-TID_RESP *tr_msg_decode_tidresp(json_t *jresp)
+static TID_RESP *tr_msg_decode_tidresp(json_t *jresp)
 {
   TID_RESP *tresp = NULL;
   json_error_t rc;
index b5e1526..62c3baa 100644 (file)
@@ -35,7 +35,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <tr_name.h>
+#include <trust_router/tr_name.h>
 
 TR_NAME *tr_new_name (char *name) 
 {
index f39b06e..0ffcb25 100644 (file)
@@ -1,4 +1,5 @@
 AM_CPPFLAGS=-I$(top_srcdir)/include
+AM_CFLAGS = -fvisibility=hidden
 
 noinst_LTLIBRARIES = libgsscon.la
 noinst_PROGRAMS=test/gsscon_client test/gsscon_server
index f7804d9..8548bd1 100644 (file)
@@ -36,9 +36,9 @@
 #define TR_H
 
 #include <tr_msg.h>
-#include <tr_name.h>
+#include <trust_router/tr_name.h>
 #include <tr_config.h>
-#include <tid.h>
+#include <trust_router/tid.h>
 
 #define TRUST_ROUTER_PORT      12308
 
index ef3f0a9..b027e83 100644 (file)
@@ -41,6 +41,6 @@
 DH *tr_create_dh_params(char *key, size_t len);
 DH *tr_create_matching_dh(char *key, size_t len, DH *in_dh);
 void tr_destroy_dh_params(DH *dh);
-int tr_compute_dh_key(char *buf, size_t buflen, BIGNUM *pub_key, DH *priv_dh);
+int tr_compute_dh_key(unsigned char *buf, size_t buflen, BIGNUM *pub_key, DH *priv_dh);
 
 #endif
index c30fe23..1ab2c72 100644 (file)
@@ -35,7 +35,7 @@
 #ifndef TR_MSG_H
 #define TR_MSG_H
 
-#include <tid.h>
+#include <trust_router/tid.h>
 #include <jansson.h>
 
 enum msg_type {
similarity index 80%
rename from include/tid.h
rename to include/trust_router/tid.h
index 69aa32a..2c37e18 100644 (file)
 #include <arpa/inet.h>
 #include <openssl/dh.h>
 
-#include <gsscon.h>
-#include <tr_name.h>
+#include <trust_router/tr_name.h>
+#include <trust_router/tr_versioning.h>
 
 #define TID_PORT       12309
 
+typedef struct gss_ctx_id_struct *gss_ctx_id_t;
+
 typedef struct tid_req {
   struct tid_req *next_req;
   int conn;
@@ -89,13 +91,13 @@ typedef struct tids_instance {
 typedef void (TIDC_RESP_FUNC)(TIDC_INSTANCE *, TID_RESP *, void *);
 typedef int (TIDS_REQ_FUNC)(TIDS_INSTANCE *, TID_REQ *, TID_RESP *, void *);
 
-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);
+TR_EXPORT TIDC_INSTANCE *tidc_create (void);
+TR_EXPORT int tidc_open_connection (TIDC_INSTANCE *tidc, char *server, gss_ctx_id_t *gssctx);
+TR_EXPORT 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);
+TR_EXPORT void tidc_destroy (TIDC_INSTANCE *tidc);
 
-TIDS_INSTANCE *tids_create ();
-int tids_start (TIDS_INSTANCE *tids, TIDS_REQ_FUNC *req_handler, void *cookie);
-void tids_destroy (TIDS_INSTANCE *tids);
+TR_EXPORT TIDS_INSTANCE *tids_create (void);
+TR_EXPORT int tids_start (TIDS_INSTANCE *tids, TIDS_REQ_FUNC *req_handler, void *cookie);
+TR_EXPORT void tids_destroy (TIDS_INSTANCE *tids);
 
 #endif
similarity index 92%
rename from include/tr_name.h
rename to include/trust_router/tr_name.h
index 3f610bb..21c6835 100644 (file)
 
 #ifndef TR_NAME_H
 #define TR_NAME_H
+#include <trust_router/tr_versioning.h>
 
 typedef struct tr__name {
   char *buf;
   int len;
 } TR_NAME;
 
-TR_NAME *tr_new_name (char *name);
-TR_NAME *tr_dup_name (TR_NAME *from);
+TR_EXPORT TR_NAME *tr_new_name (char *name);
+TR_EXPORT TR_NAME *tr_dup_name (TR_NAME *from);
 
 #endif
diff --git a/include/trust_router/tr_versioning.h b/include/trust_router/tr_versioning.h
new file mode 100644 (file)
index 0000000..7c3bfd5
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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 TR_VERSIONING_H
+#define TR_VERSIONING_H
+
+#define TR_EXPORT __attribute__((visibility("default")))
+
+#endif /*TR_VERSIONING_h*/
index 9f2943e..b3da638 100644 (file)
 #include <stdio.h>
 
 #include <gsscon.h>
-#include <tid.h>
+#include <trust_router/tid.h>
 
 static int tidc_response_received = 0;
 
-void tidc_print_usage (const char *name)
+void static tidc_print_usage (const char *name)
 {
   printf("Usage: %s <server> <RP-realm> <target-realm> <community>\n", name);
 }
 
-void tidc_resp_handler (TIDC_INSTANCE * tidc, 
+static void tidc_resp_handler (TIDC_INSTANCE * tidc, 
                        TID_RESP *resp, 
                        void *cookie) 
 {
index 3963233..26bb10e 100644 (file)
@@ -34,9 +34,9 @@
 
 #include <stdio.h>
 
-#include <tid.h>
+#include <trust_router/tid.h>
 
-int tids_req_handler (TIDS_INSTANCE * tids,
+static int tids_req_handler (TIDS_INSTANCE * tids,
                      TID_REQ *req, 
                      TID_RESP *resp,
                      void *cookie)
index deff4ed..4e94990 100644 (file)
@@ -38,8 +38,9 @@
 
 #include <gsscon.h>
 #include <tr_dh.h>
-#include <tid.h>
+#include <trust_router/tid.h>
 #include <tr_msg.h>
+#include <gsscon.h>
 
 /* char tmp_key[32] = 
   {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 
@@ -161,7 +162,7 @@ int tidc_send_request (TIDC_INSTANCE *tidc,
     return -1;
   }
 
-  fprintf(stdout, "Response Received, %d bytes.\n", resp_buflen);
+  fprintf(stdout, "Response Received, %u bytes.\n", (unsigned) resp_buflen);
 
   /* Parse response -- TBD */
 
index 7b7d01f..f9d20b2 100644 (file)
@@ -41,7 +41,8 @@
 #include <jansson.h>
 
 #include <gsscon.h>
-#include <tid.h>
+#include <trust_router/tid.h>
+
 
 static int tids_listen (int port) 
 {
@@ -103,7 +104,7 @@ static int tids_read_request (int conn, gss_ctx_id_t *gssctx, TID_REQ *req)
     return -1;
   }
 
-  fprintf(stdout, "Request Received, %d bytes.\n", buflen);
+  fprintf(stdout, "Request Received, %u bytes.\n", (unsigned) buflen);
 
   /* Parse request -- TBD */
 
@@ -202,7 +203,7 @@ static void tids_handle_connection (int conn)
   return;
 }
 
-TIDS_INSTANCE *tids_create ()
+TIDS_INSTANCE *tids_create (void)
 {
   TIDS_INSTANCE *tids = 0;
   if (tids = malloc(sizeof(TIDS_INSTANCE)))
index 8625383..90bfd13 100644 (file)
@@ -36,7 +36,7 @@
 
 #include <tr.h>
 
-int tids_req_handler (TIDS_INSTANCE * tids,
+int static tids_req_handler (TIDS_INSTANCE * tids,
                      TID_REQ *req, 
                      TID_RESP *resp,
                      void *cookie)