本文整理汇总了C++中RWDEBUG函数的典型用法代码示例。如果您正苦于以下问题:C++ RWDEBUG函数的具体用法?C++ RWDEBUG怎么用?C++ RWDEBUG使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RWDEBUG函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _map_proc_client_get_vp
static int _map_proc_client_get_vp(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request,
vp_map_t const *map, void *uctx)
{
client_get_vp_ctx_t *client = uctx;
VALUE_PAIR *head = NULL, *vp;
fr_cursor_t cursor;
fr_dict_attr_t const *da;
CONF_PAIR const *cp;
rad_assert(ctx != NULL);
fr_cursor_init(&cursor, &head);
/*
* FIXME: allow multiple entries.
*/
if (map->lhs->type == TMPL_TYPE_ATTR) {
da = map->lhs->tmpl_da;
} else {
char *attr;
if (tmpl_aexpand(ctx, &attr, request, map->lhs, NULL, NULL) <= 0) {
RWDEBUG("Failed expanding string");
return -1;
}
da = fr_dict_attr_by_name(request->dict, attr);
if (!da) {
RWDEBUG("No such attribute '%s'", attr);
return -1;
}
talloc_free(attr);
}
for (cp = client->cp;
cp;
cp = cf_pair_find_next(client->cs, cp, client->field)) {
char const *value = cf_pair_value(cp);
MEM(vp = fr_pair_afrom_da(ctx, da));
if (fr_pair_value_from_str(vp, value, talloc_array_length(value) - 1, '\0', false) < 0) {
RWDEBUG("Failed parsing value \"%pV\" for attribute %s: %s", fr_box_strvalue(value),
map->lhs->tmpl_da->name, fr_strerror());
fr_pair_list_free(&head);
talloc_free(vp);
return -1;
}
vp->op = map->op;
fr_cursor_append(&cursor, vp);
if (map->op != T_OP_ADD) break; /* Create multiple attribute for multiple CONF_PAIRs */
}
*out = head;
return 0;
}
示例2: csv_map_getvalue
/*
* Convert field X to a VP.
*/
static int csv_map_getvalue(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, void *uctx)
{
char const *str = uctx;
VALUE_PAIR *head = NULL, *vp;
vp_cursor_t cursor;
DICT_ATTR const *da;
rad_assert(ctx != NULL);
fr_cursor_init(&cursor, &head);
/*
* FIXME: allow multiple entries.
*/
if (map->lhs->type == TMPL_TYPE_ATTR) {
da = map->lhs->tmpl_da;
} else {
char *attr;
if (tmpl_aexpand(ctx, &attr, request, map->lhs, NULL, NULL) <= 0) {
RWDEBUG("Failed expanding string");
return -1;
}
da = dict_attrbyname(attr);
if (!da) {
RWDEBUG("No such attribute '%s'", attr);
return -1;
}
talloc_free(attr);
}
vp = pairalloc(ctx, da);
rad_assert(vp);
if (pairparsevalue(vp, str, talloc_array_length(str) - 1) < 0) {
char *escaped;
escaped = fr_aprints(vp, str, talloc_array_length(str) - 1, '\'');
RWDEBUG("Failed parsing value \"%s\" for attribute %s: %s", escaped,
map->lhs->tmpl_da->name, fr_strerror());
talloc_free(vp); /* also frees escaped */
return -1;
}
vp->op = map->op;
fr_cursor_merge(&cursor, vp);
*out = head;
return 0;
}
示例3: csv_map_getvalue
/*
* Convert field X to a VP.
*/
static int csv_map_getvalue(TALLOC_CTX *ctx, VALUE_PAIR **out, REQUEST *request, vp_map_t const *map, void *uctx)
{
char const *str = uctx;
VALUE_PAIR *head = NULL, *vp;
fr_cursor_t cursor;
fr_dict_attr_t const *da;
rad_assert(ctx != NULL);
fr_cursor_init(&cursor, &head);
/*
* FIXME: allow multiple entries.
*/
if (map->lhs->type == TMPL_TYPE_ATTR) {
da = map->lhs->tmpl_da;
} else {
char *attr;
if (tmpl_aexpand(ctx, &attr, request, map->lhs, NULL, NULL) <= 0) {
RWDEBUG("Failed expanding string");
return -1;
}
da = fr_dict_attr_by_name(request->dict, attr);
if (!da) {
RWDEBUG("No such attribute '%s'", attr);
return -1;
}
talloc_free(attr);
}
vp = fr_pair_afrom_da(ctx, da);
rad_assert(vp);
if (fr_pair_value_from_str(vp, str, talloc_array_length(str) - 1, '\0', true) < 0) {
RWDEBUG("Failed parsing value \"%pV\" for attribute %s: %s", fr_box_strvalue_buffer(str),
map->lhs->tmpl_da->name, fr_strerror());
talloc_free(vp);
return -1;
}
vp->op = map->op;
fr_cursor_append(&cursor, vp);
*out = head;
return 0;
}
示例4: xlat_client
/*
* Xlat for %{client:foo}
*/
static ssize_t xlat_client(UNUSED void *instance, REQUEST *request, char const *fmt, char *out, size_t outlen)
{
char const *value = NULL;
CONF_PAIR *cp;
if (!fmt || !out || (outlen < 1)) return 0;
if (!request->client) {
RWDEBUG("No client associated with this request");
*out = '\0';
return 0;
}
cp = cf_pair_find(request->client->cs, fmt);
if (!cp || !(value = cf_pair_value(cp))) {
if (strcmp(fmt, "shortname") == 0) {
strlcpy(out, request->client->shortname, outlen);
return strlen(out);
}
RDEBUG("Client does not contain config item \"%s\"", fmt);
*out = '\0';
return 0;
}
strlcpy(out, value, outlen);
return strlen(out);
}
示例5: eaptls_success
int eaptls_success(eap_handler_t *handler, int peap_flag)
{
EAPTLS_PACKET reply;
REQUEST *request = handler->request;
tls_session_t *tls_session = handler->opaque;
handler->finished = true;
reply.code = FR_TLS_SUCCESS;
reply.length = TLS_HEADER_LEN;
reply.flags = peap_flag;
reply.data = NULL;
reply.dlen = 0;
tls_success(tls_session, request);
/*
* Call compose AFTER checking for cached data.
*/
eaptls_compose(handler->eap_ds, &reply);
/*
* Automatically generate MPPE keying material.
*/
if (tls_session->prf_label) {
eaptls_gen_mppe_keys(handler->request,
tls_session->ssl, tls_session->prf_label);
} else {
RWDEBUG("Not adding MPPE keys because there is no PRF label");
}
eaptls_gen_eap_key(handler->request->reply, tls_session->ssl,
handler->type);
return 1;
}
示例6: xlat_listen
/*
* Xlat for %{listen:foo}
*/
static ssize_t xlat_listen(UNUSED void *instance, REQUEST *request,
char const *fmt, char *out, size_t outlen)
{
char const *value = NULL;
CONF_PAIR *cp;
if (!fmt || !out || (outlen < 1)) return 0;
if (!request->listener) {
RWDEBUG("No listener associated with this request");
*out = '\0';
return 0;
}
cp = cf_pair_find(request->listener->cs, fmt);
if (!cp || !(value = cf_pair_value(cp))) {
RDEBUG("Listener does not contain config item \"%s\"", fmt);
*out = '\0';
return 0;
}
strlcpy(out, value, outlen);
return strlen(out);
}
示例7: xlat_client
/*
* Xlat for %{client:foo}
*/
static ssize_t xlat_client(UNUSED void *instance, REQUEST *request, char const *fmt, char *out, size_t outlen)
{
char const *value = NULL;
CONF_PAIR *cp;
if (!fmt || !out || (outlen < 1)) return 0;
if (!request->client) {
RWDEBUG("No client associated with this request");
*out = '\0';
return 0;
}
cp = cf_pair_find(request->client->cs, fmt);
if (!cp || !(value = cf_pair_value(cp))) {
if (strcmp(fmt, "shortname") == 0 && request->client->shortname) {
value = request->client->shortname;
}
else if (strcmp(fmt, "nas_type") == 0 && request->client->nas_type) {
value = request->client->nas_type;
} else {
*out = '\0';
return 0;
}
}
strlcpy(out, value, outlen);
return strlen(out);
}
示例8: dhcp_options_xlat
/*
* Allow single attribute values to be retrieved from the dhcp.
*/
static ssize_t dhcp_options_xlat(UNUSED void *instance, REQUEST *request,
char const *fmt, char **out, size_t freespace)
{
vp_cursor_t cursor, src_cursor;
vp_tmpl_t src;
VALUE_PAIR *vp, *head = NULL;
int decoded = 0;
ssize_t slen;
while (isspace((int) *fmt)) fmt++;
slen = tmpl_from_attr_str(&src, fmt, REQUEST_CURRENT, PAIR_LIST_REQUEST, false, false);
if (slen <= 0) {
REMARKER(fmt, slen, fr_strerror());
error:
return -1;
}
if (src.type != TMPL_TYPE_ATTR) {
REDEBUG("dhcp_options cannot operate on a %s", fr_int2str(tmpl_names, src.type, "<INVALID>"));
goto error;
}
if (src.tmpl_da->type != PW_TYPE_OCTETS) {
REDEBUG("dhcp_options got a %s attribute needed octets",
fr_int2str(dict_attr_types, src.tmpl_da->type, "<INVALID>"));
goto error;
}
for (vp = tmpl_cursor_init(NULL, &src_cursor, request, &src);
vp;
vp = tmpl_cursor_next(&src_cursor, &src)) {
/*
* @fixme: we should pass in a cursor, then decoding multiple
* source attributes can be made atomic.
*/
if ((fr_dhcp_decode_options(request->packet, &head, vp->vp_octets, vp->vp_length) < 0) || (!head)) {
RWDEBUG("DHCP option decoding failed: %s", fr_strerror());
goto error;
}
for (vp = fr_cursor_init(&cursor, &head);
vp;
vp = fr_cursor_next(&cursor)) {
rdebug_pair(L_DBG_LVL_2, request, vp, "dhcp_options: ");
decoded++;
}
fr_pair_list_move(request->packet, &(request->packet->vps), &head);
/* Free any unmoved pairs */
fr_pair_list_free(&head);
}
snprintf(*out, freespace, "%i", decoded);
return strlen(*out);
}
示例9: gw_rwlock_wrlock
int gw_rwlock_wrlock(RWLock *lock)
{
int ret = 0;
gw_assert(lock != NULL);
#ifdef HAVE_PTHREAD_RWLOCK
ret = pthread_rwlock_wrlock(&lock->rwlock);
if (ret != 0)
panic(ret, "Error while pthread_rwlock_wrlock.");
#else
RWDEBUG("", 0, "------------ gw_rwlock_wrlock(%p) ----------", lock);
gwlist_lock(lock->rwlock);
RWDEBUG("", 0, "------------ gw_rwlock_wrlock(%p) producers=%d", lock, gwlist_producer_count(lock->rwlock));
/* wait for reader */
gwlist_consume(lock->rwlock);
lock->writer = gwthread_self();
#endif
return ret;
}
示例10: rlm_replicate_alloc
/** Allocate a request packet
*
* This is done once per request with the same packet being sent to multiple realms.
*/
static rlm_rcode_t rlm_replicate_alloc(RADIUS_PACKET **out, REQUEST *request, pair_lists_t list, PW_CODE code)
{
rlm_rcode_t rcode = RLM_MODULE_OK;
RADIUS_PACKET *packet = NULL;
VALUE_PAIR *vp, **vps;
*out = NULL;
packet = rad_alloc(request, 1);
if (!packet) {
return RLM_MODULE_FAIL;
}
packet->code = code;
/*
* Figure out which list in the request were replicating
*/
vps = radius_list(request, list);
if (!vps) {
RWDEBUG("List '%s' doesn't exist for this packet", fr_int2str(pair_lists, list, "<INVALID>"));
rcode = RLM_MODULE_INVALID;
goto error;
}
/*
* Don't assume the list actually contains any attributes.
*/
if (*vps) {
packet->vps = paircopy(packet, *vps);
if (!packet->vps) {
rcode = RLM_MODULE_FAIL;
goto error;
}
}
/*
* For CHAP, create the CHAP-Challenge if it doesn't exist.
*/
if ((code == PW_CODE_ACCESS_REQUEST) &&
(pairfind(request->packet->vps, PW_CHAP_PASSWORD, 0, TAG_ANY) != NULL) &&
(pairfind(request->packet->vps, PW_CHAP_CHALLENGE, 0, TAG_ANY) == NULL)) {
vp = radius_paircreate(packet, &packet->vps, PW_CHAP_CHALLENGE, 0);
pairmemcpy(vp, request->packet->vector, AUTH_VECTOR_LEN);
}
*out = packet;
return rcode;
error:
talloc_free(packet);
return rcode;
}
示例11: xlat_a
static ssize_t xlat_a(TALLOC_CTX *ctx, char **out, size_t outlen,
void const *mod_inst, UNUSED void const *xlat_inst,
REQUEST *request, char const *fmt)
{
rlm_unbound_t const *inst = mod_inst;
struct ub_result **ubres;
int async_id;
char *fmt2; /* For const warnings. Keep till new libunbound ships. */
/* This has to be on the heap, because threads. */
ubres = talloc(inst, struct ub_result *);
/* Used and thus impossible value from heap to designate incomplete */
memcpy(ubres, &mod_inst, sizeof(*ubres));
fmt2 = talloc_typed_strdup(ctx, fmt);
ub_resolve_async(inst->ub, fmt2, 1, 1, ubres, link_ubres, &async_id);
talloc_free(fmt2);
if (ub_common_wait(inst, request, inst->xlat_a_name, ubres, async_id)) {
goto error0;
}
if (*ubres) {
if (ub_common_fail(request, inst->xlat_a_name, *ubres)) {
goto error1;
}
if (!inet_ntop(AF_INET, (*ubres)->data[0], *out, outlen)) {
goto error1;
};
ub_resolve_free(*ubres);
talloc_free(ubres);
return strlen(*out);
}
RWDEBUG("%s - No result", inst->xlat_a_name);
error1:
ub_resolve_free(*ubres); /* Handles NULL gracefully */
error0:
talloc_free(ubres);
return -1;
}
示例12: gw_rwlock_rdlock
int gw_rwlock_rdlock(RWLock *lock)
{
int ret = 0;
gw_assert(lock != NULL);
#ifdef HAVE_PTHREAD_RWLOCK
ret = pthread_rwlock_rdlock(&lock->rwlock);
if (ret != 0) {
panic(ret, "Error while pthread_rwlock_rdlock.");
}
#else
gwlist_lock(lock->rwlock);
gwlist_add_producer(lock->rwlock);
gwlist_unlock(lock->rwlock);
RWDEBUG("", 0, "------------ gw_rwlock_rdlock(%p) ----------", lock);
#endif
return ret;
}
示例13: ub_common_fail
static int ub_common_fail(REQUEST *request, char const *name, struct ub_result *ub)
{
if (ub->bogus) {
RWDEBUG("%s - Bogus DNS response", name);
return -1;
}
if (ub->nxdomain) {
RDEBUG2("%s - NXDOMAIN", name);
return -1;
}
if (!ub->havedata) {
RDEBUG2("%s - Empty result", name);
return -1;
}
return 0;
}
示例14: gw_rwlock_unlock
int gw_rwlock_unlock(RWLock *lock)
{
int ret = 0;
gw_assert(lock != NULL);
#ifdef HAVE_PTHREAD_RWLOCK
ret = pthread_rwlock_unlock(&lock->rwlock);
if (ret != 0)
panic(ret, "Error while gw_rwlock_unlock.");
#else
RWDEBUG("", 0, "------------ gw_rwlock_unlock(%p) ----------", lock);
if (lock->writer == gwthread_self()) {
lock->writer = -1;
gwlist_unlock(lock->rwlock);
} else
gwlist_remove_producer(lock->rwlock);
#endif
return ret;
}
示例15: dhcp_options_xlat
/*
* Allow single attribute values to be retrieved from the dhcp.
*/
static size_t dhcp_options_xlat(UNUSED void *instance, REQUEST *request,
char const *fmt, char *out, size_t freespace)
{
vp_cursor_t cursor;
VALUE_PAIR *vp, *head = NULL;
int decoded = 0;
while (isspace((int) *fmt)) fmt++;
if ((radius_get_vp(request, fmt, &vp) < 0) || !vp) {
*out = '\0';
return 0;
}
if ((fr_dhcp_decode_options(request->packet,
vp->vp_octets, vp->length, &head) < 0) ||
(!head)) {
RWDEBUG("DHCP option decoding failed");
goto fail;
}
for (vp = paircursor(&cursor, &head);
vp;
vp = pairnext(&cursor)) {
decoded++;
}
pairmove(request->packet, &(request->packet->vps), &head);
/* Free any unmoved pairs */
pairfree(&head);
fail:
snprintf(out, freespace, "%i", decoded);
return strlen(out);
}