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

📄 chan_sip.c

📁 Asterisk中信道部分的源码 。。。。
💻 C
📖 第 1 页 / 共 5 页
字号:
#define SIP_PKT_IGNORE 		(1 << 2)	/*!< This is a re-transmit, ignore it */#define SIP_PKT_IGNORE_RESP	(1 << 3)	/*!< Resp ignore - ??? */#define SIP_PKT_IGNORE_REQ	(1 << 4)	/*!< Req ignore - ??? *//* T.38 set of flags */#define T38FAX_FILL_BIT_REMOVAL		(1 << 0)	/*!< Default: 0 (unset)*/#define T38FAX_TRANSCODING_MMR			(1 << 1)	/*!< Default: 0 (unset)*/#define T38FAX_TRANSCODING_JBIG		(1 << 2)	/*!< Default: 0 (unset)*//* Rate management */#define T38FAX_RATE_MANAGEMENT_TRANSFERED_TCF	(0 << 3)#define T38FAX_RATE_MANAGEMENT_LOCAL_TCF	(1 << 3)	/*!< Unset for transferredTCF (UDPTL), set for localTCF (TPKT) *//* UDP Error correction */#define T38FAX_UDP_EC_NONE			(0 << 4)	/*!< two bits, if unset NO t38UDPEC field in T38 SDP*/#define T38FAX_UDP_EC_FEC			(1 << 4)	/*!< Set for t38UDPFEC */#define T38FAX_UDP_EC_REDUNDANCY		(2 << 4)	/*!< Set for t38UDPRedundancy *//* T38 Spec version */#define T38FAX_VERSION				(3 << 6)	/*!< two bits, 2 values so far, up to 4 values max */#define T38FAX_VERSION_0			(0 << 6)	/*!< Version 0 */#define T38FAX_VERSION_1			(1 << 6)	/*!< Version 1 *//* Maximum Fax Rate */#define T38FAX_RATE_2400			(1 << 8)	/*!< 2400 bps t38FaxRate */#define T38FAX_RATE_4800			(1 << 9)	/*!< 4800 bps t38FaxRate */#define T38FAX_RATE_7200			(1 << 10)	/*!< 7200 bps t38FaxRate */#define T38FAX_RATE_9600			(1 << 11)	/*!< 9600 bps t38FaxRate */#define T38FAX_RATE_12000			(1 << 12)	/*!< 12000 bps t38FaxRate */#define T38FAX_RATE_14400			(1 << 13)	/*!< 14400 bps t38FaxRate *//*!< This is default: NO MMR and JBIG trancoding, NO fill bit removal, transferredTCF TCF, UDP FEC, Version 0 and 9600 max fax rate */static int global_t38_capability = T38FAX_VERSION_0 | T38FAX_RATE_2400 | T38FAX_RATE_4800 | T38FAX_RATE_7200 | T38FAX_RATE_9600;#define sipdebug		ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG)#define sipdebug_config		ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONFIG)#define sipdebug_console	ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG_CONSOLE)/*! \brief T38 States for a call */enum t38state {        T38_DISABLED = 0,                /*!< Not enabled */        T38_LOCAL_DIRECT,                /*!< Offered from local */        T38_LOCAL_REINVITE,              /*!< Offered from local - REINVITE */        T38_PEER_DIRECT,                 /*!< Offered from peer */        T38_PEER_REINVITE,               /*!< Offered from peer - REINVITE */        T38_ENABLED                      /*!< Negotiated (enabled) */};/*! \brief T.38 channel settings (at some point we need to make this alloc'ed */struct t38properties {	struct ast_flags t38support;	/*!< Flag for udptl, rtp or tcp support for this session */	int capability;			/*!< Our T38 capability */	int peercapability;		/*!< Peers T38 capability */	int jointcapability;		/*!< Supported T38 capability at both ends */	enum t38state state;		/*!< T.38 state */};/*! \brief Parameters to know status of transfer */enum referstatus {        REFER_IDLE,                    /*!< No REFER is in progress */        REFER_SENT,                    /*!< Sent REFER to transferee */        REFER_RECEIVED,                /*!< Received REFER from transferer */        REFER_CONFIRMED,               /*!< Refer confirmed with a 100 TRYING */        REFER_ACCEPTED,                /*!< Accepted by transferee */        REFER_RINGING,                 /*!< Target Ringing */        REFER_200OK,                   /*!< Answered by transfer target */        REFER_FAILED,                  /*!< REFER declined - go on */        REFER_NOAUTH                   /*!< We had no auth for REFER */};static const struct c_referstatusstring {	enum referstatus status;	char *text;} referstatusstrings[] = {	{ REFER_IDLE,		"<none>" },	{ REFER_SENT,		"Request sent" },	{ REFER_RECEIVED,	"Request received" },	{ REFER_ACCEPTED,	"Accepted" },	{ REFER_RINGING,	"Target ringing" },	{ REFER_200OK,		"Done" },	{ REFER_FAILED,		"Failed" },	{ REFER_NOAUTH,		"Failed - auth failure" }} ;/*! \brief Structure to handle SIP transfers. Dynamically allocated when needed  *//* OEJ: Should be moved to string fields */struct sip_refer {	char refer_to[AST_MAX_EXTENSION];		/*!< Place to store REFER-TO extension */	char refer_to_domain[AST_MAX_EXTENSION];	/*!< Place to store REFER-TO domain */	char refer_to_urioption[AST_MAX_EXTENSION];	/*!< Place to store REFER-TO uri options */	char refer_to_context[AST_MAX_EXTENSION];	/*!< Place to store REFER-TO context */	char referred_by[AST_MAX_EXTENSION];		/*!< Place to store REFERRED-BY extension */	char referred_by_name[AST_MAX_EXTENSION];	/*!< Place to store REFERRED-BY extension */	char refer_contact[AST_MAX_EXTENSION];		/*!< Place to store Contact info from a REFER extension */	char replaces_callid[SIPBUFSIZE];			/*!< Replace info: callid */	char replaces_callid_totag[SIPBUFSIZE/2];		/*!< Replace info: to-tag */	char replaces_callid_fromtag[SIPBUFSIZE/2];		/*!< Replace info: from-tag */	struct sip_pvt *refer_call;			/*!< Call we are referring */	int attendedtransfer;				/*!< Attended or blind transfer? */	int localtransfer;				/*!< Transfer to local domain? */	enum referstatus status;			/*!< REFER status */};/*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe  */static struct sip_pvt {	ast_mutex_t lock;			/*!< Dialog private lock */	int method;				/*!< SIP method that opened this dialog */	enum invitestates invitestate;		/*!< The state of the INVITE transaction only */	AST_DECLARE_STRING_FIELDS(		AST_STRING_FIELD(callid);	/*!< Global CallID */		AST_STRING_FIELD(randdata);	/*!< Random data */		AST_STRING_FIELD(accountcode);	/*!< Account code */		AST_STRING_FIELD(realm);	/*!< Authorization realm */		AST_STRING_FIELD(nonce);	/*!< Authorization nonce */		AST_STRING_FIELD(opaque);	/*!< Opaque nonsense */		AST_STRING_FIELD(qop);		/*!< Quality of Protection, since SIP wasn't complicated enough yet. */		AST_STRING_FIELD(domain);	/*!< Authorization domain */		AST_STRING_FIELD(from);		/*!< The From: header */		AST_STRING_FIELD(useragent);	/*!< User agent in SIP request */		AST_STRING_FIELD(exten);	/*!< Extension where to start */		AST_STRING_FIELD(context);	/*!< Context for this call */		AST_STRING_FIELD(subscribecontext); /*!< Subscribecontext */		AST_STRING_FIELD(subscribeuri); /*!< Subscribecontext */		AST_STRING_FIELD(fromdomain);	/*!< Domain to show in the from field */		AST_STRING_FIELD(fromuser);	/*!< User to show in the user field */		AST_STRING_FIELD(fromname);	/*!< Name to show in the user field */		AST_STRING_FIELD(tohost);	/*!< Host we should put in the "to" field */		AST_STRING_FIELD(language);	/*!< Default language for this call */		AST_STRING_FIELD(mohinterpret);	/*!< MOH class to use when put on hold */		AST_STRING_FIELD(mohsuggest);	/*!< MOH class to suggest when putting a peer on hold */		AST_STRING_FIELD(rdnis);	/*!< Referring DNIS */		AST_STRING_FIELD(theirtag);	/*!< Their tag */		AST_STRING_FIELD(username);	/*!< [user] name */		AST_STRING_FIELD(peername);	/*!< [peer] name, not set if [user] */		AST_STRING_FIELD(authname);	/*!< Who we use for authentication */		AST_STRING_FIELD(uri);		/*!< Original requested URI */		AST_STRING_FIELD(okcontacturi);	/*!< URI from the 200 OK on INVITE */		AST_STRING_FIELD(peersecret);	/*!< Password */		AST_STRING_FIELD(peermd5secret);		AST_STRING_FIELD(cid_num);	/*!< Caller*ID number */		AST_STRING_FIELD(cid_name);	/*!< Caller*ID name */		AST_STRING_FIELD(via);		/*!< Via: header */		AST_STRING_FIELD(fullcontact);	/*!< The Contact: that the UA registers with us */		AST_STRING_FIELD(our_contact);	/*!< Our contact header */		AST_STRING_FIELD(rpid);		/*!< Our RPID header */		AST_STRING_FIELD(rpid_from);	/*!< Our RPID From header */	);	unsigned int ocseq;			/*!< Current outgoing seqno */	unsigned int icseq;			/*!< Current incoming seqno */	ast_group_t callgroup;			/*!< Call group */	ast_group_t pickupgroup;		/*!< Pickup group */	int lastinvite;				/*!< Last Cseq of invite */	int lastnoninvite;                      /*!< Last Cseq of non-invite */	struct ast_flags flags[2];		/*!< SIP_ flags */	int timer_t1;				/*!< SIP timer T1, ms rtt */	unsigned int sipoptions;		/*!< Supported SIP options on the other end */	struct ast_codec_pref prefs;		/*!< codec prefs */	int capability;				/*!< Special capability (codec) */	int jointcapability;			/*!< Supported capability at both ends (codecs) */	int peercapability;			/*!< Supported peer capability */	int prefcodec;				/*!< Preferred codec (outbound only) */	int noncodeccapability;			/*!< DTMF RFC2833 telephony-event */	int jointnoncodeccapability;            /*!< Joint Non codec capability */	int redircodecs;			/*!< Redirect codecs */	int maxcallbitrate;			/*!< Maximum Call Bitrate for Video Calls */		struct t38properties t38;		/*!< T38 settings */	struct sockaddr_in udptlredirip;	/*!< Where our T.38 UDPTL should be going if not to us */	struct ast_udptl *udptl;		/*!< T.38 UDPTL session */	int callingpres;			/*!< Calling presentation */	int authtries;				/*!< Times we've tried to authenticate */	int expiry;				/*!< How long we take to expire */	long branch;				/*!< The branch identifier of this session */	char tag[11];				/*!< Our tag for this session */	int sessionid;				/*!< SDP Session ID */	int sessionversion;			/*!< SDP Session Version */	struct sockaddr_in sa;			/*!< Our peer */	struct sockaddr_in redirip;		/*!< Where our RTP should be going if not to us */	struct sockaddr_in vredirip;		/*!< Where our Video RTP should be going if not to us */	time_t lastrtprx;			/*!< Last RTP received */	time_t lastrtptx;			/*!< Last RTP sent */	int rtptimeout;				/*!< RTP timeout time */	struct sockaddr_in recv;		/*!< Received as */	struct in_addr ourip;			/*!< Our IP */	struct ast_channel *owner;		/*!< Who owns us (if we have an owner) */	struct sip_route *route;		/*!< Head of linked list of routing steps (fm Record-Route) */	int route_persistant;			/*!< Is this the "real" route? */	struct sip_auth *peerauth;		/*!< Realm authentication */	int noncecount;				/*!< Nonce-count */	char lastmsg[256];			/*!< Last Message sent/received */	int amaflags;				/*!< AMA Flags */	int pendinginvite;			/*!< Any pending INVITE or state NOTIFY (in subscribe pvt's) ? (seqno of this) */	struct sip_request initreq;		/*!< Request that opened the latest transaction						     within this SIP dialog */		int maxtime;				/*!< Max time for first response */	int initid;				/*!< Auto-congest ID if appropriate (scheduler) */	int waitid;				/*!< Wait ID for scheduler after 491 or other delays */	int autokillid;				/*!< Auto-kill ID (scheduler) */	enum transfermodes allowtransfer;	/*!< REFER: restriction scheme */	struct sip_refer *refer;		/*!< REFER: SIP transfer data structure */	enum subscriptiontype subscribed;	/*!< SUBSCRIBE: Is this dialog a subscription?  */	int stateid;				/*!< SUBSCRIBE: ID for devicestate subscriptions */	int laststate;				/*!< SUBSCRIBE: Last known extension state */	int dialogver;				/*!< SUBSCRIBE: Version for subscription dialog-info */		struct ast_dsp *vad;			/*!< Voice Activation Detection dsp */		struct sip_peer *relatedpeer;		/*!< If this dialog is related to a peer, which one 							Used in peerpoke, mwi subscriptions */	struct sip_registry *registry;		/*!< If this is a REGISTER dialog, to which registry */	struct ast_rtp *rtp;			/*!< RTP Session */	struct ast_rtp *vrtp;			/*!< Video RTP session */	struct sip_pkt *packets;		/*!< Packets scheduled for re-transmission */	struct sip_history_head *history;	/*!< History of this SIP dialog */	size_t history_entries;			/*!< Number of entires in the history */	struct ast_variable *chanvars;		/*!< Channel variables to set for inbound call */	struct sip_pvt *next;			/*!< Next dialog in chain */	struct sip_invite_param *options;	/*!< Options for INVITE */	int autoframing;} *iflist = NULL;/*! Max entires in the history list for a sip_pvt */#define MAX_HISTORY_ENTRIES 50#define FLAG_RESPONSE (1 << 0)#define FLAG_FATAL (1 << 1)/*! \brief sip packet - raw format for outbound packets that are sent or scheduled for transmission */struct sip_pkt {	struct sip_pkt *next;			/*!< Next packet in linked list */	int retrans;				/*!< Retransmission number */	int method;				/*!< SIP method for this packet */	int seqno;				/*!< Sequence number */	unsigned int flags;			/*!< non-zero if this is a response packet (e.g. 200 OK) */	struct sip_pvt *owner;			/*!< Owner AST call */	int retransid;				/*!< Retransmission ID */	int timer_a;				/*!< SIP timer A, retransmission timer */	int timer_t1;				/*!< SIP Timer T1, estimated RTT or 500 ms */	int packetlen;				/*!< Length of packet */	char data[0];};	/*! \brief Structure for SIP user data. User's place calls to us */struct sip_user {	/* Users who can access various contexts */	ASTOBJ_COMPONENTS(struct sip_user);	char secret[80];		/*!< Password */	char md5secret[80];		/*!< Password in md5 */	char context[AST_MAX_CONTEXT];	/*!< Default context for incoming calls */	char subscribecontext[AST_MAX_CONTEXT];	/* Default context for subscriptions */	char cid_num[80];		/*!< Caller ID num */	char cid_name[80];		/*!< Caller ID name */	char accountcode[AST_MAX_ACCOUNT_CODE];	/* Account code */	char language[MAX_LANGUAGE];	/*!< Default language for this user */	char mohinterpret[MAX_MUSICCLASS];/*!< Music on Hold class */	char mohsuggest[MAX_MUSICCLASS];/*!< Music on Hold class */	char useragent[256];		/*!< User agent in SIP request */	struct ast_codec_pref prefs;	/*!< codec prefs */	ast_group_t callgroup;		/*!< Call group */	ast_group_t pickupgroup;	/*!< Pickup Group */	unsigned int sipoptions;	/*!< Supported SIP options */	struct ast_flags flags[2];	/*!< SIP_ flags */	int amaflags;			/*!< AMA flags for billing */	int callingpres;		/*!< Calling id presentation */	int capability;			/*!< Codec capability */	int inUse;			/*!< Number of calls in use */	int call_limit;			/*!< Limit of concurrent calls */	enum transfermodes allowtransfer;	/*! SIP Refer restriction scheme */	struct ast_ha *ha;		/*!< ACL setting */	struct ast_variable *chanvars;	/*!< Variables to set for channel created by user */	int maxcallbitrate;		/*!< Maximum Bitrate for a video call */	int autoframing;};

⌨️ 快捷键说明

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