Exemple #1
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_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_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;		
}
Exemple #2
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;		
}
Exemple #3
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;		
}
/**
 * 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;		
}