⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chan_sip.c

📁 Asterisk中信道部分的源码 。。。。
💻 C
📖 第 1 页 / 共 5 页
字号:
   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 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 */};enum parse_register_result {	PARSE_REGISTER_FAILED,	PARSE_REGISTER_UPDATE,	PARSE_REGISTER_QUERY,};enum subscriptiontype { 	NONE = 0,	XPIDF_XML,	DIALOG_INFO_XML,	CPIM_PIDF_XML,	PIDF_XML,	MWI_NOTIFICATION};static const struct cfsubscription_types {	enum subscriptiontype type;	const char * const event;	const char * const mediatype;	const char * const text;} subscription_types[] = {	{ NONE,		   "-",        "unknown",	             "unknown" }, 	/* RFC 4235: SIP Dialog event package */	{ DIALOG_INFO_XML, "dialog",   "application/dialog-info+xml", "dialog-info+xml" },	{ CPIM_PIDF_XML,   "presence", "application/cpim-pidf+xml",   "cpim-pidf+xml" },  /* RFC 3863 */	{ PIDF_XML,        "presence", "application/pidf+xml",        "pidf+xml" },       /* RFC 3863 */	{ XPIDF_XML,       "presence", "application/xpidf+xml",       "xpidf+xml" },       /* Pre-RFC 3863 with MS additions */	{ MWI_NOTIFICATION,	"message-summary", "application/simple-message-summary", "mwi" } /* RFC 3842: Mailbox notification */};/*! \brief SIP Request methods known by Asterisk */enum sipmethod {	SIP_UNKNOWN,		/* Unknown response */	SIP_RESPONSE,		/* Not request, response to outbound request */	SIP_REGISTER,	SIP_OPTIONS,	SIP_NOTIFY,	SIP_INVITE,	SIP_ACK,	SIP_PRACK,		/* Not supported at all */	SIP_BYE,	SIP_REFER,	SIP_SUBSCRIBE,	SIP_MESSAGE,	SIP_UPDATE,		/* We can send UPDATE; but not accept it */	SIP_INFO,	SIP_CANCEL,	SIP_PUBLISH,		/* Not supported at all */	SIP_PING,		/* Not supported at all, no standard but still implemented out there */};/*! \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,	WWW_AUTH,};/*! \brief Authentication result from check_auth* functions */enum check_auth_result {	AUTH_SUCCESSFUL = 0,	AUTH_CHALLENGE_SENT = 1,	AUTH_SECRET_FAILED = -1,	AUTH_USERNAME_MISMATCH = -2,	AUTH_NOT_FOUND = -3,	AUTH_FAKE_AUTH = -4,	AUTH_UNKNOWN_DOMAIN = -5,	AUTH_PEER_NOT_DYNAMIC = -6,	AUTH_ACL_FAILED = -7,};/*! \brief States for outbound registrations (with register= lines in sip.conf */enum sipregistrystate {	REG_STATE_UNREGISTERED = 0,	/*!< We are not registred */	REG_STATE_REGSENT,	/*!< Registration request sent */	REG_STATE_AUTHSENT,	/*!< We have tried to authenticate */	REG_STATE_REGISTERED,	/*!< Registred and done */	REG_STATE_REJECTED,	/*!< Registration rejected */	REG_STATE_TIMEOUT,	/*!< Registration timed out */	REG_STATE_NOAUTH,	/*!< We have no accepted credentials */	REG_STATE_FAILED,	/*!< Registration failed after several tries */};#define CAN_NOT_CREATE_DIALOG	0#define CAN_CREATE_DIALOG	1#define CAN_CREATE_DIALOG_UNSUPPORTED_METHOD	2/*! XXX Note that sip_methods[i].id == i must hold or the code breaks */static const struct  cfsip_methods { 	enum sipmethod id;	int need_rtp;		/*!< when this is the 'primary' use for a pvt structure, does it need RTP? */	char * const text;	int can_create;} sip_methods[] = {	{ SIP_UNKNOWN,	 RTP,    "-UNKNOWN-", 	CAN_CREATE_DIALOG },	{ SIP_RESPONSE,	 NO_RTP, "SIP/2.0",	CAN_NOT_CREATE_DIALOG },	{ SIP_REGISTER,	 NO_RTP, "REGISTER", 	CAN_CREATE_DIALOG }, 	{ SIP_OPTIONS,	 NO_RTP, "OPTIONS", 	CAN_CREATE_DIALOG },	{ SIP_NOTIFY,	 NO_RTP, "NOTIFY", 	CAN_CREATE_DIALOG },	{ SIP_INVITE,	 RTP,    "INVITE", 	CAN_CREATE_DIALOG },	{ SIP_ACK,	 NO_RTP, "ACK", 	CAN_NOT_CREATE_DIALOG },	{ SIP_PRACK,	 NO_RTP, "PRACK", 	CAN_NOT_CREATE_DIALOG },	{ SIP_BYE,	 NO_RTP, "BYE", 	CAN_NOT_CREATE_DIALOG },	{ SIP_REFER,	 NO_RTP, "REFER", 	CAN_CREATE_DIALOG },	{ SIP_SUBSCRIBE, NO_RTP, "SUBSCRIBE", 	CAN_CREATE_DIALOG },	{ SIP_MESSAGE,	 NO_RTP, "MESSAGE", 	CAN_CREATE_DIALOG },	{ SIP_UPDATE,	 NO_RTP, "UPDATE", 	CAN_NOT_CREATE_DIALOG },	{ SIP_INFO,	 NO_RTP, "INFO", 	CAN_NOT_CREATE_DIALOG },	{ SIP_CANCEL,	 NO_RTP, "CANCEL", 	CAN_NOT_CREATE_DIALOG },	{ SIP_PUBLISH,	 NO_RTP, "PUBLISH", 	CAN_CREATE_DIALOG_UNSUPPORTED_METHOD },	{ SIP_PING,	 NO_RTP, "PING", 	CAN_CREATE_DIALOG_UNSUPPORTED_METHOD }};/*!  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#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)/*! \brief List of well-known SIP options. If we get this in a require,   we should check the list and answer accordingly. */static const struct cfsip_options {	int id;			/*!< Bitmap ID */	int supported;		/*!< Supported by Asterisk ? */	char * const text;	/*!< Text id, as in standard */} sip_options[] = {	/* XXX used in 3 places */	/* RFC3891: Replaces: header for transfer */	{ SIP_OPT_REPLACES,	SUPPORTED,	"replaces" },		/* One version of Polycom firmware has the wrong label */	{ SIP_OPT_REPLACES,	SUPPORTED,	"replace" },		/* RFC3262: PRACK 100% reliability */	{ SIP_OPT_100REL,	NOT_SUPPORTED,	"100rel" },		/* RFC4028: SIP Session Timers */	{ SIP_OPT_TIMER,	NOT_SUPPORTED,	"timer" },	/* RFC3959: SIP Early session support */	{ SIP_OPT_EARLY_SESSION, NOT_SUPPORTED,	"early-session" },	/* RFC3911: SIP Join header support */	{ SIP_OPT_JOIN,		NOT_SUPPORTED,	"join" },	/* RFC3327: Path support */	{ SIP_OPT_PATH,		NOT_SUPPORTED,	"path" },	/* RFC3840: Callee preferences */	{ SIP_OPT_PREF,		NOT_SUPPORTED,	"pref" },	/* RFC3312: Precondition support */	{ SIP_OPT_PRECONDITION,	NOT_SUPPORTED,	"precondition" },	/* RFC3323: Privacy with proxies*/	{ SIP_OPT_PRIVACY,	NOT_SUPPORTED,	"privacy" },	/* RFC4092: Usage of the SDP ANAT Semantics in the SIP */	{ SIP_OPT_SDP_ANAT,	NOT_SUPPORTED,	"sdp-anat" },	/* RFC3329: Security agreement mechanism */	{ SIP_OPT_SEC_AGREE,	NOT_SUPPORTED,	"sec_agree" },	/* SIMPLE events:  RFC4662 */	{ SIP_OPT_EVENTLIST,	NOT_SUPPORTED,	"eventlist" },	/* GRUU: Globally Routable User Agent URI's */	{ SIP_OPT_GRUU,		NOT_SUPPORTED,	"gruu" },	/* RFC4538: Target-dialog */	{ SIP_OPT_TARGET_DIALOG,NOT_SUPPORTED,	"tdialog" },	/* Disable the REFER subscription, RFC 4488 */	{ SIP_OPT_NOREFERSUB,	NOT_SUPPORTED,	"norefersub" },	/* ietf-sip-history-info-06.txt */	{ SIP_OPT_HISTINFO,	NOT_SUPPORTED,	"histinfo" },	/* ietf-sip-resource-priority-10.txt */	{ SIP_OPT_RESPRIORITY,	NOT_SUPPORTED,	"resource-priority" },};/*! \brief SIP Methods we support */#define ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY"/*! \brief SIP Extensions we support */#define SUPPORTED_EXTENSIONS "replaces" /*! \brief Standard SIP port from RFC 3261. DO NOT CHANGE THIS */#define STANDARD_SIP_PORT	5060/* 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. *//* 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"#define DEFAULT_MOHINTERPRET    "default"#define DEFAULT_MOHSUGGEST      ""#define DEFAULT_VMEXTEN 	"asterisk"#define DEFAULT_CALLERID 	"asterisk"#define DEFAULT_NOTIFYMIME 	"application/simple-message-summary"#define DEFAULT_MWITIME 	10#define DEFAULT_ALLOWGUEST	TRUE#define DEFAULT_SRVLOOKUP	TRUE		/*!< Recommended setting is ON */#define DEFAULT_COMPACTHEADERS	FALSE#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_ALLOW_EXT_DOM	TRUE#define DEFAULT_REALM		"asterisk"#define DEFAULT_NOTIFYRINGING	TRUE#define DEFAULT_PEDANTIC	FALSE#define DEFAULT_AUTOCREATEPEER	FALSE#define DEFAULT_QUALIFY		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 */#endif/* Default setttings are used as a channel setting and as a default when   configuring devices */static char default_context[AST_MAX_CONTEXT];static char default_subscribecontext[AST_MAX_CONTEXT];static char default_language[MAX_LANGUAGE];static char default_callerid[AST_MAX_EXTENSION];static char default_fromdomain[AST_MAX_EXTENSION];static char default_notifymime[AST_MAX_EXTENSION];static int default_qualify;		/*!< Default Qualify= setting */static char default_vmexten[AST_MAX_EXTENSION];static char default_mohinterpret[MAX_MUSICCLASS];  /*!< Global setting for moh class to use when put on hold */static char default_mohsuggest[MAX_MUSICCLASS];	   /*!< Global setting for moh class to suggest when putting                                                     *   a bridged channel on hold */static int default_maxcallbitrate;	/*!< Maximum bitrate for call */static struct ast_codec_pref default_prefs;		/*!< Default codec prefs *//* Global settings only apply to the channel */static int global_directrtpsetup;	/*!< Enable support for Direct RTP setup (no re-invites) */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -