[libpri-commits] rmudgett: branch rmudgett/check_tei r2093 - /team/rmudgett/check_tei/
SVN commits to the libpri project
libpri-commits at lists.digium.com
Thu Nov 4 13:15:43 CDT 2010
Author: rmudgett
Date: Thu Nov 4 13:15:39 2010
New Revision: 2093
URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2093
Log:
Convert TEI identity defines to enum and create 2str() function.
Modified:
team/rmudgett/check_tei/pri_q921.h
team/rmudgett/check_tei/q921.c
Modified: team/rmudgett/check_tei/pri_q921.h
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/check_tei/pri_q921.h?view=diff&rev=2093&r1=2092&r2=2093
==============================================================================
--- team/rmudgett/check_tei/pri_q921.h (original)
+++ team/rmudgett/check_tei/pri_q921.h Thu Nov 4 13:15:39 2010
@@ -69,13 +69,16 @@
#define Q921_SAPI_LAYER2_MANAGEMENT 63
-#define Q921_TEI_IDENTITY_REQUEST 1
-#define Q921_TEI_IDENTITY_ASSIGNED 2
-#define Q921_TEI_IDENTITY_DENIED 3
-#define Q921_TEI_IDENTITY_CHECK_REQUEST 4
-#define Q921_TEI_IDENTITY_CHECK_RESPONSE 5
-#define Q921_TEI_IDENTITY_REMOVE 6
-#define Q921_TEI_IDENTITY_VERIFY 7
+/*! Q.921 TEI management message type */
+enum q921_tei_identity {
+ Q921_TEI_IDENTITY_REQUEST = 1,
+ Q921_TEI_IDENTITY_ASSIGNED = 2,
+ Q921_TEI_IDENTITY_DENIED = 3,
+ Q921_TEI_IDENTITY_CHECK_REQUEST = 4,
+ Q921_TEI_IDENTITY_CHECK_RESPONSE = 5,
+ Q921_TEI_IDENTITY_REMOVE = 6,
+ Q921_TEI_IDENTITY_VERIFY = 7,
+};
typedef struct q921_header {
#if __BYTE_ORDER == __BIG_ENDIAN
Modified: team/rmudgett/check_tei/q921.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/check_tei/q921.c?view=diff&rev=2093&r1=2092&r2=2093
==============================================================================
--- team/rmudgett/check_tei/q921.c (original)
+++ team/rmudgett/check_tei/q921.c Thu Nov 4 13:15:39 2010
@@ -61,6 +61,36 @@
/*!
* \internal
+ * \brief Convert Q.921 TEI management message type to a string.
+ *
+ * \param message Q.921 TEI management message type to convert.
+ *
+ * \return TEI management message type name string
+ */
+static const char *q921_tei_mgmt2str(enum q921_tei_identity message)
+{
+ switch (message) {
+ case Q921_TEI_IDENTITY_REQUEST:
+ return "TEI Identity Request";
+ case Q921_TEI_IDENTITY_ASSIGNED:
+ return "TEI Identity Assigned";
+ case Q921_TEI_IDENTITY_CHECK_REQUEST:
+ return "TEI Identity Check Request";
+ case Q921_TEI_IDENTITY_REMOVE:
+ return "TEI Identity Remove";
+ case Q921_TEI_IDENTITY_DENIED:
+ return "TEI Identity Denied";
+ case Q921_TEI_IDENTITY_CHECK_RESPONSE:
+ return "TEI Identity Check Response";
+ case Q921_TEI_IDENTITY_VERIFY:
+ return "TEI Identity Verify";
+ }
+
+ return "Unknown";
+}
+
+/*!
+ * \internal
* \brief Convert Q.921 state to a string.
*
* \param state Q.921 state to convert.
@@ -168,7 +198,7 @@
return 0;
}
-static void q921_send_tei(struct pri *ctrl, int message, int ri, int ai, int iscommand)
+static void q921_send_tei(struct pri *ctrl, enum q921_tei_identity message, int ri, int ai, int iscommand)
{
q921_u *f;
struct q921_link *link;
@@ -187,7 +217,9 @@
f->data[3] = message;
f->data[4] = (ai << 1) | 1;
if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
- pri_message(ctrl, "Sending TEI management message %d, TEI=%d\n", message, ai);
+ pri_message(ctrl,
+ "Sending TEI management message %d(%s), TEI=%d\n",
+ message, q921_tei_mgmt2str(message), ai);
}
q921_transmit(ctrl, (q921_h *)f, 8);
free(f);
@@ -962,7 +994,7 @@
void q921_dump(struct pri *ctrl, q921_h *h, int len, int showraw, int txrx)
{
int x;
- char *type;
+ const char *type;
char direction_tag;
direction_tag = txrx ? '>' : '<';
@@ -1101,33 +1133,8 @@
ri = (h->u.data[1] << 8) | h->u.data[2];
tei = (h->u.data[4] >> 1);
/* TEI assignment related */
- switch (h->u.data[3]) {
- case Q921_TEI_IDENTITY_REQUEST:
- type = "TEI Identity Request";
- break;
- case Q921_TEI_IDENTITY_ASSIGNED:
- type = "TEI Identity Assigned";
- break;
- case Q921_TEI_IDENTITY_CHECK_REQUEST:
- type = "TEI Identity Check Request";
- break;
- case Q921_TEI_IDENTITY_REMOVE:
- type = "TEI Identity Remove";
- break;
- case Q921_TEI_IDENTITY_DENIED:
- type = "TEI Identity Denied";
- break;
- case Q921_TEI_IDENTITY_CHECK_RESPONSE:
- type = "TEI Identity Check Response";
- break;
- case Q921_TEI_IDENTITY_VERIFY:
- type = "TEI Identity Verify";
- break;
- default:
- type = "Unknown";
- break;
- }
- pri_message(ctrl, "%c MDL Message: %s (%d)\n", direction_tag, type, h->u.data[3]);
+ type = q921_tei_mgmt2str(h->u.data[3]);
+ pri_message(ctrl, "%c MDL Message: %d(%s)\n", direction_tag, h->u.data[3], type);
pri_message(ctrl, "%c RI: %d\n", direction_tag, ri);
pri_message(ctrl, "%c Ai: %d E:%d\n", direction_tag, (h->u.data[4] >> 1) & 0x7f, h->u.data[4] & 1);
}
More information about the libpri-commits
mailing list