Beispiel #1
0
/**
 *	Encode and append a Service Profile
 * @param x - binary data to append to
 * @param sp - the service profile to encode
 * @returns 1 on succcess or 0 on error
 */
static int bin_encode_service_profile(bin_data *x,ims_service_profile *sp)
{
	int i;
		
	//public identity
	if (!bin_encode_ushort(x,sp->public_identities_cnt)) return 0;
	for(i=0;i<sp->public_identities_cnt;i++)
		if (!bin_encode_public_identity(x,sp->public_identities+i)) goto error;
	
	//filter criteria
	if (!bin_encode_ushort(x,sp->filter_criteria_cnt)) return 0;
	for(i=0;i<sp->filter_criteria_cnt;i++)
		if (!bin_encode_filter_criteria(x,sp->filter_criteria+i)) goto error;
		
	//cn service_auth
	if (sp->cn_service_auth)
		i = sp->cn_service_auth->subscribed_media_profile_id;
	else i = 0xFFFFFFFF;
	if (!bin_encode_int(x,i)) goto error;

	//shared_ifc
	if (!bin_encode_ushort(x,sp->shared_ifc_set_cnt)) return 0;
	for(i=0;i<sp->shared_ifc_set_cnt;i++)
		if (!bin_encode_int(x,sp->shared_ifc_set[i])) goto error;

	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_service_profile: Error while encoding.\n");
	return 0;		
}
Beispiel #2
0
/**
 * Encode a dialog into a binary form
 * @param x - binary data to append to
 * @param u - the dialog to encode
 * @returns 1 on succcess or 0 on error
 */
int bin_encode_s_dialog(bin_data *x,s_dialog *d)
{
	char ch;
	if (!bin_encode_str(x,&(d->call_id))) goto error;
	ch = d->direction;
	if (!bin_encode_char(x,ch)) goto error;
	
	if (!bin_encode_str(x,&(d->aor))) goto error;
	
	ch = d->method;
	if (!bin_encode_char(x,ch)) goto error;	
	if (!bin_encode_str(x,&(d->method_str))) goto error;
	
	if (!bin_encode_int(x,d->first_cseq)) goto error;	
	if (!bin_encode_int(x,d->last_cseq)) goto error;	

	ch = d->state;
	if (!bin_encode_char(x,ch)) goto error;	

	if (!bin_encode_time_t(x,d->expires)) goto error;
	
	if (!bin_encode_uchar(x,d->is_releasing)) goto error;
	if (!bin_encode_dlg_t(x,d->dialog_c)) goto error;	
	if (!bin_encode_dlg_t(x,d->dialog_s)) goto error;
	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_s_dialog: Error while encoding.\n");
	return 0;		
}
Beispiel #3
0
/**
 * Encode an security into a binary form
 * @param x - binary data to append to
 * @param s - the r_security to encode
 * @returns 1 s succcess or 0 on error
 */
int bin_encode_r_security(bin_data *x,r_security *s)
{
	if (!s){
		if (!bin_encode_char(x,0)) goto error;
		return 1;
	}
	
	if (!bin_encode_char(x,1)) goto error;

	if (!bin_encode_str(x,&(s->sec_header))) goto error;	
	if (!bin_encode_int(x,s->type)) goto error;
	switch (s->type){		
		case SEC_NONE:
			break;
		case SEC_TLS:
			if (!bin_encode_tls(x,s->data.tls)) goto error;
			break;
		case SEC_IPSEC:
			if (!bin_encode_ipsec(x,s->data.ipsec)) goto error;
			break;		
	}	
	if (!bin_encode_int(x,s->q*1000)) goto error; /* yeah yeah.... */
	
	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_security: Error while encoding.\n");
	return 0;		
}
Beispiel #4
0
/**
 *	Encode and Append a Filter Criteria
 * @param x - binary data to append to
 * @param spt - the service point trigger to encode
 * @returns 1 on succcess or 0 on error
 */
static int bin_encode_filter_criteria(bin_data *x, ims_filter_criteria *fc)
{
	int i;
	char ppindicator;

	//priority
	if (!bin_encode_int(x,fc->priority)) goto error;
	
	//profile part indicator
	if (fc->profile_part_indicator) ppindicator = (*fc->profile_part_indicator)+1;
	else ppindicator = 0;
	if (!bin_encode_char(x,ppindicator)) goto error;
			
	// trigger point 
	if (fc->trigger_point) {
		if (!bin_encode_char(x,fc->trigger_point->condition_type_cnf)) goto error;
		
		if (!bin_encode_ushort(x,fc->trigger_point->spt_cnt)) goto error;
		
		for(i=0;i<fc->trigger_point->spt_cnt;i++)
			if (!bin_encode_spt(x,fc->trigger_point->spt+i)) goto error;
	} else {
		if (!bin_encode_char(x,100)) goto error;
	}
	
	//app server
	if (!bin_encode_str(x,&(fc->application_server.server_name))) goto error;
	if (!bin_encode_char(x,fc->application_server.default_handling)) goto error;
	if (!bin_encode_str(x,&(fc->application_server.service_info))) goto error;
	
	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_filter_criteria: Error while encoding.\n");
	return 0;		
}
Beispiel #5
0
/**
 *	Encode and append a SPT
 * @param x - binary data to append to
 * @param spt - the service point trigger to encode
 * @returns 1 on succcess or 0 on error
 */
static int bin_encode_spt(bin_data *x, ims_spt *spt)
{
	unsigned char c = spt->condition_negated<<7 | spt->registration_type<<4 | spt->type;
	// cond negated, reg type, spt type
	if (!bin_encode_uchar(x,c)) goto error;

	//group
	if (!bin_encode_int(x,spt->group)) goto error;

	//spt
	switch(spt->type){
		case 1:
			if (!bin_encode_str(x,&(spt->request_uri))) goto error; 
			break;
		case 2:
			if (!bin_encode_str(x,&(spt->method))) goto error; 
			break;
		case 3:
			if (!bin_encode_short(x,spt->sip_header.type)) goto error;
			if (!bin_encode_str(x,&(spt->sip_header.header))) goto error; 
			if (!bin_encode_str(x,&(spt->sip_header.content))) goto error; 
			break;
		case 4:
			if (!bin_encode_char(x,spt->session_case)) goto error;
			break;
		case 5:
			if (!bin_encode_str(x,&(spt->session_desc.line))) goto error; 
			if (!bin_encode_str(x,&(spt->session_desc.content))) goto error; 
			break;
	}
	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_spt: Error while encoding.\n");
	return 0;		
}
Beispiel #6
0
/**
 * Encode an dialog into a binary form
 * @param x - binary data to append to
 * @param u - the dialog to encode
 * @returns 1 on succcess or 0 on error
 */
int bin_encode_p_dialog(bin_data *x,p_dialog *d)
{
	int i;
	char c;
	
	if (!bin_encode_str(x,&(d->call_id))) goto error;
	
	c = d->direction;
	if (!bin_encode_uchar(x,c)) goto error;
	
	if (!bin_encode_str(x,&(d->host))) goto error;
	if (!bin_encode_ushort(x,d->port)) goto error;
	
	c = d->transport;
	if (!bin_encode_uchar(x,c)) goto error;

	if (!bin_encode_ushort(x,d->routes_cnt)) goto error;
	for(i=0;i<d->routes_cnt;i++)
		if (!bin_encode_str(x,d->routes+i)) goto error;
	
	c = d->method;
	if (!bin_encode_uchar(x,c)) goto error;
	if (!bin_encode_str(x,&(d->method_str))) goto error;
	
	if (!bin_encode_int(x,d->first_cseq)) goto error;	
	if (!bin_encode_int(x,d->last_cseq)) goto error;	

	c = d->state;
	if (!bin_encode_uchar(x,c)) goto error;	

	if (!bin_encode_time_t(x,d->expires)) goto error;		
	if (!bin_encode_time_t(x,d->lr_session_expires)) goto error;
	if (!bin_encode_str(x,&(d->refresher))) goto error;
	if (!bin_encode_uchar(x,d->uac_supp_timer)) goto error;
	
	if (!bin_encode_uchar(x,d->is_releasing)) goto error;
	
	if (!bin_encode_str(x,&(d->pcc_session_id))) goto error;
	
	if (!bin_encode_dlg_t(x,d->dialog_c)) goto error;	
	if (!bin_encode_dlg_t(x,d->dialog_s)) goto error;
	
	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_p_dialog: Error while encoding.\n");
	return 0;		
}
Beispiel #7
0
/**
 * Encode a r_subscriber into a binary form
 * @param x - binary data to append to
 * @param s - the r_subscriber to encode
 * @returns 1 on succcess or 0 on error
 */
int bin_encode_r_subscriber(bin_data *x,r_subscriber *s)
{
	if (!bin_encode_str(x,&(s->subscriber))) goto error;
	if (!bin_encode_char(x,s->event)) goto error;
	if (!bin_encode_time_t(x,s->expires)) goto error;
	if (!bin_encode_dlg_t(x,s->dialog)) goto error;
	if (!bin_encode_int(x,s->version)) goto error;

	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_subscriber: Error while encoding.\n");
	return 0;		
}
Beispiel #8
0
/**
 * Encode an authentication vector into a binary form
 * @param x - binary data to append to
 * @param v - the authentication vector to encode
 * @returns 1 on succcess or 0 on error
 */
 int bin_encode_auth_vector(bin_data *x,auth_vector *v)
{
	char ch;
	if (!bin_encode_int(x,v->item_number)) goto error;
	if (!bin_encode_uchar(x,v->type)) goto error;
	if (!bin_encode_str(x,&(v->authenticate))) goto error;
	if (!bin_encode_str(x,&(v->authorization))) goto error;
	if (!bin_encode_str(x,&(v->ck))) goto error;
	if (!bin_encode_str(x,&(v->ik))) goto error;
	if (!bin_encode_time_t(x,v->expires)) goto error;
	ch = v->status;
	if (!bin_encode_char(x,ch)) goto error;

	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_auth_vector: Error while encoding.\n");
	return 0;		
}
Beispiel #9
0
/**
 * Encode a r_subscription into a binary form
 * @param x - binary data to append to
 * @param p - the r_subscription to encode
 * @returns 1 on succcess or 0 on error
 */
int bin_encode_r_subscription(bin_data *x,r_subscription *s)
{
	char c;
	
	if (!bin_encode_str(x,&(s->req_uri))) goto error;
	if (!bin_encode_int(x,s->duration)) goto error;
	if (!bin_encode_time_t(x,s->expires)) goto error;
	
	c = s->attempts_left;
	if (!bin_encode_char(x,c)) goto error;

	if (!bin_encode_dlg_t(x,s->dialog)) goto error;	
	
	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_subscription: Error while encoding.\n");
	return 0;		
}