Use accessor functions for TRP objects.
[trust_router.git] / include / trp_internal.h
index 2557ddc..d951012 100644 (file)
@@ -5,21 +5,82 @@
 
 #include <gsscon.h>
 #include <trust_router/tr_dh.h>
+#include <trust_router/trp.h>
+
+/* info records */
+typedef enum trp_inforec_type {
+  TRP_INFOREC_TYPE_UNKNOWN=0, /* conveniently, JSON parser returns 0 if a non-integer number is specified */
+  TRP_INFOREC_TYPE_ROUTE,
+  TRP_INFOREC_TYPE_COMMUNITY, /* not yet implemented (2016-06-14) */
+} TRP_INFOREC_TYPE;
+
+/* TRP update record types */
+typedef struct trp_inforec_route {
+  TR_NAME *comm;
+  TR_NAME *realm;
+  TR_NAME *trust_router;
+  unsigned int metric;
+  unsigned int interval;
+} TRP_INFOREC_ROUTE;
+
+/* TODO: define struct trp_msg_info_community */
+
+typedef union trp_inforec_data {
+  TRP_INFOREC_ROUTE *route;
+  /* TRP_INFOREC_COMM *comm; */
+} TRP_INFOREC_DATA;
+
+typedef struct trp_inforec TRP_INFOREC;
+struct trp_inforec {
+  TRP_INFOREC *next;
+  TRP_INFOREC_TYPE type;
+  TRP_INFOREC_DATA data; /* contains pointer to one of the record types */
+};
 
-#define TRP_PORT 12310
+struct trp_update {
+  TRP_INFOREC *records;
+};
 
-typedef struct trp_req {
-  int msg;
-} TRP_REQ;
+struct trp_req {
+  TR_NAME *comm;
+  TR_NAME *realm;
+};
 
-typedef struct trp_resp {
-  int msg;
-} TRP_RESP;
+TRP_UPD *trp_upd_new(TALLOC_CTX *mem_ctx);
+void trp_upd_free(TRP_UPD *update);
+TRP_INFOREC *trp_upd_get_inforec(TRP_UPD *upd);
+void trp_upd_set_inforec(TRP_UPD *upd, TRP_INFOREC *rec);
+TRP_INFOREC *trp_inforec_new(TALLOC_CTX *mem_ctx, TRP_INFOREC_TYPE type);
+void trp_inforec_free(TRP_INFOREC *rec);
+TRP_INFOREC *trp_inforec_get_next(TRP_INFOREC *rec);
+void trp_inforec_set_next(TRP_INFOREC *rec, TRP_INFOREC *next_rec);
+TRP_INFOREC_TYPE trp_inforec_get_type(TRP_INFOREC *rec);
+void trp_inforec_set_type(TRP_INFOREC *rec, TRP_INFOREC_TYPE type);
+TR_NAME *trp_inforec_get_comm(TRP_INFOREC *rec);
+TRP_RC trp_inforec_set_comm(TRP_INFOREC *rec, TR_NAME *comm);
+TR_NAME *trp_inforec_get_realm(TRP_INFOREC *rec);
+TRP_RC trp_inforec_set_realm(TRP_INFOREC *rec, TR_NAME *realm);
+TR_NAME *trp_inforec_get_trust_router(TRP_INFOREC *rec);
+TRP_RC trp_inforec_set_trust_router(TRP_INFOREC *rec, TR_NAME *trust_router);
+unsigned int trp_inforec_get_metric(TRP_INFOREC *rec);
+TRP_RC trp_inforec_set_metric(TRP_INFOREC *rec, unsigned int metric);
+unsigned int trp_inforec_get_interval(TRP_INFOREC *rec);
+TRP_RC trp_inforec_set_interval(TRP_INFOREC *rec, unsigned int interval);
+TRP_INFOREC_TYPE trp_inforec_type_from_string(const char *s);
+const char *trp_inforec_type_to_string(TRP_INFOREC_TYPE msgtype);
+
+
+TRP_REQ *trp_req_new(TALLOC_CTX *mem_ctx);
+void trp_req_free(TRP_REQ *req);
+TR_NAME *trp_req_get_comm(TRP_REQ *req);
+void trp_req_set_comm(TRP_REQ *req, TR_NAME *comm);
+TR_NAME *trp_req_get_realm(TRP_REQ *req);
+void trp_req_set_realm(TRP_REQ *req, TR_NAME *realm);
 
 typedef struct trps_instance TRPS_INSTANCE;
 
-typedef int (TRPS_REQ_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
-typedef void (TRPS_RESP_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
+typedef int (TRPS_REQ_FUNC)();
+typedef void (TRPS_RESP_FUNC)();
 typedef int (trps_auth_func)(gss_name_t client_name, TR_NAME *display_name, void *cookie);
 
 
@@ -30,7 +91,7 @@ typedef struct trps_connection {
 } TRPS_CONNECTION;
 
 /* a collection of the above */
-#define TRPS_CONNECTIONS_MAX 10;
+#define TRPS_CONNECTIONS_MAX 10
 typedef struct trps_connection_set {
   TRPS_CONNECTION *conn[TRPS_CONNECTIONS_MAX];
   unsigned int nconn;