4 #include <trust_router/tr_name.h>
5 #include <trp_internal.h>
8 static int trp_req_destructor(void *object)
10 TRP_REQ *req=talloc_get_type_abort(object, TRP_REQ);
12 /* clean up TR_NAME data, which are not managed by talloc */
13 if (req->comm != NULL)
14 tr_free_name(req->comm);
16 if (req->realm != NULL)
17 tr_free_name(req->realm);
19 if (req->peer != NULL)
20 tr_free_name(req->peer);
25 TRP_REQ *trp_req_new(TALLOC_CTX *mem_ctx)
27 TRP_REQ *new_req=talloc(mem_ctx, TRP_REQ);
29 if (new_req != NULL) {
35 talloc_set_destructor((void *)new_req, trp_req_destructor);
39 void trp_req_free(TRP_REQ *req)
45 TR_NAME *trp_req_get_comm(TRP_REQ *req)
53 void trp_req_set_comm(TRP_REQ *req, TR_NAME *comm)
59 TR_NAME *trp_req_get_realm(TRP_REQ *req)
68 void trp_req_set_realm(TRP_REQ *req, TR_NAME *realm)
74 TR_NAME *trp_req_get_peer(TRP_REQ *req)
83 void trp_req_set_peer(TRP_REQ *req, TR_NAME *peer)
89 /* Defines what we use as a wildcard for realm or community name.
90 * Must not be a valid name for either of those. Currently, we
91 * use the empty string. */
92 static int trp_req_name_is_wildcard(TR_NAME *name)
94 return (name!=NULL) && (name->len==0);
97 int trp_req_is_wildcard(TRP_REQ *req)
99 return (req!=NULL) && trp_req_name_is_wildcard(req->comm) && trp_req_name_is_wildcard(req->realm);
102 TRP_RC trp_req_make_wildcard(TRP_REQ *req)
107 req->comm=tr_new_name("");
111 req->realm=tr_new_name("");
112 if (req->realm==NULL) {
113 tr_free_name(req->comm);