本文整理汇总了C++中rc_avpair_free函数的典型用法代码示例。如果您正苦于以下问题:C++ rc_avpair_free函数的具体用法?C++ rc_avpair_free怎么用?C++ rc_avpair_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rc_avpair_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rc_acct_proxy
int rc_acct_proxy(VALUE_PAIR *send)
{
SEND_DATA data;
int result;
char msg[4096];
int i;
SERVER *acctserver = rc_conf_srv("authserver");
int timeout = rc_conf_int("radius_timeout");
int retries = rc_conf_int("radius_retries");
data.send_pairs = send;
data.receive_pairs = NULL;
result = ERROR_RC;
for(i=0; (i<acctserver->max) && (result != OK_RC) && (result != BADRESP_RC)
; i++)
{
if (data.receive_pairs != NULL) {
rc_avpair_free(data.receive_pairs);
data.receive_pairs = NULL;
}
rc_buildreq(&data, PW_ACCOUNTING_REQUEST, acctserver->name[i],
acctserver->port[i], timeout, retries);
result = rc_send_server (&data, msg, NULL);
}
rc_avpair_free(data.receive_pairs);
return result;
}
示例2: rc_acct_using_server
int rc_acct_using_server(SERVER *acctserver,
UINT4 client_port,
VALUE_PAIR *send)
{
SEND_DATA data;
VALUE_PAIR *adt_vp;
int result;
time_t start_time, dtime;
char msg[4096];
int i;
int timeout = rc_conf_int("radius_timeout");
int retries = rc_conf_int("radius_retries");
data.send_pairs = send;
data.receive_pairs = NULL;
/*
* Fill in NAS-IP-Address or NAS-Identifier
*/
if (rc_get_nas_id(&(data.send_pairs)) == ERROR_RC)
return (ERROR_RC);
/*
* Fill in NAS-Port
*/
if (rc_avpair_add(&(data.send_pairs), PW_NAS_PORT, &client_port, 0, VENDOR_NONE) == NULL)
return (ERROR_RC);
/*
* Fill in Acct-Delay-Time
*/
dtime = 0;
if ((adt_vp = rc_avpair_add(&(data.send_pairs), PW_ACCT_DELAY_TIME, &dtime, 0, VENDOR_NONE)) == NULL)
return (ERROR_RC);
start_time = time(NULL);
result = ERROR_RC;
for(i=0; (i<acctserver->max) && (result != OK_RC) && (result != BADRESP_RC)
; i++)
{
if (data.receive_pairs != NULL) {
rc_avpair_free(data.receive_pairs);
data.receive_pairs = NULL;
}
rc_buildreq(&data, PW_ACCOUNTING_REQUEST, acctserver->name[i],
acctserver->port[i], timeout, retries);
dtime = time(NULL) - start_time;
rc_avpair_assign(adt_vp, &dtime, 0);
result = rc_send_server (&data, msg, NULL);
}
rc_avpair_free(data.receive_pairs);
return result;
}
示例3: send_acct_func_async
int send_acct_func_async(struct sip_msg* msg, async_resume_module **resume_f,
void **resume_param, str *s)
{
int i, index = -1, res;
VALUE_PAIR *send = NULL;
SEND_CONTEXT *ctx = 0;
struct rad_ctx *rctx;
if (!rh) {
if (init_radius_handle()) {
LM_ERR("invalid radius handle\n");
return -1;
}
}
for (i = 0; i < set_size; i++) {
if (sets[i]->set_name.len == s->len &&
!strncmp(sets[i]->set_name.s, s->s, s->len))
index = i;
}
if (index == -1) {
LM_ERR("set not found\n");
return -1;
}
if (make_send_message(msg, index, &send) < 0) {
LM_ERR("make message failed\n");
return -1;
}
res = rc_acct_async(rh, SIP_PORT, send, &ctx);
if (res == OK_RC) {
LM_DBG("radius accounting message sent\n");
rctx = pkg_malloc(sizeof(struct rad_ctx));
if (rctx == NULL) {
LM_ERR("no pkg mem\n");
if (send) rc_avpair_free(send);
return -1;
}
rctx->send = send;
rctx->ctx = ctx;
*resume_param = rctx;
*resume_f = resume_send_acct;
async_status = ctx->sockfd;
return 1;
}
if (send) rc_avpair_free(send);
return -1;
}
示例4: load_user_attrs
static int load_user_attrs(struct sip_msg* msg, unsigned long flags, fparam_t* fp)
{
static char rad_msg[4096];
str uid;
UINT4 service;
VALUE_PAIR* send, *received;
send = NULL;
received = NULL;
if (get_str_fparam(&uid, msg, (fparam_t*)fp) < 0) {
ERR("Unable to get UID\n");
return -1;
}
service = vals[V_GET_USER_ATTRS].v;
if (!rc_avpair_add(rh, &send, ATTRID(attrs[A_USER_NAME].v),
uid.s, uid.len,
VENDOR(attrs[A_USER_NAME].v))) {
ERR("Error while adding A_USER_NAME\n");
goto error;
}
if (!rc_avpair_add(rh, &send, ATTRID(attrs[A_SER_SERVICE_TYPE].v),
&vals[V_GET_USER_ATTRS].v, -1,
VENDOR(attrs[A_SER_SERVICE_TYPE].v))) {
ERR("Error adding A_SERVICE_TYPE\n");
goto error;
}
if (rc_auth(rh, 0, send, &received, rad_msg) != OK_RC) {
DBG("load_user_attrs: Failure\n");
goto error;
}
DBG("load_user_attrs: Success\n");
rc_avpair_free(send);
if (generate_avps(flags, received) < 0) {
rc_avpair_free(received);
goto error;
}
rc_avpair_free(received);
return 1;
error:
if (send) rc_avpair_free(send);
if (received) rc_avpair_free(send);
return -1;
}
示例5: free_radius_auth_value_pair
void free_radius_auth_value_pair(VALUE_PAIR *send, VALUE_PAIR *received, rc_handle *rh)
{
if (send)
rc_avpair_free(send);
if (received)
rc_avpair_free(received);
if (rh)
rc_destroy(rh);
rh = NULL;
}
示例6: process
int process(void *rh, VALUE_PAIR * send, int acct, int nas_port)
{
VALUE_PAIR *received;
char msg[PW_MAX_MSG_SIZE];
char buf[BUF_LEN];
int i, fd;
fd = rc_tls_fd(rh);
if (fd >= 0) {
dup(fd);
close(fd);
}
received = NULL;
if (acct == 0) {
i = rc_auth(rh, nas_port, send, &received, msg);
if (i != OK_RC) {
fprintf(stderr, "tls-restart: error sending 1 (ok)\n");
}
i = rc_auth(rh, nas_port, send, &received, msg);
if (i != OK_RC) {
fprintf(stderr, "tls-restart: error sending 2\n");
exit(2);
}
if (received != NULL) {
printf("%s", rc_avpair_log(rh, received, buf, BUF_LEN));
rc_avpair_free(received);
}
} else {
i = rc_acct(rh, nas_port, send);
}
return (i == OK_RC) ? 0 : 1;
}
示例7: radius_log
static void radius_log(struct ast_event *event)
{
int result = ERROR_RC;
VALUE_PAIR *send = NULL;
struct ast_cel_event_record record = {
.version = AST_CEL_EVENT_RECORD_VERSION,
};
if (ast_cel_fill_record(event, &record)) {
return;
}
if (build_radius_record(&send, &record)) {
ast_debug(1, "Unable to create RADIUS record. CEL not recorded!\n");
goto return_cleanup;
}
result = rc_acct(rh, 0, send);
if (result != OK_RC) {
ast_log(LOG_ERROR, "Failed to record Radius CEL record!\n");
}
return_cleanup:
if (send) {
rc_avpair_free(send);
}
}
示例8: rc_check
int rc_check(char *host, unsigned short port, char *msg)
{
SEND_DATA data;
int result;
UINT4 service_type;
int timeout = rc_conf_int("radius_timeout");
int retries = rc_conf_int("radius_retries");
data.send_pairs = data.receive_pairs = NULL;
/*
* Fill in NAS-IP-Address or NAS-Identifier,
* although it isn't neccessary
*/
if (rc_get_nas_id(&(data.send_pairs)) == ERROR_RC)
return (ERROR_RC);
/*
* Fill in Service-Type
*/
service_type = PW_ADMINISTRATIVE;
rc_avpair_add(&(data.send_pairs), PW_SERVICE_TYPE, &service_type, 0, VENDOR_NONE);
rc_buildreq(&data, PW_STATUS_SERVER, host, port, timeout, retries);
result = rc_send_server (&data, msg, NULL);
rc_avpair_free(data.receive_pairs);
return result;
}
示例9: rc_check
/** Asks the server hostname on the specified port for a status message
*
* @param rh a handle to parsed configuration.
* @param host the name of the server.
* @param secret the secret used by the server.
* @param port the server's port number.
* @param msg must be an array of PW_MAX_MSG_SIZE or NULL; will contain the concatenation of any
* PW_REPLY_MESSAGE received.
* @return OK_RC (0) on success, negative on failure as return value.
*/
int rc_check(rc_handle *rh, char *host, char *secret, unsigned short port, char *msg)
{
SEND_DATA data;
int result;
uint32_t service_type;
int timeout = rc_conf_int(rh, "radius_timeout");
int retries = rc_conf_int(rh, "radius_retries");
rc_type type;
data.send_pairs = data.receive_pairs = NULL;
if (rh->so_type == RC_SOCKET_TLS || rh->so_type == RC_SOCKET_DTLS)
type = AUTH;
else
type = ACCT;
/*
* Fill in Service-Type
*/
service_type = PW_ADMINISTRATIVE;
rc_avpair_add(rh, &(data.send_pairs), PW_SERVICE_TYPE, &service_type, 0, 0);
rc_buildreq(rh, &data, PW_STATUS_SERVER, host, port, secret, timeout, retries);
result = rc_send_server (rh, &data, msg, type);
rc_avpair_free(data.receive_pairs);
return result;
}
示例10: resume_send_acct
/* TODO
* when timeout mechanism will be available
* rc_auth_function shall be called to try another
* destination if the current one has timed out
* */
int resume_send_acct(int fd, struct sip_msg *msg, void *param)
{
int res, retval;
struct rad_ctx *rctx;
rctx = (struct rad_ctx *)param;
if (rctx == NULL) {
LM_ERR("no context given\n");
return -1;
}
res = rc_acct_resume(&rctx->ctx);
if (res == OK_RC || res == REJECT_RC) {
async_status = ASYNC_DONE;
retval = 1;
} else if (res == READBLOCK_RC) {
async_status = ASYNC_CONTINUE;
retval = 1;
goto exit;
} else {
LM_ERR("radius authentication message failed with %s\n",
((res==BADRESP_RC)?"BAD REPLY":"ERROR"));
retval = -1;
}
if (rctx->send) rc_avpair_free(rctx->send);
pkg_free(rctx);
exit:
return retval;
}
示例11: process
int
process(void *rh, VALUE_PAIR *send, int acct, int nas_port, int send_info)
{
VALUE_PAIR *received = NULL;
char buf[BUF_LEN];
RC_AAA_CTX *ctx = NULL;
const unsigned char *p;
int i, j;
received = NULL;
if (acct == 0) {
i = rc_aaa_ctx(rh, &ctx, nas_port, send, &received, NULL, 1, PW_ACCESS_REQUEST);
if (received != NULL) {
printf("%s", rc_avpair_log(rh, received, buf, BUF_LEN));
rc_avpair_free(received);
}
if (ctx) {
if (send_info) {
printf("Request-Info-Secret = %s\n", rc_aaa_ctx_get_secret(ctx));
printf("Request-Info-Vector = ");
p = rc_aaa_ctx_get_vector(ctx);
for (j=0; j<AUTH_VECTOR_LEN; j++) {
printf("%.2x", (unsigned)p[j]);
}
printf("\n");
}
rc_aaa_ctx_free(ctx);
}
} else {
i = rc_acct(rh, nas_port, send);
}
return (i == OK_RC) ? 0 : 1;
}
示例12: mod_xml_radius_accounting_end
switch_status_t mod_xml_radius_accounting_end(switch_core_session_t *session){
VALUE_PAIR *send = NULL;
uint32_t service = PW_STATUS_STOP;
rc_handle *new_handle = NULL;
switch_xml_t fields = NULL, conditions = NULL;
switch_channel_t *channel = switch_core_session_get_channel(session);
if (GLOBAL_DEBUG ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: starting accounting stop\n");
switch_core_session_execute_application(session, "info", NULL);
}
/* If there are conditions defined, and none of them pass, then skip this accounting */
if ((conditions = switch_xml_child(globals.acct_start_configs, "conditions")) != NULL &&
mod_xml_radius_check_conditions(channel, conditions) != SWITCH_STATUS_SUCCESS ) {
goto end;
}
if ( mod_xml_radius_new_handle(&new_handle, globals.acct_end_configs) != SWITCH_STATUS_SUCCESS || new_handle == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new accounting_end handle for call: %s\n",
switch_channel_get_variable(channel, "uuid"));
goto end;
}
if ((fields = switch_xml_child(globals.acct_end_configs, "fields")) == NULL ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not find 'fields' section in config file.\n");
goto end;
}
if ( mod_xml_radius_add_params(session, NULL, new_handle, &send, fields) != SWITCH_STATUS_SUCCESS ) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to add params to rc_handle\n");
goto end;
}
if (rc_avpair_add(new_handle, &send, PW_ACCT_STATUS_TYPE, &service, -1, 0) == NULL) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: failed to add option to handle\n");
goto end;
}
if (rc_acct(new_handle, 0, send) == OK_RC) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "mod_xml_radius: Accounting Stop success\n");
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "mod_xml_radius: Accounting Stop failed\n");
}
end:
if ( send ) {
rc_avpair_free(send);
send = NULL;
}
if ( new_handle) {
rc_destroy(new_handle);
new_handle = NULL;
}
return SWITCH_STATUS_SUCCESS;
}
示例13: log_request
/* skip leading text and begin with first item's
* separator ", " which will be overwritten by the
* leading text later
*
*/
static int log_request(struct sip_msg* rq, str* ouri, struct hdr_field* to, unsigned int code, time_t req_time)
{
VALUE_PAIR *send;
UINT4 av_type;
send = NULL;
if (skip_cancel(rq)) return 1;
if (fmt2rad(log_fmt, rq, ouri, to, code, &send, req_time) < 0) goto error;
/* Add Acct-Status-Type attribute */
av_type = rad_status(rq, code);
if (!rc_avpair_add(rh, &send, ATTRID(attrs[A_ACCT_STATUS_TYPE].v), &av_type, -1,
VENDOR(attrs[A_ACCT_STATUS_TYPE].v))) {
ERR("Add Status-Type\n");
goto error;
}
/* Add Service-Type attribute */
av_type = (service_type != -1) ? service_type : vals[V_SIP_SESSION].v;
if (!rc_avpair_add(rh, &send, ATTRID(attrs[A_SERVICE_TYPE].v), &av_type, -1,
VENDOR(attrs[A_SERVICE_TYPE].v))) {
ERR("add STATUS_TYPE\n");
goto error;
}
/* Add User-Name attribute */
if (add_user_name(rq, rh, &send) < 0) goto error;
/* Send the request out */
if (rc_acct(rh, SIP_PORT, send) != OK_RC) {
ERR("RADIUS accounting request failed\n");
goto error;
}
rc_avpair_free(send);
return 1;
error:
rc_avpair_free(send);
return -1;
}
示例14: rad_destroy_message
/*
Radius implementation for the destroy_aaa_message callback
*/
int rad_destroy_message(aaa_conn* rh, aaa_message* message) {
if (!rh || ! message) {
LM_ERR("invalid arguments\n");
return -1;
}
rc_avpair_free((VALUE_PAIR*) message->avpair);
pkg_free(message);
return 0;
}
示例15: radius_does_uri_exist
/*
* Check from Radius if request URI belongs to a local user.
* User-Name is [email protected] of request Uri and Service-Type is Call-Check.
*/
int radius_does_uri_exist(struct sip_msg* _m, char* _s1, char* _s2)
{
static char msg[4096];
VALUE_PAIR *send, *received;
UINT4 service;
char* at, *uri;
send = received = 0;
if (parse_sip_msg_uri(_m) < 0) {
LM_ERR("parsing URI failed\n");
return -1;
}
uri = (char*)pkg_malloc(_m->parsed_uri.user.len + _m->parsed_uri.host.len + 2);
if (!uri) {
LM_ERR("no more pkg memory\n");
return -2;
}
at = uri;
memcpy(at, _m->parsed_uri.user.s, _m->parsed_uri.user.len);
at += _m->parsed_uri.user.len;
*at = '@';
at++;
memcpy(at , _m->parsed_uri.host.s, _m->parsed_uri.host.len);
at += _m->parsed_uri.host.len;
*at = '\0';
if (!rc_avpair_add(rh, &send, attrs[A_USER_NAME].v, uri, -1, 0)) {
LM_ERR("adding User-Name failed\n");
rc_avpair_free(send);
pkg_free(uri);
return -3;
}
service = vals[V_CALL_CHECK].v;
if (!rc_avpair_add(rh, &send, attrs[A_SERVICE_TYPE].v, &service, -1, 0)) {
LM_ERR("adding service type failed\n");
rc_avpair_free(send);
pkg_free(uri);
return -4;
}
if (rc_auth(rh, 0, send, &received, msg) == OK_RC) {
LM_DBG("success\n");
rc_avpair_free(send);
generate_avps(received);
rc_avpair_free(received);
pkg_free(uri);
return 1;
} else {
LM_DBG("failure\n");
rc_avpair_free(send);
rc_avpair_free(received);
pkg_free(uri);
return -5;
}
}