7 #include <trust_router/tr_dh.h>
8 #include <trust_router/trp.h>
11 typedef enum trp_inforec_type {
12 TRP_INFOREC_TYPE_UNKNOWN=0, /* conveniently, JSON parser returns 0 if a non-integer number is specified */
13 TRP_INFOREC_TYPE_ROUTE,
14 TRP_INFOREC_TYPE_COMMUNITY, /* not yet implemented (2016-06-14) */
17 /* TRP update record types */
18 typedef struct trp_inforec_route {
21 TR_NAME *trust_router;
23 unsigned int interval;
26 /* TODO: define struct trp_msg_info_community */
28 typedef union trp_inforec_data {
29 TRP_INFOREC_ROUTE *route;
30 /* TRP_INFOREC_COMM *comm; */
33 typedef struct trp_inforec TRP_INFOREC;
36 TRP_INFOREC_TYPE type;
37 TRP_INFOREC_DATA data; /* contains pointer to one of the record types */
49 TRP_INFOREC_TYPE trp_inforec_type_from_string(const char *s);
50 const char *trp_inforec_type_to_string(TRP_INFOREC_TYPE msgtype);
52 TRP_UPD *trp_upd_new(TALLOC_CTX *mem_ctx);
53 void trp_upd_free(TRP_UPD *update);
54 TRP_REQ *trp_req_new(TALLOC_CTX *mem_ctx);
55 void trp_req_free(TRP_REQ *req);
56 TRP_INFOREC *trp_inforec_new(TALLOC_CTX *mem_ctx, TRP_INFOREC_TYPE type);
57 void trp_inforec_free(TRP_INFOREC *rec);
58 TR_NAME *trp_inforec_get_comm(TRP_INFOREC *rec);
59 TRP_RC trp_inforec_set_comm(TRP_INFOREC *rec, TR_NAME *comm);
60 TR_NAME *trp_inforec_get_realm(TRP_INFOREC *rec);
61 TRP_RC trp_inforec_set_realm(TRP_INFOREC *rec, TR_NAME *realm);
62 TR_NAME *trp_inforec_get_trust_router(TRP_INFOREC *rec);
63 TRP_RC trp_inforec_set_trust_router(TRP_INFOREC *rec, TR_NAME *trust_router);
64 unsigned int trp_inforec_get_metric(TRP_INFOREC *rec);
65 TRP_RC trp_inforec_set_metric(TRP_INFOREC *rec, unsigned int metric);
66 unsigned int trp_inforec_get_interval(TRP_INFOREC *rec);
67 TRP_RC trp_inforec_set_interval(TRP_INFOREC *rec, unsigned int interval);
70 typedef struct trps_instance TRPS_INSTANCE;
72 typedef int (TRPS_REQ_FUNC)();
73 typedef void (TRPS_RESP_FUNC)();
74 typedef int (trps_auth_func)(gss_name_t client_name, TR_NAME *display_name, void *cookie);
77 /* encapsulate a gss context and its connection file handle */
78 typedef struct trps_connection {
83 /* a collection of the above */
84 #define TRPS_CONNECTIONS_MAX 10
85 typedef struct trps_connection_set {
86 TRPS_CONNECTION *conn[TRPS_CONNECTIONS_MAX];
88 } TRPS_CONNECTION_SET;
90 /* TRP Client Instance Data */
91 typedef struct trpc_instance {
92 DH *client_dh; /* Client's DH struct with priv and pub keys */
95 /* TRP Server Instance Data */
96 struct trps_instance {
99 TRPS_REQ_FUNC *req_handler;
100 trps_auth_func *auth_handler;
102 struct tr_rp_client *rp_gss; /* Client matching GSS name, TBD -- FIX ME (??) */
103 TRPS_CONNECTION_SET *connections; /* active GSS connections */
107 TRPS_ERR_OK=0, /* success */
108 TRPS_ERR_NOMEM, /* allocation problem */
109 TRPS_ERR_MAX_CONN, /* out of connections */
110 TRPS_ERR_UNKNOWN /* catch-all */
115 /* these should probably be static? */
116 TRPS_CONNECTION *trps_connection_new(TALLOC_CTX *mem_ctx);
117 TRPS_CONNECTION_SET *trps_connection_set_new(TALLOC_CTX *mem_ctx);
118 TRPS_ERR trps_connection_set_add(TRPS_CONNECTION_SET *tcs, TRPS_CONNECTION *new_conn);
119 TRPS_ERR trps_connection_set_del(TRPS_CONNECTION_SET *tcs, TRPS_CONNECTION *conn);
120 unsigned int trps_connection_set_len(TRPS_CONNECTION_SET *tcs);
122 TRPC_INSTANCE *trpc_create (TALLOC_CTX *mem_ctx);
123 void trpc_destroy (TRPC_INSTANCE *trpc);
124 int trpc_open_connection (TRPC_INSTANCE *trpc, char *server, unsigned int port, gss_ctx_id_t *gssctx);
125 int trpc_send_msg (TRPC_INSTANCE *trpc, int conn, gss_ctx_id_t gssctx, const char *msg_content,
126 int *resp_handler(), void *cookie);
128 TRPS_INSTANCE *trps_create (TALLOC_CTX *mem_ctx);
129 void trps_destroy (TRPS_INSTANCE *trps);
130 int trps_send_msg (TRPS_INSTANCE *trps, int conn, gss_ctx_id_t gssctx, const char *msg_content);
131 int trps_accept(TRPS_INSTANCE *trps, int listen);
133 #endif /* TRP_INTERNAL_H */