Add stub of TRP client test program, trpc.
[trust_router.git] / include / tr_trp.h
1 #ifndef TR_TRP_H
2 #define TR_TRP_H
3
4 #include <talloc.h>
5
6 #include <tr_config.h>
7 #include <tr_event.h>
8 #include <trust_router/tr_dh.h>
9
10 #define TRP_PORT 12310
11
12 typedef struct trp_req {
13   int msg;
14 } TRP_REQ;
15
16 typedef struct trp_resp {
17   int msg;
18 } TRP_RESP;
19
20 typedef struct trps_instance TRPS_INSTANCE;
21
22 typedef int (TRPS_REQ_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
23 typedef void (TRPS_RESP_FUNC)(TRPS_INSTANCE *, TRP_REQ *, TRP_RESP *, void *);
24 typedef int (trps_auth_func)(gss_name_t client_name, TR_NAME *display_name, void *cookie);
25
26
27 /* TRP Client Instance Data */
28 typedef struct trpc_instance {
29   DH *client_dh;                        /* Client's DH struct with priv and pub keys */
30 } TRPC_INSTANCE;
31
32 /* TRP Server Instance Data */
33 struct trps_instance {
34   char *hostname;
35   unsigned int port;
36   TRPS_REQ_FUNC *req_handler;
37   trps_auth_func *auth_handler;
38   void *cookie;
39   struct tr_rp_client *rp_gss;          /* Client matching GSS name, TBD -- FIX ME (??) */
40 };
41
42
43 /* prototypes */
44 TRPC_INSTANCE *trpc_create (TALLOC_CTX *mem_ctx);
45 void trpc_destroy (TRPC_INSTANCE *trpc);
46 int trpc_open_connection (TRPC_INSTANCE *trpc, char *server, unsigned int port, gss_ctx_id_t *gssctx);
47 int trpc_send_msg (TRPC_INSTANCE *trpc, int conn, gss_ctx_id_t gssctx, const char *msg_content,
48                    int *resp_handler(), void *cookie);
49
50 TRPS_INSTANCE *trps_create (TALLOC_CTX *mem_ctx);
51 void trps_destroy (TRPS_INSTANCE *trps);
52 int tr_trps_event_init(struct event_base *base, TRPS_INSTANCE *trps, TR_CFG_MGR *cfg_mgr,
53                        struct tr_socket_event *trps_ev);
54 int trps_accept(TRPS_INSTANCE *trps, int listen);
55
56 #endif /* TR_TRP_H */