summaryrefslogtreecommitdiff
path: root/pjsip/include
diff options
context:
space:
mode:
Diffstat (limited to 'pjsip/include')
-rw-r--r--pjsip/include/pjsip/print_util.h41
-rw-r--r--pjsip/include/pjsip/sip_errno.h157
-rw-r--r--pjsip/include/pjsip/sip_event.h2
-rw-r--r--pjsip/include/pjsip/sip_parser.h28
-rw-r--r--pjsip/include/pjsip/sip_transaction.h17
-rw-r--r--pjsip/include/pjsip/sip_uri.h67
-rw-r--r--pjsip/include/pjsip/sip_util.h (renamed from pjsip/include/pjsip/sip_misc.h)0
-rw-r--r--pjsip/include/pjsip_core.h5
8 files changed, 260 insertions, 57 deletions
diff --git a/pjsip/include/pjsip/print_util.h b/pjsip/include/pjsip/print_util.h
index 340984ce..56f05851 100644
--- a/pjsip/include/pjsip/print_util.h
+++ b/pjsip/include/pjsip/print_util.h
@@ -19,9 +19,12 @@
#ifndef __PJSIP_PRINT_H__
#define __PJSIP_PRINT_H__
+/* Minimum space left in the buffer */
+#define MIN_SPACE 10
+
#define copy_advance_check(buf,str) \
do { \
- if ((str).slen+10 >= (endbuf-buf)) return -1; \
+ if ((str).slen+MIN_SPACE >= (endbuf-buf)) return -1; \
pj_memcpy(buf, (str).ptr, (str).slen); \
buf += (str).slen; \
} while (0)
@@ -31,7 +34,7 @@ static char *imp_copy_advance_pair(char *buf, char *endbuf, const char *str1, in
{
if (str2->slen) {
int printed = len1+str2->slen;
- if (printed+10 >= (endbuf-buf)) return NULL;
+ if (printed+MIN_SPACE >= (endbuf-buf)) return NULL;
pj_memcpy(buf,str1,len1);
pj_memcpy(buf+len1, str2->ptr, str2->slen);
return buf + printed;
@@ -44,7 +47,7 @@ static char *imp_copy_advance_pair(char *buf, char *endbuf, const char *str1, in
do { \
if (str2.slen) { \
printed = len1+str2.slen; \
- if (printed+10 >= (endbuf-buf)) return -1; \
+ if (printed+MIN_SPACE >= (endbuf-buf)) return -1; \
pj_memcpy(buf,str1,len1); \
pj_memcpy(buf+len1, str2.ptr, str2.slen); \
buf += printed; \
@@ -62,7 +65,7 @@ static char *imp_copy_advance_pair(char *buf, char *endbuf, const char *str1, in
do { \
if (str2.slen) { \
printed = len1+str2.slen+2; \
- if (printed+10 >= (endbuf-buf)) return -1; \
+ if (printed+MIN_SPACE >= (endbuf-buf)) return -1; \
pj_memcpy(buf,str1,len1); \
*(buf+len1)=quotebegin; \
pj_memcpy(buf+len1+1, str2.ptr, str2.slen); \
@@ -71,9 +74,35 @@ static char *imp_copy_advance_pair(char *buf, char *endbuf, const char *str1, in
} \
} while (0)
+#define copy_advance_pair_escape(buf,str1,len1,str2,unres) \
+ do { \
+ if (str2.slen) { \
+ pj_ssize_t esc_len; \
+ if (len1+str2.slen+MIN_SPACE >= (endbuf-buf)) return -1; \
+ pj_memcpy(buf,str1,len1); \
+ buf += len1; \
+ esc_len=pj_strncpy2_escape(buf, &str2, (endbuf-buf), &unres); \
+ if (esc_len < 0) return -1; \
+ buf += esc_len; \
+ if (endbuf-buf < MIN_SPACE) return -1; \
+ } \
+ } while (0)
+
+
#define copy_advance_no_check(buf,str) \
- pj_memcpy(buf, (str).ptr, (str).slen); \
- buf += (str).slen;
+ do { \
+ pj_memcpy(buf, (str).ptr, (str).slen); \
+ buf += (str).slen; \
+ } while (0)
+
+#define copy_advance_escape(buf,str,unres) \
+ do { \
+ pj_ssize_t len = \
+ pj_strncpy2_escape(buf, &(str), (endbuf-buf), &(unres)); \
+ if (len < 0) return -1; \
+ buf += len; \
+ if (endbuf-buf < MIN_SPACE) return -1; \
+ } while (0)
#define copy_advance_pair_no_check(buf,str1,len1,str2) \
if (str2.slen) { \
diff --git a/pjsip/include/pjsip/sip_errno.h b/pjsip/include/pjsip/sip_errno.h
index 5473f362..2c8e6764 100644
--- a/pjsip/include/pjsip/sip_errno.h
+++ b/pjsip/include/pjsip/sip_errno.h
@@ -21,10 +21,31 @@
#include <pj/errno.h>
+PJ_BEGIN_DECL
+
+/*
+ * PJSIP error codes occupies 170000 - 219000, and mapped as follows:
+ * - 170100 - 170799: mapped to SIP status code in response msg.
+ * - 171000 - 171999: mapped to errors generated from PJSIP core.
+ */
+
+/**
+ * Get error message for the specified error code.
+ *
+ * @param status The error code.
+ * @param buffer The buffer where to put the error message.
+ * @param bufsize Size of the buffer.
+ *
+ * @return The error message as NULL terminated string,
+ * wrapped with pj_str_t.
+ */
+PJ_DECL(pj_str_t) pjsip_strerror( pj_status_t status, char *buffer,
+ pj_size_t bufsize);
+
/**
* Start of error code relative to PJ_ERRNO_START_USER.
*/
-#define PJSIP_ERRNO_START (PJ_ERRNO_START_USER+10000)
+#define PJSIP_ERRNO_START (PJ_ERRNO_START_USER)
/**
* Create error value from SIP status code.
@@ -43,81 +64,165 @@
*/
#define PJSIP_ERRNO_TO_SIP_STATUS(status) \
((status>=PJSIP_ERRNO_FROM_SIP_STATUS(100) && \
- status<PJSIP_ERRNO_FROM_SIP_STATUS(999)) ? \
+ status<PJSIP_ERRNO_FROM_SIP_STATUS(800)) ? \
status-PJSIP_ERRNO_FROM_SIP_STATUS(0) : 599)
/**
* Start of PJSIP generated error code values.
*/
-#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 10000)
+#define PJSIP_ERRNO_START_PJSIP (PJSIP_ERRNO_START + 1000)
+
+/************************************************************
+ * GENERIC SIP ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * SIP object is busy.
+ */
+#define PJSIP_EBUSY (PJSIP_ERRNO_START_PJSIP + 1) /* 171001 */
+/**
+ * @hideinitializer
+ * SIP object with the same type already exists.
+ */
+#define PJSIP_ETYPEEXISTS (PJSIP_ERRNO_START_PJSIP + 2) /* 171002 */
+
+/************************************************************
+ * MESSAGING ERRORS
+ ***********************************************************/
/**
* @hideinitializer
* Invalid message (syntax error)
*/
-#define PJSIP_EINVALIDMSG (PJSIP_ERRNO_START_PJSIP + 0)
+#define PJSIP_EINVALIDMSG (PJSIP_ERRNO_START_PJSIP + 20) /* 171020 */
+/**
+ * @hideinitializer
+ * Unsupported URL scheme.
+ */
+#define PJSIP_EINVALIDSCHEME (PJSIP_ERRNO_START_PJSIP + 21) /* 171021 */
+/**
+ * @hideinitializer
+ * Message too long. See also PJSIP_ERXOVERFLOW.
+ */
+#define PJSIP_EMSGTOOLONG (PJSIP_ERRNO_START_PJSIP + 22) /* 171022 */
+/**
+ * @hideinitializer
+ * Message not completely received.
+ */
+#define PJSIP_EPARTIALMSG (PJSIP_ERRNO_START_PJSIP + 23) /* 171023 */
/**
* @hideinitializer
* Missing required header(s).
*/
-#define PJSIP_EMISSINGHDR (PJSIP_ERRNO_START_PJSIP + 1)
+#define PJSIP_EMISSINGHDR (PJSIP_ERRNO_START_PJSIP + 24) /* 171024 */
/**
* @hideinitializer
- * Unsupported URL scheme.
+ * Invalid Via header in response (sent-by, etc).
+ */
+#define PJSIP_EINVALIDVIA (PJSIP_ERRNO_START_PJSIP + 25) /* 171025 */
+/**
+ * @hideinitializer
+ * Multiple Via headers in response.
*/
-#define PJSIP_EINVALIDSCHEME (PJSIP_ERRNO_START_PJSIP + 2)
+#define PJSIP_EMULTIPLEVIA (PJSIP_ERRNO_START_PJSIP + 26) /* 171026 */
+
+/************************************************************
+ * TRANSPORT ERRORS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * Unsupported transport type.
+ */
+#define PJSIP_EUNSUPTRANSPORT (PJSIP_ERRNO_START_PJSIP + 40) /* 171040 */
+/**
+ * @hideinitializer
+ * Buffer is being sent, operation still pending.
+ */
+#define PJSIP_EPENDINGTX (PJSIP_ERRNO_START_PJSIP + 41) /* 171041 */
+/**
+ * @hideinitializer
+ * Rx buffer overflow. See also PJSIP_EMSGTOOLONG.
+ */
+#define PJSIP_ERXOVERFLOW (PJSIP_ERRNO_START_PJSIP + 42)/* 171042 */
+
+
+/************************************************************
+ * TRANSACTION ERRORS
+ ***********************************************************/
/**
* @hideinitializer
* Transaction has just been destroyed.
*/
-#define PJSIP_ETSXDESTROYED (PJSIP_ERRNO_START_PJSIP + 3)
+#define PJSIP_ETSXDESTROYED (PJSIP_ERRNO_START_PJSIP + 60) /* 171060 */
+
+
+/************************************************************
+ * URI COMPARISON RESULTS
+ ***********************************************************/
+/**
+ * @hideinitializer
+ * Scheme mismatch.
+ */
+#define PJSIP_ECMPSCHEME (PJSIP_ERRNO_START_PJSIP + 80) /* 171080 */
/**
* @hideinitializer
- * Buffer overflow. See also PJSIP_EMSGTOOLONG.
+ * User part mismatch.
*/
-#define PJSIP_EOVERFLOW (PJSIP_ERRNO_START_PJSIP + 4)
+#define PJSIP_ECMPUSER (PJSIP_ERRNO_START_PJSIP + 81) /* 171081 */
/**
* @hideinitializer
- * Message not completely received.
+ * Password part mismatch.
*/
-#define PJSIP_EPARTIALMSG (PJSIP_ERRNO_START_PJSIP + 5)
+#define PJSIP_ECMPPASSWD (PJSIP_ERRNO_START_PJSIP + 82) /* 171082 */
/**
* @hideinitializer
- * Message too long. See also PJSIP_EOVERFLOW.
+ * Host part mismatch.
*/
-#define PJSIP_EMSGTOOLONG (PJSIP_ERRNO_START_PJSIP + 6)
+#define PJSIP_ECMPHOST (PJSIP_ERRNO_START_PJSIP + 83) /* 171083 */
/**
* @hideinitializer
- * Buffer is being sent, operation still pending.
+ * Port part mismatch.
*/
-#define PJSIP_EPENDINGTX (PJSIP_ERRNO_START_PJSIP + 7)
+#define PJSIP_ECMPPORT (PJSIP_ERRNO_START_PJSIP + 84) /* 171084 */
/**
* @hideinitializer
- * Unsupported transport type.
+ * Transport parameter part mismatch.
*/
-#define PJSIP_EUNSUPTRANSPORT (PJSIP_ERRNO_START_PJSIP + 8)
+#define PJSIP_ECMPTRANSPORTPRM (PJSIP_ERRNO_START_PJSIP + 85) /* 171085 */
/**
* @hideinitializer
- * Invalid Via header in response (sent-by, etc).
+ * TTL parameter part mismatch.
*/
-#define PJSIP_EINVALIDVIA (PJSIP_ERRNO_START_PJSIP + 9)
+#define PJSIP_ECMPTTLPARAM (PJSIP_ERRNO_START_PJSIP + 86) /* 171086 */
/**
* @hideinitializer
- * Multiple Via headers in response.
+ * User parameter part mismatch.
*/
-#define PJSIP_EMULTIPLEVIA (PJSIP_ERRNO_START_PJSIP + 9)
+#define PJSIP_ECMPUSERPARAM (PJSIP_ERRNO_START_PJSIP + 87) /* 171087 */
/**
* @hideinitializer
- * SIP object is busy.
+ * Method parameter part mismatch.
*/
-#define PJSIP_EBUSY (PJSIP_ERRNO_START_PJSIP + 10)
+#define PJSIP_ECMPMETHODPARAM (PJSIP_ERRNO_START_PJSIP + 88) /* 171088 */
/**
* @hideinitializer
- * SIP object with the same type already exists.
+ * Maddr parameter part mismatch.
+ */
+#define PJSIP_ECMPMADDRPARAM (PJSIP_ERRNO_START_PJSIP + 89) /* 171089 */
+/**
+ * @hideinitializer
+ * Parameter part in other_param mismatch.
*/
-#define PJSIP_ETYPEEXISTS (PJSIP_ERRNO_START_PJSIP + 11)
+#define PJSIP_ECMPOTHERPARAM (PJSIP_ERRNO_START_PJSIP + 90) /* 171090 */
+/**
+ * @hideinitializer
+ * Parameter part in header_param mismatch.
+ */
+#define PJSIP_ECMPHEADERPARAM (PJSIP_ERRNO_START_PJSIP + 91) /* 171091 */
+
+PJ_END_DECL
#endif /* __PJSIP_SIP_ERRNO_H__ */
diff --git a/pjsip/include/pjsip/sip_event.h b/pjsip/include/pjsip/sip_event.h
index 595f5445..e828ae96 100644
--- a/pjsip/include/pjsip/sip_event.h
+++ b/pjsip/include/pjsip/sip_event.h
@@ -297,7 +297,7 @@ struct pjsip_event
/**
* Get the event string from the event ID.
* @param e the event ID.
- * @notes defined in sip_misc.c
+ * @notes defined in sip_util.c
*/
PJ_DEF(const char *) pjsip_event_str(pjsip_event_id_e e);
diff --git a/pjsip/include/pjsip/sip_parser.h b/pjsip/include/pjsip/sip_parser.h
index 3cc690a6..6c30e837 100644
--- a/pjsip/include/pjsip/sip_parser.h
+++ b/pjsip/include/pjsip/sip_parser.h
@@ -294,19 +294,21 @@ PJ_DECL(pj_status_t) pjsip_parse_headers( pj_pool_t *pool,
* Various specification used in parsing, exported here as extern for other
* parsers.
*/
-extern
-pj_cis_t pjsip_HOST_SPEC, /* For scanning host part. */
- pjsip_DIGIT_SPEC, /* Decimal digits */
- pjsip_ALPHA_SPEC, /* Alpha (A-Z, a-z) */
- pjsip_ALNUM_SPEC, /* Decimal + Alpha. */
- pjsip_TOKEN_SPEC, /* Token. */
- pjsip_HEX_SPEC, /* Hexadecimal digits. */
- pjsip_PARAM_CHAR_SPEC, /* For scanning pname (or pvalue when it's not quoted.) */
- pjsip_PROBE_USER_HOST_SPEC, /* Hostname characters. */
- pjsip_PASSWD_SPEC, /* Password. */
- pjsip_USER_SPEC, /* User */
- pjsip_NEWLINE_OR_EOF_SPEC, /* For eating up header.*/
- pjsip_DISPLAY_SCAN_SPEC; /* Used when searching for display name in URL. */
+extern pj_cis_t
+ pjsip_HOST_SPEC, /**< For scanning host part. */
+ pjsip_DIGIT_SPEC, /**< Decimal digits */
+ pjsip_ALPHA_SPEC, /**< Alpha (A-Z, a-z) */
+ pjsip_ALNUM_SPEC, /**< Decimal + Alpha. */
+ pjsip_TOKEN_SPEC, /**< Token. */
+ pjsip_HEX_SPEC, /**< Hexadecimal digits. */
+ pjsip_PARAM_CHAR_SPEC, /**< For scanning pname (or pvalue when it's
+ not quoted.) */
+ pjsip_HDR_CHAR_SPEC, /**< Chars in hname/havalue in URL. */
+ pjsip_PROBE_USER_HOST_SPEC, /**< Hostname characters. */
+ pjsip_PASSWD_SPEC, /**< Password. */
+ pjsip_USER_SPEC, /**< User */
+ pjsip_NEWLINE_OR_EOF_SPEC, /**< For eating up header.*/
+ pjsip_DISPLAY_SCAN_SPEC; /**< Used when searching for display name. */
/*
* Various string constants.
diff --git a/pjsip/include/pjsip/sip_transaction.h b/pjsip/include/pjsip/sip_transaction.h
index 4090ca4c..e7edceef 100644
--- a/pjsip/include/pjsip/sip_transaction.h
+++ b/pjsip/include/pjsip/sip_transaction.h
@@ -129,6 +129,23 @@ struct pjsip_transaction
};
+/**
+ * Create new transaction. Application would normally use
+ * #pjsip_endpt_create_tsx rather than this function.
+ *
+ * @param pool Pool to use by the transaction.
+ * @param endpt Endpoint.
+ * @param p_tsx Pointer to return the transaction.
+ *
+ * @return PJ_SUCCESS or the appropriate error code.
+ *
+ * @see pjsip_endpt_create_tsx
+ *
+ */
+PJ_DEF(pj_status_t) pjsip_tsx_create( pj_pool_t *pool,
+ pjsip_endpoint *endpt,
+ pjsip_transaction **p_tsx);
+
/**
* Init transaction as UAC from the specified transmit data (\c tdata).
* The transmit data must have a valid \c Request-Line and \c CSeq header.
diff --git a/pjsip/include/pjsip/sip_uri.h b/pjsip/include/pjsip/sip_uri.h
index f73207da..b72721f2 100644
--- a/pjsip/include/pjsip/sip_uri.h
+++ b/pjsip/include/pjsip/sip_uri.h
@@ -26,6 +26,7 @@
#include <pjsip/sip_types.h>
#include <pjsip/sip_config.h>
+#include <pj/list.h>
PJ_BEGIN_DECL
@@ -38,6 +39,53 @@ PJ_BEGIN_DECL
*/
/**
+ * Generic parameter, normally used in other_param or header_param.
+ */
+typedef struct pjsip_param
+{
+ PJ_DECL_LIST_MEMBER(struct pjsip_param); /**< Generic list member. */
+ pj_str_t name; /**< Param/header name. */
+ pj_str_t value; /**< Param/header value. */
+} pjsip_param;
+
+
+/**
+ * Find the specified parameter name in the list. The name will be compared
+ * in case-insensitive comparison.
+ *
+ * @param param_list List of parameters to find.
+ * @param name Parameter/header name to find.
+ *
+ * @return The parameter if found, or NULL.
+ */
+PJ_DECL(pjsip_param*) pjsip_param_find( pjsip_param *param_list,
+ const pj_str_t *name );
+
+
+/**
+ * Find the specified parameter name in the list. The name will be compared
+ * in case-insensitive comparison.
+ *
+ * @param param_list List of parameters to find.
+ * @param name Parameter/header name to find.
+ *
+ * @return The parameter if found, or NULL.
+ */
+PJ_DECL(const pjsip_param*) pjsip_param_cfind(const pjsip_param *param_list,
+ const pj_str_t *name );
+
+
+/**
+ * Duplicate the parameters.
+ *
+ * @param pool Pool to allocate memory from.
+ * @param dst_list Destination list.
+ * @param src_list Source list.
+ */
+PJ_DECL(void) pjsip_param_clone(pj_pool_t *pool, pjsip_param *dst_list,
+ const pjsip_param *src_list);
+
+/**
* URI context.
*/
typedef enum pjsip_uri_context_e
@@ -89,10 +137,11 @@ typedef struct pjsip_uri_vptr
* @param context the context.
* @param uri1 the first URI (self).
* @param uri2 the second URI.
- * @return zero if equal.
+ * @return PJ_SUCCESS if equal, or otherwise the error status which
+ * should point to the mismatch part.
*/
- int (*p_compare)(pjsip_uri_context_e context,
- const void *uri1, const void *uri2);
+ pj_status_t (*p_compare)(pjsip_uri_context_e context,
+ const void *uri1, const void *uri2);
/**
* Clone URI.
@@ -139,7 +188,6 @@ struct pjsip_uri
(pj_strnicmp2(pjsip_uri_get_scheme(url), "tel", 3)==0)
-
/**
* SIP and SIPS URL scheme.
*/
@@ -156,8 +204,8 @@ typedef struct pjsip_url
int ttl_param; /**< Optional TTL param, or -1. */
int lr_param; /**< Optional loose routing param, or zero */
pj_str_t maddr_param; /**< Optional maddr param */
- pj_str_t other_param; /**< Other parameters grouped together. */
- pj_str_t header_param; /**< Optional header parameter. */
+ pjsip_param other_param; /**< Other parameters grouped together. */
+ pjsip_param header_param; /**< Optional header parameter. */
} pjsip_url;
@@ -207,10 +255,11 @@ PJ_INLINE(void*) pjsip_uri_get_uri(void *uri)
* @param context Comparison context.
* @param uri1 The first URI.
* @param uri2 The second URI.
- * @return Zero if equal.
+ * @return PJ_SUCCESS if equal, or otherwise the error status which
+ * should point to the mismatch part.
*/
-PJ_INLINE(int) pjsip_uri_cmp(pjsip_uri_context_e context,
- const void *uri1, const void *uri2)
+PJ_INLINE(pj_status_t) pjsip_uri_cmp(pjsip_uri_context_e context,
+ const void *uri1, const void *uri2)
{
return (*((const pjsip_uri*)uri1)->vptr->p_compare)(context, uri1, uri2);
}
diff --git a/pjsip/include/pjsip/sip_misc.h b/pjsip/include/pjsip/sip_util.h
index f8685e54..f8685e54 100644
--- a/pjsip/include/pjsip/sip_misc.h
+++ b/pjsip/include/pjsip/sip_util.h
diff --git a/pjsip/include/pjsip_core.h b/pjsip/include/pjsip_core.h
index f2af3964..6edfda89 100644
--- a/pjsip/include/pjsip_core.h
+++ b/pjsip/include/pjsip_core.h
@@ -20,9 +20,10 @@
#define __PJSIP_CORE_H__
#include <pjsip/sip_types.h>
+#include <pjsip/sip_auth.h>
#include <pjsip/sip_endpoint.h>
+#include <pjsip/sip_errno.h>
#include <pjsip/sip_event.h>
-#include <pjsip/sip_misc.h>
#include <pjsip/sip_module.h>
#include <pjsip/sip_msg.h>
#include <pjsip/sip_parser.h>
@@ -30,7 +31,7 @@
#include <pjsip/sip_transaction.h>
#include <pjsip/sip_transport.h>
#include <pjsip/sip_uri.h>
-#include <pjsip/sip_auth.h>
+#include <pjsip/sip_util.h>
#endif /* __PJSIP_CORE_H__ */