Esempio n. 1
0
void print_scscf_list(int log_level)
{
	scscf_list *l;
	int i;
	scscf_entry *sl;
	LOG(log_level,"INF:"M_NAME":----------  S-CSCF Lists begin --------------\n");
	for(i=0;i<i_hash_size;i++){
		i_lock(i);
			l = i_hash_table[i].head;
			while(l){
				LOG(log_level,"INF:"M_NAME":[%4d] Call-ID: <%.*s> \n",i,
					l->call_id.len,l->call_id.s);
				sl = l->list;
				while(sl){
					LOG(log_level,"INF:"M_NAME":         Score:[%4d] S-CSCF: <%.*s> \n",
						sl->score,
						sl->scscf_name.len,sl->scscf_name.s);					
					sl = sl->next;
				}
				l = l->next;
			} 		
		i_unlock(i);
	}
	LOG(log_level,"INF:"M_NAME":----------  S-CSCF Lists end   --------------\n");
	
}
Esempio n. 2
0
/**
 * Takes on S-CSCF name for the respective Call-ID from the respective name list.
 * Should shm_free the result.s when no longer needed.
 * @param call_id - the id of the call
 * @returns the shm_malloced S-CSCF name if found or empty string if list is empty or does not exists 
 */  
str take_scscf_entry(str call_id)
{
	str scscf={0,0};
	scscf_list *l=0;
	scscf_entry *sl;
	unsigned int hash = get_call_id_hash(call_id,i_hash_size);

	i_lock(hash);
	l = i_hash_table[hash].head;
	while(l){
		if (l->call_id.len == call_id.len &&
			strncasecmp(l->call_id.s,call_id.s,call_id.len)==0) {
				if (l->list){
					scscf = l->list->scscf_name;
					sl = l->list->next;
					shm_free(l->list);
					l->list = sl;
				}
				break;
			}
		l = l->next;
	}
	i_unlock(hash);
	return scscf;
}
Esempio n. 3
0
uint8_t write_core_image(void)
{
	inoptr parent = NULLINODE;
	inoptr ino;

	udata.u_error = 0;

	/* FIXME: need to think more about the case sp is lala */
	if (uput("core", (uint8_t *)udata.u_syscall_sp - 5, 5))
		return 0;

	ino = n_open((char *)udata.u_syscall_sp - 5, &parent);
	if (ino) {
		i_deref(parent);
		return 0;
	}
	if (parent) {
		i_lock(parent);
		if ((ino = newfile(parent, "core")) != NULL) {
			ino->c_node.i_mode = F_REG | 0400;
			setftime(ino, A_TIME | M_TIME | C_TIME);
			wr_inode(ino);
			f_trunc(ino);
#if 0
	/* FIXME address ranges for different models - move core writer
	   for address spaces into helpers ?  */
			/* FIXME: need to add some arch specific header bits, and
			   also pull stuff like the true sp and registers out of
			   the return stack properly */

			corehdr.ch_base = pagemap_base;
			corehdr.ch_break = udata.u_break;
			corehdr.ch_sp = udata.u_syscall_sp;
			corehdr.ch_top = PROGTOP;
			udata.u_offset = 0;
			udata.u_base = (uint8_t *)&corehdr;
			udata.u_sysio = true;
			udata.u_count = sizeof(corehdr);
			writei(ino, 0);
			udata.u_sysio = false;
			udata.u_base = (uint8_t *)pagemap_base;
			udata.u_count = udata.u_break - pagemap_base;
			writei(ino, 0);
			udata.u_base = udata.u_sp;
			udata.u_count = PROGTOP - (uint32_t)udata.u_sp;
			writei(ino, 0);
#endif
			i_unlock_deref(ino);
			return W_COREDUMP;
		}
	}
	return 0;
}
Esempio n. 4
0
uint8_t write_core_image(void)
{
	inoptr parent = NULLINODE;
	inoptr ino;

	udata.u_error = 0;

	/* FIXME: need to think more about the case sp is lala */
	if (uput("core", udata.u_syscall_sp - 5, 5))
		return 0;

	ino = n_open(udata.u_syscall_sp - 5, &parent);
	if (ino) {
		i_deref(parent);
		return 0;
	}
	if (parent) {
		i_lock(parent);
		if (ino = newfile(parent, "core")) {
			ino->c_node.i_mode = F_REG | 0400;
			setftime(ino, A_TIME | M_TIME | C_TIME);
			wr_inode(ino);
			f_trunc(ino);

			/* FIXME: need to add some arch specific header bits, and
			   also pull stuff like the true sp and registers out of
			   the return stack properly */

			corehdr.ch_base = MAPBASE;
			corehdr.ch_break = udata.u_break;
			corehdr.ch_sp = udata.u_syscall_sp;
			corehdr.ch_top = PROGTOP;
			udata.u_offset = 0;
			udata.u_base = (uint8_t *)&corehdr;
			udata.u_sysio = true;
			udata.u_count = sizeof(corehdr);
			writei(ino, 0);
			udata.u_sysio = false;
			udata.u_base = MAPBASE;
			udata.u_count = udata.u_break - MAPBASE;
			writei(ino, 0);
			udata.u_base = udata.u_sp;
			udata.u_count = PROGTOP - (uint16_t)udata.u_sp;
			writei(ino, 0);
			i_unlock_deref(ino);
			return W_COREDUMP;
		}
	}
	return 0;
}
Esempio n. 5
0
/**
 * Destroy the hash with S-CSCF lists
 */
void i_hash_table_destroy()
{
	int i;
	scscf_list *sl,*nsl;
	for(i=0;i<i_hash_size;i++){
		i_lock(i);
			sl = i_hash_table[i].head;
			while(sl){
				nsl = sl->next;
				free_scscf_list(sl);
				sl = nsl;
			}
		i_unlock(i);
		lock_dealloc(i_hash_table[i].lock);
	}
	shm_free(i_hash_table);
}
Esempio n. 6
0
int is_scscf_list(str call_id)
{
	scscf_list *l=0;
	unsigned int hash = get_call_id_hash(call_id,i_hash_size);

	i_lock(hash);
	l = i_hash_table[hash].head;
	while(l){
		if (l->call_id.len == call_id.len &&
			strncasecmp(l->call_id.s,call_id.s,call_id.len)==0) {
				i_unlock(hash);
				return 1;
			}
		l = l->next;
	}
	i_unlock(hash);
	return 0;
}
Esempio n. 7
0
int add_scscf_list(str call_id,scscf_entry *sl)
{
	scscf_list *l;
	unsigned int hash = get_call_id_hash(call_id,i_hash_size);
	
	l = new_scscf_list(call_id,sl);
	if (!l) return 0;		
	
	i_lock(hash);
	l->prev = 0;
	l->next = i_hash_table[hash].head;
	if (l->next) l->next->prev = l;
	i_hash_table[hash].head = l;
	if (!i_hash_table[hash].tail) i_hash_table[hash].tail = l;
	i_unlock(hash);	
	
	return 1;
}
Esempio n. 8
0
void del_scscf_list(str call_id)
{
	scscf_list *l=0;
	unsigned int hash = get_call_id_hash(call_id,i_hash_size);

	i_lock(hash);
	l = i_hash_table[hash].head;
	while(l){
		if (l->call_id.len == call_id.len &&
			strncasecmp(l->call_id.s,call_id.s,call_id.len)==0) {
				if (l->prev) l->prev->next = l->next;
				else i_hash_table[hash].head = l->next;
				if (l->next) l->next->prev = l->prev;
				else i_hash_table[hash].tail = l->prev;					
				i_unlock(hash);
				free_scscf_list(l);
				return;
			}
		l = l->next;
	}
	i_unlock(hash);
}