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 */
18 TRP_UNSUPPORTED, /* unsupported feature */
22 typedef enum trp_msg_type {
23 TRP_MSG_TYPE_UNKNOWN=0, /* conveniently, JSON parser returns 0 if a non-integer number is specified */
25 TRP_MSG_TYPE_ROUTE_REQ
29 typedef enum trp_msg_info_type {
30 TRP_MSG_INFO_TYPE_UNKNOWN=0, /* conveniently, JSON parser returns 0 if a non-integer number is specified */
31 TRP_MSG_INFO_TYPE_ROUTE,
32 TRP_MSG_INFO_TYPE_COMMUNITY, /* not yet implemented (2016-06-14) */
35 typedef struct trp_msg {
40 /* update msg record types */
41 typedef struct trp_msg_info_route TRP_MSG_INFO_ROUTE;
42 struct trp_msg_info_route {
44 TRP_MSG_INFO_TYPE type;
47 TR_NAME *trust_router;
49 unsigned int interval;
52 /* TODO: define struct trp_msg_info_community */
54 typedef struct trp_route_update {
58 typedef struct trp_route_req {
63 TRP_MSG_TYPE trp_msg_type_from_string(const char *s);
64 const char *trp_msg_type_to_string(TRP_MSG_TYPE msgtype);
65 TRP_MSG_INFO_TYPE trp_msg_info_type_from_string(const char *s);
66 const char *trp_msg_info_type_to_string(TRP_MSG_INFO_TYPE msgtype);
68 TRP_MSG *trp_msg_new(TALLOC_CTX *mem_ctx);
69 void trp_msg_destroy(TRP_MSG *msg);
70 void trp_msg_pprint(TRP_MSG *msg);
71 char *trp_encode_msg(TRP_MSG *msg);
74 typedef struct trps_instance TRPS_INSTANCE;
76 /* REMOVE THIS!! --jennifer, 2016-06-13 */
77 typedef TRP_MSG TRP_REQ;
78 typedef TRP_MSG TRP_RESP;
81 typedef int (TRPS_REQ_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
82 typedef void (TRPS_RESP_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
83 typedef int (trps_auth_func)(gss_name_t client_name, TR_NAME *display_name, void *cookie);
86 /* encapsulate a gss context and its connection file handle */
87 typedef struct trps_connection {
92 /* a collection of the above */
93 #define TRPS_CONNECTIONS_MAX 10
94 typedef struct trps_connection_set {
95 TRPS_CONNECTION *conn[TRPS_CONNECTIONS_MAX];
97 } TRPS_CONNECTION_SET;
99 /* TRP Client Instance Data */
100 typedef struct trpc_instance {
101 DH *client_dh; /* Client's DH struct with priv and pub keys */
104 /* TRP Server Instance Data */
105 struct trps_instance {
108 TRPS_REQ_FUNC *req_handler;
109 trps_auth_func *auth_handler;
111 struct tr_rp_client *rp_gss; /* Client matching GSS name, TBD -- FIX ME (??) */
112 TRPS_CONNECTION_SET *connections; /* active GSS connections */
116 TRPS_ERR_OK=0, /* success */
117 TRPS_ERR_NOMEM, /* allocation problem */
118 TRPS_ERR_MAX_CONN, /* out of connections */
119 TRPS_ERR_UNKNOWN /* catch-all */
124 /* these should probably be static? */
125 TRPS_CONNECTION *trps_connection_new(TALLOC_CTX *mem_ctx);
126 TRPS_CONNECTION_SET *trps_connection_set_new(TALLOC_CTX *mem_ctx);
127 TRPS_ERR trps_connection_set_add(TRPS_CONNECTION_SET *tcs, TRPS_CONNECTION *new_conn);
128 TRPS_ERR trps_connection_set_del(TRPS_CONNECTION_SET *tcs, TRPS_CONNECTION *conn);
129 unsigned int trps_connection_set_len(TRPS_CONNECTION_SET *tcs);
131 TRPC_INSTANCE *trpc_create (TALLOC_CTX *mem_ctx);
132 void trpc_destroy (TRPC_INSTANCE *trpc);
133 int trpc_open_connection (TRPC_INSTANCE *trpc, char *server, unsigned int port, gss_ctx_id_t *gssctx);
134 int trpc_send_msg (TRPC_INSTANCE *trpc, int conn, gss_ctx_id_t gssctx, const char *msg_content,
135 int *resp_handler(), void *cookie);
137 TRPS_INSTANCE *trps_create (TALLOC_CTX *mem_ctx);
138 void trps_destroy (TRPS_INSTANCE *trps);
139 int trps_send_msg (TRPS_INSTANCE *trps, int conn, gss_ctx_id_t gssctx, const char *msg_content);
140 int trps_accept(TRPS_INSTANCE *trps, int listen);
142 #endif /* TRP_INTERNAL_H */