8 #include <trust_router/tr_dh.h>
10 #include <trust_router/trp.h>
13 /* TRP update record types */
14 typedef struct trp_inforec_route {
17 TR_NAME *trust_router;
19 unsigned int interval;
22 /* TODO: define struct trp_msg_info_community */
24 typedef union trp_inforec_data {
25 TRP_INFOREC_ROUTE *route;
26 /* TRP_INFOREC_COMM *comm; */
31 TRP_INFOREC_TYPE type;
32 TRP_INFOREC_DATA data; /* contains pointer to one of the record types */
45 typedef struct trps_instance TRPS_INSTANCE;
47 typedef int (*TRP_REQ_FUNC)();
48 typedef void (*TRP_RESP_FUNC)();
49 /*typedef int (*TRP_AUTH_FUNC)(gss_name_t client_name, TR_NAME *display_name, void *cookie);*/
50 typedef client_cb_fn TRP_AUTH_FUNC;
52 typedef enum trp_connection_status {
53 TRP_CONNECTION_DOWN=0,
55 } TRP_CONNECTION_STATUS;
57 typedef struct trp_connection TRP_CONNECTION;
58 struct trp_connection {
60 pthread_t *thread; /* thread servicing this connection */
64 TRP_CONNECTION_STATUS status;
65 pthread_mutex_t status_mutex;
68 /* TRP Client Instance Data */
69 typedef struct trpc_instance {
71 DH *client_dh; /* Client's DH struct with priv and pub keys */
74 /* TRP Server Instance Data */
75 struct trps_instance {
78 TRP_AUTH_FUNC auth_handler;
79 TRP_REQ_FUNC req_handler;
81 TRP_CONNECTION *conn; /* connections to peers */
86 TRP_CONNECTION *trp_connection_new(TALLOC_CTX *mem_ctx);
87 void trp_connection_free(TRP_CONNECTION *conn);
88 int trp_connection_get_fd(TRP_CONNECTION *conn);
89 void trp_connection_set_fd(TRP_CONNECTION *conn, int fd);
90 TR_NAME *trp_connection_get_gssname(TRP_CONNECTION *conn);
91 void trp_connection_set_gssname(TRP_CONNECTION *conn, TR_NAME *gssname);
92 gss_ctx_id_t *trp_connection_get_gssctx(TRP_CONNECTION *conn);
93 void trp_connection_set_gssctx(TRP_CONNECTION *conn, gss_ctx_id_t *gssctx);
94 TRP_CONNECTION_STATUS trp_connection_get_status(TRP_CONNECTION *conn);
95 void trp_connection_set_status(TRP_CONNECTION *conn, TRP_CONNECTION_STATUS status);
96 pthread_t *trp_connection_get_thread(TRP_CONNECTION *conn);
97 void trp_connection_set_thread(TRP_CONNECTION *conn, pthread_t *thread);
98 TRP_CONNECTION *trp_connection_get_next(TRP_CONNECTION *conn);
99 void trp_connection_append(TRP_CONNECTION *conn, TRP_CONNECTION *new);
100 int trp_connection_auth(TRP_CONNECTION *conn, TRP_AUTH_FUNC auth_callback, void *callback_data);
101 TRP_CONNECTION *trp_connection_accept(TALLOC_CTX *mem_ctx, int listen, TR_NAME *gssname,
102 TRP_AUTH_FUNC auth_callback, TRP_REQ_FUNC req_handler,
103 void *callback_data);
105 TRPC_INSTANCE *trpc_new (TALLOC_CTX *mem_ctx);
106 void trpc_free (TRPC_INSTANCE *trpc);
107 int trpc_open_connection (TRPC_INSTANCE *trpc, char *server, unsigned int port, gss_ctx_id_t *gssctx);
108 int trpc_send_msg (TRPC_INSTANCE *trpc, int conn, gss_ctx_id_t gssctx, const char *msg_content,
109 int *resp_handler(), void *cookie);
111 TRPS_INSTANCE *trps_new (TALLOC_CTX *mem_ctx);
112 void trps_free (TRPS_INSTANCE *trps);
113 int trps_send_msg (TRPS_INSTANCE *trps, int conn, gss_ctx_id_t gssctx, const char *msg_content);
114 int trps_accept(TRPS_INSTANCE *trps, int listen);
115 void trps_add_connection(TRPS_INSTANCE *trps, TRP_CONNECTION *new);
116 int trps_get_listener(TRPS_INSTANCE *trps,
117 TRP_REQ_FUNC req_handler,
118 TRP_AUTH_FUNC auth_handler,
119 const char *hostname,
122 int trps_auth_cb(gss_name_t clientName, gss_buffer_t displayName, void *data);
123 TR_MQ_MSG *trps_mq_pop(TRPS_INSTANCE *trps);
124 void trps_mq_append(TRPS_INSTANCE *trps, TR_MQ_MSG *msg);
125 #endif /* TRP_INTERNAL_H */