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

📄 chan_sip.c

📁 Asterisk中信道部分的源码 。。。。
💻 C
📖 第 1 页 / 共 5 页
字号:
static int global_limitonpeers;		/*!< Match call limit on peers only */static int global_rtautoclear;static int global_notifyringing;	/*!< Send notifications on ringing */static int global_notifyhold;		/*!< Send notifications on hold */static int global_alwaysauthreject;	/*!< Send 401 Unauthorized for all failing requests */static int srvlookup;			/*!< SRV Lookup on or off. Default is on */static int pedanticsipchecking;		/*!< Extra checking ?  Default off */static int autocreatepeer;		/*!< Auto creation of peers at registration? Default off. */static int global_relaxdtmf;			/*!< Relax DTMF */static int global_rtptimeout;		/*!< Time out call if no RTP */static int global_rtpholdtimeout;static int global_rtpkeepalive;		/*!< Send RTP keepalives */static int global_reg_timeout;	static int global_regattempts_max;	/*!< Registration attempts before giving up */static int global_allowguest;		/*!< allow unauthenticated users/peers to connect? */static int global_allowsubscribe;	/*!< Flag for disabling ALL subscriptions, this is FALSE only if all peers are FALSE 					    the global setting is in globals_flags[1] */static int global_mwitime;		/*!< Time between MWI checks for peers */static unsigned int global_tos_sip;		/*!< IP type of service for SIP packets */static unsigned int global_tos_audio;		/*!< IP type of service for audio RTP packets */static unsigned int global_tos_video;		/*!< IP type of service for video RTP packets */static int compactheaders;		/*!< send compact sip headers */static int recordhistory;		/*!< Record SIP history. Off by default */static int dumphistory;			/*!< Dump history to verbose before destroying SIP dialog */static char global_realm[MAXHOSTNAMELEN]; 		/*!< Default realm */static char global_regcontext[AST_MAX_CONTEXT];		/*!< Context for auto-extensions */static char global_useragent[AST_MAX_EXTENSION];	/*!< Useragent for the SIP channel */static int allow_external_domains;	/*!< Accept calls to external SIP domains? */static int global_callevents;		/*!< Whether we send manager events or not */static int global_t1min;		/*!< T1 roundtrip time minimum */static int global_autoframing;          /*!< Turn autoframing on or off. */static enum transfermodes global_allowtransfer;	/*!< SIP Refer restriction scheme */static int global_matchexterniplocally; /*!< Match externip/externhost setting against localnet setting *//*! \brief Codecs that we support by default: */static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;/* Object counters */static int suserobjs = 0;                /*!< Static users */static int ruserobjs = 0;                /*!< Realtime users */static int speerobjs = 0;                /*!< Statis peers */static int rpeerobjs = 0;                /*!< Realtime peers */static int apeerobjs = 0;                /*!< Autocreated peer objects */static int regobjs = 0;                  /*!< Registry objects */static struct ast_flags global_flags[2] = {{0}};        /*!< global SIP_ flags *//*! \brief Protect the SIP dialog list (of sip_pvt's) */AST_MUTEX_DEFINE_STATIC(iflock);/*! \brief Protect the monitoring thread, so only one process can kill or start it, and not   when it's doing something critical. */AST_MUTEX_DEFINE_STATIC(netlock);AST_MUTEX_DEFINE_STATIC(monlock);AST_MUTEX_DEFINE_STATIC(sip_reload_lock);/*! \brief This is the thread for the monitor which checks for input on the channels   which are not currently in use.  */static pthread_t monitor_thread = AST_PTHREADT_NULL;static int sip_reloading = FALSE;                       /*!< Flag for avoiding multiple reloads at the same time */static enum channelreloadreason sip_reloadreason;       /*!< Reason for last reload/load of configuration */static struct sched_context *sched;     /*!< The scheduling context */static struct io_context *io;           /*!< The IO context */static int *sipsock_read_id;            /*!< ID of IO entry for sipsock FD */#define DEC_CALL_LIMIT	0#define INC_CALL_LIMIT	1#define DEC_CALL_RINGING 2#define INC_CALL_RINGING 3/*! \brief sip_request: The data grabbed from the UDP socket */struct sip_request {	char *rlPart1; 	        /*!< SIP Method Name or "SIP/2.0" protocol version */	char *rlPart2; 	        /*!< The Request URI or Response Status */	int len;                /*!< Length */	int headers;            /*!< # of SIP Headers */	int method;             /*!< Method of this request */	int lines;              /*!< Body Content */	unsigned int flags;     /*!< SIP_PKT Flags for this packet */	char *header[SIP_MAX_HEADERS];	char *line[SIP_MAX_LINES];	char data[SIP_MAX_PACKET];	unsigned int sdp_start; /*!< the line number where the SDP begins */	unsigned int sdp_end;   /*!< the line number where the SDP ends */};/* * A sip packet is stored into the data[] buffer, with the header followed * by an empty line and the body of the message. * On outgoing packets, data is accumulated in data[] with len reflecting * the next available byte, headers and lines count the number of lines * in both parts. There are no '\0' in data[0..len-1]. * * On received packet, the input read from the socket is copied into data[], * len is set and the string is NUL-terminated. Then a parser fills up * the other fields -header[] and line[] to point to the lines of the * message, rlPart1 and rlPart2 parse the first lnie as below: * * Requests have in the first line	METHOD URI SIP/2.0 *	rlPart1 = method; rlPart2 = uri; * Responses have in the first line	SIP/2.0 code description *	rlPart1 = SIP/2.0; rlPart2 = code + description; * *//*! \brief structure used in transfers */struct sip_dual {	struct ast_channel *chan1;	/*!< First channel involved */	struct ast_channel *chan2;	/*!< Second channel involved */	struct sip_request req;		/*!< Request that caused the transfer (REFER) */	int seqno;			/*!< Sequence number */};struct sip_pkt;/*! \brief Parameters to the transmit_invite function */struct sip_invite_param {	const char *distinctive_ring;	/*!< Distinctive ring header */	int addsipheaders;		/*!< Add extra SIP headers */	const char *uri_options;	/*!< URI options to add to the URI */	const char *vxml_url;		/*!< VXML url for Cisco phones */	char *auth;			/*!< Authentication */	char *authheader;		/*!< Auth header */	enum sip_auth_type auth_type;	/*!< Authentication type */	const char *replaces;		/*!< Replaces header for call transfers */	int transfer;			/*!< Flag - is this Invite part of a SIP transfer? (invite/replaces) */};/*! \brief Structure to save routing information for a SIP session */struct sip_route {	struct sip_route *next;	char hop[0];};/*! \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 Domain data structure. 	\note In the future, we will connect this to a configuration tree specific	for this domain*/struct domain {	char domain[MAXHOSTNAMELEN];		/*!< SIP domain we are responsible for */	char context[AST_MAX_EXTENSION];	/*!< Incoming context for this domain */	enum domain_mode mode;			/*!< How did we find this domain? */	AST_LIST_ENTRY(domain) list;		/*!< List mechanics */};static AST_LIST_HEAD_STATIC(domain_list, domain);	/*!< The SIP domain list *//*! \brief sip_history: Structure for saving transactions within a SIP dialog */struct sip_history {	AST_LIST_ENTRY(sip_history) list;	char event[0];	/* actually more, depending on needs */};AST_LIST_HEAD_NOLOCK(sip_history_head, sip_history); /*!< history list, entry in sip_pvt *//*! \brief sip_auth: Credentials for authentication to other SIP services */struct sip_auth {	char realm[AST_MAX_EXTENSION];  /*!< Realm in which these credentials are valid */	char username[256];             /*!< Username */	char secret[256];               /*!< Secret */	char md5secret[256];            /*!< MD5Secret */	struct sip_auth *next;          /*!< Next auth structure in list */};/*--- Various flags for the flags field in the pvt structure */#define SIP_ALREADYGONE		(1 << 0)	/*!< Whether or not we've already been destroyed by our peer */#define SIP_NEEDDESTROY		(1 << 1)	/*!< if we need to be destroyed by the monitor thread */#define SIP_NOVIDEO		(1 << 2)	/*!< Didn't get video in invite, don't offer */#define SIP_RINGING		(1 << 3)	/*!< Have sent 180 ringing */#define SIP_PROGRESS_SENT	(1 << 4)	/*!< Have sent 183 message progress */#define SIP_NEEDREINVITE	(1 << 5)	/*!< Do we need to send another reinvite? */#define SIP_PENDINGBYE		(1 << 6)	/*!< Need to send bye after we ack? */#define SIP_GOTREFER		(1 << 7)	/*!< Got a refer? */#define SIP_PROMISCREDIR	(1 << 8)	/*!< Promiscuous redirection */#define SIP_TRUSTRPID		(1 << 9)	/*!< Trust RPID headers? */#define SIP_USEREQPHONE		(1 << 10)	/*!< Add user=phone to numeric URI. Default off */#define SIP_REALTIME		(1 << 11)	/*!< Flag for realtime users */#define SIP_USECLIENTCODE	(1 << 12)	/*!< Trust X-ClientCode info message */#define SIP_OUTGOING		(1 << 13)	/*!< Direction of the last transaction in this dialog */#define SIP_FREE_BIT		(1 << 14)	/*!< ---- */#define SIP_DEFER_BYE_ON_TRANSFER	(1 << 15)	/*!< Do not hangup at first ast_hangup */#define SIP_DTMF		(3 << 16)	/*!< DTMF Support: four settings, uses two bits */#define SIP_DTMF_RFC2833	(0 << 16)	/*!< DTMF Support: RTP DTMF - "rfc2833" */#define SIP_DTMF_INBAND		(1 << 16)	/*!< DTMF Support: Inband audio, only for ULAW/ALAW - "inband" */#define SIP_DTMF_INFO		(2 << 16)	/*!< DTMF Support: SIP Info messages - "info" */#define SIP_DTMF_AUTO		(3 << 16)	/*!< DTMF Support: AUTO switch between rfc2833 and in-band DTMF *//* NAT settings */#define SIP_NAT			(3 << 18)	/*!< four settings, uses two bits */#define SIP_NAT_NEVER		(0 << 18)	/*!< No nat support */#define SIP_NAT_RFC3581		(1 << 18)	/*!< NAT RFC3581 */#define SIP_NAT_ROUTE		(2 << 18)	/*!< NAT Only ROUTE */#define SIP_NAT_ALWAYS		(3 << 18)	/*!< NAT Both ROUTE and RFC3581 *//* re-INVITE related settings */#define SIP_REINVITE		(7 << 20)	/*!< three bits used */#define SIP_CAN_REINVITE	(1 << 20)	/*!< allow peers to be reinvited to send media directly p2p */#define SIP_CAN_REINVITE_NAT	(2 << 20)	/*!< allow media reinvite when new peer is behind NAT */#define SIP_REINVITE_UPDATE	(4 << 20)	/*!< use UPDATE (RFC3311) when reinviting this peer *//* "insecure" settings */#define SIP_INSECURE_PORT	(1 << 23)	/*!< don't require matching port for incoming requests */#define SIP_INSECURE_INVITE	(1 << 24)	/*!< don't require authentication for incoming INVITEs *//* Sending PROGRESS in-band settings */#define SIP_PROG_INBAND		(3 << 25)	/*!< 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_NO_HISTORY		(1 << 27)	/*!< Suppress recording request/response history */#define SIP_CALL_LIMIT		(1 << 28)	/*!< Call limit enforced for this call */#define SIP_SENDRPID		(1 << 29)	/*!< Remote Party-ID Support */#define SIP_INC_COUNT		(1 << 30)	/*!< Did this connection increment the counter of in-use calls? */#define SIP_G726_NONSTANDARD	(1 << 31)	/*!< Use non-standard packing for G726-32 data */#define SIP_FLAGS_TO_COPY \	(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \	 SIP_PROG_INBAND | SIP_USECLIENTCODE | SIP_NAT | SIP_G726_NONSTANDARD | \	 SIP_USEREQPHONE | SIP_INSECURE_PORT | SIP_INSECURE_INVITE)/*--- a new page of flags (for flags[1] *//* realtime flags */#define SIP_PAGE2_RTCACHEFRIENDS	(1 << 0)#define SIP_PAGE2_RTUPDATE		(1 << 1)#define SIP_PAGE2_RTAUTOCLEAR		(1 << 2)#define SIP_PAGE2_RT_FROMCONTACT 	(1 << 4)#define SIP_PAGE2_RTSAVE_SYSNAME 	(1 << 5)/* Space for addition of other realtime flags in the future */#define SIP_PAGE2_STATECHANGEQUEUE	(1 << 9)	/*!< D: Unsent state pending change exists */#define SIP_PAGE2_IGNOREREGEXPIRE	(1 << 10)#define SIP_PAGE2_DEBUG			(3 << 11)#define SIP_PAGE2_DEBUG_CONFIG 		(1 << 11)#define SIP_PAGE2_DEBUG_CONSOLE 	(1 << 12)#define SIP_PAGE2_DYNAMIC		(1 << 13)	/*!< Dynamic Peers register with Asterisk */#define SIP_PAGE2_SELFDESTRUCT		(1 << 14)	/*!< Automatic peers need to destruct themselves */#define SIP_PAGE2_VIDEOSUPPORT		(1 << 15)#define SIP_PAGE2_ALLOWSUBSCRIBE	(1 << 16)	/*!< Allow subscriptions from this peer? */#define SIP_PAGE2_ALLOWOVERLAP		(1 << 17)	/*!< Allow overlap dialing ? */#define SIP_PAGE2_SUBSCRIBEMWIONLY	(1 << 18)	/*!< Only issue MWI notification if subscribed to */#define SIP_PAGE2_INC_RINGING		(1 << 19)	/*!< Did this connection increment the counter of in-use calls? */#define SIP_PAGE2_T38SUPPORT		(7 << 20)	/*!< T38 Fax Passthrough Support */#define SIP_PAGE2_T38SUPPORT_UDPTL	(1 << 20)	/*!< 20: T38 Fax Passthrough Support */#define SIP_PAGE2_T38SUPPORT_RTP	(2 << 20)	/*!< 21: T38 Fax Passthrough Support (not implemented) */#define SIP_PAGE2_T38SUPPORT_TCP	(4 << 20)	/*!< 22: T38 Fax Passthrough Support (not implemented) */#define SIP_PAGE2_CALL_ONHOLD		(3 << 23)	/*!< Call states */#define SIP_PAGE2_CALL_ONHOLD_ACTIVE    (1 << 23)       /*!< 23: Active hold */#define SIP_PAGE2_CALL_ONHOLD_ONEDIR	(2 << 23)	/*!< 23: One directional hold */#define SIP_PAGE2_CALL_ONHOLD_INACTIVE	(3 << 23)	/*!< 23: Inactive hold */#define SIP_PAGE2_RFC2833_COMPENSATE    (1 << 25)	/*!< 25: ???? */#define SIP_PAGE2_BUGGY_MWI		(1 << 26)	/*!< 26: Buggy CISCO MWI fix */#define SIP_PAGE2_OUTGOING_CALL         (1 << 27)       /*!< 27: Is this an outgoing call? */#define SIP_PAGE2_UDPTL_DESTINATION     (1 << 28)       /*!< 28: Use source IP of RTP as destination if NAT is enabled */#define SIP_PAGE2_DIALOG_ESTABLISHED    (1 << 29)       /*!< 29: Has a dialog been established? */#define SIP_PAGE2_FLAGS_TO_COPY \	(SIP_PAGE2_ALLOWSUBSCRIBE | SIP_PAGE2_ALLOWOVERLAP | SIP_PAGE2_VIDEOSUPPORT | \	SIP_PAGE2_T38SUPPORT | SIP_PAGE2_RFC2833_COMPENSATE | SIP_PAGE2_BUGGY_MWI | SIP_PAGE2_UDPTL_DESTINATION)/* SIP packet flags */#define SIP_PKT_DEBUG		(1 << 0)	/*!< Debug this packet */#define SIP_PKT_WITH_TOTAG	(1 << 1)	/*!< This packet has a to-tag */

⌨️ 快捷键说明

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