9 #include <trp_internal.h>
12 /* also allocates the incoming mq */
13 TRPC_INSTANCE *trpc_new (TALLOC_CTX *mem_ctx)
15 TRPC_INSTANCE *trpc=talloc(mem_ctx, TRPC_INSTANCE);
22 trpc->mq=tr_mq_new(trpc);
31 void trpc_free (TRPC_INSTANCE *trpc)
37 TRPC_INSTANCE *trpc_get_next(TRPC_INSTANCE *trpc)
42 void trpc_set_next(TRPC_INSTANCE *trpc, TRPC_INSTANCE *next)
47 /* Ok to call more than once; guarantees trpc no longer in the list. Does not free removed element.
48 * Returns handle to new list, you must replace your old handle on the list with this. */
49 TRPC_INSTANCE *trpc_remove(TRPC_INSTANCE *trpc, TRPC_INSTANCE *remove)
51 TRPC_INSTANCE *cur=trpc;
52 TRPC_INSTANCE *last=NULL;
57 /* first element is a special case */
59 trpc=trpc_get_next(cur); /* advance list head */
61 /* it was not the first element */
63 cur=trpc_get_next(cur);
66 trpc_set_next(last, trpc_get_next(cur));
70 cur=trpc_get_next(cur);
76 static TRPC_INSTANCE *trpc_get_tail(TRPC_INSTANCE *trpc)
78 while((trpc!=NULL)&&(trpc_get_next(trpc)!=NULL))
79 trpc=trpc_get_next(trpc);
83 void trpc_append(TRPC_INSTANCE *trpc, TRPC_INSTANCE *new)
85 trpc_set_next(trpc_get_tail(trpc), new);
88 char *trpc_get_server(TRPC_INSTANCE *trpc)
93 void trpc_set_server(TRPC_INSTANCE *trpc, char *server)
98 unsigned int trpc_get_port(TRPC_INSTANCE *trpc)
103 void trpc_set_port(TRPC_INSTANCE *trpc, unsigned int port)
108 TRP_CONNECTION *trpc_get_conn(TRPC_INSTANCE *trpc)
113 void trpc_set_conn(TRPC_INSTANCE *trpc, TRP_CONNECTION *conn)
118 DH *trpc_get_dh(TRPC_INSTANCE *trpc)
123 void trpc_set_dh(TRPC_INSTANCE *trpc, DH *dh)
128 TRP_CONNECTION_STATUS trpc_get_status(TRPC_INSTANCE *trpc)
130 return trp_connection_get_status(trpc_get_conn(trpc));
133 TR_MQ *trpc_get_mq(TRPC_INSTANCE *trpc)
138 void trpc_set_mq(TRPC_INSTANCE *trpc, TR_MQ *mq)
143 /* submit msg to trpc for transmission */
144 void trpc_mq_append(TRPC_INSTANCE *trpc, TR_MQ_MSG *msg)
146 tr_mq_append(trpc->mq, msg);
149 TR_MQ_MSG *trpc_mq_pop(TRPC_INSTANCE *trpc)
151 return tr_mq_pop(trpc->mq);
154 TRP_RC trpc_connect(TRPC_INSTANCE *trpc)
156 return trp_connection_initiate(trpc_get_conn(trpc), trpc_get_server(trpc), trpc_get_port(trpc));
159 /* simple function, based on tidc_send_req */
160 TRP_RC trpc_send_msg (TRPC_INSTANCE *trpc,
161 const char *msg_content)
164 TRP_RC rc=TRP_SUCCESS;
166 /* Send the request over the connection */
167 if (err = gsscon_write_encrypted_token(trp_connection_get_fd(trpc_get_conn(trpc)),
168 *trp_connection_get_gssctx(trpc_get_conn(trpc)),
170 strlen(msg_content))) {
171 tr_err( "trpc_send_msg: Error sending message over connection.\n");