Ejemplo n.º 1
0
l3_process_t
*new_l3_process(layer3_t *l3, int cr, int n303, u_int id)
{
	l3_process_t	*p = NULL;

	if (id == MISDN_ID_ANY) {
		if (l3->entity == MISDN_ENTITY_NONE) {
			printk(KERN_WARNING "%s: no entity allocated for l3(%x)\n",
				__FUNCTION__, l3->id);
			return (NULL);
		}
		if (l3->pid_cnt == 0x7FFF)
			l3->pid_cnt = 0;
		while(l3->pid_cnt <= 0x7FFF) {
			l3->pid_cnt++;
			id = l3->pid_cnt | (l3->entity << 16);
			p = getl3proc4id(l3, id);
			if (!p)
				break;
		}
		if (p) {
			printk(KERN_WARNING "%s: no free process_id for l3(%x) entity(%x)\n",
				__FUNCTION__, l3->id, l3->entity);
			return (NULL);
		}
	} else {
		/* id from other entity */
		p = getl3proc4id(l3, id);
		if (p) {
			printk(KERN_WARNING "%s: process_id(%x) allready in use in l3(%x)\n",
				__FUNCTION__, id, l3->id);
			return (NULL);
		}
	}
	if (!(p = kmalloc(sizeof(l3_process_t), GFP_ATOMIC))) {
		printk(KERN_ERR "mISDN can't get memory for cr %d\n", cr);
		return (NULL);
	}
	memset(p, 0, sizeof(l3_process_t));

	p->cause=NO_CAUSE;
	
	p->l3 = l3;
	p->id = id;
	p->callref = cr;
	p->n303 = n303;
	L3InitTimer(p, &p->timer);
	L3InitTimer(p, &p->aux_timer);
	list_add_tail(&p->list, &l3->plist);
	return (p);
};
struct l3_process
*new_l3_process(struct PStack *st, int cr)
{
	struct l3_process *p, *np;

	if (!(p = kmalloc(sizeof(struct l3_process), GFP_ATOMIC))) {
		printk(KERN_ERR "HiSax can't get memory for cr %d\n", cr);
		return (NULL);
	}
	if (!st->l3.proc)
		st->l3.proc = p;
	else {
		np = st->l3.proc;
		while (np->next)
			np = np->next;
		np->next = p;
	}
	p->next = NULL;
	p->debug = st->l3.debug;
	p->callref = cr;
	p->state = 0;
	p->chan = NULL;
	p->st = st;
	p->N303 = st->l3.N303;
	L3InitTimer(p, &p->timer);
	return (p);
};