5 example code - building and sending sc_listen – Welltech SPCI2S Intel NetStructure SS7 Boards User Manual
Page 26

SS7 Programmer’s Manual for SPCI2, SPCI4 and CPM8 Issue 2
Page 26
3.4.5 Example code - Building and sending SC_LISTEN
/*
* Example function for building and sending an MVD_MSG_SC_LISTEN
* message to a SPCI2S, SPCI4 or CPM8 signalling card.
*
* The only change that the user needs to make is to fill in the
* OUR_MOD_ID definition below so that is equal to the module_id
* of the application module.
*/
#define OUR_MOD_ID (0xef)
#include "system.h" /* Definitions of u8, u16 etc */
#include "msg.h" /* Definitions of HDR, MSG etc */
#include "libc.h" /* Used only for memset prototype */
#include "sysgct.h" /* Prototypes for GCT_xxx */
#include "pack.h" /* Prototypes for rpackbytes */
#include "ss7_inc.h" /* Message & module definitions */
/*
* Macro to generate the value for use in the rsp_req field of the
* message header in order to request a confirmation message:
*/
#define RESPONSE(module) (((unsigned short) 1) << ((module) & 0x0f))
/*
* Function to drive an SCbus / CT bus timeslot
* onto a timeslot on a PCM port:
*/
int listen_to_scbus(board_id, liu_id, timeslot, sc_channel)
int board_id; /* board_id (0, 1, 2 ...) */
int liu_id; /* PCM port id (0 .. 7) */
int timeslot; /* Timeslot on the PCM port (1 .. 31) */
int sc_channel; /* SCbus / CT bus channel number */
{
MSG *m;
u8 *pptr;
/*
* Allocate a message (and fill in type, id, rsp_req & len):
*/
if ((m = getm(MVD_MSG_SC_LISTEN, 0, RESPONSE(OUR_MOD_ID), MVDML_SCLIS)) != 0)
{
pptr = get_param(m);
memset(pptr, 0, m->len);
/*
* Enter the parameters in machine independent format:
*/
rpackbytes(pptr, MVDMO_SCLIS_liu_id, (u32)liu_id, MVDMS_SCLIS_liu_id);
rpackbytes(pptr, MVDMO_SCLIS_timeslot, (u32)timeslot, MVDMS_SCLIS_timeslot);
rpackbytes(pptr, MVDMO_SCLIS_sc_channel, (u32)sc_channel, MVDMS_SCLIS_sc_channel);
m->hdr.dst = MVD_TASK_ID;
m->hdr.src = OUR_MOD_ID;
/*
* Call GCT_set_instance to route the message to the
* correct board and GCT_send to send the message.
* If GCT_send returns non-zero release the message.
*/
GCT_set_instance(board_id, (HDR *)m);
if (GCT_send(m->hdr.dst, (HDR *)m) != 0)
relm((HDR *)m);
}
return(0);
}