[svn-commits] dvossel: branch dvossel/sip_string_parse_testing r244323 - in /team/dvossel/s...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Feb 1 18:23:40 CST 2010


Author: dvossel
Date: Mon Feb  1 18:23:38 2010
New Revision: 244323

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=244323
Log:
addition of config-parser.h, reqresp-parser.h, and sip-utils.h


Added:
    team/dvossel/sip_string_parse_testing/channels/sip/include/
    team/dvossel/sip_string_parse_testing/channels/sip/include/config-parser.h   (with props)
    team/dvossel/sip_string_parse_testing/channels/sip/include/reqresp-parser.h   (with props)
    team/dvossel/sip_string_parse_testing/channels/sip/include/sip-utils.h   (with props)
    team/dvossel/sip_string_parse_testing/channels/sip/include/sip.h   (with props)
    team/dvossel/sip_string_parse_testing/channels/sip/reqresp-parser.c   (with props)
Removed:
    team/dvossel/sip_string_parse_testing/channels/sip/request-parser.c
    team/dvossel/sip_string_parse_testing/channels/sip/sip.h
Modified:
    team/dvossel/sip_string_parse_testing/channels/Makefile
    team/dvossel/sip_string_parse_testing/channels/chan_sip.c
    team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c

Modified: team/dvossel/sip_string_parse_testing/channels/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/Makefile?view=diff&rev=244323&r1=244322&r2=244323
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/Makefile (original)
+++ team/dvossel/sip_string_parse_testing/channels/Makefile Mon Feb  1 18:23:38 2010
@@ -69,7 +69,7 @@
 	rm -f h323/Makefile
 
 $(if $(filter chan_iax2,$(EMBEDDED_MODS)),modules.link,chan_iax2.so): iax2-parser.o iax2-provision.o
-$(if $(filter chan_sip,$(EMBEDDED_MODS)),modules.link,chan_sip.so): sip/config-parser.o sip/request-parser.o
+$(if $(filter chan_sip,$(EMBEDDED_MODS)),modules.link,chan_sip.so): sip/config-parser.o sip/reqresp-parser.o
 $(if $(filter chan_dahdi,$(EMBEDDED_MODS)),modules.link,chan_dahdi.so): sig_analog.o sig_pri.o
 
 ifneq ($(filter chan_h323,$(EMBEDDED_MODS)),)

Modified: team/dvossel/sip_string_parse_testing/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/chan_sip.c?view=diff&rev=244323&r1=244322&r2=244323
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/chan_sip.c (original)
+++ team/dvossel/sip_string_parse_testing/channels/chan_sip.c Mon Feb  1 18:23:38 2010
@@ -262,7 +262,10 @@
 #include "asterisk/event.h"
 #include "asterisk/stun.h"
 #include "asterisk/cel.h"
-#include "sip/sip.h"
+#include "sip/include/sip.h"
+#include "sip/include/config-parser.h"
+#include "sip/include/reqresp-parser.h"
+#include "sip/include/sip-utils.h"
 
 /*** DOCUMENTATION
 	<application name="SIPDtmfMode" language="en_US">
@@ -2087,7 +2090,7 @@
  *  pt buffer is provided or the pt has errors when being converted
  *  to an int value, the port provided as the standard is used.
  */
-int port_str2int(const char *pt, unsigned int standard)
+unsigned int port_str2int(const char *pt, unsigned int standard)
 {
 	int port = standard;
 	if (ast_strlen_zero(pt) || (sscanf(pt, "%30d", &port) != 1) || (port < 1) || (port > 65535)) {

Modified: team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c?view=diff&rev=244323&r1=244322&r2=244323
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c (original)
+++ team/dvossel/sip_string_parse_testing/channels/sip/config-parser.c Mon Feb  1 18:23:38 2010
@@ -23,7 +23,9 @@
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "sip.h"
+#include "include/sip.h"
+#include "include/config-parser.h"
+#include "include/sip-utils.h"
 
 /*! \brief Parse register=> line in sip.conf
  *

Added: team/dvossel/sip_string_parse_testing/channels/sip/include/config-parser.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/sip/include/config-parser.h?view=auto&rev=244323
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/sip/include/config-parser.h (added)
+++ team/dvossel/sip_string_parse_testing/channels/sip/include/config-parser.h Mon Feb  1 18:23:38 2010
@@ -1,0 +1,50 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief sip.conf parser header file
+ */
+
+#include "sip.h"
+
+#ifndef _SIP_CONF_PARSE_H
+#define _SIP_CONF_PARSE_H
+
+
+/*! \brief Parse register=> line in sip.conf
+ *
+ *  \retval 0 on success
+ *  \retval -1 on failure
+ */
+int sip_parse_register_line(struct sip_registry *reg, const char *value, int lineno);
+
+/*!
+ * \brief parses a config line for a host with a transport
+ *        i.e. tls://www.google.com:8056
+ *
+ *  \retval 0 on success
+ *  \retval -1 on failure
+ */
+int sip_parse_host(char *line, int lineno, char **hostname, int *portnum, enum sip_transport *transport);
+
+/*! \brief register config parsing tests */
+void sip_config_parser_register_tests(void);
+
+/*! \brief unregister config parsing tests */
+void sip_config_parser_unregister_tests(void);
+
+#endif

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/config-parser.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/config-parser.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/config-parser.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/dvossel/sip_string_parse_testing/channels/sip/include/reqresp-parser.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/sip/include/reqresp-parser.h?view=auto&rev=244323
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/sip/include/reqresp-parser.h (added)
+++ team/dvossel/sip_string_parse_testing/channels/sip/include/reqresp-parser.h Mon Feb  1 18:23:38 2010
@@ -1,0 +1,57 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief sip request response parser header file
+ */
+
+#ifndef _SIP_REQRESP_H
+#define _SIP_REQRESP_H
+
+/*! \brief parses a URI in its components.
+ *
+ * \note
+ * - Multiple scheme's can be specified ',' delimited. ex: "sip:,sips:"
+ * - If a component is not requested, do not split around it. This means
+ *   that if we don't have domain, we cannot split name:pass and domain:port.
+ * - It is safe to call with ret_name, pass, domain, port pointing all to
+ *   the same place.
+ * - This function overwrites the the uri string.
+ * 
+ * \retval 0 on success
+ * \retval -1 on error.
+ *
+ * \verbatim
+ * general form we are expecting is sip:user:password;user-parameters at host:port;uri-parameters?headers
+ * \endverbatim
+ *
+ */
+int parse_uri(char *uri, const char *scheme, char **ret_name, char **pass, char **domain, char **port, char **transport);
+
+/*! \brief  Get caller id name from SIP headers, copy into output buffer
+ *
+ *  \retval input string pointer placed after display-name field if possible
+ */
+const char *get_calleridname(const char *input, char *output, size_t outputsize);
+
+/*! \brief register request parsing tests */
+void sip_request_parser_register_tests(void);
+
+/*! \brief unregister request parsing tests */
+void sip_request_parser_unregister_tests(void);
+
+#endif

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/reqresp-parser.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/reqresp-parser.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/reqresp-parser.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/dvossel/sip_string_parse_testing/channels/sip/include/sip-utils.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/sip/include/sip-utils.h?view=auto&rev=244323
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/sip/include/sip-utils.h (added)
+++ team/dvossel/sip_string_parse_testing/channels/sip/include/sip-utils.h Mon Feb  1 18:23:38 2010
@@ -1,0 +1,34 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief sip utils header file
+ */
+
+#ifndef _SIP_UTILS_H
+#define _SIP_UTILS_H
+
+
+/*! \brief converts ascii port to int representation. If no
+ *  pt buffer is provided or the pt has errors when being converted
+ *  to an int value, the port provided as the standard is used.
+ *
+ *  \retval positive numeric port 
+ */
+unsigned int port_str2int(const char *pt, unsigned int standard);
+
+#endif

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/sip-utils.h
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/sip-utils.h
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: team/dvossel/sip_string_parse_testing/channels/sip/include/sip-utils.h
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: team/dvossel/sip_string_parse_testing/channels/sip/include/sip.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/sip_string_parse_testing/channels/sip/include/sip.h?view=auto&rev=244323
==============================================================================
--- team/dvossel/sip_string_parse_testing/channels/sip/include/sip.h (added)
+++ team/dvossel/sip_string_parse_testing/channels/sip/include/sip.h Mon Feb  1 18:23:38 2010
@@ -1,0 +1,1280 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief chan_sip header file
+ */
+
+#ifndef _SIP_H
+#define _SIP_H
+
+#include "asterisk.h"
+
+#include "asterisk/stringfields.h"
+#include "asterisk/linkedlists.h"
+#include "asterisk/strings.h"
+#include "asterisk/tcptls.h"
+#include "asterisk/test.h"
+#include "asterisk/channel.h"
+#include "asterisk/app.h"
+#include "asterisk/astobj.h"
+
+#ifndef FALSE
+#define FALSE    0
+#endif
+
+#ifndef TRUE
+#define TRUE     1
+#endif
+
+/* Arguments for find_peer */
+#define FINDUSERS (1 << 0)
+#define FINDPEERS (1 << 1)
+#define FINDALLDEVICES (FINDUSERS | FINDPEERS)
+
+#define	SIPBUFSIZE      512             /*!< Buffer size for many operations */
+
+#define XMIT_ERROR      -2
+
+#define SIP_RESERVED    ";/?:@&=+$,# "  /*!< Reserved characters in the username part of the URI */
+
+#define DEFAULT_DEFAULT_EXPIRY       120
+#define DEFAULT_MIN_EXPIRY           60
+#define DEFAULT_MAX_EXPIRY           3600
+#define DEFAULT_MWI_EXPIRY           3600
+#define DEFAULT_REGISTRATION_TIMEOUT 20
+#define DEFAULT_MAX_FORWARDS        "70"
+
+/* guard limit must be larger than guard secs */
+/* guard min must be < 1000, and should be >= 250 */
+#define EXPIRY_GUARD_SECS    15   /*!< How long before expiry do we reregister */
+#define EXPIRY_GUARD_LIMIT   30   /*!< Below here, we use EXPIRY_GUARD_PCT instead of EXPIRY_GUARD_SECS */
+#define EXPIRY_GUARD_MIN     500  /*!< This is the minimum guard time applied. If
+                                   *   GUARD_PCT turns out to be lower than this, it
+                                   *   will use this time instead.
+                                   *   This is in milliseconds.
+								   */
+#define EXPIRY_GUARD_PCT     0.20 /*!< Percentage of expires timeout to use when
+                                   *   below EXPIRY_GUARD_LIMIT */
+#define DEFAULT_EXPIRY       900  /*!< Expire slowly */
+
+#define DEFAULT_QUALIFY_GAP   100
+#define DEFAULT_QUALIFY_PEERS 1
+
+#define CALLERID_UNKNOWN          "Anonymous"
+#define FROMDOMAIN_INVALID        "anonymous.invalid"
+
+#define DEFAULT_MAXMS             2000        /*!< Qualification: Must be faster than 2 seconds by default */
+#define DEFAULT_QUALIFYFREQ       60 * 1000   /*!< Qualification: How often to check for the host to be up */
+#define DEFAULT_FREQ_NOTOK        10 * 1000   /*!< Qualification: How often to check, if the host is down... */
+
+#define DEFAULT_RETRANS           1000        /*!< How frequently to retransmit Default: 2 * 500 ms in RFC 3261 */
+#define MAX_RETRANS               6           /*!< Try only 6 times for retransmissions, a total of 7 transmissions */
+#define DEFAULT_TIMER_T1          500         /*!< SIP timer T1 (according to RFC 3261) */
+#define SIP_TRANS_TIMEOUT         64 * DEFAULT_TIMER_T1 /*!< SIP request timeout (rfc 3261) 64*T1
+                                                         *  \todo Use known T1 for timeout (peerpoke)
+                                                         */
+#define DEFAULT_TRANS_TIMEOUT     -1     /*!< Use default SIP transaction timeout */
+#define PROVIS_KEEPALIVE_TIMEOUT  60000  /*!< How long to wait before retransmitting a provisional response (rfc 3261 13.3.1.1) */
+#define MAX_AUTHTRIES             3      /*!< Try authentication three times, then fail */
+
+#define SIP_MAX_HEADERS           64     /*!< Max amount of SIP headers to read */
+#define SIP_MAX_LINES             64     /*!< Max amount of lines in SIP attachment (like SDP) */
+#define SIP_MIN_PACKET            4096   /*!< Initialize size of memory to allocate for packets */
+#define MAX_HISTORY_ENTRIES		  50	 /*!< Max entires in the history list for a sip_pvt */
+
+#define INITIAL_CSEQ              101    /*!< Our initial sip sequence number */
+
+#define DEFAULT_MAX_SE            1800   /*!< Session-Timer Default Session-Expires period (RFC 4028) */
+#define DEFAULT_MIN_SE            90     /*!< Session-Timer Default Min-SE period (RFC 4028) */
+
+#define SDP_MAX_RTPMAP_CODECS     32     /*!< Maximum number of codecs allowed in received SDP */
+
+#define RTP     1
+#define NO_RTP  0
+
+#define DEC_CALL_LIMIT   0
+#define INC_CALL_LIMIT   1
+#define DEC_CALL_RINGING 2
+#define INC_CALL_RINGING 3
+
+/*! Define SIP option tags, used in Require: and Supported: headers
+ *  We need to be aware of these properties in the phones to use
+ *  the replace: header. We should not do that without knowing
+ *  that the other end supports it...
+ *  This is nothing we can configure, we learn by the dialog
+ *  Supported: header on the REGISTER (peer) or the INVITE
+ *  (other devices)
+ *  We are not using many of these today, but will in the future.
+ *  This is documented in RFC 3261
+ */
+#define SUPPORTED       1
+#define NOT_SUPPORTED   0
+
+/* SIP options */
+#define SIP_OPT_REPLACES      (1 << 0)
+#define SIP_OPT_100REL        (1 << 1)
+#define SIP_OPT_TIMER         (1 << 2)
+#define SIP_OPT_EARLY_SESSION (1 << 3)
+#define SIP_OPT_JOIN          (1 << 4)
+#define SIP_OPT_PATH          (1 << 5)
+#define SIP_OPT_PREF          (1 << 6)
+#define SIP_OPT_PRECONDITION  (1 << 7)
+#define SIP_OPT_PRIVACY       (1 << 8)
+#define SIP_OPT_SDP_ANAT      (1 << 9)
+#define SIP_OPT_SEC_AGREE     (1 << 10)
+#define SIP_OPT_EVENTLIST     (1 << 11)
+#define SIP_OPT_GRUU          (1 << 12)
+#define SIP_OPT_TARGET_DIALOG (1 << 13)
+#define SIP_OPT_NOREFERSUB    (1 << 14)
+#define SIP_OPT_HISTINFO      (1 << 15)
+#define SIP_OPT_RESPRIORITY   (1 << 16)
+#define SIP_OPT_FROMCHANGE    (1 << 17)
+#define SIP_OPT_RECLISTINV    (1 << 18)
+#define SIP_OPT_RECLISTSUB    (1 << 19)
+#define SIP_OPT_OUTBOUND      (1 << 20)
+#define SIP_OPT_UNKNOWN       (1 << 21)
+
+/*! \brief SIP Methods we support
+ *  \todo This string should be set dynamically. We only support REFER and SUBSCRIBE if we have
+ *  allowsubscribe and allowrefer on in sip.conf.
+ */
+#define ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO"
+
+/*! \brief SIP Extensions we support
+ *  \note This should be generated based on the previous array
+ *  in combination with settings.
+ *
+ *  \todo We should not have "timer" if it's disabled in the configuration file.
+ */
+#define SUPPORTED_EXTENSIONS "replaces, timer"
+
+/*! \brief Standard SIP unsecure port for UDP and TCP from RFC 3261. DO NOT CHANGE THIS */
+#define STANDARD_SIP_PORT	5060
+/*! \brief Standard SIP TLS port from RFC 3261. DO NOT CHANGE THIS */
+#define STANDARD_TLS_PORT	5061
+
+/*! \note in many SIP headers, absence of a port number implies port 5060,
+ * and this is why we cannot change the above constant.
+ * There is a limited number of places in asterisk where we could,
+ * in principle, use a different "default" port number, but
+ * we do not support this feature at the moment.
+ * You can run Asterisk with SIP on a different port with a configuration
+ * option. If you change this value in the source code, the signalling will be incorrect.
+ *
+ */
+
+/*! \name DefaultValues Default values, set and reset in reload_config before reading configuration
+
+   These are default values in the source. There are other recommended values in the
+   sip.conf.sample for new installations. These may differ to keep backwards compatibility,
+   yet encouraging new behaviour on new installations
+ */
+/*@{*/
+#define DEFAULT_CONTEXT        "default"  /*!< The default context for [general] section as well as devices */
+#define DEFAULT_MOHINTERPRET   "default"  /*!< The default music class */
+#define DEFAULT_MOHSUGGEST     ""
+#define DEFAULT_VMEXTEN        "asterisk" /*!< Default voicemail extension */
+#define DEFAULT_CALLERID       "asterisk" /*!< Default caller ID */
+#define DEFAULT_MWI_FROM       ""
+#define DEFAULT_NOTIFYMIME     "application/simple-message-summary"
+#define DEFAULT_ALLOWGUEST     TRUE
+#define DEFAULT_RTPKEEPALIVE   0      /*!< Default RTPkeepalive setting */
+#define DEFAULT_CALLCOUNTER    FALSE   /*!< Do not enable call counters by default */
+#define DEFAULT_SRVLOOKUP      TRUE    /*!< Recommended setting is ON */
+#define DEFAULT_COMPACTHEADERS FALSE  /*!< Send compact (one-character) SIP headers. Default off */
+#define DEFAULT_TOS_SIP        0      /*!< Call signalling packets should be marked as DSCP CS3, but the default is 0 to be compatible with previous versions. */
+#define DEFAULT_TOS_AUDIO      0      /*!< Audio packets should be marked as DSCP EF (Expedited Forwarding), but the default is 0 to be compatible with previous versions. */
+#define DEFAULT_TOS_VIDEO      0      /*!< Video packets should be marked as DSCP AF41, but the default is 0 to be compatible with previous versions. */
+#define DEFAULT_TOS_TEXT       0      /*!< Text packets should be marked as XXXX XXXX, but the default is 0 to be compatible with previous versions. */
+#define DEFAULT_COS_SIP        4      /*!< Level 2 class of service for SIP signalling */
+#define DEFAULT_COS_AUDIO      5      /*!< Level 2 class of service for audio media  */
+#define DEFAULT_COS_VIDEO      6      /*!< Level 2 class of service for video media */
+#define DEFAULT_COS_TEXT       5      /*!< Level 2 class of service for text media (T.140) */
+#define DEFAULT_ALLOW_EXT_DOM  TRUE    /*!< Allow external domains */
+#define DEFAULT_REALM          "asterisk" /*!< Realm for HTTP digest authentication */
+#define DEFAULT_DOMAINSASREALM FALSE    /*!< Use the domain option to guess the realm for registration and invite requests */
+#define DEFAULT_NOTIFYRINGING  TRUE     /*!< Notify devicestate system on ringing state */
+#define DEFAULT_NOTIFYCID      DISABLED	/*!< Include CID with ringing notifications */
+#define DEFAULT_PEDANTIC       FALSE    /*!< Avoid following SIP standards for dialog matching */
+#define DEFAULT_AUTOCREATEPEER FALSE    /*!< Don't create peers automagically */
+#define	DEFAULT_MATCHEXTERNIPLOCALLY FALSE /*!< Match extern IP locally default setting */
+#define DEFAULT_QUALIFY        FALSE    /*!< Don't monitor devices */
+#define DEFAULT_CALLEVENTS     FALSE    /*!< Extra manager SIP call events */
+#define DEFAULT_ALWAYSAUTHREJECT  FALSE /*!< Don't reject authentication requests always */
+#define DEFAULT_REGEXTENONQUALIFY FALSE
+#define DEFAULT_T1MIN             100   /*!< 100 MS for minimal roundtrip time */
+#define DEFAULT_MAX_CALL_BITRATE (384)  /*!< Max bitrate for video */
+#ifndef DEFAULT_USERAGENT
+#define DEFAULT_USERAGENT  "Asterisk PBX"  /*!< Default Useragent: header unless re-defined in sip.conf */
+#define DEFAULT_SDPSESSION "Asterisk PBX"  /*!< Default SDP session name, (s=) header unless re-defined in sip.conf */
+#define DEFAULT_SDPOWNER   "root"          /*!< Default SDP username field in (o=) header unless re-defined in sip.conf */
+#define DEFAULT_ENGINE     "asterisk"      /*!< Default RTP engine to use for sessions */
+#define DEFAULT_CAPABILITY (AST_FORMAT_ULAW | AST_FORMAT_TESTLAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263);
+#endif
+/*@}*/
+
+/*! \name SIPflags
+	Various flags for the flags field in the pvt structure
+	Trying to sort these up (one or more of the following):
+	D: Dialog
+	P: Peer/user
+	G: Global flag
+	When flags are used by multiple structures, it is important that
+	they have a common layout so it is easy to copy them.
+*/
+/*@{*/
+#define SIP_OUTGOING        (1 << 0) /*!< D: Direction of the last transaction in this dialog */
+#define SIP_RINGING         (1 << 2) /*!< D: Have sent 180 ringing */
+#define SIP_PROGRESS_SENT   (1 << 3) /*!< D: Have sent 183 message progress */
+#define SIP_NEEDREINVITE    (1 << 4) /*!< D: Do we need to send another reinvite? */
+#define SIP_PENDINGBYE      (1 << 5) /*!< D: Need to send bye after we ack? */
+#define SIP_GOTREFER        (1 << 6) /*!< D: Got a refer? */
+#define SIP_CALL_LIMIT      (1 << 7) /*!< D: Call limit enforced for this call */
+#define SIP_INC_COUNT       (1 << 8) /*!< D: Did this dialog increment the counter of in-use calls? */
+#define SIP_INC_RINGING     (1 << 9) /*!< D: Did this connection increment the counter of in-use calls? */
+#define SIP_DEFER_BYE_ON_TRANSFER	(1 << 10) /*!< D: Do not hangup at first ast_hangup */
+
+#define SIP_PROMISCREDIR    (1 << 11) /*!< DP: Promiscuous redirection */
+#define SIP_TRUSTRPID       (1 << 12) /*!< DP: Trust RPID headers? */
+#define SIP_USEREQPHONE     (1 << 13) /*!< DP: Add user=phone to numeric URI. Default off */
+#define SIP_USECLIENTCODE   (1 << 14) /*!< DP: Trust X-ClientCode info message */
+
+/* DTMF flags - see str2dtmfmode() and dtmfmode2str() */
+#define SIP_DTMF            (7 << 15) /*!< DP: DTMF Support: five settings, uses three bits */
+#define SIP_DTMF_RFC2833    (0 << 15) /*!< DP: DTMF Support: RTP DTMF - "rfc2833" */
+#define SIP_DTMF_INBAND     (1 << 15) /*!< DP: DTMF Support: Inband audio, only for ULAW/ALAW - "inband" */
+#define SIP_DTMF_INFO       (2 << 15) /*!< DP: DTMF Support: SIP Info messages - "info" */
+#define SIP_DTMF_AUTO       (3 << 15) /*!< DP: DTMF Support: AUTO switch between rfc2833 and in-band DTMF */
+#define SIP_DTMF_SHORTINFO  (4 << 15) /*!< DP: DTMF Support: SIP Info messages - "info" - short variant */
+
+/* NAT settings */
+#define SIP_NAT_FORCE_RPORT     (1 << 18) /*!< DP: Force rport even if not present in the request */
+#define SIP_NAT_RPORT_PRESENT   (1 << 19) /*!< DP: rport was present in the request */
+
+/* re-INVITE related settings */
+#define SIP_REINVITE         (7 << 20) /*!< DP: four settings, uses three bits */
+#define SIP_REINVITE_NONE    (0 << 20) /*!< DP: no reinvite allowed */
+#define SIP_DIRECT_MEDIA     (1 << 20) /*!< DP: allow peers to be reinvited to send media directly p2p */
+#define SIP_DIRECT_MEDIA_NAT (2 << 20) /*!< DP: allow media reinvite when new peer is behind NAT */
+#define SIP_REINVITE_UPDATE  (4 << 20) /*!< DP: use UPDATE (RFC3311) when reinviting this peer */
+
+/* "insecure" settings - see insecure2str() */
+#define SIP_INSECURE         (3 << 23)    /*!< DP: three settings, uses two bits */
+#define SIP_INSECURE_NONE    (0 << 23)    /*!< DP: secure mode */
+#define SIP_INSECURE_PORT    (1 << 23)    /*!< DP: don't require matching port for incoming requests */
+#define SIP_INSECURE_INVITE  (1 << 24)    /*!< DP: don't require authentication for incoming INVITEs */
+
+/* Sending PROGRESS in-band settings */
+#define SIP_PROG_INBAND        (3 << 25) /*!< DP: three settings, uses two bits */
+#define SIP_PROG_INBAND_NEVER  (0 << 25)
+#define SIP_PROG_INBAND_NO     (1 << 25)
+#define SIP_PROG_INBAND_YES    (2 << 25)
+
+#define SIP_SENDRPID         (3 << 29) /*!< DP: Remote Party-ID Support */
+#define SIP_SENDRPID_NO      (0 << 29)
+#define SIP_SENDRPID_PAI     (1 << 29) /*!< Use "P-Asserted-Identity" for rpid */
+#define SIP_SENDRPID_RPID    (2 << 29) /*!< Use "Remote-Party-ID" for rpid */
+#define SIP_G726_NONSTANDARD (1 << 31) /*!< DP: Use non-standard packing for G726-32 data */
+
+/*! \brief Flags to copy from peer/user to dialog */
+#define SIP_FLAGS_TO_COPY \
+	(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \
+	 SIP_PROG_INBAND | SIP_USECLIENTCODE | SIP_NAT_FORCE_RPORT | SIP_G726_NONSTANDARD | \
+	 SIP_USEREQPHONE | SIP_INSECURE)
+/*@}*/
+
+/*! \name SIPflags2
+	a second page of flags (for flags[1] */
+/*@{*/
+/* realtime flags */
+#define SIP_PAGE2_RTCACHEFRIENDS        (1 << 0)    /*!< GP: Should we keep RT objects in memory for extended time? */
+#define SIP_PAGE2_RTAUTOCLEAR           (1 << 2)    /*!< GP: Should we clean memory from peers after expiry? */
+#define SIP_PAGE2_RPID_UPDATE           (1 << 3)
+#define SIP_PAGE2_Q850_REASON           (1 << 4)    /*!< DP: Get/send cause code via Reason header */
+
+/* Space for addition of other realtime flags in the future */
+#define SIP_PAGE2_CONSTANT_SSRC         (1 << 7)    /*!< GDP: Don't change SSRC on reinvite */
+#define SIP_PAGE2_SYMMETRICRTP          (1 << 8)    /*!< GDP: Whether symmetric RTP is enabled or not */
+#define SIP_PAGE2_STATECHANGEQUEUE      (1 << 9)    /*!< D: Unsent state pending change exists */
+
+#define SIP_PAGE2_CONNECTLINEUPDATE_PEND (1 << 10)
+#define SIP_PAGE2_RPID_IMMEDIATE         (1 << 11)
+#define SIP_PAGE2_RPORT_PRESENT         (1 << 12)   /*!< Was rport received in the Via header? */
+#define SIP_PAGE2_PREFERRED_CODEC	(1 << 13)   /*!< GDP: Only respond with single most preferred joint codec */
+#define SIP_PAGE2_VIDEOSUPPORT		(1 << 14)   /*!< DP: Video supported if offered? */
+#define SIP_PAGE2_TEXTSUPPORT		(1 << 15)   /*!< GDP: Global text enable */
+#define SIP_PAGE2_ALLOWSUBSCRIBE	(1 << 16)   /*!< GP: Allow subscriptions from this peer? */
+#define SIP_PAGE2_ALLOWOVERLAP		(1 << 17)   /*!< DP: Allow overlap dialing ? */
+#define SIP_PAGE2_SUBSCRIBEMWIONLY	(1 << 18)   /*!< GP: Only issue MWI notification if subscribed to */
+#define SIP_PAGE2_IGNORESDPVERSION	(1 << 19)   /*!< GDP: Ignore the SDP session version number we receive and treat all sessions as new */
+
+#define SIP_PAGE2_T38SUPPORT                   (3 << 20)    /*!< GDP: T.38 Fax Support */
+#define SIP_PAGE2_T38SUPPORT_UDPTL             (1 << 20)    /*!< GDP: T.38 Fax Support (no error correction) */
+#define SIP_PAGE2_T38SUPPORT_UDPTL_FEC         (2 << 20)    /*!< GDP: T.38 Fax Support (FEC error correction) */
+#define SIP_PAGE2_T38SUPPORT_UDPTL_REDUNDANCY  (3 << 20)    /*!< GDP: T.38 Fax Support (redundancy error correction) */
+
+#define SIP_PAGE2_CALL_ONHOLD           (3 << 23)  /*!< D: Call hold states: */
+#define SIP_PAGE2_CALL_ONHOLD_ACTIVE    (1 << 23)  /*!< D: Active hold */
+#define SIP_PAGE2_CALL_ONHOLD_ONEDIR    (2 << 23)  /*!< D: One directional hold */
+#define SIP_PAGE2_CALL_ONHOLD_INACTIVE  (3 << 23)  /*!< D: Inactive hold */
+
+#define SIP_PAGE2_RFC2833_COMPENSATE    (1 << 25)  /*!< DP: Compensate for buggy RFC2833 implementations */
+#define SIP_PAGE2_BUGGY_MWI             (1 << 26)  /*!< DP: Buggy CISCO MWI fix */
+#define SIP_PAGE2_DIALOG_ESTABLISHED    (1 << 27)  /*!< 29: Has a dialog been established? */
+#define SIP_PAGE2_FAX_DETECT            (1 << 28)  /*!< DP: Fax Detection support */
+#define SIP_PAGE2_REGISTERTRYING        (1 << 29)  /*!< DP: Send 100 Trying on REGISTER attempts */
+#define SIP_PAGE2_UDPTL_DESTINATION     (1 << 30)  /*!< DP: Use source IP of RTP as destination if NAT is enabled */
+#define SIP_PAGE2_VIDEOSUPPORT_ALWAYS   (1 << 31)  /*!< DP: Always set up video, even if endpoints don't support it */
+
+#define SIP_PAGE2_FLAGS_TO_COPY \
+	(SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_IGNORESDPVERSION | \
+	SIP_PAGE2_VIDEOSUPPORT | SIP_PAGE2_T38SUPPORT | SIP_PAGE2_RFC2833_COMPENSATE | \
+	SIP_PAGE2_BUGGY_MWI | SIP_PAGE2_TEXTSUPPORT | SIP_PAGE2_FAX_DETECT | \
+	SIP_PAGE2_UDPTL_DESTINATION | SIP_PAGE2_VIDEOSUPPORT_ALWAYS | SIP_PAGE2_PREFERRED_CODEC | \
+	SIP_PAGE2_RPID_IMMEDIATE | SIP_PAGE2_RPID_UPDATE | SIP_PAGE2_SYMMETRICRTP | SIP_PAGE2_CONSTANT_SSRC |\
+	SIP_PAGE2_Q850_REASON)
+
+/*@}*/
+
+/*----------------------------------------------------------*/
+/*----                    ENUMS                         ----*/
+/*----------------------------------------------------------*/
+
+/*! \brief Authorization scheme for call transfers
+ *
+ * \note Not a bitfield flag, since there are plans for other modes,
+ * like "only allow transfers for authenticated devices"
+ */
+enum transfermodes {
+	TRANSFER_OPENFORALL,            /*!< Allow all SIP transfers */
+	TRANSFER_CLOSED,                /*!< Allow no SIP transfers */
+};
+
+/*! \brief The result of a lot of functions */
+enum sip_result {
+	AST_SUCCESS = 0,		/*!< FALSE means success, funny enough */
+	AST_FAILURE = -1,		/*!< Failure code */
+};
+
+/*! \brief States for the INVITE transaction, not the dialog
+ *  \note this is for the INVITE that sets up the dialog
+ */
+enum invitestates {
+	INV_NONE = 0,         /*!< No state at all, maybe not an INVITE dialog */
+	INV_CALLING = 1,      /*!< Invite sent, no answer */
+	INV_PROCEEDING = 2,   /*!< We got/sent 1xx message */
+	INV_EARLY_MEDIA = 3,  /*!< We got 18x message with to-tag back */
+	INV_COMPLETED = 4,    /*!< Got final response with error. Wait for ACK, then CONFIRMED */
+	INV_CONFIRMED = 5,    /*!< Confirmed response - we've got an ack (Incoming calls only) */
+	INV_TERMINATED = 6,   /*!< Transaction done - either successful (AST_STATE_UP) or failed, but done
+				     The only way out of this is a BYE from one side */
+	INV_CANCELLED = 7,    /*!< Transaction cancelled by client or server in non-terminated state */
+};
+
+/*! \brief When sending a SIP message, we can send with a few options, depending on
+ * type of SIP request. UNRELIABLE is moslty used for responses to repeated requests,
+ * where the original response would be sent RELIABLE in an INVITE transaction
+ */
+enum xmittype {
+	XMIT_CRITICAL = 2,    /*!< Transmit critical SIP message reliably, with re-transmits.
+	                       *   If it fails, it's critical and will cause a teardown of the session */
+	XMIT_RELIABLE = 1,    /*!< Transmit SIP message reliably, with re-transmits */
+	XMIT_UNRELIABLE = 0,  /*!< Transmit SIP message without bothering with re-transmits */
+};
+
+/*! \brief Results from the parse_register() function */
+enum parse_register_result {
+	PARSE_REGISTER_DENIED,
+	PARSE_REGISTER_FAILED,
+	PARSE_REGISTER_UPDATE,
+	PARSE_REGISTER_QUERY,
+};
+
+/*! \brief Type of subscription, based on the packages we do support, see \ref subscription_types */
+enum subscriptiontype {
+	NONE = 0,
+	XPIDF_XML,
+	DIALOG_INFO_XML,
+	CPIM_PIDF_XML,
+	PIDF_XML,
+	MWI_NOTIFICATION
+};
+
+/*! \brief The number of media types in enum \ref media_type below. */
+#define OFFERED_MEDIA_COUNT	4
+
+/*! \brief Media types generate different "dummy answers" for not accepting the offer of 
+	a media stream. We need to add definitions for each RTP profile. Secure RTP is not
+	the same as normal RTP and will require a new definition */
+enum media_type {
+	SDP_AUDIO,   /*!< RTP/AVP Audio */
+	SDP_VIDEO,   /*!< RTP/AVP Video */
+	SDP_IMAGE,   /*!< Image udptl, not TCP or RTP */
+	SDP_TEXT,    /*!< RTP/AVP Realtime Text */
+};
+
+/*! \brief Authentication types - proxy or www authentication
+ *  \note Endpoints, like Asterisk, should always use WWW authentication to
+ *  allow multiple authentications in the same call - to the proxy and
+ *  to the end point.
+ */
+enum sip_auth_type {
+	PROXY_AUTH = 407,
+	WWW_AUTH = 401,
+};
+
+/*! \brief Authentication result from check_auth* functions */
+enum check_auth_result {
+	AUTH_DONT_KNOW = -100,	/*!< no result, need to check further */
+		/* XXX maybe this is the same as AUTH_NOT_FOUND */
+	AUTH_SUCCESSFUL = 0,
+	AUTH_CHALLENGE_SENT = 1,
+	AUTH_SECRET_FAILED = -1,
+	AUTH_USERNAME_MISMATCH = -2,
+	AUTH_NOT_FOUND = -3,	/*!< returned by register_verify */
+	AUTH_FAKE_AUTH = -4,
+	AUTH_UNKNOWN_DOMAIN = -5,
+	AUTH_PEER_NOT_DYNAMIC = -6,
+	AUTH_ACL_FAILED = -7,
+	AUTH_BAD_TRANSPORT = -8,
+	AUTH_RTP_FAILED = 9,
+};
+
+/*! \brief States for outbound registrations (with register= lines in sip.conf */
+enum sipregistrystate {
+	REG_STATE_UNREGISTERED = 0,	/*!< We are not registered
+		 *  \note Initial state. We should have a timeout scheduled for the initial
+		 * (or next) registration transmission, calling sip_reregister
+		 */
+
+	REG_STATE_REGSENT,	/*!< Registration request sent
+		 * \note sent initial request, waiting for an ack or a timeout to
+		 * retransmit the initial request.
+		*/
+
+	REG_STATE_AUTHSENT,	/*!< We have tried to authenticate
+		 * \note entered after transmit_register with auth info,
+		 * waiting for an ack.
+		 */
+
+	REG_STATE_REGISTERED,	/*!< Registered and done */
+
+	REG_STATE_REJECTED,	/*!< Registration rejected
+		 * \note only used when the remote party has an expire larger than
+		 * our max-expire. This is a final state from which we do not
+		 * recover (not sure how correctly).
+		 */
+
+	REG_STATE_TIMEOUT,	/*!< Registration timed out
+		* \note XXX unused */
+
+	REG_STATE_NOAUTH,	/*!< We have no accepted credentials
+		 * \note fatal - no chance to proceed */
+
+	REG_STATE_FAILED,	/*!< Registration failed after several tries
+		 * \note fatal - no chance to proceed */
+};
+
+/*! \brief Modes in which Asterisk can be configured to run SIP Session-Timers */
+enum st_mode {
+        SESSION_TIMER_MODE_INVALID = 0, /*!< Invalid value */
+        SESSION_TIMER_MODE_ACCEPT,      /*!< Honor inbound Session-Timer requests */
+        SESSION_TIMER_MODE_ORIGINATE,   /*!< Originate outbound and honor inbound requests */
+        SESSION_TIMER_MODE_REFUSE       /*!< Ignore inbound Session-Timers requests */
+};
+
+/*! \brief The entity playing the refresher role for Session-Timers */
+enum st_refresher {
+        SESSION_TIMER_REFRESHER_AUTO,    /*!< Negotiated                      */
+        SESSION_TIMER_REFRESHER_UAC,     /*!< Session is refreshed by the UAC */
+        SESSION_TIMER_REFRESHER_UAS      /*!< Session is refreshed by the UAS */
+};
+
+/*! \brief Define some implemented SIP transports
+	\note Asterisk does not support SCTP or UDP/DTLS
+*/
+enum sip_transport {
+	SIP_TRANSPORT_UDP = 1,         /*!< Unreliable transport for SIP, needs retransmissions */
+	SIP_TRANSPORT_TCP = 1 << 1,    /*!< Reliable, but unsecure */
+	SIP_TRANSPORT_TLS = 1 << 2,    /*!< TCP/TLS - reliable and secure transport for signalling */
+};
+
+/*! \brief States whether a SIP message can create a dialog in Asterisk. */
+enum can_create_dialog {
+	CAN_NOT_CREATE_DIALOG,
+	CAN_CREATE_DIALOG,
+	CAN_CREATE_DIALOG_UNSUPPORTED_METHOD,
+};
+
+/*! \brief SIP Request methods known by Asterisk
+ *
+ * \note Do _NOT_ make any changes to this enum, or the array following it;
+ * if you think you are doing the right thing, you are probably
+ * not doing the right thing. If you think there are changes
+ * needed, get someone else to review them first _before_
+ * submitting a patch. If these two lists do not match properly
+ * bad things will happen.
+ */
+enum sipmethod {
+	SIP_UNKNOWN,    /*!< Unknown response */
+	SIP_RESPONSE,   /*!< Not request, response to outbound request */
+	SIP_REGISTER,   /*!< Registration to the mothership, tell us where you are located */
+	SIP_OPTIONS,    /*!< Check capabilities of a device, used for "ping" too */
+	SIP_NOTIFY,     /*!< Status update, Part of the event package standard, result of a SUBSCRIBE or a REFER */
+	SIP_INVITE,     /*!< Set up a session */
+	SIP_ACK,        /*!< End of a three-way handshake started with INVITE. */
+	SIP_PRACK,      /*!< Reliable pre-call signalling. Not supported in Asterisk. */
+	SIP_BYE,        /*!< End of a session */
+	SIP_REFER,      /*!< Refer to another URI (transfer) */
+	SIP_SUBSCRIBE,  /*!< Subscribe for updates (voicemail, session status, device status, presence) */
+	SIP_MESSAGE,    /*!< Text messaging */
+	SIP_UPDATE,     /*!< Update a dialog. We can send UPDATE; but not accept it */
+	SIP_INFO,       /*!< Information updates during a session */
+	SIP_CANCEL,     /*!< Cancel an INVITE */
+	SIP_PUBLISH,    /*!< Not supported in Asterisk */
+	SIP_PING,       /*!< Not supported at all, no standard but still implemented out there */
+};
+
+/*! \brief Settings for the 'notifycid' option, see sip.conf.sample for details. */
+enum notifycid_setting {
+	DISABLED       = 0,
+	ENABLED        = 1,
+	IGNORE_CONTEXT = 2,
+};
+
+/*! \brief Modes for SIP domain handling in the PBX */
+enum domain_mode {
+	SIP_DOMAIN_AUTO,      /*!< This domain is auto-configured */
+	SIP_DOMAIN_CONFIG,    /*!< This domain is from configuration */
+};
+
+/*! \brief debugging state

[... 1130 lines stripped ...]



More information about the svn-commits mailing list