goto cleanup;
talloc_free(s); s=NULL;
+ trp_inforec_set_next_hop(rec, NULL); /* make sure this is null (filled in later) */
+
rc=tr_msg_get_json_integer(jrecord, "metric", &num);
if ((rc != TRP_SUCCESS) || (TRP_SUCCESS!=trp_inforec_set_metric(rec,num)))
goto cleanup;
TR_NAME *comm;
TR_NAME *realm;
TR_NAME *trust_router;
+ TR_NAME *next_hop;
unsigned int metric;
unsigned int interval;
} TRP_INFOREC_ROUTE;
TRP_CONNECTION *next;
pthread_t *thread; /* thread servicing this connection */
int fd;
+ TR_NAME *peer; /* who is this a connection to? */
TR_NAME *gssname;
gss_ctx_id_t *gssctx;
TRP_CONNECTION_STATUS status;
conn->fd=fd;
}
+TR_NAME *trp_connection_get_peer(TRP_CONNECTION *conn)
+{
+ return conn->peer;
+}
+
+void trp_connection_set_peer(TRP_CONNECTION *conn, TR_NAME *peer)
+{
+ conn->peer=peer;
+}
+
TR_NAME *trp_connection_get_gssname(TRP_CONNECTION *conn)
{
return conn->gssname;
if ((trp_connection_get_status(conn)!=TRP_CONNECTION_DOWN)
&& (trp_connection_get_fd(conn)!=-1))
close(trp_connection_get_fd(conn));
+ if (conn->peer!=NULL)
+ tr_free_name(conn->peer);
if (conn->gssname!=NULL)
tr_free_name(conn->gssname);
return 0;
if (new_conn != NULL) {
trp_connection_set_next(new_conn, NULL);
trp_connection_set_fd(new_conn, -1);
+ trp_connection_set_peer(new_conn, NULL);
trp_connection_set_gssname(new_conn, NULL);
trp_connection_mutex_init(new_conn);
trp_connection_set_status(new_conn, TRP_CONNECTION_DOWN);
return TRP_ERROR;
} else {
trp_connection_set_fd(conn, fd);
+ trp_connection_set_peer(conn, tr_new_name(server));
trp_connection_set_status(conn, TRP_CONNECTION_UP);
return TRP_SUCCESS;
}
body->trust_router=NULL;
tr_debug("trp_inforec_route_destructor: freed trust_router");
}
+ if (body->next_hop != NULL) {
+ tr_free_name(body->next_hop);
+ body->hop=NULL;
+ tr_debug("trp_inforec_route_destructor: freed next_hop");
+ }
return 0;
}
new_rec->comm=NULL;
new_rec->realm=NULL;
new_rec->trust_router=NULL;
+ new_rec->next_hop=NULL;
new_rec->metric=TRP_METRIC_INFINITY;
new_rec->interval=0;
talloc_set_destructor((void *)new_rec, trp_inforec_route_destructor);
return TRP_ERROR;
}
+TR_NAME *trp_inforec_get_next_hop(TRP_INFOREC *rec)
+{
+ switch (rec->type) {
+ case TRP_INFOREC_TYPE_ROUTE:
+ if (rec->data.route!=NULL)
+ return rec->data.route->next_hop;
+ break;
+ default:
+ break;
+ }
+ return NULL;
+}
+
+TRP_RC trp_inforec_set_next_hop(TRP_INFOREC *rec, TR_NAME *next_hop)
+{
+ switch (rec->type) {
+ case TRP_INFOREC_TYPE_ROUTE:
+ if (rec->data.route!=NULL) {
+ rec->data.route->next_hop=next_hop;
+ return TRP_SUCCESS;
+ }
+ break;
+ default:
+ break;
+ }
+ return TRP_ERROR;
+}
+
unsigned int trp_inforec_get_metric(TRP_INFOREC *rec)
{
switch (rec->type) {
free(buf);
if (*msg==NULL)
return TRP_NOPARSE;
- else
- return TRP_SUCCESS;
+
+ /* fill in the next hop as the peer who just sent this to us */
+ trp_inforec_set_next_hop(*msg, trp_connection_get_peer(conn));
+ return TRP_SUCCESS;
}
int trps_get_listener(TRPS_INSTANCE *trps,