summaryrefslogtreecommitdiff
path: root/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2006-09-14 16:07:49 +0000
committerBenny Prijono <bennylp@teluu.com>2006-09-14 16:07:49 +0000
commite015ebe064c6f5120ef2af2b73ce52796a06f790 (patch)
tree0b3ed8be366ec88d571195568bb2aa6002f2e18b /pjsip
parentf5ee360b0b649ef24fe671b6e37006badce0634d (diff)
Added pjsip_transport_register_type() API to register new transport type.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@720 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip')
-rw-r--r--pjsip/include/pjsip/sip_transport.h24
-rw-r--r--pjsip/include/pjsip/sip_types.h5
-rw-r--r--pjsip/src/pjsip/sip_transport.c41
3 files changed, 67 insertions, 3 deletions
diff --git a/pjsip/include/pjsip/sip_transport.h b/pjsip/include/pjsip/sip_transport.h
index 69a9f624..ec371f0f 100644
--- a/pjsip/include/pjsip/sip_transport.h
+++ b/pjsip/include/pjsip/sip_transport.h
@@ -80,6 +80,30 @@ enum pjsip_transport_flags_e
((tp)->flag & PJSIP_TRANSPORT_SECURE)
/**
+ * Register new transport type to PJSIP. The PJSIP transport framework
+ * contains the info for some standard transports, as declared by
+ * #pjsip_transport_type_e. Application may use non-standard transport
+ * with PJSIP, but before it does so, it must register the information
+ * about the new transport type to PJSIP by calling this function.
+ *
+ * @param tp_flag The flags describing characteristics of this
+ * transport type.
+ * @param tp_name Transport type name.
+ * @param def_port Default port to be used for the transport.
+ * @param p_tp_type On successful registration, it will be filled with
+ * the registered type. This argument is optional.
+ *
+ * @return PJ_SUCCESS if registration is successful, or
+ * PJSIP_ETYPEEXISTS if the same transport type has
+ * already been registered.
+ */
+PJ_DECL(pj_status_t) pjsip_transport_register_type(unsigned tp_flag,
+ const char *tp_name,
+ int def_port,
+ int *p_tp_type);
+
+
+/**
* Get the transport type from the transport name.
*
* @param name Transport name, such as "TCP", or "UDP".
diff --git a/pjsip/include/pjsip/sip_types.h b/pjsip/include/pjsip/sip_types.h
index d50fdba0..38525453 100644
--- a/pjsip/include/pjsip/sip_types.h
+++ b/pjsip/include/pjsip/sip_types.h
@@ -79,7 +79,10 @@ typedef enum pjsip_transport_type_e
PJSIP_TRANSPORT_LOOP,
/** Loopback (datagram, unreliable) */
- PJSIP_TRANSPORT_LOOP_DGRAM
+ PJSIP_TRANSPORT_LOOP_DGRAM,
+
+ /** Start of user defined transport */
+ PJSIP_TRANSPORT_START_OTHER
} pjsip_transport_type_e;
diff --git a/pjsip/src/pjsip/sip_transport.c b/pjsip/src/pjsip/sip_transport.c
index e18a9048..909632e8 100644
--- a/pjsip/src/pjsip/sip_transport.c
+++ b/pjsip/src/pjsip/sip_transport.c
@@ -97,13 +97,14 @@ struct transport_key
/*
* Transport names.
*/
-const struct
+struct
{
pjsip_transport_type_e type;
pj_uint16_t port;
pj_str_t name;
unsigned flag;
-} transport_names[] =
+ char name_buf[16];
+} transport_names[16] =
{
{ PJSIP_TRANSPORT_UNSPECIFIED, 0, {"Unspecified", 11}, 0},
{ PJSIP_TRANSPORT_UDP, 5060, {"UDP", 3}, PJSIP_TRANSPORT_DATAGRAM},
@@ -116,6 +117,42 @@ const struct
/*
+ * Register new transport type to PJSIP.
+ */
+PJ_DECL(pj_status_t) pjsip_transport_register_type(unsigned tp_flag,
+ const char *tp_name,
+ int def_port,
+ int *p_tp_type)
+{
+ unsigned i;
+
+ PJ_ASSERT_RETURN(tp_flag && tp_name && def_port, PJ_EINVAL);
+ PJ_ASSERT_RETURN(pj_ansi_strlen(tp_name) <
+ PJ_ARRAY_SIZE(transport_names[0].name_buf),
+ PJ_ENAMETOOLONG);
+
+ for (i=1; i<PJ_ARRAY_SIZE(transport_names); ++i) {
+ if (transport_names[i].type == 0)
+ break;
+ }
+
+ if (i == PJ_ARRAY_SIZE(transport_names))
+ return PJ_ETOOMANY;
+
+ transport_names[i].type = (pjsip_transport_type_e)i;
+ transport_names[i].port = (pj_uint16_t)def_port;
+ pj_ansi_strcpy(transport_names[i].name_buf, tp_name);
+ transport_names[i].name = pj_str(transport_names[i].name_buf);
+ transport_names[i].flag = tp_flag;
+
+ if (p_tp_type)
+ *p_tp_type = i;
+
+ return PJ_SUCCESS;
+}
+
+
+/*
* Get transport type from name.
*/
PJ_DEF(pjsip_transport_type_e)