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/ua/ua_recv.c


File /code/strss7/drivers/ua/ua_recv.c



#ident "@(#) $RCSfile: ua_recv.c,v $ $Name:  $($Revision: 0.8.2.1 $) $Date: 2002/10/18 02:26:20 $"

static char const ident[] =
    "$RCSfile: ua_recv.c,v $ $Name:  $($Revision: 0.8.2.1 $) $Date: 2002/10/18 02:26:20 $";

/*
 *  =========================================================================
 *
 *  General purpose common receive functions
 *
 *  =========================================================================
 */

int ua_recv_msg(struct spp *spp, mblk_t * pdu, struct msg_class *msg_decode)
{
	mblk_t *dp;
	uint32_t *p = ((uint32_t *) pdu->b_rptr);
	size_t len = ntohl(p[1]);
	size_t mlen = msgdsize(pdu);
	size_t elen = min(40, mlen);
	caddr_t eptr;
	uint vers, type, clas;

	ensure(spp && spp->pp && spp->pp->q, return (-EFAULT));

	if (len & 0x3 || len < 8 || UA_PAD4(len) != mlen) {
		eptr = (caddr_t) pdu->b_rptr;
		if (!(rp = ua_send_err(UA_ECODE_PROTOCOL_ERROR, eptr, elen)))
			return (-ENOBUFS);
		qreply(spp->pp->q, rp);
		return (-EPROTO);
	}
	vers = UA_MSG_VERS(*p);
	type = UA_MSG_TYPE(*p);
	clas = UA_MSG_CLAS(*p);
	if (vers != UA_VERSION) {
		uint32_t myversion = UA_MHDR(UA_VERSION, 0, 0, 0);
		eptr = (caddr_t) myversion;
		if (!(rp = ua_send_err(UA_ECODE_INVALID_VERSION, eptr, sizeof(myversion))))
			return (-ENOBUFS);
		qreply(spp->pp->q, rp);
		return (-EPROTO);
	}
	p += 2;
	if (0 < clas && clas <= UA_CLASS_LAST && msg_decode[clas].farr) {
		int err;
		int (*func) (queue_t *, mblk_t *);
		if (0 <= type && type <= msg_decode[clas].farr) {
			if ((func = msg_decode[clas].farr[type])) {
				if ((err = (*func) (spp, pdu)))
					return (err);
				freemsg(pdu);
				return (0);
			}
		}
		eptr = (caddr_t) pdu->b_rptr;
		if (!(rp = ua_send_err(UA_ECODE_UNSUPPORTED_MESSAGE_TYPE, eptr, elen)))
			return (-ENOBUFS);
		qreply(spp->pp->q, rp);
		return (-EOPNOTSUPP);
	}
	eptr = (caddr_t) pdu->b_rptr;
	if (!(rp = ua_send_err(UA_ECODE_UNSUPPORTED_MESSAGE_CLASS, eptr, elen)))
		return (-ENOBUFS);
	qreply(spp->pp->q, rp);
	return (-EPROTO);
}


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

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

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