summaryrefslogtreecommitdiff
path: root/pjsip/include/pjsip
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2010-08-01 09:48:51 +0000
committerBenny Prijono <bennylp@teluu.com>2010-08-01 09:48:51 +0000
commit059d687249f0f95e0b30785c418e1aa47555615a (patch)
tree792e10acf82954faca0a2b7fe937064a1ecb81d8 /pjsip/include/pjsip
parent1426b8301e4d99837bd70ce73b350d03fafbfd45 (diff)
Implemented core multipart support and support in the invite session (re #1070)
- incoming multipart message will be handled automatically - for testing, enable HAVE_MULTIPART_TEST in pjsua_app.c git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3243 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/include/pjsip')
-rw-r--r--pjsip/include/pjsip/sip_multipart.h179
-rw-r--r--pjsip/include/pjsip/sip_parser.h22
2 files changed, 192 insertions, 9 deletions
diff --git a/pjsip/include/pjsip/sip_multipart.h b/pjsip/include/pjsip/sip_multipart.h
new file mode 100644
index 00000000..12a27bad
--- /dev/null
+++ b/pjsip/include/pjsip/sip_multipart.h
@@ -0,0 +1,179 @@
+/* $Id$ */
+/*
+ * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+#ifndef __PJSIP_SIP_MULTIPART_H__
+#define __PJSIP_SIP_MULTIPART_H__
+
+/**
+ * @file pjsip/sip_multipart.h
+ * @brief Multipart support.
+ */
+
+#include <pjsip/sip_msg.h>
+
+PJ_BEGIN_DECL
+
+/**
+ * @defgroup PJSIP_MULTIPART Multipart message bodies.
+ * @ingroup PJSIP_MSG
+ * @brief Support for multipart message bodies.
+ * @{
+ */
+
+/**
+ * This structure describes the individual body part inside a multipart
+ * message body. It mainly contains the message body itself and optional
+ * headers.
+ */
+typedef struct pjsip_multipart_part
+{
+ /**
+ * Standard list element.
+ */
+ PJ_DECL_LIST_MEMBER(struct pjsip_multipart_part);
+
+ /**
+ * Optional message headers.
+ */
+ pjsip_hdr hdr;
+
+ /**
+ * Pointer to the message body.
+ */
+ pjsip_msg_body *body;
+
+} pjsip_multipart_part;
+
+/**
+ * Create an empty multipart body.
+ *
+ * @param pool Memory pool to allocate memory from.
+ * @param ctype Optional MIME media type of the multipart
+ * bodies. If not specified, "multipart/mixed"
+ * will be used.
+ * @param boundary Optional string to be set as part boundary.
+ * The boundary string excludes the leading
+ * hyphens. If this parameter is NULL or empty,
+ * a random boundary will be generated.
+ *
+ * @return Multipart body instance with no part.
+ */
+PJ_DECL(pjsip_msg_body*) pjsip_multipart_create(pj_pool_t *pool,
+ const pjsip_media_type *ctype,
+ const pj_str_t *boundary);
+
+/**
+ * Create an empty multipart part.
+ *
+ * @param pool The memory pool.
+ *
+ * @return The multipart part.
+ */
+PJ_DECL(pjsip_multipart_part*) pjsip_multipart_create_part(pj_pool_t *pool);
+
+
+/**
+ * Perform a deep clone to a multipart part.
+ *
+ * @param pool The memory pool.
+ * @param part The part to be duplicated.
+ *
+ * @return Copy of the multipart part.
+ */
+PJ_DECL(pjsip_multipart_part*)
+pjsip_multipart_clone_part(pj_pool_t *pool,
+ const pjsip_multipart_part *part);
+
+/**
+ * Add a part into multipart bodies.
+ *
+ * @param pool The memory pool.
+ * @param mp The multipart bodies.
+ * @param part The part to be added into the bodies.
+ *
+ * @return PJ_SUCCESS on success.
+ */
+PJ_DECL(pj_status_t) pjsip_multipart_add_part(pj_pool_t *pool,
+ pjsip_msg_body *mp,
+ pjsip_multipart_part *part);
+
+/**
+ * Get the first part of multipart bodies.
+ *
+ * @param mp The multipart bodies.
+ *
+ * @return The first part, or NULL if the multipart
+ * bodies currently doesn't hold any elements.
+ */
+PJ_DECL(pjsip_multipart_part*)
+pjsip_multipart_get_first_part(const pjsip_msg_body *mp);
+
+/**
+ * Get the next part after the specified part.
+ *
+ * @param mp The multipart bodies.
+ * @param part The part.
+ *
+ * @return The next part, or NULL if there is no other part after
+ * the part.
+ */
+PJ_DECL(pjsip_multipart_part*)
+pjsip_multipart_get_next_part(const pjsip_msg_body *mp,
+ pjsip_multipart_part *part);
+
+/**
+ * Find a body inside multipart bodies which has the specified content type.
+ *
+ * @param mp The multipart body.
+ * @param content_type Content type to find.
+ * @param start If specified, the search will begin at
+ * start->next. Otherwise it will begin at
+ * the first part in the multipart bodies.
+ *
+ * @return The first part with the specified content type
+ * if found, or NULL.
+ */
+PJ_DECL(pjsip_multipart_part*)
+pjsip_multipart_find_part( const pjsip_msg_body *mp,
+ const pjsip_media_type *content_type,
+ const pjsip_multipart_part *start);
+
+/**
+ * Parse multipart message.
+ *
+ * @param pool Memory pool.
+ * @param buf Input buffer.
+ * @param len The buffer length.
+ * @param ctype Content type of the multipart body.
+ * @param options Parsing options, must be zero for now.
+ *
+ * @return Multipart message body.
+ */
+PJ_DECL(pjsip_msg_body*) pjsip_multipart_parse(pj_pool_t *pool,
+ char *buf, pj_size_t len,
+ const pjsip_media_type *ctype,
+ unsigned options);
+
+/**
+ * @} PJSIP_MULTIPART
+ */
+
+
+PJ_END_DECL
+
+#endif /* __PJSIP_SIP_MULTIPART_H__ */
diff --git a/pjsip/include/pjsip/sip_parser.h b/pjsip/include/pjsip/sip_parser.h
index 872b87cc..8634d3b1 100644
--- a/pjsip/include/pjsip/sip_parser.h
+++ b/pjsip/include/pjsip/sip_parser.h
@@ -276,7 +276,7 @@ PJ_DECL(pj_status_t) pjsip_find_msg(const char *buf,
* lines, and two when an error happen the value can
* pinpoint the location of the error in the buffer.
*
- * @return The instance of the header if parsing was successfull,
+ * @return The instance of the header if parsing was successful,
* or otherwise a NULL pointer will be returned.
*/
PJ_DECL(void*) pjsip_parse_hdr( pj_pool_t *pool, const pj_str_t *hname,
@@ -287,21 +287,25 @@ PJ_DECL(void*) pjsip_parse_hdr( pj_pool_t *pool, const pj_str_t *hname,
* Parse header line(s). Multiple headers can be parsed by this function.
* When there are multiple headers, the headers MUST be separated by either
* a newline (as in SIP message) or ampersand mark (as in URI). This separator
- * however is optional for the last header.
+ * is optional for the last header.
*
- * @param pool the pool.
- * @param input the input text to parse, which must be NULL terminated.
- * @param size the text length.
- * @param hlist the header list to store the parsed headers.
+ * @param pool The pool.
+ * @param input The input text to parse, which must be NULL terminated.
+ * @param size The text length.
+ * @param hlist The header list to store the parsed headers.
* This list must have been initialized before calling
* this function.
+ * @param options Specify 1 here to make parsing stop when error is
+ * encountered when parsing the header. Otherwise the
+ * error is silently ignored and parsing resumes to the
+ * next line.
* @return zero if successfull, or -1 if error is encountered.
* Upon error, the \a hlist argument MAY contain
* successfully parsed headers.
*/
-PJ_DECL(pj_status_t) pjsip_parse_headers( pj_pool_t *pool,
- char *input, pj_size_t size,
- pj_list *hlist );
+PJ_DECL(pj_status_t) pjsip_parse_headers( pj_pool_t *pool, char *input,
+ pj_size_t size, pjsip_hdr *hlist,
+ unsigned options);
/**