本文整理汇总了C++中TURN_LOG_FUNC函数的典型用法代码示例。如果您正苦于以下问题:C++ TURN_LOG_FUNC函数的具体用法?C++ TURN_LOG_FUNC怎么用?C++ TURN_LOG_FUNC使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TURN_LOG_FUNC函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_mobility_ticket
int read_mobility_ticket(app_ur_conn_info *clnet_info, stun_buffer *message)
{
int ret = 0;
if(clnet_info && message) {
stun_attr_ref s_mobile_id_sar = stun_attr_get_first_by_type(message, STUN_ATTRIBUTE_MOBILITY_TICKET);
if(s_mobile_id_sar) {
int smid_len = stun_attr_get_len(s_mobile_id_sar);
if(smid_len>0 && (((size_t)smid_len)<sizeof(clnet_info->s_mobile_id))) {
const u08bits* smid_val = stun_attr_get_value(s_mobile_id_sar);
if(smid_val) {
ns_bcopy(smid_val, clnet_info->s_mobile_id, (size_t)smid_len);
clnet_info->s_mobile_id[smid_len] = 0;
if (clnet_verbose)
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,
"%s: smid=%s\n", __FUNCTION__, clnet_info->s_mobile_id);
}
} else {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
"%s: ERROR: smid_len=%d\n", __FUNCTION__, smid_len);
ret = -1;
}
}
}
return ret;
}
示例2: pgsql_get_user_key
static int pgsql_get_user_key(u08bits *usname, u08bits *realm, hmackey_t key) {
int ret = -1;
PGconn * pqc = get_pqdb_connection();
if(pqc) {
char statement[TURN_LONG_STRING_SIZE];
/* direct user input eliminated - there is no SQL injection problem (since version 4.4.5.3) */
snprintf(statement,sizeof(statement),"select hmackey from turnusers_lt where name='%s' and realm='%s'",usname,realm);
PGresult *res = PQexec(pqc, statement);
if(!res || (PQresultStatus(res) != PGRES_TUPLES_OK) || (PQntuples(res)!=1)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error retrieving PostgreSQL DB information: %s\n",PQerrorMessage(pqc));
} else {
char *kval = PQgetvalue(res,0,0);
int len = PQgetlength(res,0,0);
if(kval) {
size_t sz = get_hmackey_size(SHATYPE_DEFAULT);
if(((size_t)len<sz*2)||(strlen(kval)<sz*2)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key format: %s, user %s\n",kval,usname);
} else if(convert_string_key_to_binary(kval, key, sz)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong key: %s, user %s\n",kval,usname);
} else {
ret = 0;
}
} else {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong hmackey data for user %s: NULL\n",usname);
}
}
if(res)
PQclear(res);
}
return ret;
}
示例3: addr_debug_print
void addr_debug_print(int verbose, const ioa_addr *addr, const s08bits* s)
{
if (verbose) {
if (!addr) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: EMPTY\n", s);
} else {
s08bits addrbuf[INET6_ADDRSTRLEN];
if (!s)
s = "";
if (addr->ss.sa_family == AF_INET) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "IPv4. %s: %s:%d\n", s, inet_ntop(AF_INET,
&addr->s4.sin_addr, addrbuf, INET6_ADDRSTRLEN),
nswap16(addr->s4.sin_port));
} else if (addr->ss.sa_family == AF_INET6) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "IPv6. %s: %s:%d\n", s, inet_ntop(AF_INET6,
&addr->s6.sin6_addr, addrbuf, INET6_ADDRSTRLEN),
nswap16(addr->s6.sin6_port));
} else {
if (addr_any_no_port(addr)) {
TURN_LOG_FUNC(
TURN_LOG_LEVEL_INFO,
"IP. %s: 0.0.0.0:%d\n",
s,
nswap16(addr->s4.sin_port));
} else {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "%s: wrong IP address family: %d\n", s,
(int) (addr->ss.sa_family));
}
}
}
}
}
示例4: create_server_listener
static int create_server_listener(tls_listener_relay_server_type* server) {
FUNCSTART;
if(!server) return -1;
evutil_socket_t tls_listen_fd = -1;
tls_listen_fd = socket(server->addr.ss.ss_family, SOCK_STREAM, 0);
if (tls_listen_fd < 0) {
perror("socket");
return -1;
}
if(sock_bind_to_device(tls_listen_fd, (unsigned char*)server->ifname)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Cannot bind listener socket to device %s\n",server->ifname);
}
if(addr_bind(tls_listen_fd,&server->addr)<0) {
perror("Cannot bind local socket to addr");
char saddr[129];
addr_to_string(&server->addr,(u08bits*)saddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Cannot bind TCP/TLS listener socket to addr %s\n",saddr);
socket_closesocket(tls_listen_fd);
return -1;
}
socket_tcp_set_keepalive(tls_listen_fd);
socket_set_nonblocking(tls_listen_fd);
server->l = evconnlistener_new(server->e->event_base,
server_input_handler, server,
LEV_OPT_CLOSE_ON_FREE | LEV_OPT_REUSEABLE,
1024, tls_listen_fd);
if(!(server->l)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Cannot create TLS listener\n");
socket_closesocket(tls_listen_fd);
return -1;
}
if(addr_get_from_sock(tls_listen_fd, &(server->addr))) {
perror("Cannot get local socket addr");
socket_closesocket(tls_listen_fd);
return -1;
}
if(!no_tcp && !no_tls)
addr_debug_print(server->verbose, &server->addr,"TCP/TLS listener opened on ");
else if(!no_tls)
addr_debug_print(server->verbose, &server->addr,"TLS listener opened on ");
else if(!no_tcp)
addr_debug_print(server->verbose, &server->addr,"TCP listener opened on ");
FUNCEND;
return 0;
}
示例5: create_server_socket
static int create_server_socket(dtls_listener_relay_server_type* server) {
FUNCSTART;
if(!server) return -1;
clean_server(server);
ioa_socket_raw udp_listen_fd = -1;
udp_listen_fd = socket(server->addr.ss.ss_family, SOCK_DGRAM, 0);
if (udp_listen_fd < 0) {
perror("socket");
return -1;
}
server->udp_listen_s = create_ioa_socket_from_fd(server->e, udp_listen_fd, NULL, UDP_SOCKET, LISTENER_SOCKET, NULL, &(server->addr));
server->udp_listen_s->listener_server = server;
set_sock_buf_size(udp_listen_fd,UR_SERVER_SOCK_BUF_SIZE);
if(sock_bind_to_device(udp_listen_fd, (unsigned char*)server->ifname)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Cannot bind listener socket to device %s\n",server->ifname);
}
if(addr_bind(udp_listen_fd,&server->addr)<0) {
perror("Cannot bind local socket to addr");
char saddr[129];
addr_to_string(&server->addr,(u08bits*)saddr);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO,"Cannot bind UDP/DTLS listener socket to addr %s\n",saddr);
return -1;
}
server->udp_listen_ev = event_new(server->e->event_base,udp_listen_fd,
EV_READ|EV_PERSIST,udp_server_input_handler,server);
event_add(server->udp_listen_ev,NULL);
if(addr_get_from_sock(udp_listen_fd, &(server->addr))) {
perror("Cannot get local socket addr");
return -1;
}
if(!no_udp && !no_dtls)
addr_debug_print(server->verbose, &server->addr,"UDP/DTLS listener opened on ");
else if(!no_dtls)
addr_debug_print(server->verbose, &server->addr,"DTLS listener opened on ");
else if(!no_udp)
addr_debug_print(server->verbose, &server->addr,"UDP listener opened on ");
FUNCEND;
return 0;
}
示例6: server_input_handler
static void server_input_handler(struct evconnlistener *l, evutil_socket_t fd,
struct sockaddr *sa, int socklen, void *arg)
{
UNUSED_ARG(l);
tcp_listener_relay_server_type * server = (tcp_listener_relay_server_type*) arg;
if(!(server->e->connect_cb)) {
close(fd);
return;
}
FUNCSTART;
if (!server)
return;
if (server->stats)
++(*(server->stats));
ioa_addr client_addr;
ns_bcopy(sa,&client_addr,socklen);
addr_debug_print(server->verbose, &client_addr,"tcp connected to");
ioa_socket_handle ioas =
create_ioa_socket_from_fd(
server->e,
fd,
TCP_SOCKET,
CLIENT_SOCKET,
&client_addr,
&(server->addr));
if (ioas) {
ioa_net_data nd = { &client_addr, NULL, 0, TTL_IGNORE, TOS_IGNORE };
int rc = server->e->connect_cb(server->e, ioas, &nd);
if (rc < 0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
"Cannot create tcp session\n");
IOA_CLOSE_SOCKET(ioas);
}
} else {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,
"Cannot create ioa_socket from FD\n");
close(fd);
}
FUNCEND ;
}
示例7: get_persistent_users_db
static PGconn *get_pqdb_connection(void) {
persistent_users_db_t *pud = get_persistent_users_db();
PGconn *pqdbconnection = (PGconn*)pthread_getspecific(connection_key);
if(pqdbconnection) {
ConnStatusType status = PQstatus(pqdbconnection);
if(status != CONNECTION_OK) {
PQfinish(pqdbconnection);
pqdbconnection = NULL;
(void) pthread_setspecific(connection_key, pqdbconnection);
}
}
if(!pqdbconnection) {
char *errmsg=NULL;
PQconninfoOption *co = PQconninfoParse(pud->userdb, &errmsg);
if(!co) {
if(errmsg) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open PostgreSQL DB connection <%s>, connection string format error: %s\n",pud->userdb,errmsg);
turn_free(errmsg,strlen(errmsg)+1);
} else {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open PostgreSQL DB connection: <%s>, unknown connection string format error\n",pud->userdb);
}
} else {
PQconninfoFree(co);
if(errmsg)
turn_free(errmsg,strlen(errmsg)+1);
pqdbconnection = PQconnectdb(pud->userdb);
if(!pqdbconnection) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open PostgreSQL DB connection: <%s>, runtime error\n",pud->userdb);
} else {
ConnStatusType status = PQstatus(pqdbconnection);
if(status != CONNECTION_OK) {
PQfinish(pqdbconnection);
pqdbconnection = NULL;
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot open PostgreSQL DB connection: <%s>, runtime error\n",pud->userdb);
} else if(!donot_print_connection_success){
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "PostgreSQL DB connection success: %s\n",pud->userdb);
donot_print_connection_success = 1;
}
}
}
if(pqdbconnection) {
(void) pthread_setspecific(connection_key, pqdbconnection);
}
}
return pqdbconnection;
}
示例8: mongo_set_user_key
static int mongo_set_user_key(u08bits *usname, u08bits *realm, const char *key) {
mongoc_collection_t * collection = mongo_get_collection("turnusers_lt");
if(!collection)
return -1;
bson_t query;
bson_init(&query);
BSON_APPEND_UTF8(&query, "name", (const char *)usname);
BSON_APPEND_UTF8(&query, "realm", (const char *)realm);
bson_t doc;
bson_init(&doc);
BSON_APPEND_UTF8(&doc, "name", (const char *)usname);
BSON_APPEND_UTF8(&doc, "realm", (const char *)realm);
BSON_APPEND_UTF8(&doc, "hmackey", (const char *)key);
int ret = -1;
if (!mongoc_collection_update(collection, MONGOC_UPDATE_UPSERT, &query, &doc, NULL, NULL)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error inserting/updating user key information\n");
} else {
ret = 0;
}
mongoc_collection_destroy(collection);
bson_destroy(&doc);
bson_destroy(&query);
return ret;
}
示例9: init_server
static int init_server(tls_listener_relay_server_type* server,
const char* ifname,
const char *local_address,
int port,
int verbose,
ioa_engine_handle e,
ioa_engine_new_connection_event_handler send_socket,
struct relay_server *relay_server) {
if(!server) return -1;
server->connect_cb = send_socket;
server->relay_server = relay_server;
if(ifname) STRCPY(server->ifname,ifname);
if(make_ioa_addr((const u08bits*)local_address, port, &server->addr)<0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR,"Cannot create a TCP/TLS listener for address: %s\n",local_address);
return -1;
}
server->verbose=verbose;
server->e = e;
return create_server_listener(server);
}
示例10: mongo_set_oauth_key
static int mongo_set_oauth_key(oauth_key_data_raw *key) {
mongoc_collection_t * collection = mongo_get_collection("oauth_key");
if(!collection)
return -1;
bson_t query;
bson_init(&query);
BSON_APPEND_UTF8(&query, "kid", (const char *)key->kid);
bson_t doc;
bson_init(&doc);
BSON_APPEND_UTF8(&doc, "kid", (const char *)key->kid);
BSON_APPEND_UTF8(&doc, "as_rs_alg", (const char *)key->as_rs_alg);
BSON_APPEND_UTF8(&doc, "ikm_key", (const char *)key->ikm_key);
BSON_APPEND_INT64(&doc, "timestamp", (int64_t)key->timestamp);
BSON_APPEND_INT32(&doc, "lifetime", (int32_t)key->lifetime);
int ret = -1;
if (!mongoc_collection_update(collection, MONGOC_UPDATE_UPSERT, &query, &doc, NULL, NULL)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error inserting/updating oauth key information\n");
} else {
ret = 0;
}
mongoc_collection_destroy(collection);
bson_destroy(&doc);
bson_destroy(&query);
return ret;
}
示例11: dtls_accept_client_connection
static ioa_socket_handle dtls_accept_client_connection(
dtls_listener_relay_server_type* server,
SSL *ssl,
ioa_addr *remote_addr, ioa_addr *local_addr,
u08bits *s, int len)
{
FUNCSTART;
if (!ssl)
return NULL;
int rc = ssl_read(server->udp_listen_s->fd, ssl, (s08bits*)s, ioa_network_buffer_get_capacity(), server->verbose, &len);
if (rc < 0)
return NULL;
addr_debug_print(server->verbose, remote_addr, "Accepted connection from");
ioa_socket_handle ioas = create_ioa_socket_from_ssl(server->e, server->udp_listen_s, ssl, DTLS_SOCKET, CLIENT_SOCKET, remote_addr, local_addr);
if(ioas) {
ioas->listener_server = server;
addr_cpy(&(server->sm.m.sm.nd.src_addr),remote_addr);
server->sm.m.sm.nd.recv_ttl = TTL_IGNORE;
server->sm.m.sm.nd.recv_tos = TOS_IGNORE;
server->sm.m.sm.s = ioas;
} else {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Cannot create ioa_socket from SSL\n");
}
FUNCEND ;
return ioas;
}
示例12: pgsql_get_oauth_key
static int pgsql_get_oauth_key(const u08bits *kid, oauth_key_data_raw *key) {
int ret = -1;
char statement[TURN_LONG_STRING_SIZE];
/* direct user input eliminated - there is no SQL injection problem (since version 4.4.5.3) */
snprintf(statement,sizeof(statement),"select ikm_key,timestamp,lifetime,as_rs_alg,realm from oauth_key where kid='%s'",(const char*)kid);
PGconn * pqc = get_pqdb_connection();
if(pqc) {
PGresult *res = PQexec(pqc, statement);
if(!res || (PQresultStatus(res) != PGRES_TUPLES_OK) || (PQntuples(res)!=1)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error retrieving PostgreSQL DB information: %s\n",PQerrorMessage(pqc));
} else {
STRCPY(key->ikm_key,PQgetvalue(res,0,0));
key->timestamp = (u64bits)strtoll(PQgetvalue(res,0,1),NULL,10);
key->lifetime = (u32bits)strtol(PQgetvalue(res,0,2),NULL,10);
STRCPY(key->as_rs_alg,PQgetvalue(res,0,3));
STRCPY(key->realm,PQgetvalue(res,0,4));
STRCPY(key->kid,kid);
ret = 0;
}
if(res) {
PQclear(res);
}
}
return ret;
}
示例13: delete_tcp_connection
void delete_tcp_connection(tcp_connection *tc)
{
if(tc) {
if(tc->done) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "!!! %s: check on already closed tcp data connection: 0x%lx\n",__FUNCTION__);
return;
}
tc->done = 1;
IOA_EVENT_DEL(tc->peer_conn_timeout);
IOA_EVENT_DEL(tc->conn_bind_timeout);
allocation *a = (allocation*)(tc->owner);
if(a) {
ur_map *map = a->tcp_connections;
if(map) {
ur_map_del(map, (ur_map_key_type)(tc->id),NULL);
}
tcp_connection_list *tcl = &(a->tcl);
while(tcl->next) {
if((void*)(tcl->next) == (void*)tc) {
tcl->next = tc->list.next;
break;
} else {
tcl=tcl->next;
}
}
}
set_ioa_socket_sub_session(tc->client_s,NULL);
IOA_CLOSE_SOCKET(tc->client_s);
set_ioa_socket_sub_session(tc->peer_s,NULL);
IOA_CLOSE_SOCKET(tc->peer_s);
turn_free(tc,sizeof(tcp_connection));
}
}
示例14: mongo_set_admin_user
static int mongo_set_admin_user(const u08bits *usname, const u08bits *realm, const password_t pwd)
{
mongoc_collection_t * collection = mongo_get_collection("admin_user");
if(!collection)
return -1;
bson_t query;
bson_init(&query);
BSON_APPEND_UTF8(&query, "name", (const char *)usname);
bson_t doc;
bson_init(&doc);
BSON_APPEND_UTF8(&doc, "name", (const char *)usname);
BSON_APPEND_UTF8(&doc, "realm", (const char *)realm);
BSON_APPEND_UTF8(&doc, "password", (const char *)pwd);
int ret = -1;
if (!mongoc_collection_update(collection, MONGOC_UPDATE_UPSERT, &query, &doc, NULL, NULL)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error inserting/updating admin user information\n");
} else {
ret = 0;
}
mongoc_collection_destroy(collection);
bson_destroy(&doc);
bson_destroy(&query);
return ret;
}
示例15: pgsql_set_oauth_key
static int pgsql_set_oauth_key(oauth_key_data_raw *key) {
int ret = -1;
char statement[TURN_LONG_STRING_SIZE];
PGconn *pqc = get_pqdb_connection();
if(pqc) {
snprintf(statement,sizeof(statement),"insert into oauth_key (kid,ikm_key,timestamp,lifetime,as_rs_alg,realm) values('%s','%s',%llu,%lu,'%s','%s')",
key->kid,key->ikm_key,(unsigned long long)key->timestamp,(unsigned long)key->lifetime,
key->as_rs_alg,key->realm);
PGresult *res = PQexec(pqc, statement);
if(!res || (PQresultStatus(res) != PGRES_COMMAND_OK)) {
if(res) {
PQclear(res);
}
snprintf(statement,sizeof(statement),"update oauth_key set ikm_key='%s',timestamp=%lu,lifetime=%lu, as_rs_alg='%s', realm='%s' where kid='%s'",key->ikm_key,(unsigned long)key->timestamp,(unsigned long)key->lifetime,
key->as_rs_alg,key->realm,key->kid);
res = PQexec(pqc, statement);
if(!res || (PQresultStatus(res) != PGRES_COMMAND_OK)) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Error inserting/updating oauth_key information: %s\n",PQerrorMessage(pqc));
} else {
ret = 0;
}
} else {
ret = 0;
}
if(res) {
PQclear(res);
}
}
return ret;
}