Exemple #1
0
int loop_hunt_bchannel(class PmISDN *port, struct mISDNport *mISDNport)
{
	int channel;
	int i;
	char map[mISDNport->b_num];
	struct interface *interface;
	struct interface_port *ifport;

	chan_trace_header(mISDNport, port, "CHANNEL SELECTION (setup)", DIRECTION_NONE);
	add_trace("channel", "reserved", "%d", mISDNport->b_reserved);
	if (mISDNport->b_reserved >= mISDNport->b_num) { // of out chan..
		add_trace("conclusion", NULL, "all channels are reserved");
		end_trace();
		return(-34); // no channel
	}

	/* map all used ports of shared loopback interface */
	memset(map, 0, sizeof(map));
	interface = interface_first;
	while(interface) {
		ifport = interface->ifport;
		while(ifport) {
			if (!strcmp(ifport->portname, options.loopback_lcr)) {
				i = 0;
				while(i < mISDNport->b_num) {
					if (mISDNport->b_port[i])
						map[i] = 1;
					i++;
				}
			}
			ifport = ifport->next;
		}
		interface = interface->next;
	}

	/* find channel */
	i = 0;
	channel = 0;
	while(i < mISDNport->b_num) {
		if (!map[i]) {
			channel = i+1+(i>=15);
			break;
		}
		i++;
	}
	if (!channel) {
		add_trace("conclusion", NULL, "no channel available");
		end_trace();
		return(-6); // channel unacceptable
	}
	add_trace("conclusion", NULL, "channel available");
	add_trace("connect", "channel", "%d", channel);
	end_trace();
	return(channel);
}
void record_trace(char* c)
{
	if((NULL != traces) && (update_trace(traces, c)))
	{
		return;
	}

	traces = add_trace(traces, create_trace(c));
}
Exemple #3
0
long _likely_trace(bool cond, bool expect,
		   const char *condstr,
		   const char *file, unsigned int line)
{
	struct trace *p, trace;

	init_trace(&trace, condstr, file, line, expect);
	p = thash_get(&htable, &trace);
	if (!p)
		p = add_trace(&trace);

	p->count++;
	if (cond == expect)
		p->right++;

	return cond;
}
struct instruction_trace* add_trace(struct instruction_trace* head, struct instruction_trace* p)
{
	if(NULL == head)
	{
		return p;
	}
	if(NULL == head->next)
	{
		head->next = p;
		p->prev = head;
	}
	else
	{
		add_trace(head->next, p);
	}
	return head;
}
Exemple #5
0
long _likely_trace(bool cond, bool expect,
		   const char *condstr,
		   const char *file, unsigned int line)
{
	struct trace *p, trace;

	if (!htable)
		htable = htable_new(rehash, NULL);

	init_trace(&trace, condstr, file, line, expect);
	p = htable_get(htable, hash_trace(&trace), hash_cmp, &trace);
	if (!p)
		p = add_trace(condstr, file, line, expect);

	p->count++;
	if (cond == expect)
		p->right++;

	return cond;
}