/* 
 * Add a user data in the user data hash table
 * @param user_uri the SIP uri of the user
 * @param sevice the service that the user is trying to access
 */
user_d * add_user_data(str user_uri, str service, struct trans_info * options_tr){
		
	user_d * d;
	
	d = get_user_data(user_uri, service, options_tr->callid);
	if(d){
		LOG(L_ERR, "ERR:"M_NAME":add_user_data: there is already a user data "
				"for the user %.*s for the service %.*s and callid %.*s\n",
				user_uri.len, user_uri.s, 
				service.len, service.s,
				options_tr->callid.len, options_tr->callid.s);
		lrf_unlock(d->hash);
		return NULL;
	}

	d = new_user_data(user_uri, service, options_tr);
	if(!d)
		return NULL;

	lrf_lock(d->hash);
		d->next = 0;
		d->prev = user_datas[d->hash].tail;
		if (d->prev) d->prev->next = d;
		user_datas[d->hash].tail = d;
		if (!user_datas[d->hash].head) user_datas[d->hash].head = d;
	lrf_unlock(d->hash);
	return d;

}
Exemple #2
0
int test_close(talk_handle_t *hdl)
{
    int *fd = (int *)get_user_data(hdl);
    printf("@@@@@ test_close hdl: %p user_data: %p @@@@@\n", hdl, fd);

    *(fd + 2) = 0x0;
    return 0;
}
void user_on_closure(struct socket *sock)
{
	socket_satelite_data_t *socket_satelite_data = get_user_data(sock);
	if (!socket_satelite_data) {
		return;
	}
	ipaugenblick_mark_closed(socket_satelite_data);
}
void	interactive_animation::contact_callback(bool& do_colide,bool bo1,dContact& c,SGameMtl * /*material_1*/,SGameMtl * /*material_2*/)
{
	dxGeomUserData	*gd1 =NULL,	*gd2 =NULL;
	get_user_data( gd1, gd2, bo1, c.geom );
	VERIFY( gd1 );
	if( gd2 && gd2->ph_ref_object == gd1->ph_ref_object )
		return;
	 save_max( depth, c.geom.depth );
	//if(gd1&&gd2&&(CPhysicsShellHolder*)gd1->callback_data==gd2->ph_ref_object)	
	//																			do_colide=false;
}
void user_transmitted_callback(struct rte_mbuf *mbuf,struct socket *sock)
{
	int last = /*(rte_mbuf_refcnt_read(mbuf) == 1)*/1;
        if((sock)&&(last)) {
               socket_satelite_data_t *socket_satelite_data = get_user_data(sock);
               if(socket_satelite_data) {
//printf("%s %d %p %d %d %d\n",__FILE__,__LINE__,&g_ipaugenblick_sockets[socket_satelite_data->ringset_idx],socket_satelite_data->ringset_idx, rte_pktmbuf_data_len(mbuf),rte_mbuf_refcnt_read(mbuf));
                       user_increment_socket_tx_space(&g_ipaugenblick_sockets[socket_satelite_data->ringset_idx].tx_space,rte_pktmbuf_data_len(mbuf));
               }
        }
        rte_pktmbuf_free_seg(mbuf);
}
/*
 * delete the user data of the current user if exists(the URI is the R-URI of the current OPTIONS msg)
 * @param msg: current OPTIONS request
 * @param str1: not used
 * @param str2: not used
 */
int LRF_del_user_data(struct sip_msg* msg, char*str1, char*str2){

	str user_uri;
	user_d * d;
	unsigned int hash;
	str service;

	if (msg->first_line.u.request.method.len!=7||
		memcmp(msg->first_line.u.request.method.s,"OPTIONS",7)!=0){
		LOG(L_WARN,"WARN:"M_NAME":LRF_del_user_data: The method is not an OPTIONS, trying to replace the message\n");

		msg = cscf_get_request_from_reply(NULL);
		if(! msg || msg->first_line.type!=SIP_REQUEST || msg->first_line.u.request.method.len!=7||
			memcmp(msg->first_line.u.request.method.s,"OPTIONS",7)!=0){
					
			LOG(L_ERR,"BUG:"M_NAME":LRF_del_user_data: The new message is not an OPTIONS request either\n");
			return CSCF_RETURN_ERROR;
		}
	}

	service = cscf_get_headers_content(msg , service_hdr_name);
	if(!service.len || !service.s){
		LOG(L_ERR, "ERR:"M_NAME":LRF_del_user_data: could not find the service header in the OPTIONS, or could not be parsed\n");
		return CSCF_RETURN_FALSE;
	}

	str callid = cscf_get_call_id(msg, NULL);
	if(!callid.s || !callid.len){
		LOG(L_ERR, "ERR:"M_NAME":LRF_get_psap: could not find the callid header in the OPTIONS request\n");
		return CSCF_RETURN_FALSE;
	}

	user_uri = msg->first_line.u.request.uri;
	d = get_user_data(user_uri, service, callid);
	if(!d) return CSCF_RETURN_FALSE;

	if(d->loc_subscr)
		del_loc_subscription((loc_subscription*)d->loc_subscr);
	hash = d->hash;
	del_user_data(d);
	lrf_unlock(hash);

	return CSCF_RETURN_TRUE;
}
Exemple #7
0
static int call_xquery (request_rec *r) 
{  
  char *req_body = NULL;
  char * buf = NULL; // get_response (r, req_body);

  req_body = get_user_data (r);

  buf = get_response(r, req_body, pc_glob);


  ap_set_content_length (r, strlen(buf));
  ap_send_http_header( r );
  
  /* send response body */
  ap_rprintf (r, buf);
  
#ifndef USE_POOL
  free (req_body);
#endif
  
  return OK;
}// call_xquery()
void ipaugenblick_main_loop()
{
    struct rte_mbuf *mbuf;
    uint8_t ports_to_poll[1] = { 0 };
    int drv_poll_interval = get_max_drv_poll_interval_in_micros(0);
    app_glue_init_poll_intervals(drv_poll_interval/(2*MAX_PKT_BURST),
                                 100 /*timer_poll_interval*/,
                                 drv_poll_interval/(10*MAX_PKT_BURST),
                                drv_poll_interval/(60*MAX_PKT_BURST));
    
    ipaugenblick_service_api_init(COMMAND_POOL_SIZE,DATA_RINGS_SIZE,DATA_RINGS_SIZE);
    TAILQ_INIT(&buffers_available_notification_socket_list_head);
    TAILQ_INIT(&ipaugenblick_clients_list_head);
    init_systick(rte_lcore_id());
    ipaugenblick_log(IPAUGENBLICK_LOG_INFO,"IPAugenblick service initialized\n");
    while(1) {
        process_commands();
	app_glue_periodic(1,ports_to_poll,1);
        while(!TAILQ_EMPTY(&buffers_available_notification_socket_list_head)) {
            if(get_buffer_count() > 0) {
                struct socket *sock = TAILQ_FIRST(&buffers_available_notification_socket_list_head);
                socket_satelite_data_t *socket_data = get_user_data(sock);
		if(socket_data->socket->type == SOCK_DGRAM)
		   	user_set_socket_tx_space(&g_ipaugenblick_sockets[socket_data->ringset_idx].tx_space,sk_stream_wspace(socket_data->socket->sk));
		//printf("%s %d %d %d %d\n",__FILE__,__LINE__,socket_data->ringset_idx,g_ipaugenblick_sockets[socket_data->ringset_idx].tx_space,sk_stream_wspace(socket_data->socket->sk));
                if(!ipaugenblick_mark_writable(socket_data)) { 
                    sock->buffers_available_notification_queue_present = 0;
                    TAILQ_REMOVE(&buffers_available_notification_socket_list_head,sock,buffers_available_notification_queue_entry); 
                }
                else {
                    break;
                }
            }
            else {
                break;
            }
        }
    }
}
Exemple #9
0
/* Get map status */
void get_map_status(int mid, char* buff)
{
  struct list* user_list = &map_data_array[mid].user_data;
  int max_mobs = map_data_array[mid].map->monster_num;

  struct list_elem* e;
  char num_obj = 0;

  /* Add users to packet */
  for(e = list_begin(user_list); e != list_end(user_list); e = list_next(e))
  {
    struct user_data* d = get_user_data(*(int *)(e->conts));

    strncpy(buff+2+(int)num_obj*19, d->id, 11);
    memcpy(buff+13+(int)num_obj*19, &d->user_index, 4);
    memcpy(buff+17+(int)num_obj*19, &d->x, 2);
    memcpy(buff+19+(int)num_obj*19, &d->y, 2);

    num_obj = num_obj + 1;
  }

  /* Add monsters to packet */
  for(int i = 0; i < max_mobs; ++i)
  {
    if(map_data_array[mid].map->spwn_pts[i].spawned == 1)
    {
      memcpy(buff + 2 + 16 * 19 + (num_obj / 16) * 8, (char *)&map_data_array[mid].map->spwn_pts[i].id, 4);
      memcpy(buff + 2 + 16 * 19 + 4 + (num_obj / 16) * 8, (char *)&map_data_array[mid].map->spwn_pts[i].x_pos, 2);
      memcpy(buff + 2 + 16 * 19 + 6 + (num_obj / 16) * 8, (char *)&map_data_array[mid].map->spwn_pts[i].y_pos, 2);

      num_obj = num_obj + 16;
    }
  }

  buff[0] = (char)mid;
  buff[1] = num_obj;
}
/* Send the OPTIONS response to the E-CSCF
 * could be used after a LOCSIP NOTIFY is received
 * @param msg  - the OPTIONS request from the ECSCF
 * @param str1 - not used
 * @param str2 - not used
 * @return CSCF_RETURN_TRUE if ok, or CSCF_RETURN_FALSE if error
 */
int LRF_call_query_resp(struct sip_msg* msg, char*str1, char*str2){

	str user_uri;
	user_d * d= NULL;
	str service;
	struct cell * trans = NULL;
	str resp_body = {0,0};
	str headers = {0,0};
	unsigned int hash_index, label;

	LOG(L_INFO, "INFO:"M_NAME":LRF_call_query_resp\n");

	if (msg->first_line.u.request.method.len!=7||
		memcmp(msg->first_line.u.request.method.s,"OPTIONS",7)!=0){
		LOG(L_WARN,"WARN:"M_NAME":LRF_call_query_resp: The method is not an OPTIONS, trying to replace the message\n");

		msg = cscf_get_request_from_reply(NULL);
		if(! msg || msg->first_line.type!=SIP_REQUEST || msg->first_line.u.request.method.len!=7||
			memcmp(msg->first_line.u.request.method.s,"OPTIONS",7)!=0){
					
			LOG(L_ERR,"BUG:"M_NAME":LRF_call_query_resp: The new message is not an OPTIONS request either\n");
			return CSCF_RETURN_ERROR;
		}
	}

	service = cscf_get_headers_content(msg, service_hdr_name);
	if(!service.len || !service.s){
		LOG(L_ERR, "ERR:"M_NAME":LRF_call_query_resp: could not find the service header in the OPTIONS, or could not be parsed\n");
		return CSCF_RETURN_FALSE;
	}

	str callid = cscf_get_call_id(msg, NULL);
	if(!callid.s || !callid.len){
		LOG(L_ERR, "ERR:"M_NAME":LRF_get_psap: could not find the callid header in the OPTIONS request\n");
		return CSCF_RETURN_FALSE;
	}

	user_uri = msg->first_line.u.request.uri;
	d = get_user_data(user_uri, service, callid);
	if(!d) {
		LOG(L_ERR, "ERR:"M_NAME":LRF_call_query_resp: could not found user data for uri %.*s and service %.*s\n",
				user_uri.len, user_uri.s, service.len, service.s);
		goto error;
	}

	if(!d->psap_uri.len || !d->psap_uri.s){
		LOG(L_ERR, "ERR: "M_NAME":LRF_call_query_resp: null psap uri\n");
		goto error;
	}

	if(d->loc && d->locsip_loc){
		LOG(L_DBG, "DBG: "M_NAME":LRF_call_query_resp: LRF has location information from the LOCSIP server\n");
		if(get_options_resp_body(&resp_body, d)){
			LOG(L_ERR, "ERR:"M_NAME":LRF_call_query_resp:could not get the OPTIONS response body\n");
			goto error;
		}
	}
	
	if(get_options_resp_headers(&headers, d)){
		LOG(L_ERR, "ERR:"M_NAME":LRF_call_query_resp:could not get the OPTIONS response headers\n");
		goto error;
	}
	
	//get crt trans	
	if(cscf_get_transaction(msg, &hash_index, &label)<0){
		LOG(L_ERR, "ERR:"M_NAME":LRF_call_query_resp: could not get the trans from the message\n");
		goto error;
	}

	if(tmb.t_lookup_ident(&trans, hash_index, label)!=1){
		LOG(L_ERR, "ERR:"M_NAME":LRF_call_query_resp: could not get the trans from the hash and index\n");
		goto error;
	}
	
	if(tmb.t_reply_with_body(trans, 200, "OK - PSAP found", resp_body.s, headers.s, "lrf" )!= 1){
		LOG(L_ERR, "ERR:"M_NAME":LRF_call_query_resp: could not send the response\n");
		goto error2;
	}

#ifndef TM_DEL_UNREF
	LOG(L_ERR, "ERR:"M_NAME":LRF_call_query_resp: options ref count %i\n", trans->ref_count);
#endif
	

	lrf_unlock(d->hash);
	if(resp_body.s)
		pkg_free(resp_body.s);
	if(headers.s)
		pkg_free(headers.s);

	return CSCF_RETURN_TRUE;

error2:
	//tmb.t_unref_ident(trans->hash_index, trans->label);

error:
	LOG(L_DBG, "DBG: "M_NAME":LRF_call_query_resp: error label\n");
	if(d)
		lrf_unlock(d->hash);
	LOG(L_DBG, "DBG: "M_NAME":LRF_call_query_resp: error label\n");
	//if(resp_body.s) pkg_free(resp_body.s);
	LOG(L_DBG, "DBG: "M_NAME":LRF_call_query_resp: error label\n");
	//if(headers.s)	pkg_free(headers.s);
	LOG(L_DBG, "DBG: "M_NAME":LRF_call_query_resp: error label\n");

	return CSCF_RETURN_FALSE;
}