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;		
}
/**
 * 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;		
}
Exemple #3
0
/**
 * Encode a r_public into a binary form
 * @param x - binary data to append to
 * @param c - the r_contact to encode
 * @returns 1 on succcess or 0 on error
 */
int bin_encode_r_contact(bin_data *x,r_contact *c)
{
	if (!bin_encode_str(x,&(c->uri))) goto error;
	if (!bin_encode_time_t(x,c->expires)) goto error;
	if (!bin_encode_str(x,&(c->ua))) goto error;
	if (!bin_encode_str(x,&(c->path))) goto error;

	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_contact: Error while encoding.\n");
	return 0;		
}
Exemple #4
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;		
}
Exemple #5
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 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;		
}
/**
 * Encode a r_contact into a binary form
 * @param x - binary data to append to
 * @param p - the r_contact to encode
 * @returns 1 on succcess or 0 on error
 */
int bin_encode_r_contact(bin_data *x,r_contact *c)
{
	int i;
	char k;
	unsigned short us;
	r_public *p=0;
	
	if (!bin_encode_str(x,&(c->host))) goto error;
	if (!bin_encode_ushort(x,c->port)) goto error;
	if (!bin_encode_char(x,c->transport)) goto error;
	
	if (!bin_encode_r_security(x,c->security_temp)) goto error;
	if (!bin_encode_r_security(x,c->security)) goto error;
	
	if (!bin_encode_str(x,&(c->uri))) goto error;
	
	k = c->reg_state;
	if (!bin_encode_char(x,k)) goto error;

	if (!bin_encode_time_t(x,c->expires)) goto error;
	
	if (!bin_encode_ushort(x,c->service_route_cnt)) goto error;
	for(i=0;i<c->service_route_cnt;i++)
		if (!bin_encode_str(x,c->service_route+i)) goto error;
		
	if (!bin_encode_pinhole(x,c->pinhole)) goto error;
	
	k = c->sos_flag;
	if (!bin_encode_char(x,k)) goto error;
	
	if (!bin_encode_str(x,&(c->pcc_session_id))) goto error;
	
	us=0;
	for(p=c->head;p;p=p->next)
		us++;
	if (!bin_encode_ushort(x,us)) goto error;
	for(p=c->head;p;p=p->next)
		if (!bin_encode_r_public(x,p)) goto error;	
	
	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_contact: Error while encoding.\n");
	return 0;		
}
Exemple #8
0
/**
 * Encode an authentication userdata into a binary form
 * @param x - binary data to append to
 * @param u - the authentication usedata to encode
 * @returns 1 on succcess or 0 on error
 */
 int bin_encode_auth_userdata(bin_data *x,auth_userdata *u)
{
	unsigned short k=0;
	auth_vector *v;
	
	if (!bin_encode_str(x,&(u->private_identity))) goto error;
	if (!bin_encode_str(x,&(u->public_identity))) goto error;
	if (!bin_encode_time_t(x,u->expires)) goto error;
	
	for(v=u->head;v;v=v->next)
		k++;

	if (!bin_encode_ushort(x,k)) goto error;
	for(v=u->head;v;v=v->next)
		if (!bin_encode_auth_vector(x,v)) goto error;

	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_auth_vector: Error while encoding.\n");
	return 0;		
}
Exemple #9
0
/**
 * Encode a r_public into a binary form
 * @param x - binary data to append to
 * @param c - the r_contact to encode
 * @returns 1 on succcess or 0 on error
 */
int bin_encode_r_contact(bin_data *x,r_contact *c)
{
	unsigned short cpn=0;
	r_contact_param *cp;
	
	if (!bin_encode_str(x,&(c->uri))) goto error;
	if (!bin_encode_time_t(x,c->expires)) goto error;
	if (!bin_encode_str(x,&(c->ua))) goto error;
	if (!bin_encode_str(x,&(c->path))) goto error;

	for(cp=c->parameters;cp;cp=cp->next)
		cpn++;
	if (!bin_encode_ushort(x,cpn)) goto error;
	for(cp=c->parameters;cp;cp=cp->next){
		if (!bin_encode_str(x,&(cp->name))) goto error;
		if (!bin_encode_str(x,&(cp->value))) goto error;
	}
	
	return 1;
error:
	LOG(L_ERR,"ERR:"M_NAME":bin_encode_r_contact: Error while encoding.\n");
	return 0;		
}