OpenSS7
SS7 for the
Common Man

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified:

Home Overview Status News Documentation Resources About
   
 Overview
 Status
 News
 Documentation
 Resources
 About

   
Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/tcap/tcap_ctrl.c


File /code/strss7/drivers/tcap/tcap_ctrl.c



#ident "@(#) $RCSfile: tcap_ctrl.c,v $ $Name:  $($Revision: 0.8.2.2 $) $Date: 2003/04/03 19:51:39 $"

static char const ident[] =
    "$RCSfile: tcap_ctrl.c,v $ $Name:  $($Revision: 0.8.2.2 $) $Date: 2003/04/03 19:51:39 $";

#define __NO_VERSION__

#include <linux/config.h>
#include <linux/version.h>
#ifdef MODVERSIONS
#include <linux/modversions.h>
#endif
#include <linux/module.h>

#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/cmn_err.h>

#include "../debug.h"
#include "../bufq.h"

#include "tcap.h"
#include "tcap_data.h"

static int tcap_m_w_proto(queue_t * q, mblk_t * mp)
{
	(void) q;
	(void) mp;
	fixme(("Write this function\n"));
	return (-EFAULT);
}
static int tcap_m_r_proto(queue_t * q, mblk_t * mp)
{
	(void) q;
	(void) mp;
	fixme(("Write this function\n"));
	return (-EFAULT);
}

/*
 *  M_IOCTL Handling
 *  -----------------------------------
 */
int tcap_m_w_ioctl(queue_t * q, mblk_t * mp)
{
	int err = EOPNOTSUPP;
	struct iocblk *iocp = (struct iocblk *) mp->b_rptr;
	switch (_IOC_TYPE(iocp->ioc_cmd) << 8) {
	case __SID:
	{
		sccp_t *sp;
		struct linkblk *lb;
		if (!mp->b_cont) {
			err = EINVAL;
			break;
		}
		lb = (struct linkblk *) mp->b_cont->b_rptr;
		switch (iocp->ioc_cmd) {
		case I_PLINK:
			if (iocp->ioc_cr->cr_uid != 0) {
				ptrace(("ERROR: Non-root attempt to I_PLINK\n"));
				err = EPERM;
				break;
			}
		case I_LINK:
			if ((sp = kmalloc(sizeof(*sp), GFP_KERNEL))) {
				bzero(sp, sizeof(*sp));
				if ((sp->next = tcap_links))
					sp->next->prev = &sp->next;
				sp->prev = &tcap_links;
				tcap_links = sp;
				sp->ops.r_prim = &tcap_l_r_prim;
				sp->ops.w_prim = &tcap_l_w_prim;
				sp->q = RD(lb->l_qbot);
				sp->muxid = lb->l_index;
				sp->lmq = RD(q);
				err = 0;
				break;
			}
			ptrace(("ERROR: couldn't allocate memory\n"));
			err = ENOMEM;
			break;
		case I_PUNLINK:
			if (iocp->ioc_cr->cr_uid != 0) {
				ptrace(("ERROR: Non-root attempt to I_PUNLINK\n"));
				err = EPERM;
				break;
			}
		case I_UNLINK:
			for (sp = tcap_links; sp; sp = sp->next)
				if (sp->muxid == lb->l_index)
					break;
			if (sp) {
				if (sp->use_count || sp->tcap) {
					fixme(("Unassociate TCAP users\n"));
				}
				if (sp->prev)
					if ((*(sp->prev) = sp->next))
						sp->next->prev = sp->prev;
				enableok(RD(sp->q));
				enableok(WR(sp->q));
				qenable(RD(sp->q));
				qenable(WR(sp->q));
				sp->prev = NULL;
				sp->next = NULL;
				sp->q = NULL;
				sp->muxid = 0;
				if (sp->rbid)
					unbufcall(xchg(&sp->rbid, 0));
				if (sp->wbid)
					unbufcall(xchg(&sp->wbid, 0));
				kfree(sp);
				break;
			}
			ptrace(("ERROR: Couldn't find I_UNLINK muxid\n"));
			err = EINVAL;
			break;
		}
	}
	}
	if (err) {
		mp->b_datap->db_type = M_IOCNAK;
		iocp->ioc_error = err;
		iocp->ioc_rval = -1;
		iocp->ioc_count = 0;
	} else {
		mp->b_datap->db_type = M_IOCACK;
		iocp->ioc_error = 0;
		iocp->ioc_rval = 0;
		iocp->ioc_count = 0;
	}
	qreply(q, mp);
	return (1);
}

int tcap_m_w_prim(queue_t * q, mblk_t * mp)
{
	switch (mp->b_datap->db_type) {
	case M_PROTO:
	case M_PCPROTO:
		return tcap_m_w_proto(q, mp);
	case M_IOCTL:
		return tcap_m_w_ioctl(q, mp);
	case M_FLUSH:
		return tcap_w_flush(q, mp);
	}
	return (5);
}

int tcap_m_r_prim(queue_t * q, mblk_t * mp)
{
	switch (mp->b_datap->db_type) {
	case M_PROTO:
	case M_PCPROTO:
		return tcap_m_r_proto(q, mp);
	case M_FLUSH:
		return tcap_r_flush(q, mp);
	}
	return (5);
}


Home Index Prev Next More Download Info FAQ Mail   Home -> Resources -> Browse Source -> strss7/drivers/tcap/tcap_ctrl.c

OpenSS7
SS7 for the
Common Man
Home Overview Status News Documentation Resources About

© Copyright 1997-2004,OpenSS7 Corporation, All Rights Reserved.
Last modified: