common/tr_debug.c \
common/tr_util.c
-tid_srcs = trp/trpc.c \
-tid/tid_resp.c \
+tid_srcs = tid/tid_resp.c \
tid/tid_req.c \
tid/tids.c \
tid/tidc.c
trp/trp_req.c \
trp/trp_conn.c \
trp/trps.c \
+trp/trpc.c \
trp/trp_ptable.c \
trp/trp_rtable.c
check_PROGRAMS = common/t_constraint
TESTS = common/t_constraint
-#lib_LTLIBRARIES = libtr_tid.la libtr_trp.la
-
common_t_constraint_SOURCES = common/t_constraint.c
common_t_constraint_CPPFLAGS = $(AM_CPPFLAGS) -DTESTS=\"$(srcdir)/common/tests.json\"
-common_t_constraint_LDADD = gsscon/libgsscon.la libtr_tid.la
+common_t_constraint_LDADD = gsscon/libgsscon.la
tr_trust_router_SOURCES = $(common_srcs) \
tr/tr_main.c \
tr_trust_router_CFLAGS = $(AM_CFLAGS) -pthread -v -da -Q
tr_trust_router_LDFLAGS = $(AM_LDFLAGS) -levent_pthreads
-#tr_trust_router_LDADD = gsscon/libgsscon.la libtr_tid.la libtr_trp.la $(GLIB_LIBS)
tr_trust_router_LDADD = gsscon/libgsscon.la $(GLIB_LIBS)
tr_trpc_SOURCES = $(common_srcs) \
tr/trpc_main.c \
+common/tr_config.c \
+common/tr_idp.c \
+common/tr_apc.c \
+common/tr_comm.c \
+common/tr_filter.c \
common/tr_rp.c \
common/tr_mq.c \
tr/tr_trp.c \
$(trp_srcs) \
$(tid_srcs)
-#tr_trpc_LDADD = gsscon/libgsscon.la libtr_tid.la libtr_trp.la $(GLIB_LIBS)
tr_trpc_LDADD = gsscon/libgsscon.la $(GLIB_LIBS)
trp_msgtst_SOURCES = trp/msgtst.c \
trp/trp_req.c \
tid/tid_req.c \
tid/tid_resp.c \
-common/tr_msg.c \
-common/tr_name.c \
-common/tr_gss.c \
+trp/trp_ptable.c \
common/tr_idp.c \
common/tr_apc.c \
common/tr_comm.c \
common/tr_filter.c \
common/tr_rp.c \
common/tr_config.c \
-common/tr_debug.c
+$(common_srcs)
trp_msgtst_LDADD = $(GLIB_LIBS)
trp_test_ptbl_test_LDADD = gsscon/libgsscon.la $(GLIB_LIBS)
-tid_example_tidc_SOURCES = tid/example/tidc_main.c
+tid_example_tidc_SOURCES = tid/example/tidc_main.c \
+$(common_srcs) \
+$(tid_srcs) \
+$(trp_srcs) \
+common/tr_mq.c
-#tid_example_tidc_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS)
tid_example_tidc_LDADD = gsscon/libgsscon.la $(GLIB_LIBS)
-tid_example_tids_SOURCES = tid/example/tids_main.c
+tid_example_tids_SOURCES = tid/example/tids_main.c \
+$(common_srcs) \
+$(tid_srcs) \
+$(trp_srcs) \
+common/tr_mq.c
-#tid_example_tids_LDADD = gsscon/libgsscon.la libtr_tid.la $(GLIB_LIBS)
tid_example_tids_LDADD = gsscon/libgsscon.la $(GLIB_LIBS)
common_dh_test_tr_dh_test_SOURCES = common/tr_dh.c \
common/tr_rp.c \
common/tr_idp.c \
common/tr_filter.c \
-common/tr_constraint.c \
-common/tr_debug.c \
-common/tr_name.c \
-common/tr_gss.c \
common/tr_apc.c \
common/tr_comm.c \
-tid/tid_req.c \
+common/tr_mq.c \
+$(common_srcs) \
+$(tid_srcs) \
+$(trp_srcs) \
common/cfg_test/cfg_test.c
+common_cfg_test_cfg_test_LDADD = gsscon/libgsscon.la $(GLIB_LIBS)
common_cfg_test_cfg_test_CFLAGS = -pthread
common_cfg_test_cfg_test_LDFLAGS = $(AM_LDFLAGS) -ltalloc
common_mq_test_thread_test_CFLAGS = -pthread
common_mq_test_thread_test_LDFLAGS = $(AM_LDFLAGS) -ltalloc
-# libtr_tid_la_SOURCES = tid/tids.c tid/tidc.c tid/tid_req.c tid/tid_resp.c \
-# $(common_srcs)
-#
-# libtr_tid_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
-# libtr_tid_la_LIBADD = gsscon/libgsscon.la $(GLIB_LIBS)
-# libtr_tid_la_LDFLAGS = $(AM_LDFLAGS) -version-info 2 -no-undefined
-#
-# libtr_trp_la_SOURCES = trp/trps.c trp/trpc.c trp/trp_req.c trp/trp_upd.c trp/trp_conn.c \
-# $(common_srcs)
-#
-# libtr_trp_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
-# libtr_trp_la_LIBADD = gsscon/libgsscon.la $(GLIB_LIBS)
-# libtr_trp_la_LDFLAGS = $(AM_LDFLAGS) -version-info 2 -no-undefined
-
pkginclude_HEADERS = include/trust_router/tid.h include/trust_router/tr_name.h \
include/tr_debug.h \
include/trust_router/tr_dh.h \
assert(cfg->rp_clients!=NULL);
assert(cfg->rp_clients->next==NULL);
assert(cfg->rp_clients->comm_next==NULL);
+ /* need to update next test to use TR_GSS_NAMES structure */
+#if 0
for (ii=1; ii<TR_MAX_GSS_NAMES; ii++)
assert(cfg->rp_clients->gss_names[ii]==NULL);
assert(cfg->rp_clients->gss_names[0]!=NULL);
name=tr_new_name("gss@example.com");
assert(tr_name_cmp(name, cfg->rp_clients->gss_names[0])==0);
+#endif
return 0;
}
mq->notify_cb=notify_cb;
mq->notify_cb_arg=mq_name;
- msg1=tr_mq_msg_new(NULL);
- asprintf((char **)&(msg1->p), "First message.\n");
+ msg1=tr_mq_msg_new(NULL,"Message 1", TR_MQ_PRIO_NORMAL);
+ asprintf((char **)&(msg2->p), "First message.\n");
msg1->p_free=free;
- tr_mq_append(mq, msg1);
+ tr_mq_add(mq, msg1);
assert(mq->head==msg1);
assert(mq->tail==msg1);
assert(msg1->next==NULL);
- msg2=tr_mq_msg_new(NULL);
+ msg2=tr_mq_msg_new(NULL, "Message 2", TR_MQ_PRIO_NORMAL);
asprintf((char **)&(msg2->p), "Second message.\n");
msg2->p_free=free;
- tr_mq_append(mq, msg2);
+ tr_mq_add(mq, msg2);
assert(mq->head==msg1);
assert(msg1->next==msg2);
assert(mq->tail==msg2);
} else
printf("no message to pop\n");
- msg3=tr_mq_msg_new(NULL);
+ msg3=tr_mq_msg_new(NULL, "Message 3", TR_MQ_PRIO_NORMAL);
asprintf((char **)&(msg3->p), "Third message.\n");
msg3->p_free=free;
- tr_mq_append(mq, msg3);
+ tr_mq_add(mq, msg3);
assert(mq->head==msg2);
assert(mq->tail==msg3);
assert(msg2->next==msg3);
} else
printf("no message to pop\n");
- msg4=tr_mq_msg_new(NULL);
+ msg4=tr_mq_msg_new(NULL, "Message 4", TR_MQ_PRIO_NORMAL);
asprintf((char **)&(msg4->p), "Fourth message.\n");
msg4->p_free=free;
- tr_mq_append(mq, msg4);
+ tr_mq_add(mq, msg4);
assert(mq->head==msg4);
assert(mq->tail==msg4);
assert(msg4->next==NULL);
TR_MQ_MSG *make_msg(label, n)
{
TR_MQ_MSG *msg=NULL;
- msg=tr_mq_msg_new(NULL);
+ msg=tr_mq_msg_new(NULL, "Message", TR_MQ_PRIO_NORMAL);
asprintf((char **)&(msg->p), "%s: %d messages to go...", label, n);
msg->p_free=free;
return msg;
while (n_msgs>=0) {
usleep(msg_dly);
- tr_mq_append(mq, make_msg(label, n_msgs));
+ tr_mq_add(mq, make_msg(label, n_msgs));
n_msgs--;
}
- tr_mq_append(mq, make_msg(label, -9999));
+ tr_mq_add(mq, make_msg(label, -9999));
return NULL;
}
#include <talloc.h>
+#include <trust_router/tr_name.h>
+#include <trust_router/tr_versioning.h>
+
#define TRP_PORT 12308
#define TRP_METRIC_INFINITY 0xFFFF
#define TRP_METRIC_INVALID 0xFFFFFFFF
#include <talloc.h>
#include <assert.h>
+#include <tr_gss.h>
#include <trp_internal.h>
#include <trp_ptable.h>
+
+/* Can't do the updates test because trps_select_updates_for_peer() is now static */
+#define VERIFY_UPDATES 0
+
struct peer_entry {
char *server;
unsigned int port;
gssname=tr_new_name(s);
free(s);
assert(gssname!=NULL);
- assert(!tr_name_cmp(trp_peer_get_gssname(peer), gssname));
+ assert(tr_gss_names_matches(trp_peer_get_gss_names(peer), gssname));
tr_free_name(gssname);
peer=peer->next;
}
};
static size_t n_routes=sizeof(route_table)/sizeof(route_table[0]);
+#if VERIFY_UPDATES
/* These are the correct updates to select from the above route table for each peer.
* The rule is: send selected route unless it is through that peer, otherwise send
* the best (lowest metric) alternative route.
{NULL}
}
};
+#endif /* VERIFY_UPDATES */
static void populate_rtable(TRPS_INSTANCE *trps)
{
int i;
- TRP_RENTRY *new;
+ TRP_ROUTE *new;
for (i=0; i<n_routes; i++) {
- new=trp_rentry_new(NULL);
+ new=trp_route_new(NULL);
assert(new!=NULL);
- trp_rentry_set_apc(new, tr_new_name(route_table[i].apc));
- trp_rentry_set_realm(new, tr_new_name(route_table[i].realm));
- trp_rentry_set_peer(new, tr_new_name(route_table[i].peer));
- trp_rentry_set_metric(new, route_table[i].metric);
- trp_rentry_set_trust_router(new, tr_new_name(route_table[i].trust_router));
- trp_rentry_set_next_hop(new, tr_new_name(route_table[i].next_hop));
- trp_rentry_set_selected(new, route_table[i].selected);
- trp_rentry_set_interval(new, route_table[i].interval);
+ trp_route_set_comm(new, tr_new_name(route_table[i].apc));
+ trp_route_set_realm(new, tr_new_name(route_table[i].realm));
+ trp_route_set_peer(new, tr_new_name(route_table[i].peer));
+ trp_route_set_metric(new, route_table[i].metric);
+ trp_route_set_trust_router(new, tr_new_name(route_table[i].trust_router));
+ trp_route_set_next_hop(new, tr_new_name(route_table[i].next_hop));
+ trp_route_set_selected(new, route_table[i].selected);
+ trp_route_set_interval(new, route_table[i].interval);
/* do not set expiry */
trp_rtable_add(trps->rtable, new);
new=NULL;
}
}
-static void verify_update(TRP_RENTRY **updates, size_t n_updates, struct route_data *expected)
+#if VERIFY_UPDATES
+static void verify_update(TRP_ROUTE **updates, size_t n_updates, struct route_data *expected)
{
int ii,jj;
int found;
for(jj=0; jj<n_updates; jj++) {
found=0;
for (ii=0; expected[ii].apc!=NULL; ii++) {
- if ((0==strcmp(expected[ii].apc, updates[jj]->apc->buf))
+ if ((0==strcmp(expected[ii].apc, updates[jj]->comm->buf))
&&(0==strcmp(expected[ii].realm, updates[jj]->realm->buf))
&&(0==strcmp(expected[ii].peer, updates[jj]->peer->buf))
&&(expected[ii].metric==updates[jj]->metric)
}
}
if (!found) {
- printf("missing:\n%s\n", trp_rentry_to_str(NULL,updates[jj], " | "));
+ printf("missing:\n%s\n", trp_route_to_str(NULL,updates[jj], " | "));
assert(0);
}
}
static void verify_update_selection(TRPS_INSTANCE *trps)
{
int ii;
- TRP_RENTRY **updates=NULL;
+ TRP_ROUTE **updates=NULL;
size_t n_updates;
TR_NAME *gssname=NULL;
char *s;
assert(0<asprintf(&s, "trustrouter@%s", peer_data[ii].server));
assert(NULL!=(gssname=tr_new_name(s)));
free(s);
+
updates=trps_select_updates_for_peer(NULL, trps, gssname, &n_updates);
tr_free_name(gssname);
verify_update(updates, n_updates, update_table[ii]);
talloc_free(updates);
}
}
+#endif /* VERIFY_UPDATES */
int main(void)
{
s=trp_rtable_to_str(main_ctx, trps->rtable, " | ", NULL);
printf("Route Table:\n%s---\n", s);
+#if VERIFY_UPDATES
printf("\nVerifying route update selection...\n");
verify_update_selection(trps);
+#endif /* VERIFY_UPDATES */
printf("\nDone\n\n");
talloc_report_full(main_ctx, stderr);
static void populate_rtable(TRP_RTABLE *table, unsigned int (*metric)(size_t, size_t, size_t))
{
- TRP_RENTRY *entry=NULL;
+ TRP_ROUTE *entry=NULL;
size_t ii=0, jj=0, kk=0;
struct timespec ts={0,0};
for (ii=0; ii<n_apc; ii++) {
for (jj=0; jj<n_realm; jj++) {
for (kk=0; kk<n_peer; kk++) {
- entry=trp_rentry_new(NULL);
- trp_rentry_set_apc(entry, tr_new_name(apc[ii]));
- trp_rentry_set_realm(entry, tr_new_name(realm[jj]));
- trp_rentry_set_trust_router(entry, tr_new_name(realm[jj]));
- trp_rentry_set_peer(entry, tr_new_name(peer[kk]));
- trp_rentry_set_metric(entry, metric(ii,jj,kk));
- trp_rentry_set_next_hop(entry, tr_new_name(peer[kk]));
+ entry=trp_route_new(NULL);
+ trp_route_set_comm(entry, tr_new_name(apc[ii]));
+ trp_route_set_realm(entry, tr_new_name(realm[jj]));
+ trp_route_set_trust_router(entry, tr_new_name(realm[jj]));
+ trp_route_set_peer(entry, tr_new_name(peer[kk]));
+ trp_route_set_metric(entry, metric(ii,jj,kk));
+ trp_route_set_next_hop(entry, tr_new_name(peer[kk]));
ts=(struct timespec){jj+1,ii+kk+1};
- trp_rentry_set_expiry(entry, &ts);
+ trp_route_set_expiry(entry, &ts);
trp_rtable_add(table, entry);
entry=NULL; /* entry belongs to the table now */
}
static void verify_rtable(TRP_RTABLE *table, unsigned int (*metric)(size_t, size_t, size_t))
{
- TRP_RENTRY *entry=NULL;
+ TRP_ROUTE *entry=NULL;
size_t ii=0, jj=0, kk=0;
size_t len=0;
TR_NAME *apc_n, *realm_n, *peer_n;
assert(entry!=NULL);
- len=trp_rentry_get_apc(entry)->len;
+ len=trp_route_get_comm(entry)->len;
assert(len==strlen(apc[ii]));
- assert(0==strncmp(trp_rentry_get_apc(entry)->buf, apc[ii], len));
+ assert(0==strncmp(trp_route_get_comm(entry)->buf, apc[ii], len));
- len=trp_rentry_get_realm(entry)->len;
+ len=trp_route_get_realm(entry)->len;
assert(len==strlen(realm[jj]));
- assert(0==strncmp(trp_rentry_get_realm(entry)->buf, realm[jj], len));
+ assert(0==strncmp(trp_route_get_realm(entry)->buf, realm[jj], len));
- len=trp_rentry_get_peer(entry)->len;
+ len=trp_route_get_peer(entry)->len;
assert(len==strlen(peer[kk]));
- assert(0==strncmp(trp_rentry_get_peer(entry)->buf, peer[kk], len));
+ assert(0==strncmp(trp_route_get_peer(entry)->buf, peer[kk], len));
- len=trp_rentry_get_trust_router(entry)->len;
+ len=trp_route_get_trust_router(entry)->len;
assert(len==strlen(realm[jj]));
- assert(0==strncmp(trp_rentry_get_trust_router(entry)->buf, realm[jj], len));
+ assert(0==strncmp(trp_route_get_trust_router(entry)->buf, realm[jj], len));
- assert(trp_rentry_get_metric(entry)==metric(ii,jj,kk));
+ assert(trp_route_get_metric(entry)==metric(ii,jj,kk));
- len=trp_rentry_get_next_hop(entry)->len;
+ len=trp_route_get_next_hop(entry)->len;
assert(len==strlen(peer[kk]));
- assert(0==strncmp(trp_rentry_get_next_hop(entry)->buf, peer[kk], len));
+ assert(0==strncmp(trp_route_get_next_hop(entry)->buf, peer[kk], len));
- assert(trp_rentry_get_selected(entry)==0);
- assert(trp_rentry_get_expiry(entry)->tv_sec==jj+1);
- assert(trp_rentry_get_expiry(entry)->tv_nsec==ii+kk+1);
+ assert(trp_route_is_selected(entry)==0);
+ assert(trp_route_get_expiry(entry)->tv_sec==jj+1);
+ assert(trp_route_get_expiry(entry)->tv_nsec==ii+kk+1);
printf("{%s %s %s} entry OK!\n", apc[ii], realm[jj], peer[kk]);
}
static void verify_apc_list(TRP_RTABLE *table)
{
size_t n=0;
- TR_NAME **apcs_found=trp_rtable_get_apcs(table, &n);
+ TR_NAME **apcs_found=trp_rtable_get_comms(table, &n);
assert(n==n_apc);
while(n--)
assert(1==is_in(apcs_found[n]->buf, apc, n_apc));
for (ii=0; ii<n_apc; ii++) {
apc_n=tr_new_name(apc[ii]);
- realms_found=trp_rtable_get_apc_realms(table, apc_n, &n);
+ realms_found=trp_rtable_get_comm_realms(table, apc_n, &n);
tr_free_name(apc_n);
assert(n==n_realm);
while (n--)
static void verify_get_apc_entries(TRP_RTABLE *table)
{
size_t n=0, ii=0;
- TRP_RENTRY **apc_entries=NULL;
+ TRP_ROUTE **apc_entries=NULL;
TR_NAME *apc_n=NULL;
for (ii=0; ii<n_apc; ii++) {
apc_n=tr_new_name(apc[ii]);
- apc_entries=trp_rtable_get_apc_entries(table, apc_n, &n);
+ apc_entries=trp_rtable_get_comm_entries(table, apc_n, &n);
tr_free_name(apc_n);
assert(n==n_realm*n_peer);
while (n--) {
- assert(0==strncmp(trp_rentry_get_apc(apc_entries[n])->buf,
+ assert(0==strncmp(trp_route_get_comm(apc_entries[n])->buf,
apc[ii],
- trp_rentry_get_apc(apc_entries[n])->len));
- assert(1==is_in(trp_rentry_get_realm(apc_entries[n])->buf, realm, n_realm));
- assert(1==is_in(trp_rentry_get_peer(apc_entries[n])->buf, peer, n_peer));
+ trp_route_get_comm(apc_entries[n])->len));
+ assert(1==is_in(trp_route_get_realm(apc_entries[n])->buf, realm, n_realm));
+ assert(1==is_in(trp_route_get_peer(apc_entries[n])->buf, peer, n_peer));
}
printf("APC %s ok!\n", apc[ii]);
talloc_free(apc_entries);
static void verify_get_realm_entries(TRP_RTABLE *table)
{
size_t n=0, ii=0, jj=0;
- TRP_RENTRY **realm_entries=NULL;
+ TRP_ROUTE **realm_entries=NULL;
TR_NAME *apc_n=NULL, *realm_n=NULL;
for (ii=0; ii<n_apc; ii++) {
tr_free_name(realm_n);
assert(n==n_peer);
while (n--) {
- assert(0==strncmp(trp_rentry_get_apc(realm_entries[n])->buf,
+ assert(0==strncmp(trp_route_get_comm(realm_entries[n])->buf,
apc[ii],
- trp_rentry_get_apc(realm_entries[n])->len));
- assert(0==strncmp(trp_rentry_get_realm(realm_entries[n])->buf,
+ trp_route_get_comm(realm_entries[n])->len));
+ assert(0==strncmp(trp_route_get_realm(realm_entries[n])->buf,
realm[jj],
- trp_rentry_get_realm(realm_entries[n])->len));
- assert(1==is_in(trp_rentry_get_peer(realm_entries[n])->buf, peer, n_peer));
+ trp_route_get_realm(realm_entries[n])->len));
+ assert(1==is_in(trp_route_get_peer(realm_entries[n])->buf, peer, n_peer));
}
printf("APC %s realm %s ok!\n", apc[ii], realm[jj]);
talloc_free(realm_entries);
static void update_metric(TRP_RTABLE *table, unsigned int (*new_metric)(size_t, size_t, size_t))
{
- TRP_RENTRY **entries=NULL;
+ TRP_ROUTE **entries=NULL;
size_t n=0, ii=0,jj=0,kk=0;
entries=trp_rtable_get_entries(table, &n);
while (n--) {
- ii=get_index(trp_rentry_get_apc(entries[n])->buf, apc, n_apc);
- jj=get_index(trp_rentry_get_realm(entries[n])->buf, realm, n_realm);
- kk=get_index(trp_rentry_get_peer(entries[n])->buf, peer, n_peer);
- trp_rentry_set_metric(entries[n],
+ ii=get_index(trp_route_get_comm(entries[n])->buf, apc, n_apc);
+ jj=get_index(trp_route_get_realm(entries[n])->buf, realm, n_realm);
+ kk=get_index(trp_route_get_peer(entries[n])->buf, peer, n_peer);
+ trp_route_set_metric(entries[n],
new_metric(ii,jj,kk));
}
talloc_free(entries);
size_t n=trp_rtable_size(table);
size_t ii,jj,kk;
TR_NAME *apc_n, *realm_n, *peer_n;
- TRP_RENTRY *entry=NULL;
+ TRP_ROUTE *entry=NULL;
for (ii=0; ii<n_apc; ii++) {
for (jj=0; jj<n_realm; jj++) {