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 */
17 TRP_BADTYPE, /* typing error */
21 typedef enum trp_msg_type {
22 TRP_MSG_TYPE_UNKNOWN=0, /* conveniently, JSON parser returns 0 if a non-integer number is specified */
24 TRP_MSG_TYPE_ROUTE_REQ
27 typedef struct trp_msg {
32 typedef struct trp_msg_body_update TRP_MSG_BODY_UPDATE;
33 struct trp_msg_body_update {
34 TRP_MSG_BODY_UPDATE *next;
37 TR_NAME *trust_router;
39 unsigned int interval;
42 typedef struct trp_msg_body_route_req {
45 } TRP_MSG_BODY_ROUTE_REQ;
47 TRP_MSG_TYPE trp_msg_type_from_string(const char *s);
48 const char *trp_msg_type_to_string(TRP_MSG_TYPE msgtype);
50 TRP_MSG *trp_msg_new(TALLOC_CTX *mem_ctx);
51 void trp_msg_destroy(TRP_MSG *msg);
54 typedef struct trps_instance TRPS_INSTANCE;
56 /* REMOVE THIS!! --jennifer, 2016-06-13 */
57 typedef TRP_MSG TRP_REQ;
58 typedef TRP_MSG TRP_RESP;
61 typedef int (TRPS_REQ_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
62 typedef void (TRPS_RESP_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
63 typedef int (trps_auth_func)(gss_name_t client_name, TR_NAME *display_name, void *cookie);
66 /* encapsulate a gss context and its connection file handle */
67 typedef struct trps_connection {
72 /* a collection of the above */
73 #define TRPS_CONNECTIONS_MAX 10
74 typedef struct trps_connection_set {
75 TRPS_CONNECTION *conn[TRPS_CONNECTIONS_MAX];
77 } TRPS_CONNECTION_SET;
79 /* TRP Client Instance Data */
80 typedef struct trpc_instance {
81 DH *client_dh; /* Client's DH struct with priv and pub keys */
84 /* TRP Server Instance Data */
85 struct trps_instance {
88 TRPS_REQ_FUNC *req_handler;
89 trps_auth_func *auth_handler;
91 struct tr_rp_client *rp_gss; /* Client matching GSS name, TBD -- FIX ME (??) */
92 TRPS_CONNECTION_SET *connections; /* active GSS connections */
96 TRPS_ERR_OK=0, /* success */
97 TRPS_ERR_NOMEM, /* allocation problem */
98 TRPS_ERR_MAX_CONN, /* out of connections */
99 TRPS_ERR_UNKNOWN /* catch-all */
104 /* these should probably be static? */
105 TRPS_CONNECTION *trps_connection_new(TALLOC_CTX *mem_ctx);
106 TRPS_CONNECTION_SET *trps_connection_set_new(TALLOC_CTX *mem_ctx);
107 TRPS_ERR trps_connection_set_add(TRPS_CONNECTION_SET *tcs, TRPS_CONNECTION *new_conn);
108 TRPS_ERR trps_connection_set_del(TRPS_CONNECTION_SET *tcs, TRPS_CONNECTION *conn);
109 unsigned int trps_connection_set_len(TRPS_CONNECTION_SET *tcs);
111 TRPC_INSTANCE *trpc_create (TALLOC_CTX *mem_ctx);
112 void trpc_destroy (TRPC_INSTANCE *trpc);
113 int trpc_open_connection (TRPC_INSTANCE *trpc, char *server, unsigned int port, gss_ctx_id_t *gssctx);
114 int trpc_send_msg (TRPC_INSTANCE *trpc, int conn, gss_ctx_id_t gssctx, const char *msg_content,
115 int *resp_handler(), void *cookie);
117 TRPS_INSTANCE *trps_create (TALLOC_CTX *mem_ctx);
118 void trps_destroy (TRPS_INSTANCE *trps);
119 int trps_send_msg (TRPS_INSTANCE *trps, int conn, gss_ctx_id_t gssctx, const char *msg_content);
120 int trps_accept(TRPS_INSTANCE *trps, int listen);
122 #endif /* TRP_INTERNAL_H */