7 #include <trust_router/tr_dh.h>
10 #define TRP_METRIC_INFINITY 0xFFFF
14 TRP_ERROR, /* generic error */
15 TRP_NOPARSE, /* parse error */
16 TRP_NOMEM, /* allocation error */
20 typedef enum trp_msg_type {
21 TRP_MSG_TYPE_UNKNOWN=0, /* conveniently, JSON parser returns 0 if a non-integer number is specified */
23 TRP_MSG_TYPE_ROUTE_REQ
26 typedef struct trp_msg {
31 typedef struct trp_msg_body_update TRP_MSG_BODY_UPDATE;
32 struct trp_msg_body_update {
33 TRP_MSG_BODY_UPDATE *next;
36 TR_NAME *trust_router;
38 unsigned int interval;
41 typedef struct trp_msg_body_route_req {
44 } TRP_MSG_BODY_ROUTE_REQ;
46 TRP_MSG_TYPE trp_msg_type_from_string(const char *s);
47 const char *trp_msg_type_to_string(TRP_MSG_TYPE msgtype);
49 TRP_MSG *trp_msg_new(TALLOC_CTX *mem_ctx);
50 void trp_msg_destroy(TRP_MSG *msg);
53 typedef struct trps_instance TRPS_INSTANCE;
55 /* REMOVE THIS!! --jennifer, 2016-06-13 */
56 typedef TRP_MSG TRP_REQ;
57 typedef TRP_MSG TRP_RESP;
60 typedef int (TRPS_REQ_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
61 typedef void (TRPS_RESP_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
62 typedef int (trps_auth_func)(gss_name_t client_name, TR_NAME *display_name, void *cookie);
65 /* encapsulate a gss context and its connection file handle */
66 typedef struct trps_connection {
71 /* a collection of the above */
72 #define TRPS_CONNECTIONS_MAX 10
73 typedef struct trps_connection_set {
74 TRPS_CONNECTION *conn[TRPS_CONNECTIONS_MAX];
76 } TRPS_CONNECTION_SET;
78 /* TRP Client Instance Data */
79 typedef struct trpc_instance {
80 DH *client_dh; /* Client's DH struct with priv and pub keys */
83 /* TRP Server Instance Data */
84 struct trps_instance {
87 TRPS_REQ_FUNC *req_handler;
88 trps_auth_func *auth_handler;
90 struct tr_rp_client *rp_gss; /* Client matching GSS name, TBD -- FIX ME (??) */
91 TRPS_CONNECTION_SET *connections; /* active GSS connections */
95 TRPS_ERR_OK=0, /* success */
96 TRPS_ERR_NOMEM, /* allocation problem */
97 TRPS_ERR_MAX_CONN, /* out of connections */
98 TRPS_ERR_UNKNOWN /* catch-all */
103 /* these should probably be static? */
104 TRPS_CONNECTION *trps_connection_new(TALLOC_CTX *mem_ctx);
105 TRPS_CONNECTION_SET *trps_connection_set_new(TALLOC_CTX *mem_ctx);
106 TRPS_ERR trps_connection_set_add(TRPS_CONNECTION_SET *tcs, TRPS_CONNECTION *new_conn);
107 TRPS_ERR trps_connection_set_del(TRPS_CONNECTION_SET *tcs, TRPS_CONNECTION *conn);
108 unsigned int trps_connection_set_len(TRPS_CONNECTION_SET *tcs);
110 TRPC_INSTANCE *trpc_create (TALLOC_CTX *mem_ctx);
111 void trpc_destroy (TRPC_INSTANCE *trpc);
112 int trpc_open_connection (TRPC_INSTANCE *trpc, char *server, unsigned int port, gss_ctx_id_t *gssctx);
113 int trpc_send_msg (TRPC_INSTANCE *trpc, int conn, gss_ctx_id_t gssctx, const char *msg_content,
114 int *resp_handler(), void *cookie);
116 TRPS_INSTANCE *trps_create (TALLOC_CTX *mem_ctx);
117 void trps_destroy (TRPS_INSTANCE *trps);
118 int trps_send_msg (TRPS_INSTANCE *trps, int conn, gss_ctx_id_t gssctx, const char *msg_content);
119 int trps_accept(TRPS_INSTANCE *trps, int listen);
121 #endif /* TRP_INTERNAL_H */