#include "asterisk.h"
#include <ctype.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/signal.h>
#include <regex.h>
#include <time.h>
#include "asterisk/network.h"
#include "asterisk/paths.h"
#include "asterisk/lock.h"
#include "asterisk/channel.h"
#include "asterisk/config.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/sched.h"
#include "asterisk/io.h"
#include "asterisk/rtp.h"
#include "asterisk/udptl.h"
#include "asterisk/acl.h"
#include "asterisk/manager.h"
#include "asterisk/callerid.h"
#include "asterisk/cli.h"
#include "asterisk/app.h"
#include "asterisk/musiconhold.h"
#include "asterisk/dsp.h"
#include "asterisk/features.h"
#include "asterisk/srv.h"
#include "asterisk/astdb.h"
#include "asterisk/causes.h"
#include "asterisk/utils.h"
#include "asterisk/file.h"
#include "asterisk/astobj.h"
#include "asterisk/astobj2.h"
#include "asterisk/dnsmgr.h"
#include "asterisk/devicestate.h"
#include "asterisk/linkedlists.h"
#include "asterisk/stringfields.h"
#include "asterisk/monitor.h"
#include "asterisk/netsock.h"
#include "asterisk/localtime.h"
#include "asterisk/abstract_jb.h"
#include "asterisk/threadstorage.h"
#include "asterisk/translate.h"
#include "asterisk/ast_version.h"
#include "asterisk/event.h"
#include "asterisk/tcptls.h"
#include "asterisk/strings.h"

Go to the source code of this file.
Data Structures | |
| struct | __show_chan_arg |
| argument for the 'show channels|subscriptions' callback. More... | |
| struct | _map_x_s |
| generic struct to map between strings and integers. Fill it with x-s pairs, terminate with an entry with s = NULL; Then you can call map_x_s(...) to map an integer to a string, and map_s_x() for the string -> integer mapping. More... | |
| struct | ast_register_list |
| The register list: Other SIP proxies we register with and place calls to. More... | |
| struct | ast_subscription_mwi_list |
| The MWI subscription list. More... | |
| struct | cfsip_methods |
| The core structure to setup dialogs. We parse incoming messages by using structure and then route the messages according to the type. More... | |
| struct | cfsip_options |
| List of well-known SIP options. If we get this in a require, we should check the list and answer accordingly. More... | |
| struct | cfsubscription_types |
Subscription types that we support. We support
| |
| struct | domain |
| Domain data structure. More... | |
| struct | domain_list |
| struct | find_call_cb_arg |
| argument to the helper function to identify a call More... | |
| struct | invstate2stringtable |
| Readable descriptions of device states. More... | |
| struct | offered_media |
| struct | sip_auth |
| sip_auth: Credentials for authentication to other SIP services More... | |
| struct | sip_dual |
| structure used in transfers More... | |
| struct | sip_history |
| sip_history: Structure for saving transactions within a SIP dialog More... | |
| struct | sip_history_head |
| struct | sip_invite_param |
| Parameters to the transmit_invite function. More... | |
| struct | sip_mailbox |
| A peer's mailbox. More... | |
| struct | sip_peer |
| Structure for SIP peer data, we place calls to peers if registered or fixed IP address (host). More... | |
| struct | sip_pkt |
| sip packet - raw format for outbound packets that are sent or scheduled for transmission Packets are linked in a list, whose head is in the struct sip_pvt they belong to. Each packet holds a reference to the parent struct sip_pvt. This structure is allocated in __sip_reliable_xmit() and only for packets that require retransmissions. More... | |
| struct | sip_proxy |
| definition of a sip proxy server More... | |
| struct | sip_pvt |
| Structure used for each SIP dialog, ie. a call, a registration, a subscribe. Created and initialized by sip_alloc(), the descriptor goes into the list of descriptors (dialoglist). More... | |
| struct | sip_pvt::request_queue |
| struct | sip_refer |
| Structure to handle SIP transfers. Dynamically allocated when needed. More... | |
| struct | sip_registry |
| Registrations with other SIP proxies. More... | |
| struct | sip_request |
| sip_request: The data grabbed from the UDP socket More... | |
| struct | sip_route |
| Structure to save routing information for a SIP session. More... | |
| struct | sip_settings |
| a place to store all global settings for the sip channel driver These are settings that will be possibly to apply on a group level later on. More... | |
| struct | sip_socket |
| The SIP socket definition. More... | |
| struct | sip_st_cfg |
| Structure that encapsulates all attributes related to configuration of SIP Session-Timers feature on a per user/peer basis. More... | |
| struct | sip_st_dlg |
| Structure that encapsulates all attributes related to running SIP Session-Timers feature on a per dialog basis. More... | |
| struct | sip_subscription_mwi |
| Definition of an MWI subscription to another server. More... | |
| struct | sip_threadinfo |
| Definition of a thread that handles a socket. More... | |
| struct | sip_via |
| Structure to store Via information. More... | |
| struct | t38properties |
| T.38 channel settings (at some point we need to make this alloc'ed. More... | |
| struct | tcptls_packet |
Object counters @{ | |
| |
| #define | DEC_CALL_LIMIT 0 |
| #define | DEC_CALL_RINGING 2 |
| #define | INC_CALL_LIMIT 1 |
| #define | INC_CALL_RINGING 3 |
| #define | REQ_OFFSET_TO_STR(req, offset) (ast_str_buffer((req)->data) + ((req)->offset)) |
| enum | domain_mode { SIP_DOMAIN_AUTO, SIP_DOMAIN_CONFIG } |
| Modes for SIP domain handling in the PBX. More... | |
| static int | apeerobjs = 0 |
| static struct ast_flags | global_flags [2] = {{0}} |
| static int | global_t38_maxdatagram |
| static struct io_context * | io |
| static pthread_t | monitor_thread = AST_PTHREADT_NULL |
| This is the thread for the monitor which checks for input on the channels which are not currently in use. | |
| static ast_mutex_t | monlock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) |
| Protect the monitoring thread, so only one process can kill or start it, and not when it's doing something critical. | |
| static ast_mutex_t | netlock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) |
| static int | regobjs = 0 |
| static int | rpeerobjs = 0 |
| static struct sched_context * | sched |
| static ast_mutex_t | sip_reload_lock = ((ast_mutex_t) PTHREAD_MUTEX_INITIALIZER ) |
| static int | sip_reloading = FALSE |
| static enum channelreloadreason | sip_reloadreason |
| static int * | sipsock_read_id |
| static int | speerobjs = 0 |
| static char | used_context [AST_MAX_CONTEXT] |
Defines | |
| #define | ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO" |
| SIP Methods we support. | |
| #define | append_history(p, event, fmt, args...) append_history_full(p, "%-15s " fmt, event, ## args) |
| Append to SIP dialog history. | |
| #define | CALLERID_UNKNOWN "Anonymous" |
| #define | CHECK_AUTH_BUF_INITLEN 256 |
| #define | check_request_transport(peer, tmpl) |
| generic function for determining if a correct transport is being used to contact a peer | |
| #define | DEFAULT_AUTHLIMIT 100 |
| #define | DEFAULT_AUTHTIMEOUT 30 |
| #define | DEFAULT_DEFAULT_EXPIRY 120 |
| #define | DEFAULT_EXPIRY 900 |
| #define | DEFAULT_FREQ_NOTOK 10 * 1000 |
| #define | DEFAULT_MAX_EXPIRY 3600 |
| #define | DEFAULT_MAX_FORWARDS "70" |
| #define | DEFAULT_MAX_SE 1800 |
| #define | DEFAULT_MAXMS 2000 |
| #define | DEFAULT_MIN_EXPIRY 60 |
| #define | DEFAULT_MIN_SE 90 |
| #define | DEFAULT_MWI_EXPIRY 3600 |
| #define | DEFAULT_QUALIFY_GAP 100 |
| #define | DEFAULT_QUALIFY_PEERS 1 |
| #define | DEFAULT_QUALIFYFREQ 60 * 1000 |
| #define | DEFAULT_REGISTRATION_TIMEOUT 20 |
| #define | DEFAULT_RETRANS 1000 |
| #define | DEFAULT_TIMER_T1 500 |
| #define | DEFAULT_TRANS_TIMEOUT -1 |
| #define | EXPIRY_GUARD_LIMIT 30 |
| #define | EXPIRY_GUARD_MIN 500 |
| #define | EXPIRY_GUARD_PCT 0.20 |
| #define | EXPIRY_GUARD_SECS 15 |
| #define | FALSE 0 |
| #define | FINDALLDEVICES (FINDUSERS | FINDPEERS) |
| #define | FINDPEERS (1 << 1) |
| #define | FINDUSERS (1 << 0) |
| #define | FORMAT "%-15.15s %-15.15s %-15.15s %-15.15s %-3.3s %-3.3s %-15.15s %-10.10s\n" |
| #define | FORMAT "%-30.30s %-12.12s %-10.10s %-10.10s\n" |
| #define | FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.6u %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.6u\n" |
| #define | FORMAT "%-30.30s %-6.6s %-12.12s %8d %-20.20s %-25.25s\n" |
| #define | FORMAT "%-40.40s %-20.20s %-16.16s\n" |
| #define | FORMAT "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-8d %-10s %s\n" |
| #define | FORMAT "%-25.25s %-15.15s %-15.15s %-15.15s %-5.5s%-10.10s\n" |
| #define | FORMAT "%-30.30s %-6d %-9.9s %-6.6s\n" |
| #define | FORMAT "%-25.25s %-15.15s %-15.15s \n" |
| #define | FORMAT2 "%-15.15s %-15.15s %-15.15s %-15.15s %-7.7s %-15.15s %-6.6s\n" |
| #define | FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s ( %%) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n" |
| #define | FORMAT2 "%-30.30s %-6.6s %-12.12s %8.8s %-20.20s %-25.25s\n" |
| #define | FORMAT2 "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-8s %-10s %s\n" |
| #define | FORMAT2 "%-30.30s %3.6s %9.9s %6.6s\n" |
| #define | FORMAT2 "%-25.25s %-15.15s %-15.15s \n" |
| #define | FORMAT3 "%-15.15s %-15.15s %-15.15s %-15.15s %-13.13s %-15.15s %-10.10s %-6.6s\n" |
| #define | FORMAT4 "%-15.15s %-15.15s %-15.15s %-15.15s %-13.13s %-15.15s %-10.10s %-6.6d\n" |
| #define | FROMDOMAIN_INVALID "anonymous.invalid" |
| #define | INITIAL_CSEQ 101 |
| #define | IS_SIP_TECH(t) ((t) == &sip_tech || (t) == &sip_tech_info) |
| #define | MAX_AUTHTRIES 3 |
| #define | MAX_HISTORY_ENTRIES 50 |
| #define | MAX_RETRANS 6 |
| #define | NO_RTP 0 |
| #define | NOT_SUPPORTED 0 |
| #define | PROVIS_KEEPALIVE_TIMEOUT 60000 |
| #define | RTP 1 |
| #define | SDP_MAX_RTPMAP_CODECS 32 |
| #define | SIP_MAX_HEADERS 64 |
| #define | SIP_MAX_LINES 256 |
| #define | SIP_MIN_PACKET 4096 |
| #define | SIP_OPT_100REL (1 << 1) |
| #define | SIP_OPT_EARLY_SESSION (1 << 3) |
| #define | SIP_OPT_EVENTLIST (1 << 11) |
| #define | SIP_OPT_FROMCHANGE (1 << 17) |
| #define | SIP_OPT_GRUU (1 << 12) |
| #define | SIP_OPT_HISTINFO (1 << 15) |
| #define | SIP_OPT_JOIN (1 << 4) |
| #define | SIP_OPT_NOREFERSUB (1 << 14) |
| #define | SIP_OPT_OUTBOUND (1 << 20) |
| #define | SIP_OPT_PATH (1 << 5) |
| #define | SIP_OPT_PRECONDITION (1 << 7) |
| #define | SIP_OPT_PREF (1 << 6) |
| #define | SIP_OPT_PRIVACY (1 << 8) |
| #define | SIP_OPT_RECLISTINV (1 << 18) |
| #define | SIP_OPT_RECLISTSUB (1 << 19) |
| #define | SIP_OPT_REPLACES (1 << 0) |
| #define | SIP_OPT_RESPRIORITY (1 << 16) |
| #define | SIP_OPT_SDP_ANAT (1 << 9) |
| #define | SIP_OPT_SEC_AGREE (1 << 10) |
| #define | SIP_OPT_TARGET_DIALOG (1 << 13) |
| #define | SIP_OPT_TIMER (1 << 2) |
| #define | SIP_OPT_UNKNOWN (1 << 21) |
| #define | sip_pvt_lock(x) ao2_lock(x) |
| #define | sip_pvt_trylock(x) ao2_trylock(x) |
| #define | sip_pvt_unlock(x) ao2_unlock(x) |
| #define | SIP_RESERVED ";/?:@&=+$,# " |
| #define | SIP_TRANS_TIMEOUT 64 * DEFAULT_TIMER_T1 |
| #define | SIPBUFSIZE 512 |
| #define | STANDARD_SIP_PORT 5060 |
| Standard SIP unsecure port for UDP and TCP from RFC 3261. DO NOT CHANGE THIS. | |
| #define | STANDARD_TLS_PORT 5061 |
| Standard SIP TLS port from RFC 3261. DO NOT CHANGE THIS. | |
| #define | SUPPORTED 1 |
| #define | TRUE 1 |
| #define | UNLINK(element, head, prev) |
| #define | XMIT_ERROR -2 |
DefaultValues Default values, set and reset in reload_config before reading configuration | |
| |
| #define | DEFAULT_ALLOW_EXT_DOM TRUE |
| #define | DEFAULT_ALLOWGUEST TRUE |
| #define | DEFAULT_ALWAYSAUTHREJECT FALSE |
| #define | DEFAULT_AUTOCREATEPEER FALSE |
| #define | DEFAULT_CALLCOUNTER FALSE |
| #define | DEFAULT_CALLERID "asterisk" |
| #define | DEFAULT_CALLEVENTS FALSE |
| #define | DEFAULT_COMPACTHEADERS FALSE |
| #define | DEFAULT_CONTEXT "default" |
| #define | DEFAULT_COS_AUDIO 5 |
| #define | DEFAULT_COS_SIP 4 |
| #define | DEFAULT_COS_TEXT 5 |
| #define | DEFAULT_COS_VIDEO 6 |
| #define | DEFAULT_MATCHEXTERNIPLOCALLY FALSE |
| #define | DEFAULT_MAX_CALL_BITRATE (384) |
| #define | DEFAULT_MOHINTERPRET "default" |
| #define | DEFAULT_MOHSUGGEST "" |
| #define | DEFAULT_NOTIFYCID DISABLED |
| #define | DEFAULT_NOTIFYMIME "application/simple-message-summary" |
| #define | DEFAULT_NOTIFYRINGING TRUE |
| #define | DEFAULT_PEDANTIC FALSE |
| #define | DEFAULT_QUALIFY FALSE |
| #define | DEFAULT_REALM "asterisk" |
| #define | DEFAULT_REGEXTENONQUALIFY FALSE |
| #define | DEFAULT_RTPKEEPALIVE 0 |
| #define | DEFAULT_SDPOWNER "root" |
| #define | DEFAULT_SDPSESSION "Asterisk PBX" |
| #define | DEFAULT_SRVLOOKUP TRUE |
| #define | DEFAULT_T1MIN 100 |
| #define | DEFAULT_TOS_AUDIO 0 |
| #define | DEFAULT_TOS_SIP 0 |
| #define | DEFAULT_TOS_TEXT 0 |
| #define | DEFAULT_TOS_VIDEO 0 |
| #define | DEFAULT_USERAGENT "Asterisk PBX" |
| #define | DEFAULT_VMEXTEN "asterisk" |
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_CALL_LIMIT (1 << 7) |
| #define | SIP_DEFER_BYE_ON_TRANSFER (1 << 10) |
| #define | SIP_DIRECT_MEDIA (1 << 20) |
| #define | SIP_DIRECT_MEDIA_NAT (2 << 20) |
| #define | SIP_DTMF (7 << 15) |
| #define | SIP_DTMF_AUTO (3 << 15) |
| #define | SIP_DTMF_INBAND (1 << 15) |
| #define | SIP_DTMF_INFO (2 << 15) |
| #define | SIP_DTMF_RFC2833 (0 << 15) |
| #define | SIP_DTMF_SHORTINFO (4 << 15) |
| #define | SIP_FLAGS_TO_COPY |
| Flags to copy from peer/user to dialog. | |
| #define | SIP_G726_NONSTANDARD (1 << 31) |
| #define | SIP_GOTREFER (1 << 6) |
| #define | SIP_INC_COUNT (1 << 8) |
| #define | SIP_INC_RINGING (1 << 9) |
| #define | SIP_INSECURE (3 << 23) |
| #define | SIP_INSECURE_INVITE (1 << 24) |
| #define | SIP_INSECURE_NONE (0 << 23) |
| #define | SIP_INSECURE_PORT (1 << 23) |
| #define | SIP_NAT (3 << 18) |
| #define | SIP_NAT_ALWAYS (3 << 18) |
| #define | SIP_NAT_NEVER (0 << 18) |
| #define | SIP_NAT_RFC3581 (1 << 18) |
| #define | SIP_NAT_ROUTE (2 << 18) |
| #define | SIP_NEEDREINVITE (1 << 4) |
| #define | SIP_OUTGOING (1 << 0) |
| #define | SIP_PENDINGBYE (1 << 5) |
| #define | SIP_PROG_INBAND (3 << 25) |
| #define | SIP_PROG_INBAND_NEVER (0 << 25) |
| #define | SIP_PROG_INBAND_NO (1 << 25) |
| #define | SIP_PROG_INBAND_YES (2 << 25) |
| #define | SIP_PROGRESS_SENT (1 << 3) |
| #define | SIP_PROMISCREDIR (1 << 11) |
| #define | SIP_REINVITE (7 << 20) |
| #define | SIP_REINVITE_NONE (0 << 20) |
| #define | SIP_REINVITE_UPDATE (4 << 20) |
| #define | SIP_RINGING (1 << 2) |
| #define | SIP_SENDRPID (1 << 29) |
| #define | SIP_TRUSTRPID (1 << 12) |
| #define | SIP_USECLIENTCODE (1 << 14) |
| #define | SIP_USEREQPHONE (1 << 13) |
SIPflags2 | |
a second page of flags (for flags[1] | |
| #define | SIP_PAGE2_ALLOWOVERLAP (1 << 17) |
| #define | SIP_PAGE2_ALLOWSUBSCRIBE (1 << 16) |
| #define | SIP_PAGE2_BUGGY_MWI (1 << 26) |
| #define | SIP_PAGE2_CALL_ONHOLD (3 << 23) |
| #define | SIP_PAGE2_CALL_ONHOLD_ACTIVE (1 << 23) |
| #define | SIP_PAGE2_CALL_ONHOLD_INACTIVE (3 << 23) |
| #define | SIP_PAGE2_CALL_ONHOLD_ONEDIR (2 << 23) |
| #define | SIP_PAGE2_DIALOG_ESTABLISHED (1 << 27) |
| #define | SIP_PAGE2_FAX_DETECT (3 << 28) |
| #define | SIP_PAGE2_FAX_DETECT_BOTH (3 << 28) |
| #define | SIP_PAGE2_FAX_DETECT_CNG (1 << 28) |
| #define | SIP_PAGE2_FAX_DETECT_T38 (2 << 28) |
| #define | SIP_PAGE2_FLAGS_TO_COPY |
| #define | SIP_PAGE2_FORWARD_LOOP_DETECTED (1 << 8) |
| #define | SIP_PAGE2_HAVEPEERCONTEXT (1 << 3) |
| #define | SIP_PAGE2_IGNORESDPVERSION (1 << 19) |
| #define | SIP_PAGE2_REGISTERTRYING (1 << 29) |
| #define | SIP_PAGE2_RFC2833_COMPENSATE (1 << 25) |
| #define | SIP_PAGE2_RPORT_PRESENT (1 << 10) |
| #define | SIP_PAGE2_RTAUTOCLEAR (1 << 2) |
| #define | SIP_PAGE2_RTCACHEFRIENDS (1 << 0) |
| #define | SIP_PAGE2_STATECHANGEQUEUE (1 << 9) |
| #define | SIP_PAGE2_SUBSCRIBEMWIONLY (1 << 18) |
| #define | SIP_PAGE2_T38SUPPORT (3 << 20) |
| #define | SIP_PAGE2_T38SUPPORT_UDPTL (1 << 20) |
| #define | SIP_PAGE2_T38SUPPORT_UDPTL_FEC (2 << 20) |
| #define | SIP_PAGE2_T38SUPPORT_UDPTL_REDUNDANCY (3 << 20) |
| #define | SIP_PAGE2_TEXTSUPPORT (1 << 15) |
| #define | SIP_PAGE2_UDPTL_DESTINATION (1 << 30) |
| #define | SIP_PAGE2_VIDEOSUPPORT (1 << 14) |
| #define | SIP_PAGE2_VIDEOSUPPORT_ALWAYS (1 << 31) |
Enumerations | |
| enum | can_create_dialog { CAN_NOT_CREATE_DIALOG, CAN_CREATE_DIALOG, CAN_CREATE_DIALOG_UNSUPPORTED_METHOD } |
| States whether a SIP message can create a dialog in Asterisk. More... | |
| enum | check_auth_result { AUTH_DONT_KNOW = -100, 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, AUTH_BAD_TRANSPORT = -8 } |
| Authentication result from check_auth* functions. More... | |
| enum | invitestates { INV_NONE = 0, INV_CALLING = 1, INV_PROCEEDING = 2, INV_EARLY_MEDIA = 3, INV_COMPLETED = 4, INV_CONFIRMED = 5, INV_TERMINATED = 6, INV_CANCELLED = 7 } |
| States for the INVITE transaction, not the dialog. More... | |
| enum | media_type { SDP_AUDIO, SDP_VIDEO, SDP_IMAGE, SDP_TEXT } |
| enum | notifycid_setting { DISABLED = 0, ENABLED = 1, IGNORE_CONTEXT = 2 } |
| Settings for the 'notifycid' option, see sip.conf.sample for details. More... | |
| enum | parse_register_result { PARSE_REGISTER_DENIED, PARSE_REGISTER_FAILED, PARSE_REGISTER_UPDATE, PARSE_REGISTER_QUERY } |
| Results from the parse_register() function. More... | |
| enum | peer_unlink_flag_t { SIP_PEERS_MARKED, SIP_PEERS_ALL } |
| enum | referstatus { REFER_IDLE, REFER_SENT, REFER_RECEIVED, REFER_CONFIRMED, REFER_ACCEPTED, REFER_RINGING, REFER_200OK, REFER_FAILED, REFER_NOAUTH } |
| Parameters to know status of transfer. More... | |
| enum | sip_auth_type { PROXY_AUTH = 407, WWW_AUTH = 401 } |
| Authentication types - proxy or www authentication. More... | |
| enum | sip_debug_e { sip_debug_none = 0, sip_debug_config = 1, sip_debug_console = 2 } |
| debugging state We store separately the debugging requests from the config file and requests from the CLI. Debugging is enabled if either is set (which means that if sipdebug is set in the config file, we can only turn it off by reloading the config). More... | |
| enum | sip_peer_type { SIP_TYPE_PEER = (1 << 0), SIP_TYPE_USER = (1 << 1) } |
| enum | sip_result { AST_SUCCESS = 0, AST_FAILURE = -1 } |
| The result of a lot of functions. More... | |
| enum | sip_tcptls_alert { TCPTLS_ALERT_DATA, TCPTLS_ALERT_STOP } |
| enum | sip_transport { SIP_TRANSPORT_UDP = 1, SIP_TRANSPORT_TCP = 1 << 1, SIP_TRANSPORT_TLS = 1 << 2 } |
| Define some implemented SIP transports. More... | |
| enum | sipmethod { SIP_UNKNOWN, SIP_RESPONSE, SIP_REGISTER, SIP_OPTIONS, SIP_NOTIFY, SIP_INVITE, SIP_ACK, SIP_PRACK, SIP_BYE, SIP_REFER, SIP_SUBSCRIBE, SIP_MESSAGE, SIP_UPDATE, SIP_INFO, SIP_CANCEL, SIP_PUBLISH, SIP_PING } |
| SIP Request methods known by Asterisk. More... | |
| enum | sipregistrystate { REG_STATE_UNREGISTERED = 0, REG_STATE_REGSENT, REG_STATE_AUTHSENT, REG_STATE_REGISTERED, REG_STATE_REJECTED, REG_STATE_TIMEOUT, REG_STATE_NOAUTH, REG_STATE_FAILED } |
| States for outbound registrations (with register= lines in sip.conf. More... | |
| enum | st_mode { SESSION_TIMER_MODE_INVALID = 0, SESSION_TIMER_MODE_ACCEPT, SESSION_TIMER_MODE_ORIGINATE, SESSION_TIMER_MODE_REFUSE } |
| Modes in which Asterisk can be configured to run SIP Session-Timers. More... | |
| enum | st_refresher { SESSION_TIMER_REFRESHER_AUTO, SESSION_TIMER_REFRESHER_UAC, SESSION_TIMER_REFRESHER_UAS } |
| The entity playing the refresher role for Session-Timers. More... | |
| enum | subscriptiontype { NONE = 0, XPIDF_XML, DIALOG_INFO_XML, CPIM_PIDF_XML, PIDF_XML, MWI_NOTIFICATION } |
| Type of subscription, based on the packages we do support, see subscription_types. More... | |
| enum | t38_action_flag { SDP_T38_NONE = 0, SDP_T38_INITIATE, SDP_T38_ACCEPT } |
| enum | t38state { T38_DISABLED = 0, T38_LOCAL_REINVITE, T38_PEER_REINVITE, T38_ENABLED } |
| T38 States for a call. More... | |
| enum | transfermodes { TRANSFER_OPENFORALL, TRANSFER_CLOSED } |
| Authorization scheme for call transfers. More... | |
| enum | xmittype { XMIT_CRITICAL = 2, XMIT_RELIABLE = 1, XMIT_UNRELIABLE = 0 } |
| 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. More... | |
Functions | |
| static const char * | __get_header (const struct sip_request *req, const char *name, int *start) |
| static void | __init_check_auth_buf (void) |
| static void | __init_ts_temp_pvt (void) |
| A per-thread temporary pvt structure. | |
| static void | __reg_module (void) |
| static int | __set_address_from_contact (const char *fullcontact, struct sockaddr_in *sin, int tcp) |
| static int | __sip_ack (struct sip_pvt *p, int seqno, int resp, int sipmethod) |
| Acknowledges receipt of a packet and stops retransmission called with p locked. | |
| static int | __sip_autodestruct (const void *data) |
| Kill a SIP dialog (called only by the scheduler) The scheduler has a reference to this dialog when p->autokillid != -1, and we are called using that reference. So if the event is not rescheduled, we need to call dialog_unref(). | |
| static void | __sip_destroy (struct sip_pvt *p, int lockowner, int lockdialoglist) |
| Execute destruction of SIP dialog structure, release memory. | |
| static int | __sip_do_register (struct sip_registry *r) |
| Register with SIP proxy. | |
| static void | __sip_pretend_ack (struct sip_pvt *p) |
| Pretend to ack all packets called with p locked. | |
| static int | __sip_reliable_xmit (struct sip_pvt *p, int seqno, int resp, struct ast_str *data, int len, int fatal, int sipmethod) |
| Transmit packet with retransmits. | |
| static int | __sip_semi_ack (struct sip_pvt *p, int seqno, int resp, int sipmethod) |
| Acks receipt of packet, keep it around (used for provisional responses). | |
| static int | __sip_subscribe_mwi_do (struct sip_subscription_mwi *mwi) |
| Actually setup an MWI subscription or resubscribe. | |
| static int | __sip_xmit (struct sip_pvt *p, struct ast_str *data, int len) |
| Transmit SIP message Sends a SIP request or response on a given socket (in the pvt) Called by retrans_pkt, send_request, send_response and __sip_reliable_xmit. | |
| static int | __transmit_response (struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable) |
| Base transmit response function. | |
| static void | __unreg_module (void) |
| static char * | _sip_qualify_peer (int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[]) |
| Send qualify message to peer from cli or manager. Mostly for debugging. | |
| static char * | _sip_show_peer (int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[]) |
| Show one peer in detail (main function). | |
| static char * | _sip_show_peers (int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[]) |
| Execute sip show peers command. | |
| static void * | _sip_tcp_helper_thread (struct sip_pvt *pvt, struct ast_tcptls_session_instance *tcptls_session) |
| SIP TCP thread management function This function reads from the socket, parses the packet into a request. | |
| static int | acf_channel_read (struct ast_channel *chan, const char *funcname, char *preparse, char *buf, size_t buflen) |
| static void | add_blank (struct sip_request *req) |
| add a blank line if no body | |
| static void | add_codec_to_sdp (const struct sip_pvt *p, int codec, struct ast_str **m_buf, struct ast_str **a_buf, int debug, int *min_packet_size) |
| Add codec offer to SDP offer/answer body in INVITE or 200 OK. | |
| static int | add_content (struct sip_request *req, const char *line) |
| Add content (not header) to SIP message. | |
| static int | add_digit (struct sip_request *req, char digit, unsigned int duration, int mode) |
| Add DTMF INFO tone to sip message Mode = 0 for application/dtmf-relay (Cisco) 1 for application/dtmf. | |
| static int | add_header (struct sip_request *req, const char *var, const char *value) |
| Add header to SIP message. | |
| static void | add_noncodec_to_sdp (const struct sip_pvt *p, int format, struct ast_str **m_buf, struct ast_str **a_buf, int debug) |
| Add RFC 2833 DTMF offer to SDP. | |
| static void | add_peer_mailboxes (struct sip_peer *peer, const char *value) |
| static void | add_peer_mwi_subs (struct sip_peer *peer) |
| static struct sip_auth * | add_realm_authentication (struct sip_auth *authlist, const char *configuration, int lineno) |
| Add realm authentication in list. | |
| static void | add_route (struct sip_request *req, struct sip_route *route) |
| Add route header into request per learned route. | |
| static enum sip_result | add_sdp (struct sip_request *resp, struct sip_pvt *p, int oldsdp, int add_audio, int add_t38) |
| Add Session Description Protocol message. | |
| static int | add_sip_domain (const char *domain, const enum domain_mode mode, const char *context) |
| Add SIP domain to list of domains we are responsible for. | |
| static int | add_supported_header (struct sip_pvt *pvt, struct sip_request *req) |
| Add "Supported" header to sip message. Since some options may be disabled in the config, the sip_pvt must be inspected to determine what is supported for this dialog. | |
| static void | add_tcodec_to_sdp (const struct sip_pvt *p, int codec, struct ast_str **m_buf, struct ast_str **a_buf, int debug, int *min_packet_size) |
| Add text codec offer to SDP offer/answer body in INVITE or 200 OK. | |
| static int | add_text (struct sip_request *req, const char *text) |
| Add text body to SIP message. | |
| static struct ast_variable * | add_var (const char *buf, struct ast_variable *list) |
| implement the setvar config line | |
| static void | add_vcodec_to_sdp (const struct sip_pvt *p, int codec, struct ast_str **m_buf, struct ast_str **a_buf, int debug, int *min_packet_size) |
| Add video codec offer to SDP offer/answer body in INVITE or 200 OK. | |
| static int | add_vidupdate (struct sip_request *req) |
| add XML encoded media control with update | |
| static int | addr_is_multicast (struct in_addr *addr) |
| Check if an ip is an multicast IP. addr the address to check. | |
| static void | append_date (struct sip_request *req) |
| Append date to SIP message. | |
| static void | append_history_full (struct sip_pvt *p, const char *fmt,...) |
| Append to SIP dialog history with arg list. | |
| static void | append_history_va (struct sip_pvt *p, const char *fmt, va_list ap) |
| Append to SIP dialog history with arg list. | |
| static void | ast_quiet_chan (struct ast_channel *chan) |
| Turn off generator data XXX Does this function belong in the SIP channel? | |
| static void | ast_sip_ouraddrfor (struct in_addr *them, struct sockaddr_in *us, struct sip_pvt *p) |
| NAT fix - decide which IP address to use for Asterisk server? | |
| static int | attempt_transfer (struct sip_dual *transferer, struct sip_dual *target) |
| Attempt transfer of SIP call This fix for attended transfers on a local PBX. | |
| static void | auth_headers (enum sip_auth_type code, char **header, char **respheader) |
| return the request and response heade for a 401 or 407 code | |
| static int | auto_congest (const void *arg) |
| Scheduled congestion on a call. Only called by the scheduler, must return the reference when done. | |
| static void | build_callid_pvt (struct sip_pvt *pvt) |
| Build SIP Call-ID value for a non-REGISTER transaction. | |
| static void | build_callid_registry (struct sip_registry *reg, struct in_addr ourip, const char *fromdomain) |
| Build SIP Call-ID value for a REGISTER transaction. | |
| static void | build_contact (struct sip_pvt *p) |
| Build contact header - the contact header we send out. | |
| static struct sip_peer * | build_peer (const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime, int devstate_only) |
| Build peer from configuration (file or realtime static/dynamic). | |
| static int | build_reply_digest (struct sip_pvt *p, int method, char *digest, int digest_len) |
| Build reply digest. | |
| static void | build_route (struct sip_pvt *p, struct sip_request *req, int backwards) |
| Build route list from Record-Route header. | |
| static void | build_rpid (struct sip_pvt *p) |
| Build the Remote Party-ID & From using callingpres options. | |
| static void | build_via (struct sip_pvt *p) |
| Build a Via header for a request. | |
| static int | cb_extensionstate (char *context, char *exten, int state, void *data) |
| Callback for the devicestate notification (SUBSCRIBE) support subsystem. | |
| static void | change_hold_state (struct sip_pvt *dialog, struct sip_request *req, int holdstate, int sendonly) |
| Change hold state for a call. | |
| static void | change_t38_state (struct sip_pvt *p, int state) |
| Change the T38 state on a SIP dialog. | |
| static enum check_auth_result | check_auth (struct sip_pvt *p, struct sip_request *req, const char *username, const char *secret, const char *md5secret, int sipmethod, char *uri, enum xmittype reliable, int ignore) |
| Check user authorization from peer definition Some actions, like REGISTER and INVITEs from peers require authentication (if peer have secret set). | |
| static enum check_auth_result | check_peer_ok (struct sip_pvt *p, char *of, struct sip_request *req, int sipmethod, struct sockaddr_in *sin, struct sip_peer **authpeer, enum xmittype reliable, char *rpid_num, char *calleridname, char *uri2) |
| Validate device authentication. | |
| static void | check_pendings (struct sip_pvt *p) |
| Check pending actions on SIP call. | |
| static void | check_rtp_timeout (struct sip_pvt *dialog, time_t t) |
| helper function for the monitoring thread -- seems to be called with the assumption that the dialog is locked | |
| static int | check_sip_domain (const char *domain, char *context, size_t len) |
| check_sip_domain: Check if domain part of uri is local to our server | |
| static int | check_user (struct sip_pvt *p, struct sip_request *req, int sipmethod, char *uri, enum xmittype reliable, struct sockaddr_in *sin) |
| Find user If we get a match, this will add a reference pointer to the user object in ASTOBJ, that needs to be unreferenced. | |
| static enum check_auth_result | check_user_full (struct sip_pvt *p, struct sip_request *req, int sipmethod, char *uri, enum xmittype reliable, struct sockaddr_in *sin, struct sip_peer **authpeer) |
| Check if matching user or peer is defined Match user on From: user name and peer on IP/port This is used on first invite (not re-invites) and subscribe requests. | |
| static void | check_via (struct sip_pvt *p, struct sip_request *req) |
| check Via: header for hostname, port and rport request/answer | |
| static attribute_unused void | check_via_response (struct sip_pvt *p, struct sip_request *req) |
| check received= and rport= in a SIP response. If we get a response with received= and/or rport= in the Via: line, use them as 'p->ourip' (see RFC 3581 for rport, and RFC 3261 for received). Using these two fields SIP can produce the correct address and port in the SIP headers without the need for STUN. The address part is also reused for the media sessions. Note that ast_sip_ouraddrfor() still rewrites p->ourip if you specify externip/seternaddr/stunaddr. | |
| static void | cleanup_stale_contexts (char *new, char *old) |
| Destroy disused contexts between reloads Only used in reload_config so the code for regcontext doesn't get ugly. | |
| static void | clear_peer_mailboxes (struct sip_peer *peer) |
| static int | clear_realm_authentication (struct sip_auth *authlist) |
| Clear realm authentication list (at reload). | |
| static void | clear_sip_domains (void) |
| Clear our domain list (at reload). | |
| static const char * | cli_yesno (int x) |
| return Yes or No depending on the argument. This is used in many places in CLI command, having a function to generate this helps maintaining a consistent output (and possibly emitting the output in other languages, at some point). | |
| static char * | complete_sip_peer (const char *word, int state, int flags2) |
| Do completion on peer name. | |
| static char * | complete_sip_registered_peer (const char *word, int state, int flags2) |
| Do completion on registered peer name. | |
| static char * | complete_sip_show_history (const char *line, const char *word, int pos, int state) |
| Support routine for 'sip show history' CLI. | |
| static char * | complete_sip_show_peer (const char *line, const char *word, int pos, int state) |
| Support routine for 'sip show peer' CLI. | |
| static char * | complete_sip_show_user (const char *line, const char *word, int pos, int state) |
| Support routine for 'sip show user' CLI. | |
| static char * | complete_sip_unregister (const char *line, const char *word, int pos, int state) |
| Support routine for 'sip unregister' CLI. | |
| static char * | complete_sip_user (const char *word, int state) |
| Do completion on user name. | |
| static char * | complete_sipch (const char *line, const char *word, int pos, int state) |
| Support routine for 'sip show channel' and 'sip show history' CLI This is in charge of generating all strings that match a prefix in the given position. As many functions of this kind, each invokation has O(state) time complexity so be careful in using it. | |
| static char * | complete_sipnotify (const char *line, const char *word, int pos, int state) |
| Support routine for 'sip notify' CLI. | |
| static int | copy_all_header (struct sip_request *req, const struct sip_request *orig, const char *field) |
| Copy all headers from one request to another. | |
| static int | copy_header (struct sip_request *req, const struct sip_request *orig, const char *field) |
| Copy one header field from one request to another. | |
| static void | copy_request (struct sip_request *dst, const struct sip_request *src) |
| copy SIP request (mostly used to save request for responses) | |
| static void | copy_socket_data (struct sip_socket *to_sock, const struct sip_socket *from_sock) |
| static struct ast_variable * | copy_vars (struct ast_variable *src) |
| static int | copy_via_headers (struct sip_pvt *p, struct sip_request *req, const struct sip_request *orig, const char *field) |
| Copy SIP VIA Headers from the request to the response. | |
| static int | create_addr (struct sip_pvt *dialog, const char *opeer, struct sockaddr_in *sin, int newdialog) |
| create address structure from device name Or, if peer not found, find it in the global DNS returns TRUE (-1) on failure, FALSE on success | |
| static int | create_addr_from_peer (struct sip_pvt *dialog, struct sip_peer *peer) |
| Create address structure from peer reference. This function copies data from peer to the dialog, so we don't have to look up the peer again from memory or database during the life time of the dialog. | |
| static void | deinit_req (struct sip_request *req) |
| Deinitialize SIP response/request. | |
| static void | destroy_association (struct sip_peer *peer) |
| Remove registration data from realtime database or AST/DB when registration expires. | |
| static void | destroy_mailbox (struct sip_mailbox *mailbox) |
| static int | determine_firstline_parts (struct sip_request *req) |
| Parse first line of incoming SIP request. | |
| static int | dialog_cmp_cb (void *obj, void *arg, int flags) |
| static int | dialog_dump_func (void *userobj, void *arg, int flags) |
| static int | dialog_hash_cb (const void *obj, const int flags) |
| static int | dialog_needdestroy (void *dialogobj, void *arg, int flags) |
| Match dialogs that need to be destroyed. | |
| static struct sip_pvt * | dialog_ref (struct sip_pvt *p, char *tag) |
| when we create or delete references, make sure to use these functions so we keep track of the refcounts. To simplify the code, we allow a NULL to be passed to dialog_unref(). | |
| static void * | dialog_unlink_all (struct sip_pvt *dialog, int lockowner, int lockdialoglist) |
| Unlink a dialog from the dialogs container, as well as any other places that it may be currently stored. | |
| static struct sip_pvt * | dialog_unref (struct sip_pvt *p, char *tag) |
| static void | display_nat_warning (const char *cat, int reason, struct ast_flags *flags) |
| static int | do_magic_pickup (struct ast_channel *channel, const char *extension, const char *context) |
| static void * | do_monitor (void *data) |
| The SIP monitoring thread. | |
| static int | do_proxy_auth (struct sip_pvt *p, struct sip_request *req, enum sip_auth_type code, int sipmethod, int init) |
| Add authentication on outbound SIP packet. | |
| static int | do_register_auth (struct sip_pvt *p, struct sip_request *req, enum sip_auth_type code) |
| Authenticate for outbound registration. | |
| static void | do_setnat (struct sip_pvt *p, int natflags) |
| Set nat mode on the various data sockets. | |
| static const char * | domain_mode_to_text (const enum domain_mode mode) |
| Print domain mode to cli. | |
| static const char * | dtmfmode2str (int mode) |
| Convert DTMF mode to printable string. | |
| static int | expire_register (const void *data) |
| Expire registration of SIP peer. | |
| static void | extract_uri (struct sip_pvt *p, struct sip_request *req) |
| Check Contact: URI of SIP message. | |
| static const char * | faxec2str (int faxec) |
| static int | finalize_content (struct sip_request *req) |
| Add 'Content-Length' header and content to SIP message. | |
| static const char * | find_alias (const char *name, const char *_default) |
| Find compressed SIP alias. | |
| static int | find_by_name (void *obj, void *arg, void *data, int flags) |
| static struct sip_pvt * | find_call (struct sip_request *req, struct sockaddr_in *sin, const int intended_method) |
| find or create a dialog structure for an incoming SIP message. Connect incoming SIP message to current dialog or create new dialog structure Returns a reference to the sip_pvt object, remember to give it back once done. Called by handle_request_do | |
| static int | find_call_cb (void *__pvt, void *__arg, int flags) |
| static int | find_calling_channel (struct ast_channel *c, void *data) |
| static const char * | find_closing_quote (const char *start, const char *lim) |
| Locate closing quote in a string, skipping escaped quotes. optionally with a limit on the search. start must be past the first quote. | |
| static struct sip_peer * | find_peer (const char *peer, struct sockaddr_in *sin, int realtime, int which_objects, int devstate_only, int transport) |
| Locate device by name or ip address. | |
| static struct sip_auth * | find_realm_authentication (struct sip_auth *authlist, const char *realm) |
| Find authentication for a specific realm. | |
| static int | find_sdp (struct sip_request *req) |
| Determine whether a SIP message contains an SDP in its body. | |
| static int | find_sip_method (const char *msg) |
| find_sip_method: Find SIP method from header | |
| static struct cfsubscription_types * | find_subscription_type (enum subscriptiontype subtype) |
| Find subscription type in array. | |
| static void | free_old_route (struct sip_route *route) |
| Remove route from route list. | |
| static void | free_via (struct sip_via *v) |
| static int | func_check_sipdomain (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| Dial plan function to check if domain is local. | |
| static int | func_header_read (struct ast_channel *chan, const char *function, char *data, char *buf, size_t len) |
| Read SIP header (dialplan function). | |
| static int | function_sipchaninfo_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| ${SIPCHANINFO()} Dialplan function - reads sip channel data | |
| static int | function_sippeer (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| ${SIPPEER()} Dialplan function - reads peer data | |
| static char * | generate_random_string (char *buf, size_t size) |
| Generate 32 byte random string for callid's etc. | |
| static int | get_also_info (struct sip_pvt *p, struct sip_request *oreq) |
| Call transfer support (old way, deprecated by the IETF). | |
| static char * | get_body (struct sip_request *req, char *name, char delimiter) |
| Get a specific line from the message body. | |
| static char * | get_body_by_line (const char *line, const char *name, int nameLen, char delimiter) |
| Reads one line of SIP message body. | |
| static int | get_cached_mwi (struct sip_peer *peer, int *new, int *old) |
| Get cached MWI info. | |
| static char * | get_calleridname (const char *input, char *output, size_t outputsize) |
| Get caller id name from SIP headers. | |
| static int | get_destination (struct sip_pvt *p, struct sip_request *oreq) |
| Find out who the call is for. We use the request uri as a destination. This code assumes authentication has been done, so that the device (peer/user) context is already set. | |
| static const char * | get_header (const struct sip_request *req, const char *name) |
| Get header from SIP request. | |
| static char * | get_in_brackets (char *tmp) |
| Pick out text in brackets from character string. | |
| static struct ast_variable * | get_insecure_variable_from_config (struct ast_config *config) |
| static int | get_ip_and_port_from_sdp (struct sip_request *req, const enum media_type media, struct sockaddr_in *sin) |
| static int | get_msg_text (char *buf, int len, struct sip_request *req, int addnewline) |
| Get text out of a SIP MESSAGE packet. | |
| static const char * | get_name_from_variable (struct ast_variable *var, const char *newpeername) |
| static void | get_our_media_address (struct sip_pvt *p, int needvideo, struct sockaddr_in *sin, struct sockaddr_in *vsin, struct sockaddr_in *tsin, struct sockaddr_in *dest, struct sockaddr_in *vdest) |
| Set all IP media addresses for this call. | |
| static int | get_rdnis (struct sip_pvt *p, struct sip_request *oreq) |
| Get referring dnis. | |
| static int | get_refer_info (struct sip_pvt *transferer, struct sip_request *outgoing_req) |
| Call transfer support (the REFER method) Extracts Refer headers into pvt dialog structure. | |
| static int | get_rpid_num (const char *input, char *output, int maxlen) |
| Get caller id number from Remote-Party-ID header field Returns true if number should be restricted (privacy setting found) output is set to NULL if no number found. | |
| static const char * | get_sdp_iterate (int *start, struct sip_request *req, const char *name) |
| Lookup 'name' in the SDP starting at the 'start' line. Returns the matching line, and 'start' is updated with the next line number. | |
| static char | get_sdp_line (int *start, int stop, struct sip_request *req, const char **value) |
| Fetches the next valid SDP line between the 'start' line (inclusive) and the 'stop' line (exclusive). Returns the type ('a', 'c', ...) and matching line in reference 'start' is updated with the next line number. | |
| static struct sip_pvt * | get_sip_pvt_byid_locked (const char *callid, const char *totag, const char *fromtag) |
| Lock dialog lock and find matching pvt lock. | |
| static const char * | get_srv_protocol (enum sip_transport t) |
| Return protocol string for srv dns query. | |
| static const char * | get_srv_service (enum sip_transport t) |
| Return service string for srv dns query. | |
| static const char * | get_transport (enum sip_transport t) |
| Return transport as string. | |
| static const char * | get_transport_list (unsigned int transports) |
| Return configuration of transports for a device. | |
| static const char * | get_transport_pvt (struct sip_pvt *p) |
| Return transport of dialog. | |
| static int | get_transport_str2enum (const char *transport) |
| Return int representing a bit field of transport types found in const char *transport. | |
| static const char * | gettag (const struct sip_request *req, const char *header, char *tagbuf, int tagbufsize) |
| Get tag from packet. | |
| static int | handle_common_options (struct ast_flags *flags, struct ast_flags *mask, struct ast_variable *v) |
| Handle flag-type options common to configuration of devices - peers. | |
| static int | handle_incoming (struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int *recount, int *nounlock) |
| Handle incoming SIP requests (methods). | |
| static int | handle_invite_replaces (struct sip_pvt *p, struct sip_request *req, int debug, int seqno, struct sockaddr_in *sin, int *nounlock) |
| Handle the transfer part of INVITE with a replaces: header, meaning a target pickup or an attended transfer. Used only once. XXX 'ignore' is unused. | |
| static int | handle_request_bye (struct sip_pvt *p, struct sip_request *req) |
| Handle incoming BYE request. | |
| static int | handle_request_cancel (struct sip_pvt *p, struct sip_request *req) |
| Handle incoming CANCEL request. | |
| static int | handle_request_do (struct sip_request *req, struct sockaddr_in *sin) |
| Handle incoming SIP message - request or response. | |
| static void | handle_request_info (struct sip_pvt *p, struct sip_request *req) |
| Receive SIP INFO Message. | |
| static int | handle_request_invite (struct sip_pvt *p, struct sip_request *req, int debug, int seqno, struct sockaddr_in *sin, int *recount, char *e, int *nounlock) |
| Handle incoming INVITE request. | |
| static int | handle_request_message (struct sip_pvt *p, struct sip_request *req) |
| Handle incoming MESSAGE request. | |
| static int | handle_request_notify (struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e) |
| Handle incoming notifications. | |
| static int | handle_request_options (struct sip_pvt *p, struct sip_request *req) |
| Handle incoming OPTIONS request An OPTIONS request should be answered like an INVITE from the same UA, including SDP. | |
| static int | handle_request_refer (struct sip_pvt *p, struct sip_request *req, int debug, int seqno, int *nounlock) |
| static int | handle_request_register (struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, char *e) |
| Handle incoming REGISTER request. | |
| static int | handle_request_subscribe (struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e) |
| Handle incoming SUBSCRIBE request. | |
| static void | handle_response (struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno) |
| Handle SIP response in dialogue. | |
| static void | handle_response_invite (struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno) |
| Handle SIP response to INVITE dialogue. | |
| static void | handle_response_notify (struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno) |
| static void | handle_response_peerpoke (struct sip_pvt *p, int resp, struct sip_request *req) |
| Handle qualification responses (OPTIONS). | |
| static void | handle_response_refer (struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno) |
| static int | handle_response_register (struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno) |
| Handle responses on REGISTER to services. | |
| static void | handle_response_subscribe (struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno) |
| static int | handle_t38_options (struct ast_flags *flags, struct ast_flags *mask, struct ast_variable *v, int *maxdatagram) |
| Handle T.38 configuration options common to users and peers. | |
| static const char * | hangup_cause2sip (int cause) |
| Convert Asterisk hangup causes to SIP codes. | |
| static int | hangup_sip2cause (int cause) |
| Convert SIP hangup causes to Asterisk hangup causes. | |
| static int | init_req (struct sip_request *req, int sipmethod, const char *recip) |
| Initialize SIP request. | |
| static int | init_resp (struct sip_request *resp, const char *msg) |
| Initialize SIP response, based on SIP request. | |
| static void | initialize_initreq (struct sip_pvt *p, struct sip_request *req) |
| Initialize the initital request packet in the pvt structure. This packet is used for creating replies and future requests in a dialog. | |
| static void | initreqprep (struct sip_request *req, struct sip_pvt *p, int sipmethod) |
| Initiate new SIP request to peer/user. | |
| static const char * | insecure2str (int mode) |
| Convert Insecure setting to printable string. | |
| static int | interpret_t38_parameters (struct sip_pvt *p, const struct ast_control_t38_parameters *parameters) |
| Helper function which updates T.38 capability information and triggers a reinvite. | |
| static void | list_route (struct sip_route *route) |
| List all routes - mostly for debugging. | |
| static int | load_module (void) |
| PBX load module - initialization. | |
| static int | local_attended_transfer (struct sip_pvt *transferer, struct sip_dual *current, struct sip_request *req, int seqno) |
| Find all call legs and bridge transferee with target called from handle_request_refer. | |
| static int | lws2sws (char *msgbuf, int len) |
| Parse multiline SIP headers into one header This is enabled if pedanticsipchecking is enabled. | |
| static void | make_our_tag (char *tagbuf, size_t len) |
| Make our SIP dialog tag. | |
| static int | manager_show_registry (struct mansession *s, const struct message *m) |
| Show SIP registrations in the manager API. | |
| static int | manager_sip_qualify_peer (struct mansession *s, const struct message *m) |
| Qualify SIP peers in the manager API. | |
| static int | manager_sip_show_peer (struct mansession *s, const struct message *m) |
| Show SIP peers in the manager API. | |
| static int | manager_sip_show_peers (struct mansession *s, const struct message *m) |
| Show SIP peers in the manager API. | |
| static int | manager_sipnotify (struct mansession *s, const struct message *m) |
| static int | map_s_x (const struct _map_x_s *table, const char *s, int errorvalue) |
| map from a string to an integer value, case insensitive. If no match is found, return errorvalue. | |
| static const char * | map_x_s (const struct _map_x_s *table, int x, const char *errorstring) |
| map from an integer value to a string. If no match is found, return errorstring | |
| static int | match_and_cleanup_peer_sched (void *peerobj, void *arg, int flags) |
| static int | method_match (enum sipmethod id, const char *name) |
| returns true if 'name' (with optional trailing whitespace) matches the sip method 'id'. Strictly speaking, SIP methods are case SENSITIVE, but we do a case-insensitive comparison to be more tolerant. following Jon Postel's rule: Be gentle in what you accept, strict with what you send | |
| static void | mwi_event_cb (const struct ast_event *event, void *userdata) |
| Receive MWI events that we have subscribed to. | |
| static const char * | nat2str (int nat) |
| Convert NAT setting to text string. | |
| static struct sip_proxy * | obproxy_get (struct sip_pvt *dialog, struct sip_peer *peer) |
| Get default outbound proxy or global proxy. | |
| static void | parse_copy (struct sip_request *dst, const struct sip_request *src) |
| Copy SIP request, parse it. | |
| static int | parse_minse (const char *p_hdrval, int *const p_interval) |
| Session-Timers: Function for parsing Min-SE header. | |
| static void | parse_moved_contact (struct sip_pvt *p, struct sip_request *req) |
| Parse 302 Moved temporalily response. | |
| static int | parse_ok_contact (struct sip_pvt *pvt, struct sip_request *req) |
| Save contact header for 200 OK on INVITE. | |
| static enum parse_register_result | parse_register_contact (struct sip_pvt *pvt, struct sip_peer *peer, struct sip_request *req) |
| Parse contact header and save registration (peer registration). | |
| static int | parse_request (struct sip_request *req) |
| Parse a SIP message. | |
| static int | parse_session_expires (const char *p_hdrval, int *const p_interval, enum st_refresher *const p_ref) |
| Session-Timers: Function for parsing Session-Expires header. | |
| static unsigned int | parse_sip_options (struct sip_pvt *pvt, const char *supported) |
| Parse supported header in incoming packet. | |
| static int | parse_uri (char *uri, const char *scheme, char **ret_name, char **pass, char **domain, char **port, char **options, char **transport) |
| * parses a URI in its components. | |
| static struct sip_via * | parse_via (const char *header) |
| Parse a Via header. | |
| static int | peer_cmp_cb (void *obj, void *arg, int flags) |
| static int | peer_dump_func (void *userobj, void *arg, int flags) |
| static int | peer_hash_cb (const void *obj, const int flags) |
| static int | peer_ipcmp_cb (void *obj, void *arg, int flags) |
| static int | peer_iphash_cb (const void *obj, const int flags) |
| static void | peer_mailboxes_to_str (struct ast_str **mailbox_str, struct sip_peer *peer) |
| list peer mailboxes to CLI | |
| static int | peer_markall_func (void *device, void *arg, int flags) |
| static void | peer_sched_cleanup (struct sip_peer *peer) |
| static int | peer_status (struct sip_peer *peer, char *status, int statuslen) |
| int | peercomparefunc (const void *a, const void *b) |
| static int | port_str2int (const char *pt, unsigned int standard) |
| 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. | |
| static void | print_codec_to_cli (int fd, struct ast_codec_pref *pref) |
| Print codec list from preference to CLI/manager. | |
| static void | print_group (int fd, ast_group_t group, int crlf) |
| Print call group and pickup group. | |
| static void | proc_422_rsp (struct sip_pvt *p, struct sip_request *rsp) |
| Handle 422 response to INVITE with session-timer requested. | |
| static int | proc_session_timer (const void *vp) |
| Session-Timers: Process session refresh timeout event. | |
| static void | process_request_queue (struct sip_pvt *p, int *recount, int *nounlock) |
| static int | process_sdp (struct sip_pvt *p, struct sip_request *req, int t38action) |
| Process SIP SDP offer, select formats and activate RTP channels If offer is rejected, we will not change any properties of the call Return 0 on success, a negative value on errors. Must be called after find_sdp(). | |
| static int | process_sdp_a_audio (const char *a, struct sip_pvt *p, struct ast_rtp *newaudiortp, int *last_rtpmap_codec) |
| static int | process_sdp_a_image (const char *a, struct sip_pvt *p) |
| static int | process_sdp_a_sendonly (const char *a, int *sendonly) |
| static int | process_sdp_a_text (const char *a, struct sip_pvt *p, struct ast_rtp *newtextrtp, char *red_fmtp, int *red_num_gen, int *red_data_pt, int *last_rtpmap_codec) |
| static int | process_sdp_a_video (const char *a, struct sip_pvt *p, struct ast_rtp *newvideortp, int *last_rtpmap_codec) |
| static int | process_sdp_c (const char *c, struct ast_hostent *hp) |
| static int | process_sdp_o (const char *o, struct sip_pvt *p) |
| static int | process_via (struct sip_pvt *p, const struct sip_request *req) |
| Process the Via header according to RFC 3261 section 18.2.2. | |
| static struct sip_proxy * | proxy_allocate (char *name, char *port, int force) |
| Allocate and initialize sip proxy. | |
| static int | proxy_update (struct sip_proxy *proxy) |
| static void | pvt_set_needdestroy (struct sip_pvt *pvt, const char *reason) |
| static int | queue_request (struct sip_pvt *p, const struct sip_request *req) |
| static struct sip_peer * | realtime_peer (const char *newpeername, struct sockaddr_in *sin, int devstate_only) |
| realtime_peer: Get peer from realtime storage Checks the "sippeers" realtime family from extconfig.conf Checks the "sipregs" realtime family from extconfig.conf if it's configured. This returns a pointer to a peer and because we use build_peer, we can rest assured that the refcount is bumped. | |
| static void | realtime_update_peer (const char *peername, struct sockaddr_in *sin, const char *defaultuser, const char *fullcontact, const char *useragent, int expirey, int deprecated_username, int lastms) |
| Update peer object in realtime storage If the Asterisk system name is set in asterisk.conf, we will use that name and store that in the "regserver" field in the sippeers table to facilitate multi-server setups. | |
| static void | receive_message (struct sip_pvt *p, struct sip_request *req) |
| Receive SIP MESSAGE method messages. | |
| static struct sip_peer * | ref_peer (struct sip_peer *peer, char *tag) |
| static void | ref_proxy (struct sip_pvt *pvt, struct sip_proxy *proxy) |
| maintain proper refcounts for a sip_pvt's outboundproxy | |
| static const char * | referstatus2str (enum referstatus rstatus) |
| Convert transfer status to string. | |
| static void | reg_source_db (struct sip_peer *peer) |
| Get registration details from Asterisk DB. | |
| static void | register_peer_exten (struct sip_peer *peer, int onoff) |
| Automatically add peer extension to dial plan. | |
| static enum check_auth_result | register_verify (struct sip_pvt *p, struct sockaddr_in *sin, struct sip_request *req, char *uri) |
Verify registration of user
| |
| static struct sip_registry * | registry_addref (struct sip_registry *reg, char *tag) |
| Add object reference to SIP registry. | |
| static void * | registry_unref (struct sip_registry *reg, char *tag) |
| static const char * | regstate2str (enum sipregistrystate regstate) |
| Convert registration state status to string. | |
| static int | reload (void) |
| Part of Asterisk module interface. | |
| static int | reload_config (enum channelreloadreason reason) |
| Re-read SIP.conf config file. | |
| static char * | remove_uri_parameters (char *uri) |
| static void | replace_cid (struct sip_pvt *p, const char *rpid_num, const char *calleridname) |
| helper function for check_{user|peer}_ok() | |
| static int | reply_digest (struct sip_pvt *p, struct sip_request *req, char *header, int sipmethod, char *digest, int digest_len) |
| reply to authentication for outbound registrations | |
| static int | reqprep (struct sip_request *req, struct sip_pvt *p, int sipmethod, int seqno, int newbranch) |
| Initialize a SIP request message (not the initial one in a dialog). | |
| static int | resp_needs_contact (const char *msg, enum sipmethod method) |
| Test if this response needs a contact header. | |
| static int | respprep (struct sip_request *resp, struct sip_pvt *p, const char *msg, const struct sip_request *req) |
| Prepare SIP response packet. | |
| static int | restart_monitor (void) |
| Start the channel monitor thread. | |
| static void | restart_session_timer (struct sip_pvt *p) |
| Session-Timers: Restart session timer. | |
| static int | retrans_pkt (const void *data) |
| Retransmit SIP message if no answer (Called from scheduler). | |
| static int | scheduler_process_request_queue (const void *data) |
| static int | send_provisional_keepalive (const void *data) |
| static int | send_provisional_keepalive_full (struct sip_pvt *pvt, int with_sdp) |
| static int | send_provisional_keepalive_with_sdp (const void *data) |
| static int | send_request (struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, int seqno) |
| Send SIP Request to the other part of the dialogue. | |
| static int | send_response (struct sip_pvt *p, struct sip_request *req, enum xmittype reliable, int seqno) |
| Transmit response on SIP request. | |
| static int | set_address_from_contact (struct sip_pvt *pvt) |
| Change the other partys IP address based on given contact. | |
| static void | set_destination (struct sip_pvt *p, char *uri) |
| Set destination from SIP URI. | |
| static void | set_insecure_flags (struct ast_flags *flags, const char *value, int lineno) |
| Parse insecure= setting in sip.conf and set flags according to setting. | |
| static void | set_nonce_randdata (struct sip_pvt *p, int forceupdate) |
| builds the sip_pvt's randdata field which is used for the nonce challenge. When forceupdate is not set, the nonce is only updated if the current one is stale. In this case, a stalenonce is one which has already received a response, if a nonce has not received a response it is not always necessary or beneficial to create a new one. | |
| static void | set_peer_defaults (struct sip_peer *peer) |
| Set peer defaults before configuring specific configurations. | |
| static void | set_socket_transport (struct sip_socket *socket, int transport) |
| static void | set_t38_capabilities (struct sip_pvt *p) |
| Set the global T38 capabilities on a SIP dialog structure. | |
| static int | show_channels_cb (void *__cur, void *__arg, int flags) |
| callback for show channel|subscription | |
| static int | show_chanstats_cb (void *__cur, void *__arg, int flags) |
| Callback for show_chanstats. | |
| static int | sip_addheader (struct ast_channel *chan, void *data) |
| Add a SIP header to an outbound INVITE. | |
| static struct sip_pvt * | sip_alloc (ast_string_field callid, struct sockaddr_in *sin, int useglobal_nat, const int intended_method, struct sip_request *req) |
| Allocate sip_pvt structure, set defaults and link in the container. Returns a reference to the object so whoever uses it later must remember to release the reference. | |
| static void | sip_alreadygone (struct sip_pvt *dialog) |
| Encapsulate setting of SIP_ALREADYGONE to be able to trace it with debugging. | |
| static int | sip_answer (struct ast_channel *ast) |
| sip_answer: Answer SIP call , send 200 OK on Invite Part of PBX interface | |
| static int | sip_call (struct ast_channel *ast, char *dest, int timeout) |
| Initiate SIP call from PBX used from the dial() application. | |
| static int | sip_cancel_destroy (struct sip_pvt *p) |
| Cancel destruction of SIP dialog. Be careful as this also absorbs the reference - if you call it from within the scheduler, this might be the last reference. | |
| static int | sip_check_authtimeout (time_t start) |
| Check if the authtimeout has expired. | |
| static char * | sip_cli_notify (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Cli command to send SIP notify to peer. | |
| static int | sip_debug_test_addr (const struct sockaddr_in *addr) |
| See if we pass debug IP filter. | |
| static int | sip_debug_test_pvt (struct sip_pvt *p) |
| Test PVT for debugging output. | |
| static struct sip_pvt * | sip_destroy (struct sip_pvt *p) |
| Destroy SIP call structure. Make it return NULL so the caller can do things like foo = sip_destroy(foo); and reduce the chance of bugs due to dangling pointers. | |
| static void | sip_destroy_fn (void *p) |
| static void | sip_destroy_peer (struct sip_peer *peer) |
| Destroy peer object from memory. | |
| static void | sip_destroy_peer_fn (void *peer) |
| static int | sip_devicestate (void *data) |
| Part of PBX channel interface. | |
| static char * | sip_do_debug (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Turn on SIP debugging (CLI command). | |
| static char * | sip_do_debug_ip (int fd, char *arg) |
| Enable SIP Debugging for a single IP. | |
| static char * | sip_do_debug_peer (int fd, char *arg) |
| Turn on SIP debugging for a given peer. | |
| static int | sip_do_reload (enum channelreloadreason reason) |
| Reload module. | |
| static int | sip_dtmfmode (struct ast_channel *chan, void *data) |
| Set the DTMFmode for an outbound SIP call (application). | |
| static void | sip_dump_history (struct sip_pvt *dialog) |
| Dump SIP history to debug log file at end of lifespan for SIP dialog. | |
| static int | sip_fixup (struct ast_channel *oldchan, struct ast_channel *newchan) |
| sip_fixup: Fix up a channel: If a channel is consumed, this is called. Basically update any ->owner links | |
| static const char * | sip_get_callid (struct ast_channel *chan) |
| Deliver SIP call ID for the call. | |
| static int | sip_get_codec (struct ast_channel *chan) |
| Return SIP UA's codec (part of the RTP interface). | |
| static enum ast_rtp_get_result | sip_get_rtp_peer (struct ast_channel *chan, struct ast_rtp **rtp) |
| Returns null if we can't reinvite audio (part of RTP interface). | |
| static enum ast_rtp_get_result | sip_get_trtp_peer (struct ast_channel *chan, struct ast_rtp **rtp) |
| Returns null if we can't reinvite text (part of RTP interface). | |
| static struct ast_udptl * | sip_get_udptl_peer (struct ast_channel *chan) |
| static enum ast_rtp_get_result | sip_get_vrtp_peer (struct ast_channel *chan, struct ast_rtp **rtp) |
| Returns null if we can't reinvite video (part of RTP interface). | |
| static int | sip_hangup (struct ast_channel *ast) |
| sip_hangup: Hangup SIP call Part of PBX interface, called from ast_hangup | |
| static int | sip_indicate (struct ast_channel *ast, int condition, const void *data, size_t datalen) |
| Play indication to user With SIP a lot of indications is sent as messages, letting the device play the indication - busy signal, congestion etc. | |
| static const char * | sip_nat_mode (const struct sip_pvt *p) |
| Display SIP nat mode. | |
| static struct ast_channel * | sip_new (struct sip_pvt *i, int state, const char *title) |
| Initiate a call in the SIP channel called from sip_request_call (calls from the pbx ) for outbound channels and from handle_request_invite for inbound channels. | |
| static int | sip_park (struct ast_channel *chan1, struct ast_channel *chan2, struct sip_request *req, int seqno) |
| Park a call using the subsystem in res_features.c This is executed in a separate thread. | |
| static void * | sip_park_thread (void *stuff) |
| Park SIP call support function Starts in a new thread, then parks the call XXX Should we add a wait period after streaming audio and before hangup?? Sometimes the audio can't be heard before hangup. | |
| static int | sip_parse_host (char *line, int lineno, char **hostname, int *portnum, enum sip_transport *transport) |
| Small function to parse a config line for a host with a transport i.e. tls://www.google.com:8056. | |
| static void | sip_peer_hold (struct sip_pvt *p, int hold) |
| Change onhold state of a peer using a pvt structure. | |
| static int | sip_pickup (struct ast_channel *chan) |
| Pickup a call using the subsystem in features.c This is executed in a separate thread. | |
| static void * | sip_pickup_thread (void *stuff) |
| SIP pickup support function Starts in a new thread, then pickup the call. | |
| static void | sip_poke_all_peers (void) |
| Send a poke to all known peers. | |
| static int | sip_poke_noanswer (const void *data) |
| React to lack of answer to Qualify poke. | |
| static int | sip_poke_peer (struct sip_peer *peer, int force) |
| Check availability of peer, also keep NAT open. | |
| static int | sip_poke_peer_s (const void *data) |
| Poke peer (send qualify to check if peer is alive and well). | |
| static int | sip_prepare_socket (struct sip_pvt *p) |
| static char * | sip_prune_realtime (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Remove temporary realtime objects from memory (CLI). | |
| static char * | sip_qualify_peer (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Send an OPTIONS packet to a SIP peer. | |
| static int | sip_queryoption (struct ast_channel *chan, int option, void *data, int *datalen) |
| Query an option on a SIP dialog. | |
| static struct ast_frame * | sip_read (struct ast_channel *ast) |
| Read SIP RTP from channel. | |
| static struct sockaddr_in * | sip_real_dst (const struct sip_pvt *p) |
| The real destination address for a write. | |
| static int | sip_refer_allocate (struct sip_pvt *p) |
| Allocate SIP refer structure. | |
| static int | sip_reg_timeout (const void *data) |
| Registration timeout, register again Registered as a timeout handler during transmit_register(), to retransmit the packet if a reply does not come back. This is called by the scheduler so the event is not pending anymore when we are called. | |
| static int | sip_register (const char *value, int lineno) |
| Parse register=> line in sip.conf and add to registry. | |
| static void | sip_registry_destroy (struct sip_registry *reg) |
| Destroy registry object Objects created with the register= statement in static configuration. | |
| static int | sip_reinvite_retry (const void *data) |
| Reset the NEEDREINVITE flag after waiting when we get 491 on a Re-invite to avoid race conditions between asterisk servers. Called from the scheduler. | |
| static char * | sip_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Force reload of module from cli. | |
| static int | sip_removeheader (struct ast_channel *chan, void *data) |
| Remove SIP headers added previously with SipAddHeader application. | |
| static struct ast_channel * | sip_request_call (const char *type, int format, void *data, int *cause) |
| PBX interface function -build SIP pvt structure SIP calls initiated by the PBX arrive here. | |
| static int | sip_reregister (const void *data) |
| Update registration with SIP Proxy. Called from the scheduler when the previous registration expires, so we don't have to cancel the pending event. We assume the reference so the sip_registry is valid, since it is stored in the scheduled event anyways. | |
| static struct ast_frame * | sip_rtp_read (struct ast_channel *ast, struct sip_pvt *p, int *faxdetect) |
| Read RTP from network. | |
| static void | sip_scheddestroy (struct sip_pvt *p, int ms) |
| Schedule destruction of SIP dialog. | |
| static void | sip_send_all_mwi_subscriptions (void) |
| Send all MWI subscriptions. | |
| static void | sip_send_all_registers (void) |
| Send all known registrations. | |
| static int | sip_send_mwi_to_peer (struct sip_peer *peer, const struct ast_event *event, int cache_only) |
| Send message waiting indication to alert peer that they've got voicemail. | |
| static int | sip_senddigit_begin (struct ast_channel *ast, char digit) |
| static int | sip_senddigit_end (struct ast_channel *ast, char digit, unsigned int duration) |
| Send DTMF character on SIP channel within one call, we're able to transmit in many methods simultaneously. | |
| static int | sip_sendhtml (struct ast_channel *chan, int subclass, const char *data, int datalen) |
| Send message with Access-URL header, if this is an HTML URL only! | |
| static int | sip_sendtext (struct ast_channel *ast, const char *text) |
| Send SIP MESSAGE text within a call Called from PBX core sendtext() application. | |
| static char * | sip_set_history (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Enable/Disable SIP History logging (CLI). | |
| static void | sip_set_redirstr (struct sip_pvt *p, char *reason) |
| Translate referring cause. | |
| static int | sip_set_rtp_peer (struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, struct ast_rtp *trtp, int codecs, int nat_active) |
| Set the RTP peer for this call. | |
| static int | sip_set_udptl_peer (struct ast_channel *chan, struct ast_udptl *udptl) |
| static char * | sip_show_channel (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show details of one active dialog. | |
| static char * | sip_show_channels (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| CLI for show channels or subscriptions. This is a new-style CLI handler so a single function contains the prototype for the function, the 'generator' to produce multiple entries in case it is required, and the actual handler for the command. | |
| static char * | sip_show_channelstats (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| SIP show channelstats CLI (main function). | |
| static char * | sip_show_domains (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| CLI command to list local domains. | |
| static char * | sip_show_history (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show history details of one dialog. | |
| static char * | sip_show_inuse (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| CLI Command to show calls within limits set by call_limit. | |
| static char * | sip_show_mwi (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | sip_show_objects (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| List all allocated SIP Objects (realtime or static). | |
| static char * | sip_show_peer (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show one peer in detail. | |
| static char * | sip_show_peers (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| CLI Show Peers command. | |
| static char * | sip_show_registry (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show SIP Registry (registrations with other SIP proxies. | |
| static char * | sip_show_sched (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | sip_show_settings (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| List global settings for the SIP channel. | |
| static char * | sip_show_tcp (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show active TCP connections. | |
| static char * | sip_show_user (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Show one user in detail. | |
| static char * | sip_show_users (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| CLI Command 'SIP Show Users'. | |
| static int | sip_sipredirect (struct sip_pvt *p, const char *dest) |
| Transfer call before connect with a 302 redirect. | |
| static struct sip_st_dlg * | sip_st_alloc (struct sip_pvt *const p) |
| Allocate Session-Timers struct w/in dialog. | |
| static int | sip_standard_port (enum sip_transport type, int port) |
| Returns the port to use for this socket. | |
| static int | sip_subscribe_mwi (const char *value, int lineno) |
| Parse mwi=> line in sip.conf and add to list. | |
| static void | sip_subscribe_mwi_destroy (struct sip_subscription_mwi *mwi) |
| Destroy MWI subscription object. | |
| static int | sip_subscribe_mwi_do (const void *data) |
| Send a subscription or resubscription for MWI. | |
| static int | sip_t38_abort (const void *data) |
| Called to deny a T38 reinvite if the core does not respond to our request. | |
| static struct ast_tcptls_session_instance * | sip_tcp_locate (struct sockaddr_in *s) |
| Find thread for TCP/TLS session (based on IP/Port. | |
| static void * | sip_tcp_worker_fn (void *data) |
| SIP TCP connection handler. | |
| static void | sip_tcptls_client_args_destructor (void *obj) |
| static int | sip_tcptls_write (struct ast_tcptls_session_instance *tcptls_session, const void *buf, size_t len) |
| used to indicate to a tcptls thread that data is ready to be written | |
| static struct sip_threadinfo * | sip_threadinfo_create (struct ast_tcptls_session_instance *tcptls_session, int transport) |
| creates a sip_threadinfo object and links it into the threadt table. | |
| static void | sip_threadinfo_destructor (void *obj) |
| static int | sip_transfer (struct ast_channel *ast, const char *dest) |
| Transfer SIP call. | |
| static char * | sip_unregister (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| Unregister (force expiration) a SIP peer in the registry via CLI. | |
| static int | sip_uri_cmp (const char *input1, const char *input2) |
| static int | sip_uri_headers_cmp (const char *input1, const char *input2) |
| helper routine for sip_uri_cmp | |
| static int | sip_uri_params_cmp (const char *input1, const char *input2) |
| helper routine for sip_uri_cmp to compare URI parameters | |
| static int | sip_write (struct ast_channel *ast, struct ast_frame *frame) |
| Send frame to media channel (rtp). | |
| static int | sipsock_read (int *id, int fd, short events, void *ignore) |
| Read data from SIP UDP socket. | |
| static enum st_mode | st_get_mode (struct sip_pvt *p, int no_cached) |
| Get the session-timer mode. | |
| static enum st_refresher | st_get_refresher (struct sip_pvt *p) |
| Get the entity (UAC or UAS) that's acting as the session-timer refresher. | |
| static int | st_get_se (struct sip_pvt *p, int max) |
| Get Max or Min SE (session timer expiry). | |
| static void | start_session_timer (struct sip_pvt *p) |
| Session-Timers: Start session timer. | |
| static const char * | stmode2str (enum st_mode m) |
| static void | stop_media_flows (struct sip_pvt *p) |
| Immediately stop RTP, VRTP and UDPTL as applicable. | |
| static void | stop_session_timer (struct sip_pvt *p) |
| Session-Timers: Stop session timer. | |
| static int | str2dtmfmode (const char *str) |
| maps a string to dtmfmode, returns -1 on error | |
| static enum st_mode | str2stmode (const char *s) |
| static enum st_refresher | str2strefresher (const char *s) |
| static const char * | strefresher2str (enum st_refresher r) |
| static const char * | subscription_type2str (enum subscriptiontype subtype) |
| Show subscription type in string format. | |
| static unsigned int | t38_get_rate (enum ast_control_t38_rate rate) |
| Get Max T.38 Transmission rate from T38 capabilities. | |
| static void | tcptls_packet_destructor (void *obj) |
| static struct sip_peer * | temp_peer (const char *name) |
| Create temporary peer (used in autocreatepeer mode). | |
| static void | temp_pvt_cleanup (void *) |
| static int | temp_pvt_init (void *) |
| static char * | terminate_uri (char *uri) |
| static int | threadinfo_locate_cb (void *obj, void *arg, int flags) |
| static int | threadt_cmp_cb (void *obj, void *arg, int flags) |
| static int | threadt_hash_cb (const void *obj, const int flags) |
| static char * | transfermode2str (enum transfermodes mode) |
| Convert transfer mode to text string. | |
| static void | transmit_fake_auth_response (struct sip_pvt *p, int sipmethod, struct sip_request *req, enum xmittype reliable) |
| Send a fake 401 Unauthorized response when the administrator wants to hide the names of local devices from fishers. | |
| static int | transmit_info_with_digit (struct sip_pvt *p, const char digit, unsigned int duration) |
| Send SIP INFO dtmf message, see Cisco documentation on cisco.com. | |
| static int | transmit_info_with_vidupdate (struct sip_pvt *p) |
| Send SIP INFO with video update request. | |
| static int | transmit_invite (struct sip_pvt *p, int sipmethod, int sdp, int init) |
| Build REFER/INVITE/OPTIONS/SUBSCRIBE message and transmit it. | |
| static int | transmit_message_with_text (struct sip_pvt *p, const char *text) |
| Transmit text with SIP MESSAGE method. | |
| static int | transmit_notify_custom (struct sip_pvt *p, struct ast_variable *vars) |
| Notify device with custom headers from sip_notify.conf. | |
| static int | transmit_notify_with_mwi (struct sip_pvt *p, int newmsgs, int oldmsgs, const char *vmexten) |
| Notify user of messages waiting in voicemail (RFC3842). | |
| static int | transmit_notify_with_sipfrag (struct sip_pvt *p, int cseq, char *message, int terminate) |
| Notify a transferring party of the status of transfer (RFC3515). | |
| static int | transmit_provisional_response (struct sip_pvt *p, const char *msg, const struct sip_request *req, int with_sdp) |
| static int | transmit_refer (struct sip_pvt *p, const char *dest) |
| Transmit SIP REFER message (initiated by the transfer() dialplan application. | |
| static int | transmit_register (struct sip_registry *r, int sipmethod, const char *auth, const char *authheader) |
| Transmit register to SIP proxy or UA auth = NULL on the initial registration (from sip_reregister()). | |
| static int | transmit_reinvite_with_sdp (struct sip_pvt *p, int t38version, int oldsdp) |
| Transmit reinvite with SDP. | |
| static int | transmit_request (struct sip_pvt *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch) |
| Transmit generic SIP request returns XMIT_ERROR if transmit failed with a critical error (don't retry). | |
| static int | transmit_request_with_auth (struct sip_pvt *p, int sipmethod, int seqno, enum xmittype reliable, int newbranch) |
| Transmit SIP request, auth added. | |
| static int | transmit_response (struct sip_pvt *p, const char *msg, const struct sip_request *req) |
| Transmit response, no retransmits. | |
| static int | transmit_response_reliable (struct sip_pvt *p, const char *msg, const struct sip_request *req) |
| Transmit response, Make sure you get an ACK This is only used for responses to INVITEs, where we need to make sure we get an ACK. | |
| static int | transmit_response_using_temp (ast_string_field callid, struct sockaddr_in *sin, int useglobal_nat, const int intended_method, const struct sip_request *req, const char *msg) |
| Transmit response, no retransmits, using a temporary pvt structure. | |
| static int | transmit_response_with_allow (struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable) |
| Append Accept header, content length before transmitting response. | |
| static int | transmit_response_with_auth (struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *randdata, enum xmittype reliable, const char *header, int stale) |
| Respond with authorization request. | |
| static int | transmit_response_with_date (struct sip_pvt *p, const char *msg, const struct sip_request *req) |
| Append date and content length before transmitting response. | |
| static int | transmit_response_with_minse (struct sip_pvt *p, const char *msg, const struct sip_request *req, int minse_int) |
| Transmit 422 response with Min-SE header (Session-Timers). | |
| static int | transmit_response_with_sdp (struct sip_pvt *p, const char *msg, const struct sip_request *req, enum xmittype reliable, int oldsdp) |
| Used for 200 OK and 183 early media. | |
| static int | transmit_response_with_t38_sdp (struct sip_pvt *p, char *msg, struct sip_request *req, int retrans) |
| Used for 200 OK and 183 early media. | |
| static int | transmit_response_with_unsupported (struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *unsupported) |
| Transmit response, no retransmits. | |
| static int | transmit_state_notify (struct sip_pvt *p, int state, int full, int timeout) |
| Used in the SUBSCRIBE notification subsystem (RFC3265). | |
| static void | try_suggested_sip_codec (struct sip_pvt *p) |
| Try setting codec suggested by the SIP_CODEC channel variable. | |
| static void | unlink_all_peers_from_tables (void) |
| static void | unlink_marked_peers_from_tables (void) |
| static void | unlink_peer_from_tables (struct sip_peer *peer) |
| static void | unlink_peers_from_tables (peer_unlink_flag_t flag) |
| static int | unload_module (void) |
| PBX unload module API. | |
| static void * | unref_peer (struct sip_peer *peer, char *tag) |
| static int | update_call_counter (struct sip_pvt *fup, int event) |
| update_call_counter: Handle call_limit for SIP devices Setting a call-limit will cause calls above the limit not to be accepted. | |
| static void | update_peer (struct sip_peer *p, int expire) |
| Update peer data in database (if used). | |
| static void | update_provisional_keepalive (struct sip_pvt *pvt, int with_sdp) |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Session Initiation Protocol (SIP)" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } |
| static char * | app_dtmfmode = "SIPDtmfMode" |
| static char * | app_sipaddheader = "SIPAddHeader" |
| static char * | app_sipremoveheader = "SIPRemoveHeader" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static struct sip_auth * | authl = NULL |
| Authentication list for realm authentication. | |
| static int | authlimit = DEFAULT_AUTHLIMIT |
| static int | authtimeout = DEFAULT_AUTHTIMEOUT |
| static struct sockaddr_in | bindaddr |
| static unsigned int | chan_idx |
| static struct ast_threadstorage | check_auth_buf = { .once = PTHREAD_ONCE_INIT , .key_init = __init_check_auth_buf , .custom_init = NULL , } |
| static struct ast_custom_function | checksipdomain_function |
| static struct ast_cli_entry | cli_sip [] |
| SIP Cli commands definition. | |
| static const char | config [] = "sip.conf" |
| static struct sockaddr_in | debugaddr |
| static int | default_expiry = DEFAULT_DEFAULT_EXPIRY |
| static struct ast_jb_conf | default_jbconf |
| Global jitterbuffer configuration - by default, jb is disabled. | |
| static struct ast_tls_config | default_tls_cfg |
| Default TLS connection configuration. | |
| struct ao2_container * | dialogs |
| Here we implement the container for dialogs (sip_pvt), defining generic wrapper functions to ease the transition from the current implementation (a single linked list) to a different container. In addition to a reference to the container, we need functions to lock/unlock the container and individual items, and functions to add/remove references to the individual items. | |
| static struct _map_x_s | dtmfstr [] |
| mapping between dtmf flags and strings | |
| static time_t | externexpire |
| static char | externhost [MAXHOSTNAMELEN] |
| static struct sockaddr_in | externip |
| our external IP address/port for SIP sessions. externip.sin_addr is only set when we know we might be behind a NAT, and this is done using a variety of (mutually exclusive) ways from the config file: | |
| static int | externrefresh = 10 |
| static struct _map_x_s | faxecmodes [] |
| static struct ast_ha * | global_contact_ha = NULL |
| Global list of addresses dynamic peers are not allowed to use. | |
| static struct ast_jb_conf | global_jbconf |
| static const int | HASH_DIALOG_SIZE = 563 |
| static const int | HASH_PEER_SIZE = 563 |
| static struct _map_x_s | insecurestr [] |
| static struct sockaddr_in | internip |
| our (internal) default address/port to put in SIP/SDP messages internip is initialized picking a suitable address from one of the interfaces, and the same port number we bind to. It is used as the default address/port in SIP messages, and as the default address (but not port) in SDP messages. | |
| static struct invstate2stringtable | invitestate2string [] |
| Readable descriptions of device states. | |
| static struct ast_ha * | localaddr |
| List of local networks We store "localnet" addresses from the config file into an access list, marked as 'DENY', so the call to ast_apply_ha() will return AST_SENSE_DENY for 'local' addresses, and AST_SENSE_ALLOW for 'non local' (i.e. presumably public) addresses. | |
| static char | mandescr_show_peer [] |
| static char | mandescr_show_peers [] |
| static char | mandescr_show_registry [] |
| Manager Action SIPShowRegistry description. | |
| static char | mandescr_sipnotify [] |
| static int | max_expiry = DEFAULT_MAX_EXPIRY |
| static int | min_expiry = DEFAULT_MIN_EXPIRY |
| static int | mwi_expiry = DEFAULT_MWI_EXPIRY |
| static struct _map_x_s | natmodes [] |
| static const char | notify_config [] = "sip_notify.conf" |
| static struct ast_config * | notify_types = NULL |
| static int | ourport_tcp |
| static int | ourport_tls |
| struct ao2_container * | peers |
| The peer list: Users, Peers and Friends. | |
| struct ao2_container * | peers_by_ip |
| static struct _map_x_s | referstatusstrings [] |
| static struct ast_register_list | regl |
| The register list: Other SIP proxies we register with and place calls to. | |
| static struct _map_x_s | regstatestrings [] |
| static struct ast_custom_function | sip_header_function |
| static struct cfsip_methods | sip_methods [] |
| The core structure to setup dialogs. We parse incoming messages by using structure and then route the messages according to the type. | |
| static struct cfsip_options | sip_options [] |
| List of well-known SIP options. If we get this in a require, we should check the list and answer accordingly. | |
| static struct ast_rtp_protocol | sip_rtp |
| Interface structure with callbacks used to connect to RTP module. | |
| static struct ast_tcptls_session_args | sip_tcp_desc |
| The TCP server definition. | |
| static struct ast_channel_tech | sip_tech |
| Definition of this channel for PBX channel registration. | |
| static struct ast_channel_tech | sip_tech_info |
| This version of the sip channel tech has no send_digit_begin callback so that the core knows that the channel does not want DTMF BEGIN frames. The struct is initialized just before registering the channel driver, and is for use with channels using SIP INFO DTMF. | |
| static struct ast_tls_config | sip_tls_cfg |
| Working TLS connection configuration. | |
| static struct ast_tcptls_session_args | sip_tls_desc |
| The TCP/TLS server definition. | |
| static struct ast_udptl_protocol | sip_udptl |
| Interface structure with callbacks used to connect to UDPTL module. | |
| static struct ast_custom_function | sipchaninfo_function |
| Structure to declare a dialplan function: SIPCHANINFO. | |
| static enum sip_debug_e | sipdebug |
| static int | sipdebug_text |
| extra debugging for 'text' related events. At the moment this is set together with sip_debug_console. | |
| static struct ast_custom_function | sippeer_function |
| Structure to declare a dialplan function: SIPPEER. | |
| static int | sipsock = -1 |
| Main socket for UDP SIP communication. | |
| static struct _map_x_s | stmodes [] |
| Report Peer status in character string. | |
| static struct _map_x_s | strefreshers [] |
| static struct sockaddr_in | stunaddr |
| static struct ast_subscription_mwi_list | submwil |
| The MWI subscription list. | |
| static struct cfsubscription_types | subscription_types [] |
Subscription types that we support. We support
| |
| static struct ao2_container * | threadt |
| static struct ast_threadstorage | ts_temp_pvt = { .once = PTHREAD_ONCE_INIT , .key_init = __init_ts_temp_pvt , .custom_init = temp_pvt_init , } |
| static int | unauth_sessions = 0 |
DefaultSettings | |
| static char | default_callerid [AST_MAX_EXTENSION] |
| static char | default_fromdomain [AST_MAX_EXTENSION] |
| static char | default_language [MAX_LANGUAGE] |
| static int | default_maxcallbitrate |
| static char | default_mohinterpret [MAX_MUSICCLASS] |
| static char | default_mohsuggest [MAX_MUSICCLASS] |
| static char | default_notifymime [AST_MAX_EXTENSION] |
| static char | default_parkinglot [AST_MAX_CONTEXT] |
| static struct ast_codec_pref | default_prefs |
| static unsigned int | default_primary_transport |
| static int | default_qualify |
| static unsigned int | default_transports |
| static char | default_vmexten [AST_MAX_EXTENSION] |
GlobalSettings | |
Global settings apply to the channel (often settings you can change in the general section of sip.conf | |
| static int | dumphistory |
| static int | global_authfailureevents |
| static int | global_autoframing |
| static int | global_callcounter |
| static int | global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263 |
| Codecs that we support by default:. | |
| static unsigned int | global_cos_audio |
| static unsigned int | global_cos_sip |
| static unsigned int | global_cos_text |
| static unsigned int | global_cos_video |
| static int | global_dynamic_exclude_static = 0 |
| static int | global_match_auth_username |
| static int | global_max_se |
| static int | global_min_se |
| static int | global_prematuremediafilter |
| static int | global_qualify_gap |
| static int | global_qualify_peers |
| static int | global_qualifyfreq |
| static int | global_reg_timeout |
| static int | global_regattempts_max |
| static char | global_regcontext [AST_MAX_CONTEXT] |
| static int | global_relaxdtmf |
| static int | global_rtpholdtimeout |
| static int | global_rtpkeepalive |
| static int | global_rtptimeout |
| static char | global_sdpowner [AST_MAX_EXTENSION] |
| static char | global_sdpsession [AST_MAX_EXTENSION] |
| static int | global_shrinkcallerid |
| static enum st_mode | global_st_mode |
| static enum st_refresher | global_st_refresher |
| static int | global_t1 |
| static int | global_t1min |
| static int | global_timer_b |
| static unsigned int | global_tos_audio |
| static unsigned int | global_tos_sip |
| static unsigned int | global_tos_text |
| static unsigned int | global_tos_video |
| static char | global_useragent [AST_MAX_EXTENSION] |
| static int | recordhistory |
| static struct sip_settings | sip_cfg |
See Also: Implementation of RFC 3261 - without S/MIME, and experimental TCP and TLS support Configuration file sip.conf
********** IMPORTANT *
A new INVITE is sent to handle_request_invite(), that will end up starting a new channel in the PBX, the new channel after that executing in a separate channel thread. This is an incoming "call". When the call is answered, either by a bridged channel or the PBX itself the sip_answer() function is called.
The actual media - Video or Audio - is mostly handled by the RTP subsystem in rtp.c
Definition in file chan_sip.c.
| #define ALLOWED_METHODS "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO" |
SIP Methods we support.
Definition at line 955 of file chan_sip.c.
Referenced by respprep(), transmit_invite(), transmit_notify_with_sipfrag(), transmit_refer(), and transmit_reinvite_with_sdp().
| #define append_history | ( | p, | |||
| event, | |||||
| fmt, | |||||
| args... | ) | append_history_full(p, "%-15s " fmt, event, ## args) |
Append to SIP dialog history.
Definition at line 2507 of file chan_sip.c.
Referenced by __sip_autodestruct(), __sip_reliable_xmit(), auto_congest(), build_reply_digest(), cb_extensionstate(), change_hold_state(), check_auth(), do_register_auth(), handle_invite_replaces(), handle_request_bye(), handle_request_do(), handle_request_invite(), handle_request_refer(), handle_request_register(), handle_request_subscribe(), handle_response(), handle_response_invite(), local_attended_transfer(), obproxy_get(), pvt_set_needdestroy(), retrans_pkt(), send_request(), send_response(), sip_cancel_destroy(), sip_fixup(), sip_hangup(), sip_new(), sip_park_thread(), sip_reregister(), sip_scheddestroy(), sip_set_rtp_peer(), transmit_register(), transmit_reinvite_with_sdp(), and transmit_response_with_auth().
| #define CALLERID_UNKNOWN "Anonymous" |
| #define CHECK_AUTH_BUF_INITLEN 256 |
Definition at line 13179 of file chan_sip.c.
Referenced by check_auth(), and transmit_fake_auth_response().
| #define check_request_transport | ( | peer, | |||
| tmpl | ) |
generic function for determining if a correct transport is being used to contact a peer
this is done as a macro so that the "tmpl" var can be passed either a sip_request or a sip_peer
Definition at line 2414 of file chan_sip.c.
Referenced by create_addr_from_peer(), and register_verify().
| #define DEC_CALL_LIMIT 0 |
Definition at line 1165 of file chan_sip.c.
Referenced by __sip_destroy(), handle_request_cancel(), handle_request_invite(), handle_response_invite(), sip_hangup(), and update_call_counter().
| #define DEC_CALL_RINGING 2 |
Definition at line 1167 of file chan_sip.c.
Referenced by handle_response_invite(), and update_call_counter().
| #define DEFAULT_ALLOW_EXT_DOM TRUE |
| #define DEFAULT_ALLOWGUEST TRUE |
| #define DEFAULT_ALWAYSAUTHREJECT FALSE |
Don't reject authentication requests always
Definition at line 1006 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_AUTHLIMIT 100 |
| #define DEFAULT_AUTHTIMEOUT 30 |
| #define DEFAULT_AUTOCREATEPEER FALSE |
Don't create peers automagically
Definition at line 1002 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_CALLCOUNTER FALSE |
| #define DEFAULT_CALLERID "asterisk" |
| #define DEFAULT_CALLEVENTS FALSE |
Extra manager SIP call events
Definition at line 1005 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_COMPACTHEADERS FALSE |
Send compact (one-character) SIP headers. Default off
Definition at line 988 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_CONTEXT "default" |
The default context for [general] section as well as devices
Definition at line 978 of file chan_sip.c.
| #define DEFAULT_COS_AUDIO 5 |
Level 2 class of service for audio media
Definition at line 994 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_COS_SIP 4 |
Level 2 class of service for SIP signalling
Definition at line 993 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_COS_TEXT 5 |
Level 2 class of service for text media (T.140)
Definition at line 996 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_COS_VIDEO 6 |
Level 2 class of service for video media
Definition at line 995 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_DEFAULT_EXPIRY 120 |
| #define DEFAULT_EXPIRY 900 |
Expire slowly
Definition at line 517 of file chan_sip.c.
| #define DEFAULT_FREQ_NOTOK 10 * 1000 |
Qualification: How often to check, if the host is down...
Definition at line 533 of file chan_sip.c.
| #define DEFAULT_MATCHEXTERNIPLOCALLY FALSE |
Match extern IP locally default setting
Definition at line 1003 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_MAX_CALL_BITRATE (384) |
| #define DEFAULT_MAX_EXPIRY 3600 |
| #define DEFAULT_MAX_FORWARDS "70" |
Definition at line 502 of file chan_sip.c.
Referenced by initreqprep(), reqprep(), and transmit_register().
| #define DEFAULT_MAX_SE 1800 |
Session-Timer Default Session-Expires period (RFC 4028)
Definition at line 552 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_MAXMS 2000 |
Qualification: Must be faster than 2 seconds by default
Definition at line 531 of file chan_sip.c.
| #define DEFAULT_MIN_EXPIRY 60 |
| #define DEFAULT_MIN_SE 90 |
Session-Timer Default Min-SE period (RFC 4028)
Definition at line 553 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_MOHINTERPRET "default" |
| #define DEFAULT_MOHSUGGEST "" |
| #define DEFAULT_MWI_EXPIRY 3600 |
| #define DEFAULT_NOTIFYCID DISABLED |
Include CID with ringing notifications
Definition at line 1000 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_NOTIFYMIME "application/simple-message-summary" |
| #define DEFAULT_NOTIFYRINGING TRUE |
Notify devicestate system on ringing state
Definition at line 999 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_PEDANTIC FALSE |
Avoid following SIP standards for dialog matching
Definition at line 1001 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_QUALIFY FALSE |
| #define DEFAULT_QUALIFY_GAP 100 |
| #define DEFAULT_QUALIFY_PEERS 1 |
| #define DEFAULT_QUALIFYFREQ 60 * 1000 |
Qualification: How often to check for the host to be up
Definition at line 532 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_REALM "asterisk" |
Realm for HTTP digest authentication
Definition at line 998 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_REGEXTENONQUALIFY FALSE |
| #define DEFAULT_REGISTRATION_TIMEOUT 20 |
| #define DEFAULT_RETRANS 1000 |
How frequently to retransmit Default: 2 * 500 ms in RFC 3261
Definition at line 535 of file chan_sip.c.
| #define DEFAULT_RTPKEEPALIVE 0 |
Default RTPkeepalive setting
Definition at line 985 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_SDPOWNER "root" |
Default SDP username field in (o=) header unless re-defined in sip.conf
Definition at line 1013 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_SDPSESSION "Asterisk PBX" |
Default SDP session name, (s=) header unless re-defined in sip.conf
Definition at line 1012 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_SRVLOOKUP TRUE |
| #define DEFAULT_T1MIN 100 |
100 MS for minimal roundtrip time
Definition at line 1008 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_TIMER_T1 500 |
SIP timer T1 (according to RFC 3261)
Definition at line 537 of file chan_sip.c.
Referenced by reload_config().
| #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.
Definition at line 990 of file chan_sip.c.
Referenced by reload_config().
| #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.
Definition at line 989 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_TOS_TEXT 0 |
Text packets should be marked as XXXX XXXX, but the default is 0 to be compatible with previous versions.
Definition at line 992 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_TOS_VIDEO 0 |
Video packets should be marked as DSCP AF41, but the default is 0 to be compatible with previous versions.
Definition at line 991 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_TRANS_TIMEOUT -1 |
Use default SIP transaction timeout
Definition at line 541 of file chan_sip.c.
Referenced by __sip_autodestruct(), auto_congest(), cb_extensionstate(), check_auth(), check_pendings(), handle_incoming(), handle_invite_replaces(), handle_request_bye(), handle_request_cancel(), handle_request_info(), handle_request_invite(), handle_request_notify(), handle_request_options(), handle_request_register(), handle_response_invite(), handle_response_register(), receive_message(), sip_hangup(), sip_send_mwi_to_peer(), and transmit_fake_auth_response().
| #define DEFAULT_USERAGENT "Asterisk PBX" |
Default Useragent: header unless re-defined in sip.conf
Definition at line 1011 of file chan_sip.c.
Referenced by reload_config().
| #define DEFAULT_VMEXTEN "asterisk" |
Default voicemail extension
Definition at line 981 of file chan_sip.c.
Referenced by reload_config().
| #define EXPIRY_GUARD_LIMIT 30 |
Below here, we use EXPIRY_GUARD_PCT instead of EXPIRY_GUARD_SECS
Definition at line 509 of file chan_sip.c.
Referenced by handle_response_register().
| #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.
Definition at line 511 of file chan_sip.c.
Referenced by handle_response_register().
| #define EXPIRY_GUARD_PCT 0.20 |
Percentage of expires timeout to use when below EXPIRY_GUARD_LIMIT
Definition at line 515 of file chan_sip.c.
Referenced by handle_response_register().
| #define EXPIRY_GUARD_SECS 15 |
How long before expiry do we reregister
Definition at line 508 of file chan_sip.c.
Referenced by handle_response_register().
| #define FALSE 0 |
Definition at line 477 of file chan_sip.c.
| #define FINDALLDEVICES (FINDUSERS | FINDPEERS) |
Definition at line 487 of file chan_sip.c.
Referenced by check_peer_ok(), find_by_name(), find_peer(), sip_devicestate(), sip_peer_hold(), and update_call_counter().
| #define FINDPEERS (1 << 1) |
Definition at line 486 of file chan_sip.c.
Referenced by _sip_qualify_peer(), _sip_show_peer(), check_peer_ok(), create_addr(), find_by_name(), find_peer(), function_sippeer(), register_verify(), sip_do_debug_peer(), sip_unregister(), st_get_mode(), st_get_refresher(), st_get_se(), and transmit_register().
| #define FINDUSERS (1 << 0) |
Definition at line 485 of file chan_sip.c.
Referenced by check_peer_ok(), find_by_name(), find_peer(), and sip_show_user().
| #define FORMAT "%-15.15s %-15.15s %-15.15s %-15.15s %-3.3s %-3.3s %-15.15s %-10.10s\n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT "%-30.30s %-12.12s %-10.10s %-10.10s\n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT "%-15.15s %-11.11s %-8.8s %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.6u %-10.10u%-1.1s %-10.10u (%5.2f%%) %-6.6u\n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT "%-30.30s %-6.6s %-12.12s %8d %-20.20s %-25.25s\n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT "%-40.40s %-20.20s %-16.16s\n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-8d %-10s %s\n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT "%-25.25s %-15.15s %-15.15s %-15.15s %-5.5s%-10.10s\n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT "%-30.30s %-6d %-9.9s %-6.6s\n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT "%-25.25s %-15.15s %-15.15s \n" |
Definition at line 16850 of file chan_sip.c.
| #define FORMAT2 "%-15.15s %-15.15s %-15.15s %-15.15s %-7.7s %-15.15s %-6.6s\n" |
Definition at line 16849 of file chan_sip.c.
| #define FORMAT2 "%-15.15s %-11.11s %-8.8s %-10.10s %-10.10s ( %%) %-6.6s %-10.10s %-10.10s ( %%) %-6.6s\n" |
Definition at line 16849 of file chan_sip.c.
| #define FORMAT2 "%-30.30s %-6.6s %-12.12s %8.8s %-20.20s %-25.25s\n" |
Definition at line 16849 of file chan_sip.c.
| #define FORMAT2 "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-8s %-10s %s\n" |
Definition at line 16849 of file chan_sip.c.
| #define FORMAT2 "%-30.30s %3.6s %9.9s %6.6s\n" |
Definition at line 16849 of file chan_sip.c.
| #define FORMAT2 "%-25.25s %-15.15s %-15.15s \n" |
Definition at line 16849 of file chan_sip.c.
| #define FORMAT3 "%-15.15s %-15.15s %-15.15s %-15.15s %-13.13s %-15.15s %-10.10s %-6.6s\n" |
| #define FORMAT4 "%-15.15s %-15.15s %-15.15s %-15.15s %-13.13s %-15.15s %-10.10s %-6.6d\n" |
| #define FROMDOMAIN_INVALID "anonymous.invalid" |
| #define INC_CALL_LIMIT 1 |
Definition at line 1166 of file chan_sip.c.
Referenced by handle_request_invite(), and update_call_counter().
| #define INC_CALL_RINGING 3 |
| #define INITIAL_CSEQ 101 |
Our initial sip sequence number
Definition at line 550 of file chan_sip.c.
Referenced by sip_alloc(), sip_register(), and transmit_response_using_temp().
| #define IS_SIP_TECH | ( | t | ) | ((t) == &sip_tech || (t) == &sip_tech_info) |
Definition at line 2741 of file chan_sip.c.
Referenced by acf_channel_read(), func_header_read(), function_sipchaninfo_read(), handle_request_bye(), sip_dtmfmode(), and sip_hangup().
| #define MAX_AUTHTRIES 3 |
Try authentication three times, then fail
Definition at line 543 of file chan_sip.c.
Referenced by handle_response(), handle_response_invite(), and handle_response_register().
| #define MAX_HISTORY_ENTRIES 50 |
Max entires in the history list for a sip_pvt
Definition at line 548 of file chan_sip.c.
Referenced by append_history_va().
| #define MAX_RETRANS 6 |
Try only 6 times for retransmissions, a total of 7 transmissions
Definition at line 536 of file chan_sip.c.
| #define NO_RTP 0 |
Definition at line 576 of file chan_sip.c.
| #define NOT_SUPPORTED 0 |
Definition at line 870 of file chan_sip.c.
| #define PROVIS_KEEPALIVE_TIMEOUT 60000 |
How long to wait before retransmitting a provisional response (rfc 3261 13.3.1.1)
Definition at line 542 of file chan_sip.c.
Referenced by send_provisional_keepalive_full(), and update_provisional_keepalive().
| #define REQ_OFFSET_TO_STR | ( | req, | |||
| offset | ) | (ast_str_buffer((req)->data) + ((req)->offset)) |
Definition at line 1233 of file chan_sip.c.
Referenced by __get_header(), _sip_tcp_helper_thread(), find_sdp(), get_body(), get_destination(), get_msg_text(), get_sdp_iterate(), get_sdp_line(), handle_incoming(), handle_request_do(), handle_request_invite(), reqprep(), and send_response().
| #define RTP 1 |
Definition at line 575 of file chan_sip.c.
| #define SDP_MAX_RTPMAP_CODECS 32 |
Maximum number of codecs allowed in received SDP
Definition at line 555 of file chan_sip.c.
Referenced by process_sdp_a_audio(), process_sdp_a_text(), and process_sdp_a_video().
| #define SIP_CALL_LIMIT (1 << 7) |
D: Call limit enforced for this call
Definition at line 1327 of file chan_sip.c.
Referenced by check_peer_ok(), create_addr_from_peer(), and update_call_counter().
| #define SIP_DEFER_BYE_ON_TRANSFER (1 << 10) |
D: Do not hangup at first ast_hangup
Definition at line 1330 of file chan_sip.c.
Referenced by handle_invite_replaces(), handle_request_refer(), local_attended_transfer(), sip_hangup(), and sip_set_rtp_peer().
| #define SIP_DIRECT_MEDIA (1 << 20) |
DP: allow peers to be reinvited to send media directly p2p
Definition at line 1355 of file chan_sip.c.
Referenced by _sip_show_peer(), handle_common_options(), reload_config(), sip_get_rtp_peer(), sip_get_trtp_peer(), sip_get_udptl_peer(), and sip_get_vrtp_peer().
| #define SIP_DIRECT_MEDIA_NAT (2 << 20) |
DP: allow media reinvite when new peer is behind NAT
Definition at line 1356 of file chan_sip.c.
Referenced by handle_common_options(), sip_get_rtp_peer(), and sip_set_rtp_peer().
| #define SIP_DTMF (7 << 15) |
DP: DTMF Support: five settings, uses three bits
Definition at line 1338 of file chan_sip.c.
Referenced by _sip_show_peer(), check_peer_ok(), create_addr_from_peer(), handle_common_options(), handle_request_invite(), process_sdp(), sip_alloc(), sip_dtmfmode(), sip_new(), sip_rtp_read(), sip_senddigit_begin(), sip_senddigit_end(), sip_show_channel(), sip_show_settings(), and transmit_info_with_digit().
| #define SIP_DTMF_AUTO (3 << 15) |
DP: DTMF Support: AUTO switch between rfc2833 and in-band DTMF
Definition at line 1342 of file chan_sip.c.
Referenced by check_peer_ok(), create_addr_from_peer(), handle_common_options(), process_sdp(), sip_alloc(), and sip_new().
| #define SIP_DTMF_INBAND (1 << 15) |
DP: DTMF Support: Inband audio, only for ULAW/ALAW - "inband"
Definition at line 1340 of file chan_sip.c.
Referenced by handle_common_options(), process_sdp(), sip_dtmfmode(), sip_new(), sip_rtp_read(), sip_senddigit_begin(), and sip_senddigit_end().
| #define SIP_DTMF_INFO (2 << 15) |
DP: DTMF Support: SIP Info messages - "info"
Definition at line 1341 of file chan_sip.c.
Referenced by handle_common_options(), sip_dtmfmode(), sip_new(), and sip_senddigit_end().
| #define SIP_DTMF_RFC2833 (0 << 15) |
DP: DTMF Support: RTP DTMF - "rfc2833"
Definition at line 1339 of file chan_sip.c.
Referenced by check_peer_ok(), create_addr_from_peer(), handle_common_options(), handle_request_invite(), process_sdp(), reload_config(), sip_alloc(), sip_dtmfmode(), sip_rtp_read(), sip_senddigit_begin(), and sip_senddigit_end().
| #define SIP_DTMF_SHORTINFO (4 << 15) |
DP: DTMF Support: SIP Info messages - "info" - short variant
Definition at line 1343 of file chan_sip.c.
Referenced by handle_common_options(), sip_dtmfmode(), sip_new(), sip_senddigit_end(), and transmit_info_with_digit().
| #define SIP_FLAGS_TO_COPY |
Value:
(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \ SIP_PROG_INBAND | SIP_USECLIENTCODE | SIP_NAT | SIP_G726_NONSTANDARD | \ SIP_USEREQPHONE | SIP_INSECURE)
Definition at line 1375 of file chan_sip.c.
Referenced by check_peer_ok(), create_addr_from_peer(), set_peer_defaults(), sip_alloc(), and sip_poke_peer().
| #define SIP_G726_NONSTANDARD (1 << 31) |
DP: Use non-standard packing for G726-32 data
Definition at line 1372 of file chan_sip.c.
Referenced by add_codec_to_sdp(), handle_common_options(), and process_sdp_a_audio().
| #define SIP_GOTREFER (1 << 6) |
D: Got a refer?
Definition at line 1326 of file chan_sip.c.
Referenced by handle_request_refer(), local_attended_transfer(), sip_set_rtp_peer(), and sip_set_udptl_peer().
| #define SIP_INC_COUNT (1 << 8) |
D: Did this dialog increment the counter of in-use calls?
Definition at line 1328 of file chan_sip.c.
Referenced by __sip_destroy(), handle_request_cancel(), sip_hangup(), and update_call_counter().
| #define SIP_INC_RINGING (1 << 9) |
D: Did this connection increment the counter of in-use calls?
Definition at line 1329 of file chan_sip.c.
Referenced by update_call_counter().
| #define SIP_INSECURE (3 << 23) |
DP: three settings, uses two bits
Definition at line 1360 of file chan_sip.c.
Referenced by _sip_show_peer(), and handle_common_options().
| #define SIP_INSECURE_INVITE (1 << 24) |
DP: don't require authentication for incoming INVITEs
Definition at line 1363 of file chan_sip.c.
Referenced by check_peer_ok(), and set_insecure_flags().
| #define SIP_INSECURE_NONE (0 << 23) |
DP: secure mode
Definition at line 1361 of file chan_sip.c.
| #define SIP_INSECURE_PORT (1 << 23) |
DP: don't require matching port for incoming requests
Definition at line 1362 of file chan_sip.c.
Referenced by find_peer(), get_insecure_variable_from_config(), peer_ipcmp_cb(), and set_insecure_flags().
| #define SIP_MAX_HEADERS 64 |
Max amount of SIP headers to read
Definition at line 545 of file chan_sip.c.
Referenced by add_header(), and parse_request().
| #define SIP_MAX_LINES 256 |
Max amount of lines in SIP attachment (like SDP)
Definition at line 546 of file chan_sip.c.
Referenced by parse_request().
| #define SIP_MIN_PACKET 4096 |
Initialize size of memory to allocate for packets
Definition at line 547 of file chan_sip.c.
Referenced by _sip_tcp_helper_thread(), init_req(), init_resp(), and sipsock_read().
| #define SIP_NAT (3 << 18) |
DP: four settings, uses two bits
Definition at line 1346 of file chan_sip.c.
Referenced by _sip_show_peer(), build_via(), copy_via_headers(), create_addr(), create_addr_from_peer(), display_nat_warning(), handle_common_options(), process_sdp(), register_verify(), sip_alloc(), sip_nat_mode(), sip_real_dst(), sip_show_channel(), sip_show_settings(), sip_show_users(), and transmit_response_using_temp().
| #define SIP_NAT_ALWAYS (3 << 18) |
DP: NAT Both ROUTE and RFC3581
Definition at line 1350 of file chan_sip.c.
Referenced by copy_via_headers(), handle_common_options(), and reload_config().
| #define SIP_NAT_NEVER (0 << 18) |
DP: No nat support
Definition at line 1347 of file chan_sip.c.
Referenced by handle_common_options().
| #define SIP_NAT_RFC3581 (1 << 18) |
DP: NAT RFC3581
Definition at line 1348 of file chan_sip.c.
Referenced by build_via(), copy_via_headers(), and handle_common_options().
| #define SIP_NAT_ROUTE (2 << 18) |
DP: NAT Only ROUTE
Definition at line 1349 of file chan_sip.c.
Referenced by _sip_show_peers(), build_peer(), check_peer_ok(), check_user_full(), create_addr(), create_addr_from_peer(), handle_common_options(), parse_register_contact(), send_request(), set_address_from_contact(), sip_alloc(), sip_nat_mode(), sip_real_dst(), and transmit_response_using_temp().
| #define SIP_NEEDREINVITE (1 << 4) |
D: Do we need to send another reinvite?
Definition at line 1324 of file chan_sip.c.
Referenced by check_pendings(), interpret_t38_parameters(), sip_hangup(), sip_reinvite_retry(), sip_sendhtml(), sip_set_rtp_peer(), and sip_set_udptl_peer().
| #define SIP_OPT_100REL (1 << 1) |
Definition at line 874 of file chan_sip.c.
| #define SIP_OPT_EARLY_SESSION (1 << 3) |
Definition at line 876 of file chan_sip.c.
| #define SIP_OPT_EVENTLIST (1 << 11) |
Definition at line 884 of file chan_sip.c.
| #define SIP_OPT_FROMCHANGE (1 << 17) |
Definition at line 890 of file chan_sip.c.
| #define SIP_OPT_GRUU (1 << 12) |
Definition at line 885 of file chan_sip.c.
| #define SIP_OPT_HISTINFO (1 << 15) |
Definition at line 888 of file chan_sip.c.
| #define SIP_OPT_JOIN (1 << 4) |
Definition at line 877 of file chan_sip.c.
| #define SIP_OPT_NOREFERSUB (1 << 14) |
Definition at line 887 of file chan_sip.c.
| #define SIP_OPT_OUTBOUND (1 << 20) |
Definition at line 893 of file chan_sip.c.
| #define SIP_OPT_PATH (1 << 5) |
Definition at line 878 of file chan_sip.c.
| #define SIP_OPT_PRECONDITION (1 << 7) |
Definition at line 880 of file chan_sip.c.
| #define SIP_OPT_PREF (1 << 6) |
Definition at line 879 of file chan_sip.c.
| #define SIP_OPT_PRIVACY (1 << 8) |
Definition at line 881 of file chan_sip.c.
| #define SIP_OPT_RECLISTINV (1 << 18) |
Definition at line 891 of file chan_sip.c.
| #define SIP_OPT_RECLISTSUB (1 << 19) |
Definition at line 892 of file chan_sip.c.
| #define SIP_OPT_REPLACES (1 << 0) |
| #define SIP_OPT_RESPRIORITY (1 << 16) |
Definition at line 889 of file chan_sip.c.
| #define SIP_OPT_SDP_ANAT (1 << 9) |
Definition at line 882 of file chan_sip.c.
| #define SIP_OPT_SEC_AGREE (1 << 10) |
Definition at line 883 of file chan_sip.c.
| #define SIP_OPT_TARGET_DIALOG (1 << 13) |
Definition at line 886 of file chan_sip.c.
| #define SIP_OPT_TIMER (1 << 2) |
| #define SIP_OPT_UNKNOWN (1 << 21) |
| #define SIP_OUTGOING (1 << 0) |
D: Direction of the last transaction in this dialog
Definition at line 1321 of file chan_sip.c.
Referenced by __sip_subscribe_mwi_do(), handle_request_bye(), handle_request_invite(), handle_request_refer(), handle_response(), handle_response_invite(), manager_sipnotify(), reqprep(), respprep(), sip_call(), sip_cli_notify(), sip_hangup(), sip_indicate(), sip_poke_peer(), sip_send_mwi_to_peer(), sip_show_channel(), sip_write(), transmit_refer(), transmit_register(), transmit_reinvite_with_sdp(), and transmit_response_with_sdp().
| #define SIP_PAGE2_ALLOWOVERLAP (1 << 17) |
DP: Allow overlap dialing ?
Definition at line 1396 of file chan_sip.c.
Referenced by _sip_show_peer(), get_destination(), handle_common_options(), handle_request_invite(), reload_config(), and sip_show_settings().
| #define SIP_PAGE2_ALLOWSUBSCRIBE (1 << 16) |
GP: Allow subscriptions from this peer?
Definition at line 1395 of file chan_sip.c.
Referenced by _sip_show_peer(), build_peer(), handle_common_options(), handle_request_subscribe(), reload_config(), and sip_show_settings().
| #define SIP_PAGE2_BUGGY_MWI (1 << 26) |
DP: Buggy CISCO MWI fix
Definition at line 1411 of file chan_sip.c.
Referenced by handle_common_options(), and transmit_notify_with_mwi().
| #define SIP_PAGE2_CALL_ONHOLD (3 << 23) |
D: Call hold states:
Definition at line 1405 of file chan_sip.c.
Referenced by __sip_destroy(), add_sdp(), change_hold_state(), check_rtp_timeout(), handle_request_cancel(), handle_request_invite(), process_sdp(), show_channels_cb(), sip_hangup(), and update_call_counter().
| #define SIP_PAGE2_CALL_ONHOLD_ACTIVE (1 << 23) |
| #define SIP_PAGE2_CALL_ONHOLD_INACTIVE (3 << 23) |
D: Inactive hold
Definition at line 1408 of file chan_sip.c.
Referenced by add_sdp(), and change_hold_state().
| #define SIP_PAGE2_CALL_ONHOLD_ONEDIR (2 << 23) |
D: One directional hold
Definition at line 1407 of file chan_sip.c.
Referenced by add_sdp(), and change_hold_state().
| #define SIP_PAGE2_DIALOG_ESTABLISHED (1 << 27) |
29: Has a dialog been established?
Definition at line 1412 of file chan_sip.c.
Referenced by find_call_cb(), handle_request_bye(), handle_request_invite(), handle_request_subscribe(), handle_response(), handle_response_invite(), and sip_answer().
| #define SIP_PAGE2_FAX_DETECT (3 << 28) |
DP: Fax Detection support
Definition at line 1413 of file chan_sip.c.
Referenced by handle_common_options(), reload_config(), sip_new(), and sip_rtp_read().
| #define SIP_PAGE2_FAX_DETECT_BOTH (3 << 28) |
DP: Fax Detection support - detect both
Definition at line 1416 of file chan_sip.c.
Referenced by handle_common_options().
| #define SIP_PAGE2_FAX_DETECT_CNG (1 << 28) |
DP: Fax Detection support - detect CNG in audio
Definition at line 1414 of file chan_sip.c.
Referenced by handle_common_options(), and sip_read().
| #define SIP_PAGE2_FAX_DETECT_T38 (2 << 28) |
DP: Fax Detection support - detect T.38 reinvite from peer
Definition at line 1415 of file chan_sip.c.
Referenced by handle_common_options(), process_sdp(), and sip_call().
| #define SIP_PAGE2_FLAGS_TO_COPY |
Value:
(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_HAVEPEERCONTEXT | SIP_PAGE2_FORWARD_LOOP_DETECTED)
Definition at line 1421 of file chan_sip.c.
Referenced by check_peer_ok(), create_addr_from_peer(), set_peer_defaults(), sip_alloc(), and sip_poke_peer().
| #define SIP_PAGE2_FORWARD_LOOP_DETECTED (1 << 8) |
31: Do call forward when receiving 482 Loop Detected
Definition at line 1389 of file chan_sip.c.
Referenced by _sip_show_peer(), handle_response(), handle_t38_options(), reload_config(), and sip_show_settings().
| #define SIP_PAGE2_HAVEPEERCONTEXT (1 << 3) |
| #define SIP_PAGE2_IGNORESDPVERSION (1 << 19) |
GDP: Ignore the SDP session version number we receive and treat all sessions as new
Definition at line 1398 of file chan_sip.c.
Referenced by _sip_show_peer(), handle_common_options(), process_sdp_o(), reload_config(), and sip_show_settings().
| #define SIP_PAGE2_REGISTERTRYING (1 << 29) |
DP: Send 100 Trying on REGISTER attempts
Definition at line 1417 of file chan_sip.c.
Referenced by _sip_show_peer(), build_peer(), and register_verify().
| #define SIP_PAGE2_RFC2833_COMPENSATE (1 << 25) |
DP: Compensate for buggy RFC2833 implementations
Definition at line 1410 of file chan_sip.c.
Referenced by create_addr_from_peer(), handle_common_options(), handle_request_invite(), process_sdp(), sip_alloc(), and sip_show_settings().
| #define SIP_PAGE2_RPORT_PRESENT (1 << 10) |
Was rport received in the Via header?
Definition at line 1392 of file chan_sip.c.
Referenced by check_user_full(), and check_via().
| #define SIP_PAGE2_RTAUTOCLEAR (1 << 2) |
GP: Should we clean memory from peers after expiry?
Definition at line 1386 of file chan_sip.c.
Referenced by expire_register(), realtime_peer(), reload_config(), and sip_show_settings().
| #define SIP_PAGE2_RTCACHEFRIENDS (1 << 0) |
GP: Should we keep RT objects in memory for extended time?
Definition at line 1385 of file chan_sip.c.
Referenced by build_peer(), parse_register_contact(), realtime_peer(), reload_config(), sip_destroy_peer(), sip_prune_realtime(), sip_show_settings(), and update_peer().
| #define SIP_PAGE2_STATECHANGEQUEUE (1 << 9) |
D: Unsent state pending change exists
Definition at line 1390 of file chan_sip.c.
Referenced by cb_extensionstate(), handle_response(), and handle_response_notify().
| #define SIP_PAGE2_SUBSCRIBEMWIONLY (1 << 18) |
GP: Only issue MWI notification if subscribed to
Definition at line 1397 of file chan_sip.c.
Referenced by build_peer(), handle_request_subscribe(), register_verify(), and sip_send_mwi_to_peer().
| #define SIP_PAGE2_T38SUPPORT (3 << 20) |
GDP: T.38 Fax Support
Definition at line 1400 of file chan_sip.c.
Referenced by _sip_show_peer(), check_peer_ok(), create_addr_from_peer(), handle_request_invite(), handle_t38_options(), interpret_t38_parameters(), set_t38_capabilities(), sip_alloc(), sip_queryoption(), and sip_show_settings().
| #define SIP_PAGE2_T38SUPPORT_UDPTL (1 << 20) |
GDP: T.38 Fax Support (no error correction)
Definition at line 1401 of file chan_sip.c.
Referenced by handle_t38_options(), and set_t38_capabilities().
| #define SIP_PAGE2_T38SUPPORT_UDPTL_FEC (2 << 20) |
GDP: T.38 Fax Support (FEC error correction)
Definition at line 1402 of file chan_sip.c.
Referenced by handle_t38_options(), and set_t38_capabilities().
| #define SIP_PAGE2_T38SUPPORT_UDPTL_REDUNDANCY (3 << 20) |
GDP: T.38 Fax Support (redundancy error correction)
Definition at line 1403 of file chan_sip.c.
Referenced by handle_t38_options(), and set_t38_capabilities().
| #define SIP_PAGE2_TEXTSUPPORT (1 << 15) |
GDP: Global text enable
Definition at line 1394 of file chan_sip.c.
Referenced by _sip_show_peer(), _sip_show_peers(), check_peer_ok(), create_addr_from_peer(), handle_common_options(), reload_config(), sip_alloc(), and sip_show_settings().
| #define SIP_PAGE2_UDPTL_DESTINATION (1 << 30) |
DP: Use source IP of RTP as destination if NAT is enabled
Definition at line 1418 of file chan_sip.c.
Referenced by handle_t38_options(), and process_sdp().
| #define SIP_PAGE2_VIDEOSUPPORT (1 << 14) |
DP: Video supported if offered?
Definition at line 1393 of file chan_sip.c.
Referenced by _sip_show_peer(), _sip_show_peers(), check_peer_ok(), create_addr_from_peer(), handle_common_options(), reload_config(), sip_alloc(), sip_new(), and sip_show_settings().
| #define SIP_PAGE2_VIDEOSUPPORT_ALWAYS (1 << 31) |
DP: Always set up video, even if endpoints don't support it
Definition at line 1419 of file chan_sip.c.
Referenced by _sip_show_peer(), check_peer_ok(), create_addr_from_peer(), handle_common_options(), reload_config(), and sip_alloc().
| #define SIP_PENDINGBYE (1 << 5) |
D: Need to send bye after we ack?
Definition at line 1325 of file chan_sip.c.
Referenced by check_pendings(), handle_response_invite(), interpret_t38_parameters(), register_verify(), sip_hangup(), sip_sendhtml(), sip_set_rtp_peer(), and sip_set_udptl_peer().
| #define SIP_PROG_INBAND (3 << 25) |
DP: three settings, uses two bits
Definition at line 1366 of file chan_sip.c.
Referenced by handle_common_options(), sip_indicate(), and sip_show_settings().
| #define SIP_PROG_INBAND_NEVER (0 << 25) |
| #define SIP_PROG_INBAND_NO (1 << 25) |
Definition at line 1368 of file chan_sip.c.
Referenced by handle_common_options(), and sip_show_settings().
| #define SIP_PROG_INBAND_YES (2 << 25) |
Definition at line 1369 of file chan_sip.c.
Referenced by handle_common_options(), and sip_indicate().
| #define SIP_PROGRESS_SENT (1 << 3) |
D: Have sent 183 message progress
Definition at line 1323 of file chan_sip.c.
Referenced by sip_indicate(), and sip_write().
| #define SIP_PROMISCREDIR (1 << 11) |
DP: Promiscuous redirection
Definition at line 1332 of file chan_sip.c.
Referenced by _sip_show_peer(), handle_common_options(), parse_moved_contact(), sip_show_channel(), and sip_show_settings().
| #define sip_pvt_lock | ( | x | ) | ao2_lock(x) |
Definition at line 1747 of file chan_sip.c.
Referenced by __sip_ack(), __sip_autodestruct(), auto_congest(), cb_extensionstate(), check_rtp_timeout(), complete_sipch(), find_call(), get_sip_pvt_byid_locked(), handle_invite_replaces(), handle_request_bye(), handle_request_invite(), proc_session_timer(), retrans_pkt(), scheduler_process_request_queue(), sip_answer(), sip_dtmfmode(), sip_fixup(), sip_get_rtp_peer(), sip_get_trtp_peer(), sip_get_udptl_peer(), sip_get_vrtp_peer(), sip_hangup(), sip_indicate(), sip_new(), sip_park(), sip_queryoption(), sip_read(), sip_reg_timeout(), sip_reinvite_retry(), sip_request_call(), sip_senddigit_begin(), sip_senddigit_end(), sip_set_rtp_peer(), sip_set_udptl_peer(), sip_show_channel(), sip_show_history(), sip_t38_abort(), sip_transfer(), sip_write(), and update_call_counter().
| #define sip_pvt_trylock | ( | x | ) | ao2_trylock(x) |
Definition at line 1748 of file chan_sip.c.
Referenced by dialog_needdestroy(), find_call(), and sip_hangup().
| #define sip_pvt_unlock | ( | x | ) | ao2_unlock(x) |
Definition at line 1749 of file chan_sip.c.
Referenced by __sip_ack(), __sip_autodestruct(), auto_congest(), cb_extensionstate(), check_rtp_timeout(), complete_sipch(), dialog_needdestroy(), get_sip_pvt_byid_locked(), handle_invite_replaces(), handle_request_bye(), handle_request_do(), handle_request_invite(), local_attended_transfer(), proc_session_timer(), retrans_pkt(), scheduler_process_request_queue(), sip_answer(), sip_dtmfmode(), sip_fixup(), sip_get_rtp_peer(), sip_get_trtp_peer(), sip_get_udptl_peer(), sip_get_vrtp_peer(), sip_hangup(), sip_indicate(), sip_new(), sip_park(), sip_queryoption(), sip_read(), sip_reg_timeout(), sip_reinvite_retry(), sip_request_call(), sip_senddigit_begin(), sip_senddigit_end(), sip_set_rtp_peer(), sip_set_udptl_peer(), sip_show_channel(), sip_show_history(), sip_t38_abort(), sip_transfer(), sip_write(), and update_call_counter().
| #define SIP_REINVITE (7 << 20) |
DP: four settings, uses three bits
Definition at line 1353 of file chan_sip.c.
Referenced by handle_common_options().
| #define SIP_REINVITE_NONE (0 << 20) |
DP: no reinvite allowed
Definition at line 1354 of file chan_sip.c.
| #define SIP_REINVITE_UPDATE (4 << 20) |
DP: use UPDATE (RFC3311) when reinviting this peer
Definition at line 1357 of file chan_sip.c.
Referenced by handle_common_options(), and transmit_reinvite_with_sdp().
| #define SIP_RESERVED ";/?:@&=+$,# " |
Reserved characters in the username part of the URI
Definition at line 493 of file chan_sip.c.
| #define SIP_RINGING (1 << 2) |
| #define SIP_SENDRPID (1 << 29) |
DP: Remote Party-ID Support
Definition at line 1371 of file chan_sip.c.
Referenced by _sip_show_peer(), handle_common_options(), and initreqprep().
| #define SIP_TRANS_TIMEOUT 64 * DEFAULT_TIMER_T1 |
SIP request timeout (rfc 3261) 64*T1
Definition at line 538 of file chan_sip.c.
Referenced by manager_sipnotify(), sip_cli_notify(), and sip_sipredirect().
| #define SIP_TRUSTRPID (1 << 12) |
DP: Trust RPID headers?
Definition at line 1333 of file chan_sip.c.
Referenced by _sip_show_peer(), handle_common_options(), and replace_cid().
| #define SIP_USECLIENTCODE (1 << 14) |
DP: Trust X-ClientCode info message
Definition at line 1335 of file chan_sip.c.
Referenced by handle_common_options(), handle_request_info(), and sip_show_settings().
| #define SIP_USEREQPHONE (1 << 13) |
DP: Add user=phone to numeric URI. Default off
Definition at line 1334 of file chan_sip.c.
Referenced by _sip_show_peer(), build_peer(), initreqprep(), reload_config(), and sip_show_settings().
| #define SIPBUFSIZE 512 |
Buffer size for many operations
Definition at line 489 of file chan_sip.c.
Referenced by add_route(), add_sdp(), build_contact(), extract_uri(), handle_request_refer(), initreqprep(), parse_moved_contact(), parse_ok_contact(), parse_register_contact(), process_sdp(), respprep(), show_channels_cb(), sip_call(), sip_new(), sip_show_channel(), sip_show_settings(), transmit_invite(), and transmit_notify_with_sipfrag().
| #define STANDARD_SIP_PORT 5060 |
Standard SIP unsecure port for UDP and TCP from RFC 3261. DO NOT CHANGE THIS.
Definition at line 958 of file chan_sip.c.
Referenced by __set_address_from_contact(), build_peer(), check_via(), create_addr(), manager_show_registry(), parse_register_contact(), process_via(), proxy_allocate(), reload_config(), set_destination(), set_peer_defaults(), sip_parse_host(), sip_register(), sip_show_mwi(), sip_show_registry(), sip_standard_port(), and transmit_register().
| #define STANDARD_TLS_PORT 5061 |
Standard SIP TLS port from RFC 3261. DO NOT CHANGE THIS.
Definition at line 960 of file chan_sip.c.
Referenced by __set_address_from_contact(), build_peer(), create_addr(), parse_register_contact(), reload_config(), set_destination(), sip_parse_host(), sip_register(), and sip_standard_port().
| #define SUPPORTED 1 |
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
Definition at line 869 of file chan_sip.c.
| #define TRUE 1 |
Definition at line 481 of file chan_sip.c.
| #define UNLINK | ( | element, | |||
| head, | |||||
| prev | ) |
some list management macros.
Definition at line 2240 of file chan_sip.c.
Referenced by __sip_ack(), handle_request_cancel(), and retrans_pkt().
| #define XMIT_ERROR -2 |
Definition at line 491 of file chan_sip.c.
Referenced by __sip_reliable_xmit(), __sip_xmit(), handle_response_invite(), retrans_pkt(), sip_call(), sip_poke_peer(), and sip_tcptls_write().
| enum can_create_dialog |
States whether a SIP message can create a dialog in Asterisk.
Definition at line 785 of file chan_sip.c.
00785 { 00786 CAN_NOT_CREATE_DIALOG, 00787 CAN_CREATE_DIALOG, 00788 CAN_CREATE_DIALOG_UNSUPPORTED_METHOD, 00789 };
| enum check_auth_result |
Authentication result from check_auth* functions.
Definition at line 685 of file chan_sip.c.
00685 { 00686 AUTH_DONT_KNOW = -100, /*!< no result, need to check further */ 00687 /* XXX maybe this is the same as AUTH_NOT_FOUND */ 00688 00689 AUTH_SUCCESSFUL = 0, 00690 AUTH_CHALLENGE_SENT = 1, 00691 AUTH_SECRET_FAILED = -1, 00692 AUTH_USERNAME_MISMATCH = -2, 00693 AUTH_NOT_FOUND = -3, /*!< returned by register_verify */ 00694 AUTH_FAKE_AUTH = -4, 00695 AUTH_UNKNOWN_DOMAIN = -5, 00696 AUTH_PEER_NOT_DYNAMIC = -6, 00697 AUTH_ACL_FAILED = -7, 00698 AUTH_BAD_TRANSPORT = -8, 00699 };
| enum domain_mode |
Modes for SIP domain handling in the PBX.
| SIP_DOMAIN_AUTO | This domain is auto-configured |
| SIP_DOMAIN_CONFIG | This domain is from configuration |
Definition at line 1275 of file chan_sip.c.
01275 { 01276 SIP_DOMAIN_AUTO, /*!< This domain is auto-configured */ 01277 SIP_DOMAIN_CONFIG, /*!< This domain is from configuration */ 01278 };
| enum invitestates |
States for the INVITE transaction, not the dialog.
| INV_NONE | No state at all, maybe not an INVITE dialog |
| INV_CALLING | Invite sent, no answer |
| INV_PROCEEDING | We got/sent 1xx message |
| INV_EARLY_MEDIA | We got 18x message with to-tag back |
| INV_COMPLETED | Got final response with error. Wait for ACK, then CONFIRMED |
| INV_CONFIRMED | Confirmed response - we've got an ack (Incoming calls only) |
| INV_TERMINATED | 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 | Transaction cancelled by client or server in non-terminated state |
Definition at line 597 of file chan_sip.c.
00597 { 00598 INV_NONE = 0, /*!< No state at all, maybe not an INVITE dialog */ 00599 INV_CALLING = 1, /*!< Invite sent, no answer */ 00600 INV_PROCEEDING = 2, /*!< We got/sent 1xx message */ 00601 INV_EARLY_MEDIA = 3, /*!< We got 18x message with to-tag back */ 00602 INV_COMPLETED = 4, /*!< Got final response with error. Wait for ACK, then CONFIRMED */ 00603 INV_CONFIRMED = 5, /*!< Confirmed response - we've got an ack (Incoming calls only) */ 00604 INV_TERMINATED = 6, /*!< Transaction done - either successful (AST_STATE_UP) or failed, but done 00605 The only way out of this is a BYE from one side */ 00606 INV_CANCELLED = 7, /*!< Transaction cancelled by client or server in non-terminated state */ 00607 };
| enum media_type |
| enum notifycid_setting |
Settings for the 'notifycid' option, see sip.conf.sample for details.
Definition at line 822 of file chan_sip.c.
00822 { 00823 DISABLED = 0, 00824 ENABLED = 1, 00825 IGNORE_CONTEXT = 2, 00826 };
Results from the parse_register() function.
Definition at line 636 of file chan_sip.c.
00636 { 00637 PARSE_REGISTER_DENIED, 00638 PARSE_REGISTER_FAILED, 00639 PARSE_REGISTER_UPDATE, 00640 PARSE_REGISTER_QUERY, 00641 };
| enum peer_unlink_flag_t |
Definition at line 3319 of file chan_sip.c.
03319 { 03320 SIP_PEERS_MARKED, 03321 SIP_PEERS_ALL, 03322 } peer_unlink_flag_t;
| enum referstatus |
Parameters to know status of transfer.
| REFER_IDLE | No REFER is in progress |
| REFER_SENT | Sent REFER to transferee |
| REFER_RECEIVED | Received REFER from transferrer |
| REFER_CONFIRMED | Refer confirmed with a 100 TRYING (unused) |
| 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 |
Definition at line 1466 of file chan_sip.c.
01466 { 01467 REFER_IDLE, /*!< No REFER is in progress */ 01468 REFER_SENT, /*!< Sent REFER to transferee */ 01469 REFER_RECEIVED, /*!< Received REFER from transferrer */ 01470 REFER_CONFIRMED, /*!< Refer confirmed with a 100 TRYING (unused) */ 01471 REFER_ACCEPTED, /*!< Accepted by transferee */ 01472 REFER_RINGING, /*!< Target Ringing */ 01473 REFER_200OK, /*!< Answered by transfer target */ 01474 REFER_FAILED, /*!< REFER declined - go on */ 01475 REFER_NOAUTH /*!< We had no auth for REFER */ 01476 };
| enum sip_auth_type |
Authentication types - proxy or www authentication.
Definition at line 679 of file chan_sip.c.
00679 { 00680 PROXY_AUTH = 407, 00681 WWW_AUTH = 401, 00682 };
| enum sip_debug_e |
debugging state We store separately the debugging requests from the config file and requests from the CLI. Debugging is enabled if either is set (which means that if sipdebug is set in the config file, we can only turn it off by reloading the config).
Definition at line 1436 of file chan_sip.c.
01436 { 01437 sip_debug_none = 0, 01438 sip_debug_config = 1, 01439 sip_debug_console = 2, 01440 };
| enum sip_peer_type |
Definition at line 1830 of file chan_sip.c.
01830 { 01831 SIP_TYPE_PEER = (1 << 0), 01832 SIP_TYPE_USER = (1 << 1), 01833 };
| enum sip_result |
The result of a lot of functions.
Definition at line 589 of file chan_sip.c.
00589 { 00590 AST_SUCCESS = 0, /*!< FALSE means success, funny enough */ 00591 AST_FAILURE = -1, /*!< Failure code */ 00592 };
| enum sip_tcptls_alert |
| TCPTLS_ALERT_DATA | There is new data to be sent out. |
| TCPTLS_ALERT_STOP | A request to stop the tcp_handler thread. |
Definition at line 1976 of file chan_sip.c.
01976 { 01977 /*! \brief There is new data to be sent out */ 01978 TCPTLS_ALERT_DATA, 01979 /*! \brief A request to stop the tcp_handler thread */ 01980 TCPTLS_ALERT_STOP, 01981 };
| enum sip_transport |
Define some implemented SIP transports.
| SIP_TRANSPORT_UDP | Unreliable transport for SIP, needs retransmissions |
| SIP_TRANSPORT_TCP | Reliable, but unsecure |
| SIP_TRANSPORT_TLS | TCP/TLS - reliable and secure transport for signalling |
Definition at line 754 of file chan_sip.c.
00754 { 00755 SIP_TRANSPORT_UDP = 1, /*!< Unreliable transport for SIP, needs retransmissions */ 00756 SIP_TRANSPORT_TCP = 1 << 1, /*!< Reliable, but unsecure */ 00757 SIP_TRANSPORT_TLS = 1 << 2, /*!< TCP/TLS - reliable and secure transport for signalling */ 00758 };
| enum sipmethod |
SIP Request methods known by Asterisk.
Definition at line 801 of file chan_sip.c.
00801 { 00802 SIP_UNKNOWN, /*!< Unknown response */ 00803 SIP_RESPONSE, /*!< Not request, response to outbound request */ 00804 SIP_REGISTER, /*!< Registration to the mothership, tell us where you are located */ 00805 SIP_OPTIONS, /*!< Check capabilities of a device, used for "ping" too */ 00806 SIP_NOTIFY, /*!< Status update, Part of the event package standard, result of a SUBSCRIBE or a REFER */ 00807 SIP_INVITE, /*!< Set up a session */ 00808 SIP_ACK, /*!< End of a three-way handshake started with INVITE. */ 00809 SIP_PRACK, /*!< Reliable pre-call signalling. Not supported in Asterisk. */ 00810 SIP_BYE, /*!< End of a session */ 00811 SIP_REFER, /*!< Refer to another URI (transfer) */ 00812 SIP_SUBSCRIBE, /*!< Subscribe for updates (voicemail, session status, device status, presence) */ 00813 SIP_MESSAGE, /*!< Text messaging */ 00814 SIP_UPDATE, /*!< Update a dialog. We can send UPDATE; but not accept it */ 00815 SIP_INFO, /*!< Information updates during a session */ 00816 SIP_CANCEL, /*!< Cancel an INVITE */ 00817 SIP_PUBLISH, /*!< Not supported in Asterisk */ 00818 SIP_PING, /*!< Not supported at all, no standard but still implemented out there */ 00819 };
| enum sipregistrystate |
States for outbound registrations (with register= lines in sip.conf.
| REG_STATE_UNREGISTERED |
We are not registered
|
| REG_STATE_REGSENT |
Registration request sent
|
| REG_STATE_AUTHSENT |
We have tried to authenticate
|
| REG_STATE_REGISTERED | Registered 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
|
Definition at line 702 of file chan_sip.c.
00702 { 00703 REG_STATE_UNREGISTERED = 0, /*!< We are not registered 00704 * \note Initial state. We should have a timeout scheduled for the initial 00705 * (or next) registration transmission, calling sip_reregister 00706 */ 00707 00708 REG_STATE_REGSENT, /*!< Registration request sent 00709 * \note sent initial request, waiting for an ack or a timeout to 00710 * retransmit the initial request. 00711 */ 00712 00713 REG_STATE_AUTHSENT, /*!< We have tried to authenticate 00714 * \note entered after transmit_register with auth info, 00715 * waiting for an ack. 00716 */ 00717 00718 REG_STATE_REGISTERED, /*!< Registered and done */ 00719 00720 REG_STATE_REJECTED, /*!< Registration rejected * 00721 * \note only used when the remote party has an expire larger than 00722 * our max-expire. This is a final state from which we do not 00723 * recover (not sure how correctly). 00724 */ 00725 00726 REG_STATE_TIMEOUT, /*!< Registration timed out * 00727 * \note XXX unused */ 00728 00729 REG_STATE_NOAUTH, /*!< We have no accepted credentials 00730 * \note fatal - no chance to proceed */ 00731 00732 REG_STATE_FAILED, /*!< Registration failed after several tries 00733 * \note fatal - no chance to proceed */ 00734 };
| enum st_mode |
Modes in which Asterisk can be configured to run SIP Session-Timers.
| SESSION_TIMER_MODE_INVALID | 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 |
Definition at line 737 of file chan_sip.c.
00737 { 00738 SESSION_TIMER_MODE_INVALID = 0, /*!< Invalid value */ 00739 SESSION_TIMER_MODE_ACCEPT, /*!< Honor inbound Session-Timer requests */ 00740 SESSION_TIMER_MODE_ORIGINATE, /*!< Originate outbound and honor inbound requests */ 00741 SESSION_TIMER_MODE_REFUSE /*!< Ignore inbound Session-Timers requests */ 00742 };
| enum st_refresher |
The entity playing the refresher role for Session-Timers.
| 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 |
Definition at line 745 of file chan_sip.c.
00745 { 00746 SESSION_TIMER_REFRESHER_AUTO, /*!< Negotiated */ 00747 SESSION_TIMER_REFRESHER_UAC, /*!< Session is refreshed by the UAC */ 00748 SESSION_TIMER_REFRESHER_UAS /*!< Session is refreshed by the UAS */ 00749 };
| enum subscriptiontype |
Type of subscription, based on the packages we do support, see subscription_types.
Definition at line 644 of file chan_sip.c.
00644 { 00645 NONE = 0, 00646 XPIDF_XML, 00647 DIALOG_INFO_XML, 00648 CPIM_PIDF_XML, 00649 PIDF_XML, 00650 MWI_NOTIFICATION 00651 };
| enum t38_action_flag |
| SDP_T38_NONE | Do not modify T38 information at all |
| SDP_T38_INITIATE | Remote side has requested T38 with us |
| SDP_T38_ACCEPT | Remote side accepted our T38 request |
Definition at line 2247 of file chan_sip.c.
02247 { 02248 SDP_T38_NONE = 0, /*!< Do not modify T38 information at all */ 02249 SDP_T38_INITIATE, /*!< Remote side has requested T38 with us */ 02250 SDP_T38_ACCEPT, /*!< Remote side accepted our T38 request */ 02251 };
| enum t38state |
T38 States for a call.
| T38_DISABLED | Not enabled |
| T38_LOCAL_REINVITE | Offered from local - REINVITE |
| T38_PEER_REINVITE | Offered from peer - REINVITE |
| T38_ENABLED | Negotiated (enabled) |
Definition at line 1451 of file chan_sip.c.
01451 { 01452 T38_DISABLED = 0, /*!< Not enabled */ 01453 T38_LOCAL_REINVITE, /*!< Offered from local - REINVITE */ 01454 T38_PEER_REINVITE, /*!< Offered from peer - REINVITE */ 01455 T38_ENABLED /*!< Negotiated (enabled) */ 01456 };
| enum transfermodes |
Authorization scheme for call transfers.
Definition at line 582 of file chan_sip.c.
00582 { 00583 TRANSFER_OPENFORALL, /*!< Allow all SIP transfers */ 00584 TRANSFER_CLOSED, /*!< Allow no SIP transfers */ 00585 };
| enum xmittype |
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.
| XMIT_CRITICAL | Transmit critical SIP message reliably, with re-transmits. If it fails, it's critical and will cause a teardown of the session |
| XMIT_RELIABLE | Transmit SIP message reliably, with re-transmits |
| XMIT_UNRELIABLE | Transmit SIP message without bothering with re-transmits |
Definition at line 628 of file chan_sip.c.
00628 { 00629 XMIT_CRITICAL = 2, /*!< Transmit critical SIP message reliably, with re-transmits. 00630 If it fails, it's critical and will cause a teardown of the session */ 00631 XMIT_RELIABLE = 1, /*!< Transmit SIP message reliably, with re-transmits */ 00632 XMIT_UNRELIABLE = 0, /*!< Transmit SIP message without bothering with re-transmits */ 00633 };
| static const char * __get_header | ( | const struct sip_request * | req, | |
| const char * | name, | |||
| int * | start | |||
| ) | [static] |
Definition at line 7224 of file chan_sip.c.
References ast_skip_blanks(), find_alias(), sip_request::header, sip_request::headers, pass, sip_settings::pedanticsipchecking, REQ_OFFSET_TO_STR, and sip_cfg.
07225 { 07226 int pass; 07227 07228 /* 07229 * Technically you can place arbitrary whitespace both before and after the ':' in 07230 * a header, although RFC3261 clearly says you shouldn't before, and place just 07231 * one afterwards. If you shouldn't do it, what absolute idiot decided it was 07232 * a good idea to say you can do it, and if you can do it, why in the hell would. 07233 * you say you shouldn't. 07234 * Anyways, pedanticsipchecking controls whether we allow spaces before ':', 07235 * and we always allow spaces after that for compatibility. 07236 */ 07237 for (pass = 0; name && pass < 2;pass++) { 07238 int x, len = strlen(name); 07239 for (x = *start; x < req->headers; x++) { 07240 char *header = REQ_OFFSET_TO_STR(req, header[x]); 07241 if (!strncasecmp(header, name, len)) { 07242 char *r = header + len; /* skip name */ 07243 if (sip_cfg.pedanticsipchecking) 07244 r = ast_skip_blanks(r); 07245 07246 if (*r == ':') { 07247 *start = x+1; 07248 return ast_skip_blanks(r+1); 07249 } 07250 } 07251 } 07252 if (pass == 0) /* Try aliases */ 07253 name = find_alias(name, NULL); 07254 } 07255 07256 /* Don't return NULL, so get_header is always a valid pointer */ 07257 return ""; 07258 }
| static void __init_check_auth_buf | ( | void | ) | [static] |
| static void __init_ts_temp_pvt | ( | void | ) | [static] |
| static void __reg_module | ( | void | ) | [static] |
Definition at line 26863 of file chan_sip.c.
| static int __set_address_from_contact | ( | const char * | fullcontact, | |
| struct sockaddr_in * | sin, | |||
| int | tcp | |||
| ) | [static] |
Definition at line 12759 of file chan_sip.c.
References ast_copy_string(), ast_gethostbyname(), ast_log(), get_transport_str2enum(), hp, LOG_WARNING, parse_uri(), port_str2int(), SIP_TRANSPORT_TLS, STANDARD_SIP_PORT, and STANDARD_TLS_PORT.
Referenced by build_peer(), and set_address_from_contact().
12760 { 12761 struct hostent *hp; 12762 struct ast_hostent ahp; 12763 int port = STANDARD_SIP_PORT; 12764 char *host, *pt, *transport; 12765 char contact_buf[256]; 12766 char *contact; 12767 12768 /* Work on a copy */ 12769 ast_copy_string(contact_buf, fullcontact, sizeof(contact_buf)); 12770 contact = contact_buf; 12771 12772 /* 12773 * We have only the part in <brackets> here so we just need to parse a SIP URI. 12774 * 12775 * Note: The outbound proxy could be using UDP between the proxy and Asterisk. 12776 * We still need to be able to send to the remote agent through the proxy. 12777 */ 12778 12779 if (parse_uri(contact, "sip:,sips:", &contact, NULL, &host, &pt, NULL, &transport)) { 12780 ast_log(LOG_WARNING, "Invalid contact uri %s (missing sip: or sips:), attempting to use anyway\n", fullcontact); 12781 } 12782 12783 /* set port */ 12784 if (((get_transport_str2enum(transport) == SIP_TRANSPORT_TLS)) || !(strncasecmp(fullcontact, "sips", 4))) { 12785 port = port_str2int(pt, STANDARD_TLS_PORT); 12786 } else { 12787 port = port_str2int(pt, STANDARD_SIP_PORT); 12788 } 12789 12790 12791 /* XXX This could block for a long time XXX */ 12792 /* We should only do this if it's a name, not an IP */ 12793 /* \todo - if there's no PORT number in contact - we are required to check NAPTR/SRV records 12794 to find transport, port address and hostname. If there's a port number, we have to 12795 assume that the domain part is a host name and only look for an A/AAAA record in DNS. 12796 */ 12797 hp = ast_gethostbyname(host, &ahp); 12798 if (!hp) { 12799 ast_log(LOG_WARNING, "Invalid host name in Contact: (can't resolve in DNS) : '%s'\n", host); 12800 return -1; 12801 } 12802 sin->sin_family = AF_INET; 12803 memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr)); 12804 sin->sin_port = htons(port); 12805 12806 return 0; 12807 }
| static int __sip_ack | ( | struct sip_pvt * | p, | |
| int | seqno, | |||
| int | resp, | |||
| int | sipmethod | |||
| ) | [static] |
Acknowledges receipt of a packet and stops retransmission called with p locked.
Definition at line 4312 of file chan_sip.c.
References ast_debug, ast_free, ast_sched_del(), sip_pvt::callid, sip_pkt::data, dialog_unref(), FALSE, sip_proxy::force, sip_pkt::is_resp, sip_pkt::method, msg, sip_pkt::next, sip_pvt::outboundproxy, sip_pkt::owner, sip_pvt::packets, sip_pvt::pendinginvite, ref_proxy(), sip_pkt::retransid, sip_pkt::seqno, sip_pvt_lock, sip_pvt_unlock, TRUE, and UNLINK.
Referenced by __sip_pretend_ack(), handle_incoming(), handle_request_invite(), and handle_response().
04313 { 04314 struct sip_pkt *cur, *prev = NULL; 04315 const char *msg = "Not Found"; /* used only for debugging */ 04316 int res = FALSE; 04317 04318 /* If we have an outbound proxy for this dialog, then delete it now since 04319 the rest of the requests in this dialog needs to follow the routing. 04320 If obforcing is set, we will keep the outbound proxy during the whole 04321 dialog, regardless of what the SIP rfc says 04322 */ 04323 if (p->outboundproxy && !p->outboundproxy->force){ 04324 ref_proxy(p, NULL); 04325 } 04326 04327 for (cur = p->packets; cur; prev = cur, cur = cur->next) { 04328 if (cur->seqno != seqno || cur->is_resp != resp) 04329 continue; 04330 if (cur->is_resp || cur->method == sipmethod) { 04331 res = TRUE; 04332 msg = "Found"; 04333 if (!resp && (seqno == p->pendinginvite)) { 04334 ast_debug(1, "Acked pending invite %d\n", p->pendinginvite); 04335 p->pendinginvite = 0; 04336 } 04337 if (cur->retransid > -1) { 04338 if (sipdebug) 04339 ast_debug(4, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid); 04340 } 04341 /* This odd section is designed to thwart a 04342 * race condition in the packet scheduler. There are 04343 * two conditions under which deleting the packet from the 04344 * scheduler can fail. 04345 * 04346 * 1. The packet has been removed from the scheduler because retransmission 04347 * is being attempted. The problem is that if the packet is currently attempting 04348 * retransmission and we are at this point in the code, then that MUST mean 04349 * that retrans_pkt is waiting on p's lock. Therefore we will relinquish the 04350 * lock temporarily to allow retransmission. 04351 * 04352 * 2. The packet has reached its maximum number of retransmissions and has 04353 * been permanently removed from the packet scheduler. If this is the case, then 04354 * the packet's retransid will be set to -1. The atomicity of the setting and checking 04355 * of the retransid to -1 is ensured since in both cases p's lock is held. 04356 */ 04357 while (cur->retransid > -1 && ast_sched_del(sched, cur->retransid)) { 04358 sip_pvt_unlock(p); 04359 usleep(1); 04360 sip_pvt_lock(p); 04361 } 04362 UNLINK(cur, p->packets, prev); 04363 dialog_unref(cur->owner, "unref pkt cur->owner dialog from sip ack before freeing pkt"); 04364 if (cur->data) 04365 ast_free(cur->data); 04366 ast_free(cur); 04367 break; 04368 } 04369 } 04370 ast_debug(1, "Stopping retransmission on '%s' of %s %d: Match %s\n", 04371 p->callid, resp ? "Response" : "Request", seqno, msg); 04372 return res; 04373 }
| static int __sip_autodestruct | ( | const void * | data | ) | [static] |
Kill a SIP dialog (called only by the scheduler) The scheduler has a reference to this dialog when p->autokillid != -1, and we are called using that reference. So if the event is not rescheduled, we need to call dialog_unref().
Definition at line 4204 of file chan_sip.c.
References __sip_pretend_ack(), sip_pvt::alreadygone, append_history, AST_CAUSE_PROTOCOL_ERROR, ast_channel_trylock, ast_channel_unlock, ast_debug, AST_EXTENSION_DEACTIVATED, ast_log(), ast_queue_hangup_with_cause(), sip_pvt::autokillid, sip_pvt::callid, DEFAULT_TRANS_TIMEOUT, dialog_unlink_all(), dialog_unref(), sip_pvt::lastmsg, LOG_WARNING, sip_pvt::method, method_match(), sip_pvt::needdestroy, NONE, sip_pvt::owner, sip_pvt::packets, pvt_set_needdestroy(), sip_pvt::refer, SIP_BYE, SIP_CANCEL, sip_methods, sip_pvt_lock, sip_pvt_unlock, sip_scheddestroy(), sip_pvt::subscribed, cfsip_methods::text, transmit_request_with_auth(), transmit_state_notify(), TRUE, and XMIT_RELIABLE.
Referenced by sip_scheddestroy(), and sip_show_sched().
04205 { 04206 struct sip_pvt *p = (struct sip_pvt *)data; 04207 04208 /* If this is a subscription, tell the phone that we got a timeout */ 04209 if (p->subscribed) { 04210 transmit_state_notify(p, AST_EXTENSION_DEACTIVATED, 1, TRUE); /* Send last notification */ 04211 p->subscribed = NONE; 04212 append_history(p, "Subscribestatus", "timeout"); 04213 ast_debug(3, "Re-scheduled destruction of SIP subscription %s\n", p->callid ? p->callid : "<unknown>"); 04214 return 10000; /* Reschedule this destruction so that we know that it's gone */ 04215 } 04216 04217 /* If there are packets still waiting for delivery, delay the destruction */ 04218 if (p->packets) { 04219 if (!p->needdestroy) { 04220 char method_str[31]; 04221 ast_debug(3, "Re-scheduled destruction of SIP call %s\n", p->callid ? p->callid : "<unknown>"); 04222 append_history(p, "ReliableXmit", "timeout"); 04223 if (sscanf(p->lastmsg, "Tx: %30s", method_str) == 1 || sscanf(p->lastmsg, "Rx: %30s", method_str) == 1) { 04224 if (method_match(SIP_CANCEL, method_str) || method_match(SIP_BYE, method_str)) { 04225 pvt_set_needdestroy(p, "autodestruct"); 04226 } 04227 } 04228 return 10000; 04229 } else { 04230 /* They've had their chance to respond. Time to bail */ 04231 __sip_pretend_ack(p); 04232 } 04233 } 04234 04235 /* Reset schedule ID */ 04236 p->autokillid = -1; 04237 04238 04239 /* 04240 * Lock both the pvt and the channel safely so that we can queue up a frame. 04241 */ 04242 sip_pvt_lock(p); 04243 while (p->owner && ast_channel_trylock(p->owner)) { 04244 sip_pvt_unlock(p); 04245 sched_yield(); 04246 sip_pvt_lock(p); 04247 } 04248 04249 if (p->owner) { 04250 ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text); 04251 ast_queue_hangup_with_cause(p->owner, AST_CAUSE_PROTOCOL_ERROR); 04252 ast_channel_unlock(p->owner); 04253 } else if (p->refer && !p->alreadygone) { 04254 ast_debug(3, "Finally hanging up channel after transfer: %s\n", p->callid); 04255 transmit_request_with_auth(p, SIP_BYE, 0, XMIT_RELIABLE, 1); 04256 append_history(p, "ReferBYE", "Sending BYE on transferer call leg %s", p->callid); 04257 sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT); 04258 } else { 04259 append_history(p, "AutoDestroy", "%s", p->callid); 04260 ast_debug(3, "Auto destroying SIP dialog '%s'\n", p->callid); 04261 dialog_unlink_all(p, TRUE, TRUE); /* once it's unlinked and unrefd everywhere, it'll be freed automagically */ 04262 /* dialog_unref(p, "unref dialog-- no other matching conditions"); -- unlink all now should finish off the dialog's references and free it. */ 04263 /* sip_destroy(p); */ /* Go ahead and destroy dialog. All attempts to recover is done */ 04264 /* sip_destroy also absorbs the reference */ 04265 } 04266 04267 sip_pvt_unlock(p); 04268 04269 dialog_unref(p, "The ref to a dialog passed to this sched callback is going out of scope; unref it."); 04270 04271 return 0; 04272 }
| static void __sip_destroy | ( | struct sip_pvt * | p, | |
| int | lockowner, | |||
| int | lockdialoglist | |||
| ) | [static] |
Execute destruction of SIP dialog structure, release memory.
Definition at line 5791 of file chan_sip.c.
References ast_channel::_softhangup, ao2_ref, ast_channel_lock, ast_channel_unlock, ast_debug, ast_free, AST_LIST_REMOVE_HEAD, ast_log(), ast_rtp_destroy(), ast_rtp_get_bridged(), AST_SOFTHANGUP_DEV, ast_string_field_free_memory, ast_test_flag, ast_udptl_destroy(), ast_variables_destroy(), ast_verbose, sip_subscription_mwi::call, sip_registry::call, sip_peer::call, sip_pvt::callid, sip_pvt::chanvars, DEC_CALL_LIMIT, deinit_req(), dialog_unref(), sip_pvt::flags, free_old_route(), sip_pvt::history, sip_pvt::history_entries, sip_pvt::initreq, LOG_DEBUG, sip_pvt::method, sip_pvt::mwi, sip_peer::mwipvt, ast_channel::name, sip_pvt::notify_headers, option_debug, sip_pvt::options, sip_pvt::owner, sip_st_dlg::quit_flag, sip_pvt::refer, sip_pvt::registry, registry_unref(), sip_pvt::relatedpeer, sip_pvt::request_queue, sip_pvt::route, sip_pvt::rtp, sip_debug_test_pvt(), sip_dump_history(), SIP_INC_COUNT, sip_methods, SIP_PAGE2_CALL_ONHOLD, sip_pvt::socket, sip_pvt::stimer, stop_session_timer(), sip_socket::tcptls_session, ast_channel::tech_pvt, cfsip_methods::text, sip_pvt::trtp, sip_pvt::udptl, unref_peer(), update_call_counter(), and sip_pvt::vrtp.
Referenced by sip_destroy().
05792 { 05793 struct sip_request *req; 05794 05795 /* Destroy Session-Timers if allocated */ 05796 if (p->stimer) { 05797 p->stimer->quit_flag = 1; 05798 stop_session_timer(p); 05799 ast_free(p->stimer); 05800 p->stimer = NULL; 05801 } 05802 05803 if (sip_debug_test_pvt(p)) 05804 ast_verbose("Really destroying SIP dialog '%s' Method: %s\n", p->callid, sip_methods[p->method].text); 05805 05806 if (ast_test_flag(&p->flags[0], SIP_INC_COUNT) || ast_test_flag(&p->flags[1], SIP_PAGE2_CALL_ONHOLD)) { 05807 update_call_counter(p, DEC_CALL_LIMIT); 05808 ast_debug(2, "This call did not properly clean up call limits. Call ID %s\n", p->callid); 05809 } 05810 05811 /* Unlink us from the owner if we have one */ 05812 if (p->owner) { 05813 if (lockowner) 05814 ast_channel_lock(p->owner); 05815 if (option_debug) 05816 ast_log(LOG_DEBUG, "Detaching from %s\n", p->owner->name); 05817 p->owner->tech_pvt = NULL; 05818 /* Make sure that the channel knows its backend is going away */ 05819 p->owner->_softhangup |= AST_SOFTHANGUP_DEV; 05820 if (lockowner) 05821 ast_channel_unlock(p->owner); 05822 /* Give the channel a chance to react before deallocation */ 05823 usleep(1); 05824 } 05825 05826 /* Remove link from peer to subscription of MWI */ 05827 if (p->relatedpeer && p->relatedpeer->mwipvt) 05828 p->relatedpeer->mwipvt = dialog_unref(p->relatedpeer->mwipvt, "delete ->relatedpeer->mwipvt"); 05829 if (p->relatedpeer && p->relatedpeer->call == p) 05830 p->relatedpeer->call = dialog_unref(p->relatedpeer->call, "unset the relatedpeer->call field in tandem with relatedpeer field itself"); 05831 05832 if (p->relatedpeer) 05833 p->relatedpeer = unref_peer(p->relatedpeer,"unsetting a dialog relatedpeer field in sip_destroy"); 05834 05835 if (p->registry) { 05836 if (p->registry->call == p) 05837 p->registry->call = dialog_unref(p->registry->call, "nulling out the registry's call dialog field in unlink_all"); 05838 p->registry = registry_unref(p->registry, "delete p->registry"); 05839 } 05840 05841 if (p->mwi) { 05842 p->mwi->call = NULL; 05843 } 05844 05845 if (dumphistory) 05846 sip_dump_history(p); 05847 05848 if (p->options) 05849 ast_free(p->options); 05850 05851 if (p->notify_headers) { 05852 ast_variables_destroy(p->notify_headers); 05853 p->notify_headers = NULL; 05854 } 05855 if (p->rtp) { 05856 ast_rtp_destroy(p->rtp); 05857 } 05858 if (p->vrtp) { 05859 ast_rtp_destroy(p->vrtp); 05860 } 05861 if (p->trtp) { 05862 while (ast_rtp_get_bridged(p->trtp)) 05863 usleep(1); 05864 ast_rtp_destroy(p->trtp); 05865 } 05866 if (p->udptl) 05867 ast_udptl_destroy(p->udptl); 05868 if (p->refer) 05869 ast_free(p->refer); 05870 if (p->route) { 05871 free_old_route(p->route); 05872 p->route = NULL; 05873 } 05874 deinit_req(&p->initreq); 05875 05876 /* Clear history */ 05877 if (p->history) { 05878 struct sip_history *hist; 05879 while ( (hist = AST_LIST_REMOVE_HEAD(p->history, list)) ) { 05880 ast_free(hist); 05881 p->history_entries--; 05882 } 05883 ast_free(p->history); 05884 p->history = NULL; 05885 } 05886 05887 while ((req = AST_LIST_REMOVE_HEAD(&p->request_queue, next))) { 05888 ast_free(req); 05889 } 05890 05891 if (p->chanvars) { 05892 ast_variables_destroy(p->chanvars); 05893 p->chanvars = NULL; 05894 } 05895 05896 ast_string_field_free_memory(p); 05897 05898 if (p->socket.tcptls_session) { 05899 ao2_ref(p->socket.tcptls_session, -1); 05900 p->socket.tcptls_session = NULL; 05901 } 05902 }
| static int __sip_do_register | ( | struct sip_registry * | r | ) | [static] |
Register with SIP proxy.
Definition at line 12073 of file chan_sip.c.
References SIP_REGISTER, and transmit_register().
Referenced by sip_reregister().
12074 { 12075 int res; 12076 12077 res = transmit_register(r, SIP_REGISTER, NULL, NULL); 12078 return res; 12079 }
| static void __sip_pretend_ack | ( | struct sip_pvt * | p | ) | [static] |
Pretend to ack all packets called with p locked.
Definition at line 4377 of file chan_sip.c.
References __sip_ack(), ast_log(), sip_pkt::data, find_sip_method(), sip_pkt::is_resp, LOG_WARNING, sip_pkt::method, sip_request::method, sip_pvt::packets, sip_pkt::seqno, sip_methods, and cfsip_methods::text.
Referenced by __sip_autodestruct(), handle_request_bye(), handle_request_cancel(), and sip_reg_timeout().
04378 { 04379 struct sip_pkt *cur = NULL; 04380 04381 while (p->packets) { 04382 int method; 04383 if (cur == p->packets) { 04384 ast_log(LOG_WARNING, "Have a packet that doesn't want to give up! %s\n", sip_methods[cur->method].text); 04385 return; 04386 } 04387 cur = p->packets; 04388 method = (cur->method) ? cur->method : find_sip_method(cur->data->str); 04389 __sip_ack(p, cur->seqno, cur->is_resp, method); 04390 } 04391 }
| static enum sip_result __sip_reliable_xmit | ( | struct sip_pvt * | p, | |
| int | seqno, | |||
| int | resp, | |||
| struct ast_str * | data, | |||
| int | len, | |||
| int | fatal, | |||
| int | sipmethod | |||
| ) | [static] |
Transmit packet with retransmits.
Definition at line 4125 of file chan_sip.c.
References __sip_xmit(), append_history, ast_calloc, ast_debug, AST_FAILURE, ast_free, ast_log(), AST_SCHED_DEL, AST_SCHED_REPLACE_VARIABLE, ast_str_buffer(), ast_str_create(), ast_str_set(), AST_SUCCESS, sip_pkt::data, DEFAULT_RETRANS, dialog_ref(), dialog_unref(), sip_pkt::is_fatal, sip_pkt::is_resp, LOG_ERROR, sip_pkt::method, sip_pkt::next, sip_pkt::owner, sip_pkt::packetlen, sip_pvt::packets, sip_pvt::pendinginvite, sip_pkt::response_code, retrans_pkt(), sip_pkt::retransid, sip_pkt::seqno, SIP_INVITE, SIP_TRANSPORT_UDP, sip_pvt::socket, sip_pvt::timer_t1, sip_pkt::timer_t1, sip_socket::type, and XMIT_ERROR.
Referenced by send_request(), and send_response().
04126 { 04127 struct sip_pkt *pkt = NULL; 04128 int siptimer_a = DEFAULT_RETRANS; 04129 int xmitres = 0; 04130 int respid; 04131 04132 if (sipmethod == SIP_INVITE) { 04133 /* Note this is a pending invite */ 04134 p->pendinginvite = seqno; 04135 } 04136 04137 /* If the transport is something reliable (TCP or TLS) then don't really send this reliably */ 04138 /* I removed the code from retrans_pkt that does the same thing so it doesn't get loaded into the scheduler */ 04139 /*! \todo According to the RFC some packets need to be retransmitted even if its TCP, so this needs to get revisited */ 04140 if (!(p->socket.type & SIP_TRANSPORT_UDP)) { 04141 xmitres = __sip_xmit(p, data, len); /* Send packet */ 04142 if (xmitres == XMIT_ERROR) { /* Serious network trouble, no need to try again */ 04143 append_history(p, "XmitErr", "%s", fatal ? "(Critical)" : "(Non-critical)"); 04144 return AST_FAILURE; 04145 } else { 04146 return AST_SUCCESS; 04147 } 04148 } 04149 04150 if (!(pkt = ast_calloc(1, sizeof(*pkt)))) 04151 return AST_FAILURE; 04152 /* copy data, add a terminator and save length */ 04153 if (!(pkt->data = ast_str_create(len))) { 04154 ast_free(pkt); 04155 return AST_FAILURE; 04156 } 04157 ast_str_set(&pkt->data, 0, "%s%s", data->str, "\0"); 04158 pkt->packetlen = len; 04159 /* copy other parameters from the caller */ 04160 pkt->method = sipmethod; 04161 pkt->seqno = seqno; 04162 pkt->is_resp = resp; 04163 pkt->is_fatal = fatal; 04164 pkt->owner = dialog_ref(p, "__sip_reliable_xmit: setting pkt->owner"); 04165 pkt->next = p->packets; 04166 p->packets = pkt; /* Add it to the queue */ 04167 if (resp) { 04168 /* Parse out the response code */ 04169 if (sscanf(ast_str_buffer(pkt->data), "SIP/2.0 %30u", &respid) == 1) { 04170 pkt->response_code = respid; 04171 } 04172 } 04173 pkt->timer_t1 = p->timer_t1; /* Set SIP timer T1 */ 04174 pkt->retransid = -1; 04175 if (pkt->timer_t1) 04176 siptimer_a = pkt->timer_t1 * 2; 04177 04178 /* Schedule retransmission */ 04179 AST_SCHED_REPLACE_VARIABLE(pkt->retransid, sched, siptimer_a, retrans_pkt, pkt, 1); 04180 if (sipdebug) 04181 ast_debug(4, "*** SIP TIMER: Initializing retransmit timer on packet: Id #%d\n", pkt->retransid); 04182 04183 xmitres = __sip_xmit(pkt->owner, pkt->data, pkt->packetlen); /* Send packet */ 04184 04185 if (xmitres == XMIT_ERROR) { /* Serious network trouble, no need to try again */ 04186 append_history(pkt->owner, "XmitErr", "%s", pkt->is_fatal ? "(Critical)" : "(Non-critical)"); 04187 ast_log(LOG_ERROR, "Serious Network Trouble; __sip_xmit returns error for pkt data\n"); 04188 AST_SCHED_DEL(sched, pkt->retransid); 04189 p->packets = pkt->next; 04190 pkt->owner = dialog_unref(pkt->owner,"pkt is being freed, its dialog ref is dead now"); 04191 ast_free(pkt->data); 04192 ast_free(pkt); 04193 return AST_FAILURE; 04194 } else { 04195 return AST_SUCCESS; 04196 } 04197 }
| static int __sip_semi_ack | ( | struct sip_pvt * | p, | |
| int | seqno, | |||
| int | resp, | |||
| int | sipmethod | |||
| ) | [static] |
Acks receipt of packet, keep it around (used for provisional responses).
Definition at line 4394 of file chan_sip.c.
References ast_debug, AST_SCHED_DEL, sip_pvt::callid, sip_pkt::data, FALSE, sip_pkt::is_resp, method_match(), sip_pkt::next, sip_pvt::packets, sip_pkt::retransid, sip_pkt::seqno, sip_methods, cfsip_methods::text, and TRUE.
Referenced by handle_response(), and sip_hangup().
04395 { 04396 struct sip_pkt *cur; 04397 int res = FALSE; 04398 04399 for (cur = p->packets; cur; cur = cur->next) { 04400 if (cur->seqno == seqno && cur->is_resp == resp && 04401 (cur->is_resp || method_match(sipmethod, cur->data->str))) { 04402 /* this is our baby */ 04403 if (cur->retransid > -1) { 04404 if (sipdebug) 04405 ast_debug(4, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text); 04406 } 04407 AST_SCHED_DEL(sched, cur->retransid); 04408 res = TRUE; 04409 break; 04410 } 04411 } 04412 ast_debug(1, "(Provisional) Stopping retransmission (but retaining packet) on '%s' %s %d: %s\n", p->callid, resp ? "Response" : "Request", seqno, res == -1 ? "Not Found" : "Found"); 04413 return res; 04414 }
| static int __sip_subscribe_mwi_do | ( | struct sip_subscription_mwi * | mwi | ) | [static] |
Actually setup an MWI subscription or resubscribe.
Definition at line 11554 of file chan_sip.c.
References ast_dnsmgr_lookup(), ast_set_flag, ast_sip_ouraddrfor(), ast_string_field_set, ast_strlen_zero(), ASTOBJ_REF, sip_subscription_mwi::authuser, build_callid_pvt(), build_contact(), build_via(), sip_subscription_mwi::call, create_addr(), dialog_unlink_all(), dialog_unref(), sip_subscription_mwi::dnsmgr, sip_pvt::flags, get_srv_protocol(), get_srv_service(), sip_subscription_mwi::hostname, MAXHOSTNAMELEN, sip_pvt::mwi, obproxy_get(), sip_pvt::ourip, sip_socket::port, sip_subscription_mwi::portno, sip_pvt::recv, ref_proxy(), sip_pvt::sa, sip_subscription_mwi::secret, set_socket_transport(), sip_alloc(), sip_cfg, SIP_OUTGOING, SIP_SUBSCRIBE, sip_pvt::socket, sip_settings::srvlookup, transmit_invite(), sip_subscription_mwi::transport, TRUE, sip_subscription_mwi::us, and sip_subscription_mwi::username.
Referenced by sip_subscribe_mwi_do().
11555 { 11556 /* If we have no DNS manager let's do a lookup */ 11557 if (!mwi->dnsmgr) { 11558 char transport[MAXHOSTNAMELEN]; 11559 snprintf(transport, sizeof(transport), "_%s._%s", get_srv_service(mwi->transport), get_srv_protocol(mwi->transport)); 11560 ast_dnsmgr_lookup(mwi->hostname, &mwi->us, &mwi->dnsmgr, sip_cfg.srvlookup ? transport : NULL); 11561 } 11562 11563 /* If we already have a subscription up simply send a resubscription */ 11564 if (mwi->call) { 11565 transmit_invite(mwi->call, SIP_SUBSCRIBE, 0, 0); 11566 return 0; 11567 } 11568 11569 /* Create a dialog that we will use for the subscription */ 11570 if (!(mwi->call = sip_alloc(NULL, NULL, 0, SIP_SUBSCRIBE, NULL))) { 11571 return -1; 11572 } 11573 11574 ref_proxy(mwi->call, obproxy_get(mwi->call, NULL)); 11575 11576 if (!mwi->us.sin_port && mwi->portno) { 11577 mwi->us.sin_port = htons(mwi->portno); 11578 } 11579 11580 /* Setup the destination of our subscription */ 11581 if (create_addr(mwi->call, mwi->hostname, &mwi->us, 0)) { 11582 dialog_unlink_all(mwi->call, TRUE, TRUE); 11583 mwi->call = dialog_unref(mwi->call, "unref dialog after unlink_all"); 11584 return 0; 11585 } 11586 11587 if (!mwi->dnsmgr && mwi->portno) { 11588 mwi->call->sa.sin_port = htons(mwi->portno); 11589 mwi->call->recv.sin_port = htons(mwi->portno); 11590 } else { 11591 mwi->portno = ntohs(mwi->call->sa.sin_port); 11592 } 11593 11594 /* Set various other information */ 11595 if (!ast_strlen_zero(mwi->authuser)) { 11596 ast_string_field_set(mwi->call, peername, mwi->authuser); 11597 ast_string_field_set(mwi->call, authname, mwi->authuser); 11598 ast_string_field_set(mwi->call, fromuser, mwi->authuser); 11599 } else { 11600 ast_string_field_set(mwi->call, peername, mwi->username); 11601 ast_string_field_set(mwi->call, authname, mwi->username); 11602 ast_string_field_set(mwi->call, fromuser, mwi->username); 11603 } 11604 ast_string_field_set(mwi->call, username, mwi->username); 11605 if (!ast_strlen_zero(mwi->secret)) { 11606 ast_string_field_set(mwi->call, peersecret, mwi->secret); 11607 } 11608 set_socket_transport(&mwi->call->socket, mwi->transport); 11609 mwi->call->socket.port = htons(mwi->portno); 11610 ast_sip_ouraddrfor(&mwi->call->sa.sin_addr, &mwi->call->ourip, mwi->call); 11611 build_contact(mwi->call); 11612 build_via(mwi->call); 11613 build_callid_pvt(mwi->call); 11614 ast_set_flag(&mwi->call->flags[0], SIP_OUTGOING); 11615 11616 /* Associate the call with us */ 11617 mwi->call->mwi = ASTOBJ_REF(mwi); 11618 11619 /* Actually send the packet */ 11620 transmit_invite(mwi->call, SIP_SUBSCRIBE, 0, 2); 11621 11622 return 0; 11623 }
Transmit SIP message Sends a SIP request or response on a given socket (in the pvt) Called by retrans_pkt, send_request, send_response and __sip_reliable_xmit.
Definition at line 3822 of file chan_sip.c.
References ast_debug, ast_inet_ntoa(), ast_log(), errno, sip_socket::fd, get_transport_pvt(), LOG_WARNING, sip_prepare_socket(), sip_real_dst(), sip_tcptls_write(), SIP_TRANSPORT_UDP, sip_pvt::socket, sip_socket::tcptls_session, sip_socket::type, and XMIT_ERROR.
Referenced by __sip_reliable_xmit(), retrans_pkt(), send_request(), and send_response().
03823 { 03824 int res = 0; 03825 const struct sockaddr_in *dst = sip_real_dst(p); 03826 03827 ast_debug(2, "Trying to put '%.11s' onto %s socket destined for %s:%d\n", data->str, get_transport_pvt(p), ast_inet_ntoa(dst->sin_addr), htons(dst->sin_port)); 03828 03829 if (sip_prepare_socket(p) < 0) 03830 return XMIT_ERROR; 03831 03832 if (p->socket.type == SIP_TRANSPORT_UDP) { 03833 res = sendto(p->socket.fd, data->str, len, 0, (const struct sockaddr *)dst, sizeof(struct sockaddr_in)); 03834 } else if (p->socket.tcptls_session) { 03835 res = sip_tcptls_write(p->socket.tcptls_session, data->str, len); 03836 } else { 03837 ast_debug(2, "Socket type is TCP but no tcptls_session is present to write to\n"); 03838 return XMIT_ERROR; 03839 } 03840 03841 if (res == -1) { 03842 switch (errno) { 03843 case EBADF: /* Bad file descriptor - seems like this is generated when the host exist, but doesn't accept the UDP packet */ 03844 case EHOSTUNREACH: /* Host can't be reached */ 03845 case ENETDOWN: /* Inteface down */ 03846 case ENETUNREACH: /* Network failure */ 03847 case ECONNREFUSED: /* ICMP port unreachable */ 03848 res = XMIT_ERROR; /* Don't bother with trying to transmit again */ 03849 } 03850 } 03851 if (res != len) 03852 ast_log(LOG_WARNING, "sip_xmit of %p (len %d) to %s:%d returned %d: %s\n", data, len, ast_inet_ntoa(dst->sin_addr), ntohs(dst->sin_port), res, strerror(errno)); 03853 03854 return res; 03855 }
| static int __transmit_response | ( | struct sip_pvt * | p, | |
| const char * | msg, | |||
| const struct sip_request * | req, | |||
| enum xmittype | reliable | |||
| ) | [static] |
Base transmit response function.
Definition at line 10156 of file chan_sip.c.
References add_header(), ast_cause2str(), ast_log(), buf, get_header(), ast_channel::hangupcause, LOG_WARNING, sip_pvt::method, sip_pvt::owner, respprep(), send_response(), and SIP_INVITE.
Referenced by transmit_response(), transmit_response_reliable(), and transmit_response_using_temp().
10157 { 10158 struct sip_request resp; 10159 int seqno = 0; 10160 10161 if (reliable && (sscanf(get_header(req, "CSeq"), "%30d ", &seqno) != 1)) { 10162 ast_log(LOG_WARNING, "Unable to determine sequence number from '%s'\n", get_header(req, "CSeq")); 10163 return -1; 10164 } 10165 respprep(&resp, p, msg, req); 10166 /* If we are cancelling an incoming invite for some reason, add information 10167 about the reason why we are doing this in clear text */ 10168 if (p->method == SIP_INVITE && msg[0] != '1' && p->owner && p->owner->hangupcause) { 10169 char buf[10]; 10170 10171 add_header(&resp, "X-Asterisk-HangupCause", ast_cause2str(p->owner->hangupcause)); 10172 snprintf(buf, sizeof(buf), "%d", p->owner->hangupcause); 10173 add_header(&resp, "X-Asterisk-HangupCauseCode", buf); 10174 } 10175 return send_response(p, &resp, reliable, seqno); 10176 }
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 26863 of file chan_sip.c.
| static char * _sip_qualify_peer | ( | int | type, | |
| int | fd, | |||
| struct mansession * | s, | |||
| const struct message * | m, | |||
| int | argc, | |||
| const char * | argv[] | |||
| ) | [static] |
Send qualify message to peer from cli or manager. Mostly for debugging.
Definition at line 15925 of file chan_sip.c.
References ast_cli(), astman_send_error(), CLI_SHOWUSAGE, CLI_SUCCESS, FALSE, find_peer(), FINDPEERS, sip_poke_peer(), TRUE, and unref_peer().
Referenced by manager_sip_qualify_peer(), and sip_qualify_peer().
15926 { 15927 struct sip_peer *peer; 15928 int load_realtime; 15929 15930 if (argc < 4) 15931 return CLI_SHOWUSAGE; 15932 15933 load_realtime = (argc == 5 && !strcmp(argv[4], "load")) ? TRUE : FALSE; 15934 if ((peer = find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE, 0))) { 15935 sip_poke_peer(peer, 1); 15936 unref_peer(peer, "qualify: done with peer"); 15937 } else if (type == 0) { 15938 ast_cli(fd, "Peer '%s' not found\n", argv[3]); 15939 } else { 15940 astman_send_error(s, m, "Peer not found"); 15941 } 15942 return CLI_SUCCESS; 15943 }
| static char * _sip_show_peer | ( | int | type, | |
| int | fd, | |||
| struct mansession * | s, | |||
| const struct message * | m, | |||
| int | argc, | |||
| const char * | argv[] | |||
| ) | [static] |
Show one peer in detail (main function).
Definition at line 16010 of file chan_sip.c.
References sip_peer::accountcode, sip_peer::addr, sip_peer::allowtransfer, sip_peer::amaflags, ARRAY_LEN, ast_callerid_merge(), ast_cdr_flags2str(), ast_check_realtime(), ast_cli(), ast_codec_pref_index(), ast_describe_caller_presentation(), ast_getformatname(), ast_getformatname_multiple(), ast_inet_ntoa(), ast_print_group(), ast_sched_when(), ast_str_alloca, ast_strlen_zero(), ast_test_flag, astman_append(), astman_get_header(), astman_send_error(), sip_peer::auth, sip_peer::autoframing, sip_peer::busy_level, sip_peer::call_limit, sip_peer::callgroup, sip_peer::callingpres, sip_peer::capability, sip_peer::chanvars, sip_peer::cid_name, sip_peer::cid_num, CLI_SHOWUSAGE, CLI_SUCCESS, cli_yesno(), sip_peer::context, sip_peer::defaddr, dtmfmode2str(), sip_peer::expire, FALSE, faxec2str(), find_peer(), FINDPEERS, sip_peer::flags, sip_proxy::force, sip_peer::fromdomain, sip_peer::fromuser, sip_peer::fullcontact, get_transport(), get_transport_list(), sip_peer::ha, sip_peer::host_dynamic, cfsip_options::id, insecure2str(), sip_peer::is_realtime, sip_peer::language, sip_peer::lastmsgssent, sip_peer::maxcallbitrate, sip_auth::md5secret, sip_peer::md5secret, ast_variable::name, sip_proxy::name, sip_peer::name, nat2str(), ast_variable::next, sip_auth::next, sip_peer::outboundproxy, sip_peer::parkinglot, peer_mailboxes_to_str(), peer_status(), sip_peer::pickupgroup, sip_peer::prefs, print_codec_to_cli(), print_group(), sip_peer::qualifyfreq, sip_auth::realm, sip_peer::regexten, sip_peer::remotesecret, S_OR, sip_auth::secret, sip_peer::secret, SIP_DIRECT_MEDIA, SIP_DTMF, SIP_INSECURE, SIP_NAT, sip_options, SIP_PAGE2_ALLOWOVERLAP, SIP_PAGE2_ALLOWSUBSCRIBE, SIP_PAGE2_FORWARD_LOOP_DETECTED, SIP_PAGE2_IGNORESDPVERSION, SIP_PAGE2_REGISTERTRYING, SIP_PAGE2_T38SUPPORT, SIP_PAGE2_TEXTSUPPORT, SIP_PAGE2_VIDEOSUPPORT, SIP_PAGE2_VIDEOSUPPORT_ALWAYS, SIP_PROMISCREDIR, SIP_SENDRPID, SIP_TRUSTRPID, SIP_USEREQPHONE, sip_peer::sipoptions, sip_peer::socket, sip_st_cfg::st_max_se, sip_st_cfg::st_min_se, sip_st_cfg::st_mode_oper, sip_st_cfg::st_ref, status, sip_peer::stimer, stmode2str(), strefresher2str(), sip_peer::subscribecontext, sip_peer::t38_maxdatagram, text, sip_peer::timer_b, sip_peer::timer_t1, sip_peer::tohost, transfermode2str(), sip_peer::transports, TRUE, sip_socket::type, unref_peer(), sip_peer::useragent, sip_peer::username, sip_auth::username, ast_variable::value, and sip_peer::vmexten.
Referenced by manager_sip_show_peer(), and sip_show_peer().
16011 { 16012 char status[30] = ""; 16013 char cbuf[256]; 16014 struct sip_peer *peer; 16015 char codec_buf[512]; 16016 struct ast_codec_pref *pref; 16017 struct ast_variable *v; 16018 struct sip_auth *auth; 16019 int x = 0, codec = 0, load_realtime; 16020 int realtimepeers; 16021 16022 realtimepeers = ast_check_realtime("sippeers"); 16023 16024 if (argc < 4) 16025 return CLI_SHOWUSAGE; 16026 16027 load_realtime = (argc == 5 && !strcmp(argv[4], "load")) ? TRUE : FALSE; 16028 peer = find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE, 0); 16029 16030 if (s) { /* Manager */ 16031 if (peer) { 16032 const char *id = astman_get_header(m, "ActionID"); 16033 16034 astman_append(s, "Response: Success\r\n"); 16035 if (!ast_strlen_zero(id)) 16036 astman_append(s, "ActionID: %s\r\n", id); 16037 } else { 16038 snprintf (cbuf, sizeof(cbuf), "Peer %s not found.", argv[3]); 16039 astman_send_error(s, m, cbuf); 16040 return CLI_SUCCESS; 16041 } 16042 } 16043 if (peer && type==0 ) { /* Normal listing */ 16044 struct ast_str *mailbox_str = ast_str_alloca(512); 16045 ast_cli(fd, "\n\n"); 16046 ast_cli(fd, " * Name : %s\n", peer->name); 16047 if (realtimepeers) { /* Realtime is enabled */ 16048 ast_cli(fd, " Realtime peer: %s\n", peer->is_realtime ? "Yes, cached" : "No"); 16049 } 16050 ast_cli(fd, " Secret : %s\n", ast_strlen_zero(peer->secret)?"<Not set>":"<Set>"); 16051 ast_cli(fd, " MD5Secret : %s\n", ast_strlen_zero(peer->md5secret)?"<Not set>":"<Set>"); 16052 ast_cli(fd, " Remote Secret: %s\n", ast_strlen_zero(peer->remotesecret)?"<Not set>":"<Set>"); 16053 for (auth = peer->auth; auth; auth = auth->next) { 16054 ast_cli(fd, " Realm-auth : Realm %-15.15s User %-10.20s ", auth->realm, auth->username); 16055 ast_cli(fd, "%s\n", !ast_strlen_zero(auth->secret)?"<Secret set>":(!ast_strlen_zero(auth->md5secret)?"<MD5secret set>" : "<Not set>")); 16056 } 16057 ast_cli(fd, " Context : %s\n", peer->context); 16058 ast_cli(fd, " Subscr.Cont. : %s\n", S_OR(peer->subscribecontext, "<Not set>") ); 16059 ast_cli(fd, " Language : %s\n", peer->language); 16060 if (!ast_strlen_zero(peer->accountcode)) 16061 ast_cli(fd, " Accountcode : %s\n", peer->accountcode); 16062 ast_cli(fd, " AMA flags : %s\n", ast_cdr_flags2str(peer->amaflags)); 16063 ast_cli(fd, " Transfer mode: %s\n", transfermode2str(peer->allowtransfer)); 16064 ast_cli(fd, " CallingPres : %s\n", ast_describe_caller_presentation(peer->callingpres)); 16065 if (!ast_strlen_zero(peer->fromuser)) 16066 ast_cli(fd, " FromUser : %s\n", peer->fromuser); 16067 if (!ast_strlen_zero(peer->fromdomain)) 16068 ast_cli(fd, " FromDomain : %s\n", peer->fromdomain); 16069 ast_cli(fd, " Callgroup : "); 16070 print_group(fd, peer->callgroup, 0); 16071 ast_cli(fd, " Pickupgroup : "); 16072 print_group(fd, peer->pickupgroup, 0); 16073 peer_mailboxes_to_str(&mailbox_str, peer); 16074 ast_cli(fd, " Mailbox : %s\n", mailbox_str->str); 16075 ast_cli(fd, " VM Extension : %s\n", peer->vmexten); 16076 ast_cli(fd, " LastMsgsSent : %d/%d\n", (peer->lastmsgssent & 0x7fff0000) >> 16, peer->lastmsgssent & 0xffff); 16077 ast_cli(fd, " Call limit : %d\n", peer->call_limit); 16078 if (peer->busy_level) 16079 ast_cli(fd, " Busy level : %d\n", peer->busy_level); 16080 ast_cli(fd, " Dynamic : %s\n", cli_yesno(peer->host_dynamic)); 16081 ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "<unspecified>")); 16082 ast_cli(fd, " MaxCallBR : %d kbps\n", peer->maxcallbitrate); 16083 ast_cli(fd, " Expire : %ld\n", ast_sched_when(sched, peer->expire)); 16084 ast_cli(fd, " Insecure : %s\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE))); 16085 ast_cli(fd, " Nat : %s\n", nat2str(ast_test_flag(&peer->flags[0], SIP_NAT))); 16086 ast_cli(fd, " ACL : %s\n", cli_yesno(peer->ha != NULL)); 16087 ast_cli(fd, " T.38 support : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT))); 16088 ast_cli(fd, " T.38 EC mode : %s\n", faxec2str(ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT))); 16089 ast_cli(fd, " T.38 MaxDtgrm: %d\n", peer->t38_maxdatagram); 16090 ast_cli(fd, " DirectMedia : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_DIRECT_MEDIA))); 16091 ast_cli(fd, " PromiscRedir : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_PROMISCREDIR))); 16092 ast_cli(fd, " User=Phone : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_USEREQPHONE))); 16093 ast_cli(fd, " Video Support: %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_VIDEOSUPPORT) || ast_test_flag(&peer->flags[1], SIP_PAGE2_VIDEOSUPPORT_ALWAYS))); 16094 ast_cli(fd, " Text Support : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_TEXTSUPPORT))); 16095 ast_cli(fd, " Ign SDP ver : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_IGNORESDPVERSION))); 16096 ast_cli(fd, " Trust RPID : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_TRUSTRPID))); 16097 ast_cli(fd, " Send RPID : %s\n", cli_yesno(ast_test_flag(&peer->flags[0], SIP_SENDRPID))); 16098 ast_cli(fd, " Subscriptions: %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWSUBSCRIBE))); 16099 ast_cli(fd, " Overlap dial : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_ALLOWOVERLAP))); 16100 ast_cli(fd, " Forward Loop : %s\n", cli_yesno(ast_test_flag(&peer->flags[1], SIP_PAGE2_FORWARD_LOOP_DETECTED))); 16101 if (peer->outboundproxy) 16102 ast_cli(fd, " Outb. proxy : %s %s\n", ast_strlen_zero(peer->outboundproxy->name) ? "<not set>" : peer->outboundproxy->name, 16103 peer->outboundproxy->force ? "(forced)" : ""); 16104 16105 /* - is enumerated */ 16106 ast_cli(fd, " DTMFmode : %s\n", dtmfmode2str(ast_test_flag(&peer->flags[0], SIP_DTMF))); 16107 ast_cli(fd, " Timer T1 : %d\n", peer->timer_t1); 16108 ast_cli(fd, " Timer B : %d\n", peer->timer_b); 16109 ast_cli(fd, " ToHost : %s\n", peer->tohost); 16110 ast_cli(fd, " Addr->IP : %s Port %d\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)", ntohs(peer->addr.sin_port)); 16111 ast_cli(fd, " Defaddr->IP : %s Port %d\n", ast_inet_ntoa(peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port)); 16112 ast_cli(fd, " Prim.Transp. : %s\n", get_transport(peer->socket.type)); 16113 ast_cli(fd, " Allowed.Trsp : %s\n", get_transport_list(peer->transports)); 16114 if (!ast_strlen_zero(global_regcontext)) 16115 ast_cli(fd, " Reg. exten : %s\n", peer->regexten); 16116 ast_cli(fd, " Def. Username: %s\n", peer->username); 16117 ast_cli(fd, " SIP Options : "); 16118 if (peer->sipoptions) { 16119 int lastoption = -1; 16120 for (x = 0 ; x < ARRAY_LEN(sip_options); x++) { 16121 if (sip_options[x].id != lastoption) { 16122 if (peer->sipoptions & sip_options[x].id) 16123 ast_cli(fd, "%s ", sip_options[x].text); 16124 lastoption = x; 16125 } 16126 } 16127 } else 16128 ast_cli(fd, "(none)"); 16129 16130 ast_cli(fd, "\n"); 16131 ast_cli(fd, " Codecs : "); 16132 ast_getformatname_multiple(codec_buf, sizeof(codec_buf) -1, peer->capability); 16133 ast_cli(fd, "%s\n", codec_buf); 16134 ast_cli(fd, " Codec Order : ("); 16135 print_codec_to_cli(fd, &peer->prefs); 16136 ast_cli(fd, ")\n"); 16137 16138 ast_cli(fd, " Auto-Framing : %s \n", cli_yesno(peer->autoframing)); 16139 ast_cli(fd, " 100 on REG : %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_REGISTERTRYING) ? "Yes" : "No"); 16140 ast_cli(fd, " Status : "); 16141 peer_status(peer, status, sizeof(status)); 16142 ast_cli(fd, "%s\n", status); 16143 ast_cli(fd, " Useragent : %s\n", peer->useragent); 16144 ast_cli(fd, " Reg. Contact : %s\n", peer->fullcontact); 16145 ast_cli(fd, " Qualify Freq : %d ms\n", peer->qualifyfreq); 16146 if (peer->chanvars) { 16147 ast_cli(fd, " Variables :\n"); 16148 for (v = peer->chanvars ; v ; v = v->next) 16149 ast_cli(fd, " %s = %s\n", v->name, v->value); 16150 } 16151 16152 ast_cli(fd, " Sess-Timers : %s\n", stmode2str(peer->stimer.st_mode_oper)); 16153 ast_cli(fd, " Sess-Refresh : %s\n", strefresher2str(peer->stimer.st_ref)); 16154 ast_cli(fd, " Sess-Expires : %d secs\n", peer->stimer.st_max_se); 16155 ast_cli(fd, " Min-Sess : %d secs\n", peer->stimer.st_min_se); 16156 ast_cli(fd, " Parkinglot : %s\n", peer->parkinglot); 16157 ast_cli(fd, "\n"); 16158 peer = unref_peer(peer, "sip_show_peer: unref_peer: done with peer ptr"); 16159 } else if (peer && type == 1) { /* manager listing */ 16160 char buffer[256]; 16161 struct ast_str *mailbox_str = ast_str_alloca(512); 16162 astman_append(s, "Channeltype: SIP\r\n"); 16163 astman_append(s, "ObjectName: %s\r\n", peer->name); 16164 astman_append(s, "ChanObjectType: peer\r\n"); 16165 astman_append(s, "SecretExist: %s\r\n", ast_strlen_zero(peer->secret)?"N":"Y"); 16166 astman_append(s, "RemoteSecretExist: %s\r\n", ast_strlen_zero(peer->remotesecret)?"N":"Y"); 16167 astman_append(s, "MD5SecretExist: %s\r\n", ast_strlen_zero(peer->md5secret)?"N":"Y"); 16168 astman_append(s, "Context: %s\r\n", peer->context); 16169 astman_append(s, "Language: %s\r\n", peer->language); 16170 if (!ast_strlen_zero(peer->accountcode)) 16171 astman_append(s, "Accountcode: %s\r\n", peer->accountcode); 16172 astman_append(s, "AMAflags: %s\r\n", ast_cdr_flags2str(peer->amaflags)); 16173 astman_append(s, "CID-CallingPres: %s\r\n", ast_describe_caller_presentation(peer->callingpres)); 16174 if (!ast_strlen_zero(peer->fromuser)) 16175 astman_append(s, "SIP-FromUser: %s\r\n", peer->fromuser); 16176 if (!ast_strlen_zero(peer->fromdomain)) 16177 astman_append(s, "SIP-FromDomain: %s\r\n", peer->fromdomain); 16178 astman_append(s, "Callgroup: "); 16179 astman_append(s, "%s\r\n", ast_print_group(buffer, sizeof(buffer), peer->callgroup)); 16180 astman_append(s, "Pickupgroup: "); 16181 astman_append(s, "%s\r\n", ast_print_group(buffer, sizeof(buffer), peer->pickupgroup)); 16182 peer_mailboxes_to_str(&mailbox_str, peer); 16183 astman_append(s, "VoiceMailbox: %s\r\n", mailbox_str->str); 16184 astman_append(s, "TransferMode: %s\r\n", transfermode2str(peer->allowtransfer)); 16185 astman_append(s, "LastMsgsSent: %d\r\n", peer->lastmsgssent); 16186 astman_append(s, "Call-limit: %d\r\n", peer->call_limit); 16187 astman_append(s, "Busy-level: %d\r\n", peer->busy_level); 16188 astman_append(s, "MaxCallBR: %d kbps\r\n", peer->maxcallbitrate); 16189 astman_append(s, "Dynamic: %s\r\n", peer->host_dynamic?"Y":"N"); 16190 astman_append(s, "Callerid: %s\r\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "")); 16191 astman_append(s, "RegExpire: %ld seconds\r\n", ast_sched_when(sched, peer->expire)); 16192 astman_append(s, "SIP-AuthInsecure: %s\r\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE))); 16193 astman_append(s, "SIP-NatSupport: %s\r\n", nat2str(ast_test_flag(&peer->flags[0], SIP_NAT))); 16194 astman_append(s, "ACL: %s\r\n", (peer->ha?"Y":"N")); 16195 astman_append(s, "SIP-CanReinvite: %s\r\n", (ast_test_flag(&peer->flags[0], SIP_DIRECT_MEDIA)?"Y":"N")); 16196 astman_append(s, "SIP-DirectMedia: %s\r\n", (ast_test_flag(&peer->flags[0], SIP_DIRECT_MEDIA)?"Y":"N")); 16197 astman_append(s, "SIP-PromiscRedir: %s\r\n", (ast_test_flag(&peer->flags[0], SIP_PROMISCREDIR)?"Y":"N")); 16198 astman_append(s, "SIP-UserPhone: %s\r\n", (ast_test_flag(&peer->flags[0], SIP_USEREQPHONE)?"Y":"N")); 16199 astman_append(s, "SIP-VideoSupport: %s\r\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_VIDEOSUPPORT)?"Y":"N")); 16200 astman_append(s, "SIP-TextSupport: %s\r\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_TEXTSUPPORT)?"Y":"N")); 16201 astman_append(s, "SIP-T.38Support: %s\r\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT)?"Y":"N")); 16202 astman_append(s, "SIP-T.38EC: %s\r\n", faxec2str(ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT))); 16203 astman_append(s, "SIP-T.38MaxDtgrm: %d\r\n", peer->t38_maxdatagram); 16204 astman_append(s, "SIP-Sess-Timers: %s\r\n", stmode2str(peer->stimer.st_mode_oper)); 16205 astman_append(s, "SIP-Sess-Refresh: %s\r\n", strefresher2str(peer->stimer.st_ref)); 16206 astman_append(s, "SIP-Sess-Expires: %d\r\n", peer->stimer.st_max_se); 16207 astman_append(s, "SIP-Sess-Min: %d\r\n", peer->stimer.st_min_se); 16208 16209 /* - is enumerated */ 16210 astman_append(s, "SIP-DTMFmode: %s\r\n", dtmfmode2str(ast_test_flag(&peer->flags[0], SIP_DTMF))); 16211 astman_append(s, "ToHost: %s\r\n", peer->tohost); 16212 astman_append(s, "Address-IP: %s\r\nAddress-Port: %d\r\n", peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "", ntohs(peer->addr.sin_port)); 16213 astman_append(s, "Default-addr-IP: %s\r\nDefault-addr-port: %d\r\n", ast_inet_ntoa(peer->defaddr.sin_addr), ntohs(peer->defaddr.sin_port)); 16214 astman_append(s, "Default-Username: %s\r\n", peer->username); 16215 if (!ast_strlen_zero(global_regcontext)) 16216 astman_append(s, "RegExtension: %s\r\n", peer->regexten); 16217 astman_append(s, "Codecs: "); 16218 ast_getformatname_multiple(codec_buf, sizeof(codec_buf) -1, peer->capability); 16219 astman_append(s, "%s\r\n", codec_buf); 16220 astman_append(s, "CodecOrder: "); 16221 pref = &peer->prefs; 16222 for(x = 0; x < 32 ; x++) { 16223 codec = ast_codec_pref_index(pref, x); 16224 if (!codec) 16225 break; 16226 astman_append(s, "%s", ast_getformatname(codec)); 16227 if (x < 31 && ast_codec_pref_index(pref, x+1)) 16228 astman_append(s, ","); 16229 } 16230 16231 astman_append(s, "\r\n"); 16232 astman_append(s, "Status: "); 16233 peer_status(peer, status, sizeof(status)); 16234 astman_append(s, "%s\r\n", status); 16235 astman_append(s, "SIP-Useragent: %s\r\n", peer->useragent); 16236 astman_append(s, "Reg-Contact: %s\r\n", peer->fullcontact); 16237 astman_append(s, "QualifyFreq: %d ms\r\n", peer->qualifyfreq); 16238 astman_append(s, "Parkinglot: %s\r\n", peer->parkinglot); 16239 if (peer->chanvars) { 16240 for (v = peer->chanvars ; v ; v = v->next) { 16241 astman_append(s, "ChanVariable: %s=%s\r\n", v->name, v->value); 16242 } 16243 } 16244 16245 peer = unref_peer(peer, "sip_show_peer: unref_peer: done with peer"); 16246 16247 } else { 16248 ast_cli(fd, "Peer %s not found.\n", argv[3]); 16249 ast_cli(fd, "\n"); 16250 } 16251 16252 return CLI_SUCCESS; 16253 }
| static char * _sip_show_peers | ( | int | fd, | |
| int * | total, | |||
| struct mansession * | s, | |||
| const struct message * | m, | |||
| int | argc, | |||
| const char * | argv[] | |||
| ) | [static] |
Execute sip show peers command.
Definition at line 15327 of file chan_sip.c.
References sip_peer::addr, ao2_container_count(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_lock(), ao2_t_iterator_next, ao2_unlock(), ast_calloc, ast_check_realtime(), ast_cli(), ast_copy_string(), ast_free, ast_inet_ntoa(), ast_strlen_zero(), ast_test_flag, astman_append(), astman_get_header(), CLI_SHOWUSAGE, CLI_SUCCESS, FALSE, sip_peer::flags, FORMAT, FORMAT2, sip_peer::ha, sip_peer::host_dynamic, id, sip_peer::is_realtime, sip_peer::name, name, peer_status(), peercomparefunc(), SIP_NAT_ROUTE, SIP_PAGE2_TEXTSUPPORT, SIP_PAGE2_VIDEOSUPPORT, SIP_TYPE_PEER, status, TRUE, sip_peer::type, unref_peer(), and sip_peer::username.
Referenced by manager_sip_show_peers(), and sip_show_peers().
15328 { 15329 regex_t regexbuf; 15330 int havepattern = FALSE; 15331 struct sip_peer *peer; 15332 struct ao2_iterator i; 15333 15334 /* the last argument is left-aligned, so we don't need a size anyways */ 15335 #define FORMAT2 "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-8s %-10s %s\n" 15336 #define FORMAT "%-25.25s %-15.15s %-3.3s %-3.3s %-3.3s %-8d %-10s %s\n" 15337 15338 char name[256]; 15339 int total_peers = 0; 15340 int peers_mon_online = 0; 15341 int peers_mon_offline = 0; 15342 int peers_unmon_offline = 0; 15343 int peers_unmon_online = 0; 15344 const char *id; 15345 char idtext[256] = ""; 15346 int realtimepeers; 15347 int objcount = ao2_container_count(peers); 15348 struct sip_peer **peerarray; 15349 int k; 15350 15351 15352 realtimepeers = ast_check_realtime("sippeers"); 15353 peerarray = ast_calloc(sizeof(struct sip_peer *), objcount); 15354 15355 if (s) { /* Manager - get ActionID */ 15356 id = astman_get_header(m, "ActionID"); 15357 if (!ast_strlen_zero(id)) 15358 snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id); 15359 } 15360 15361 switch (argc) { 15362 case 5: 15363 if (!strcasecmp(argv[3], "like")) { 15364 if (regcomp(®exbuf, argv[4], REG_EXTENDED | REG_NOSUB)) 15365 return CLI_SHOWUSAGE; 15366 havepattern = TRUE; 15367 } else 15368 return CLI_SHOWUSAGE; 15369 case 3: 15370 break; 15371 default: 15372 return CLI_SHOWUSAGE; 15373 } 15374 15375 if (!s) /* Normal list */ 15376 ast_cli(fd, FORMAT2, "Name/username", "Host", "Dyn", "Nat", "ACL", "Port", "Status", (realtimepeers ? "Realtime" : "")); 15377 15378 15379 i = ao2_iterator_init(peers, 0); 15380 while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table"))) { 15381 ao2_lock(peer); 15382 15383 if (!(peer->type & SIP_TYPE_PEER)) { 15384 ao2_unlock(peer); 15385 unref_peer(peer, "unref peer because it's actually a user"); 15386 continue; 15387 } 15388 15389 if (havepattern && regexec(®exbuf, peer->name, 0, NULL, 0)) { 15390 objcount--; 15391 ao2_unlock(peer); 15392 unref_peer(peer, "toss iterator peer ptr before continue"); 15393 continue; 15394 } 15395 15396 peerarray[total_peers++] = peer; 15397 ao2_unlock(peer); 15398 } 15399 ao2_iterator_destroy(&i); 15400 15401 qsort(peerarray, total_peers, sizeof(struct sip_peer *), peercomparefunc); 15402 15403 for(k=0; k < total_peers; k++) { 15404 char status[20] = ""; 15405 char srch[2000]; 15406 char pstatus; 15407 peer = peerarray[k]; 15408 15409 ao2_lock(peer); 15410 if (havepattern && regexec(®exbuf, peer->name, 0, NULL, 0)) { 15411 ao2_unlock(peer); 15412 peer = peerarray[k] = unref_peer(peer, "toss iterator peer ptr before continue"); 15413 continue; 15414 } 15415 15416 if (!ast_strlen_zero(peer->username) && !s) 15417 snprintf(name, sizeof(name), "%s/%s", peer->name, peer->username); 15418 else 15419 ast_copy_string(name, peer->name, sizeof(name)); 15420 15421 pstatus = peer_status(peer, status, sizeof(status)); 15422 if (pstatus == 1) 15423 peers_mon_online++; 15424 else if (pstatus == 0) 15425 peers_mon_offline++; 15426 else { 15427 if (peer->addr.sin_port == 0) 15428 peers_unmon_offline++; 15429 else 15430 peers_unmon_online++; 15431 } 15432 15433 snprintf(srch, sizeof(srch), FORMAT, name, 15434 peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)", 15435 peer->host_dynamic ? " D " : " ", /* Dynamic or not? */ 15436 ast_test_flag(&peer->flags[0], SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */ 15437 peer->ha ? " A " : " ", /* permit/deny */ 15438 ntohs(peer->addr.sin_port), status, 15439 realtimepeers ? (peer->is_realtime ? "Cached RT":"") : ""); 15440 15441 if (!s) {/* Normal CLI list */ 15442 ast_cli(fd, FORMAT, name, 15443 peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)", 15444 peer->host_dynamic ? " D " : " ", /* Dynamic or not? */ 15445 ast_test_flag(&peer->flags[0], SIP_NAT_ROUTE) ? " N " : " ", /* NAT=yes? */ 15446 peer->ha ? " A " : " ", /* permit/deny */ 15447 15448 ntohs(peer->addr.sin_port), status, 15449 realtimepeers ? (peer->is_realtime ? "Cached RT":"") : ""); 15450 } else { /* Manager format */ 15451 /* The names here need to be the same as other channels */ 15452 astman_append(s, 15453 "Event: PeerEntry\r\n%s" 15454 "Channeltype: SIP\r\n" 15455 "ObjectName: %s\r\n" 15456 "ChanObjectType: peer\r\n" /* "peer" or "user" */ 15457 "IPaddress: %s\r\n" 15458 "IPport: %d\r\n" 15459 "Dynamic: %s\r\n" 15460 "Natsupport: %s\r\n" 15461 "VideoSupport: %s\r\n" 15462 "TextSupport: %s\r\n" 15463 "ACL: %s\r\n" 15464 "Status: %s\r\n" 15465 "RealtimeDevice: %s\r\n\r\n", 15466 idtext, 15467 peer->name, 15468 peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "-none-", 15469 ntohs(peer->addr.sin_port), 15470 peer->host_dynamic ? "yes" : "no", /* Dynamic or not? */ 15471 ast_test_flag(&peer->flags[0], SIP_NAT_ROUTE) ? "yes" : "no", /* NAT=yes? */ 15472 ast_test_flag(&peer->flags[1], SIP_PAGE2_VIDEOSUPPORT) ? "yes" : "no", /* VIDEOSUPPORT=yes? */ 15473 ast_test_flag(&peer->flags[1], SIP_PAGE2_TEXTSUPPORT) ? "yes" : "no", /* TEXTSUPPORT=yes? */ 15474 peer->ha ? "yes" : "no", /* permit/deny */ 15475 status, 15476 realtimepeers ? (peer->is_realtime ? "yes":"no") : "no"); 15477 } 15478 ao2_unlock(peer); 15479 peer = peerarray[k] = unref_peer(peer, "toss iterator peer ptr"); 15480 } 15481 15482 if (!s) 15483 ast_cli(fd, "%d sip peers [Monitored: %d online, %d offline Unmonitored: %d online, %d offline]\n", 15484 total_peers, peers_mon_online, peers_mon_offline, peers_unmon_online, peers_unmon_offline); 15485 15486 if (havepattern) 15487 regfree(®exbuf); 15488 15489 if (total) 15490 *total = total_peers; 15491 15492 ast_free(peerarray); 15493 15494 return CLI_SUCCESS; 15495 #undef FORMAT 15496 #undef FORMAT2 15497 }
| static void * _sip_tcp_helper_thread | ( | struct sip_pvt * | pvt, | |
| struct ast_tcptls_session_instance * | tcptls_session | |||
| ) | [static] |
SIP TCP thread management function This function reads from the socket, parses the packet into a request.
Definition at line 2955 of file chan_sip.c.
References sip_threadinfo::alert_pipe, ao2_lock(), ao2_ref, ao2_t_find, ao2_t_ref, ao2_t_unlink, ao2_unlock(), ast_atomic_fetchadd_int(), ast_debug, AST_LIST_REMOVE_HEAD, ast_log(), ast_mutex_lock(), ast_mutex_unlock(), ast_poll, ast_str_append(), ast_str_buffer(), ast_str_create(), ast_str_reset(), ast_tcptls_client_start(), ast_tcptls_server_write(), ast_wait_for_input(), sip_request::authenticated, buf, cleanup(), ast_tcptls_session_instance::client, copy_request(), tcptls_packet::data, sip_request::data, deinit_req(), errno, ast_tcptls_session_instance::f, sip_socket::fd, ast_tcptls_session_instance::fd, get_header(), handle_request_do(), tcptls_packet::len, sip_request::len, ast_tcptls_session_instance::lock, LOG_ERROR, LOG_WARNING, me, MIN, OBJ_POINTER, sip_threadinfo::packet_q, ast_tcptls_session_instance::parent, parse_request(), sip_socket::port, ast_tcptls_session_instance::remote_address, REQ_OFFSET_TO_STR, set_socket_transport(), sip_check_authtimeout(), SIP_MIN_PACKET, sip_threadinfo_create(), SIP_TRANSPORT_TCP, SIP_TRANSPORT_TLS, sip_request::socket, ast_tcptls_session_instance::ssl, sip_threadinfo::stop, TCPTLS_ALERT_DATA, TCPTLS_ALERT_STOP, sip_socket::tcptls_session, sip_threadinfo::tcptls_session, and sip_threadinfo::threadid.
Referenced by sip_tcp_worker_fn().
02956 { 02957 int res, cl, timeout = -1, authenticated = 0, flags, after_poll = 0, need_poll = 1; 02958 time_t start; 02959 struct sip_request req = { 0, } , reqcpy = { 0, }; 02960 struct sip_threadinfo *me = NULL; 02961 char buf[1024] = ""; 02962 struct pollfd fds[2] = { { 0 }, { 0 }, }; 02963 struct ast_tcptls_session_args *ca = NULL; 02964 02965 /* If this is a server session, then the connection has already been 02966 * setup. Check if the authlimit has been reached and if not create the 02967 * threadinfo object so we can access this thread for writing. 02968 * 02969 * if this is a client connection more work must be done. 02970 * 1. We own the parent session args for a client connection. This pointer needs 02971 * to be held on to so we can decrement it's ref count on thread destruction. 02972 * 2. The threadinfo object was created before this thread was launched, however 02973 * it must be found within the threadt table. 02974 * 3. Last, the tcptls_session must be started. 02975 */ 02976 if (!tcptls_session->client) { 02977 if (ast_atomic_fetchadd_int(&unauth_sessions, +1) >= authlimit) { 02978 /* unauth_sessions is decremented in the cleanup code */ 02979 goto cleanup; 02980 } 02981 02982 if ((flags = fcntl(tcptls_session->fd, F_GETFL)) == -1) { 02983 ast_log(LOG_ERROR, "error setting socket to non blocking mode, fcntl() failed: %s\n", strerror(errno)); 02984 goto cleanup; 02985 } 02986 02987 flags |= O_NONBLOCK; 02988 if (fcntl(tcptls_session->fd, F_SETFL, flags) == -1) { 02989 ast_log(LOG_ERROR, "error setting socket to non blocking mode, fcntl() failed: %s\n", strerror(errno)); 02990 goto cleanup; 02991 } 02992 02993 if (!(me = sip_threadinfo_create(tcptls_session, tcptls_session->ssl ? SIP_TRANSPORT_TLS : SIP_TRANSPORT_TCP))) { 02994 goto cleanup; 02995 } 02996 ao2_t_ref(me, +1, "Adding threadinfo ref for tcp_helper_thread"); 02997 } else { 02998 struct sip_threadinfo tmp = { 02999 .tcptls_session = tcptls_session, 03000 }; 03001 03002 if ((!(ca = tcptls_session->parent)) || 03003 (!(me = ao2_t_find(threadt, &tmp, OBJ_POINTER, "ao2_find, getting sip_threadinfo in tcp helper thread"))) || 03004 (!(tcptls_session = ast_tcptls_client_start(tcptls_session)))) { 03005 goto cleanup; 03006 } 03007 } 03008 03009 flags = 1; 03010 if (setsockopt(tcptls_session->fd, SOL_SOCKET, SO_KEEPALIVE, &flags, sizeof(flags))) { 03011 ast_log(LOG_ERROR, "error enabling TCP keep-alives on sip socket: %s\n", strerror(errno)); 03012 goto cleanup; 03013 } 03014 03015 me->threadid = pthread_self(); 03016 ast_debug(2, "Starting thread for %s server\n", tcptls_session->ssl ? "SSL" : "TCP"); 03017 03018 /* set up pollfd to watch for reads on both the socket and the alert_pipe */ 03019 fds[0].fd = tcptls_session->fd; 03020 fds[1].fd = me->alert_pipe[0]; 03021 fds[0].events = fds[1].events = POLLIN | POLLPRI; 03022 03023 if (!(req.data = ast_str_create(SIP_MIN_PACKET))) 03024 goto cleanup; 03025 if (!(reqcpy.data = ast_str_create(SIP_MIN_PACKET))) 03026 goto cleanup; 03027 03028 if(time(&start) == -1) { 03029 ast_log(LOG_ERROR, "error executing time(): %s\n", strerror(errno)); 03030 goto cleanup; 03031 } 03032 03033 for (;;) { 03034 struct ast_str *str_save; 03035 03036 if (!tcptls_session->client && req.authenticated && !authenticated) { 03037 authenticated = 1; 03038 ast_atomic_fetchadd_int(&unauth_sessions, -1); 03039 } 03040 03041 /* calculate the timeout for unauthenticated server sessions */ 03042 if (!tcptls_session->client && !authenticated ) { 03043 if ((timeout = sip_check_authtimeout(start)) < 0) { 03044 goto cleanup; 03045 } 03046 03047 if (timeout == 0) { 03048 ast_debug(2, "SIP %s server timed out\n", tcptls_session->ssl ? "SSL": "TCP"); 03049 goto cleanup; 03050 } 03051 } else { 03052 timeout = -1; 03053 } 03054 03055 res = ast_poll(fds, 2, timeout); /* polls for both socket and alert_pipe */ 03056 if (res < 0) { 03057 ast_debug(2, "SIP %s server :: ast_wait_for_input returned %d\n", tcptls_session->ssl ? "SSL": "TCP", res); 03058 goto cleanup; 03059 } else if (res == 0) { 03060 /* timeout */ 03061 ast_debug(2, "SIP %s server timed out\n", tcptls_session->ssl ? "SSL": "TCP"); 03062 goto cleanup; 03063 } 03064 03065 /* handle the socket event, check for both reads from the socket fd, 03066 * and writes from alert_pipe fd */ 03067 if (fds[0].revents) { /* there is data on the socket to be read */ 03068 after_poll = 1; 03069 03070 fds[0].revents = 0; 03071 03072 /* clear request structure */ 03073 str_save = req.data; 03074 memset(&req, 0, sizeof(req)); 03075 req.data = str_save; 03076 ast_str_reset(req.data); 03077 03078 str_save = reqcpy.data; 03079 memset(&reqcpy, 0, sizeof(reqcpy)); 03080 reqcpy.data = str_save; 03081 ast_str_reset(reqcpy.data); 03082 03083 memset(buf, 0, sizeof(buf)); 03084 03085 if (tcptls_session->ssl) { 03086 set_socket_transport(&req.socket, SIP_TRANSPORT_TLS); 03087 req.socket.port = htons(ourport_tls); 03088 } else { 03089 set_socket_transport(&req.socket, SIP_TRANSPORT_TCP); 03090 req.socket.port = htons(ourport_tcp); 03091 } 03092 req.socket.fd = tcptls_session->fd; 03093 03094 /* Read in headers one line at a time */ 03095 while (req.len < 4 || strncmp(REQ_OFFSET_TO_STR(&req, len - 4), "\r\n\r\n", 4)) { 03096 if (!tcptls_session->client && !authenticated ) { 03097 if ((timeout = sip_check_authtimeout(start)) < 0) { 03098 goto cleanup; 03099 } 03100 03101 if (timeout == 0) { 03102 ast_debug(2, "SIP %s server timed out\n", tcptls_session->ssl ? "SSL": "TCP"); 03103 goto cleanup; 03104 } 03105 } else { 03106 timeout = -1; 03107 } 03108 03109 if (!tcptls_session->ssl || need_poll) { 03110 need_poll = 0; 03111 after_poll = 1; 03112 res = ast_wait_for_input(tcptls_session->fd, timeout); 03113 if (res < 0) { 03114 ast_debug(2, "SIP %s server :: ast_wait_for_input returned %d\n", tcptls_session->ssl ? "SSL": "TCP", res); 03115 goto cleanup; 03116 } else if (res == 0) { 03117 /* timeout */ 03118 ast_debug(2, "SIP %s server timed out\n", tcptls_session->ssl ? "SSL": "TCP"); 03119 goto cleanup; 03120 } 03121 } 03122 03123 ast_mutex_lock(&tcptls_session->lock); 03124 if (!fgets(buf, sizeof(buf), tcptls_session->f)) { 03125 ast_mutex_unlock(&tcptls_session->lock); 03126 if (after_poll) { 03127 goto cleanup; 03128 } else { 03129 need_poll = 1; 03130 continue; 03131 } 03132 } 03133 ast_mutex_unlock(&tcptls_session->lock); 03134 after_poll = 0; 03135 if (me->stop) 03136 goto cleanup; 03137 ast_str_append(&req.data, 0, "%s", buf); 03138 req.len = req.data->used; 03139 } 03140 copy_request(&reqcpy, &req); 03141 parse_request(&reqcpy); 03142 /* In order to know how much to read, we need the content-length header */ 03143 if (sscanf(get_header(&reqcpy, "Content-Length"), "%30d", &cl)) { 03144 while (cl > 0) { 03145 size_t bytes_read; 03146 if (!tcptls_session->client && !authenticated ) { 03147 if ((timeout = sip_check_authtimeout(start)) < 0) { 03148 goto cleanup; 03149 } 03150 03151 if (timeout == 0) { 03152 ast_debug(2, "SIP %s server timed out\n", tcptls_session->ssl ? "SSL": "TCP"); 03153 goto cleanup; 03154 } 03155 } else { 03156 timeout = -1; 03157 } 03158 03159 if (!tcptls_session->ssl || need_poll) { 03160 res = ast_wait_for_input(tcptls_session->fd, timeout); 03161 if (res < 0) { 03162 ast_debug(2, "SIP %s server :: ast_wait_for_input returned %d\n", tcptls_session->ssl ? "SSL": "TCP", res); 03163 goto cleanup; 03164 } else if (res == 0) { 03165 /* timeout */ 03166 ast_debug(2, "SIP %s server timed out\n", tcptls_session->ssl ? "SSL": "TCP"); 03167 goto cleanup; 03168 } 03169 } 03170 03171 ast_mutex_lock(&tcptls_session->lock); 03172 if (!(bytes_read = fread(buf, 1, MIN(sizeof(buf) - 1, cl), tcptls_session->f))) { 03173 ast_mutex_unlock(&tcptls_session->lock); 03174 if (after_poll) { 03175 goto cleanup; 03176 } else { 03177 need_poll = 1; 03178 continue; 03179 } 03180 } 03181 buf[bytes_read] = '\0'; 03182 ast_mutex_unlock(&tcptls_session->lock); 03183 after_poll = 0; 03184 if (me->stop) 03185 goto cleanup; 03186 cl -= strlen(buf); 03187 ast_str_append(&req.data, 0, "%s", buf); 03188 req.len = req.data->used; 03189 } 03190 } 03191 /*! \todo XXX If there's no Content-Length or if the content-length and what 03192 we receive is not the same - we should generate an error */ 03193 03194 req.socket.tcptls_session = tcptls_session; 03195 handle_request_do(&req, &tcptls_session->remote_address); 03196 } 03197 03198 if (fds[1].revents) { /* alert_pipe indicates there is data in the send queue to be sent */ 03199 enum sip_tcptls_alert alert; 03200 struct tcptls_packet *packet; 03201 03202 fds[1].revents = 0; 03203 03204 if (read(me->alert_pipe[0], &alert, sizeof(alert)) == -1) { 03205 ast_log(LOG_ERROR, "read() failed: %s\n", strerror(errno)); 03206 continue; 03207 } 03208 03209 switch (alert) { 03210 case TCPTLS_ALERT_STOP: 03211 goto cleanup; 03212 case TCPTLS_ALERT_DATA: 03213 ao2_lock(me); 03214 if (!(packet = AST_LIST_REMOVE_HEAD(&me->packet_q, entry))) { 03215 ast_log(LOG_WARNING, "TCPTLS thread alert_pipe indicated packet should be sent, but frame_q is empty"); 03216 } 03217 ao2_unlock(me); 03218 03219 if (packet) { 03220 if (ast_tcptls_server_write(tcptls_session, ast_str_buffer(packet->data), packet->len) == -1) { 03221 ast_log(LOG_WARNING, "Failure to write to tcp/tls socket\n"); 03222 } 03223 ao2_t_ref(packet, -1, "tcptls packet sent, this is no longer needed"); 03224 } 03225 break; 03226 default: 03227 ast_log(LOG_ERROR, "Unknown tcptls thread alert '%d'\n", alert); 03228 } 03229 } 03230 } 03231 03232 ast_debug(2, "Shutting down thread for %s server\n", tcptls_session->ssl ? "SSL" : "TCP"); 03233 03234 cleanup: 03235 if (tcptls_session && !tcptls_session->client && !authenticated) { 03236 ast_atomic_fetchadd_int(&unauth_sessions, -1); 03237 } 03238 03239 if (me) { 03240 ao2_t_unlink(threadt, me, "Removing tcptls helper thread, thread is closing"); 03241 ao2_t_ref(me, -1, "Removing tcp_helper_threads threadinfo ref"); 03242 } 03243 deinit_req(&reqcpy); 03244 deinit_req(&req); 03245 03246 /* if client, we own the parent session arguments and must decrement ref */ 03247 if (ca) { 03248 ao2_t_ref(ca, -1, "closing tcptls thread, getting rid of client tcptls_session arguments"); 03249 } 03250 03251 if (tcptls_session) { 03252 ast_mutex_lock(&tcptls_session->lock); 03253 if (tcptls_session->f) { 03254 fclose(tcptls_session->f); 03255 tcptls_session->f = NULL; 03256 } 03257 if (tcptls_session->fd != -1) { 03258 close(tcptls_session->fd); 03259 tcptls_session->fd = -1; 03260 } 03261 tcptls_session->parent = NULL; 03262 ast_mutex_unlock(&tcptls_session->lock); 03263 03264 ao2_ref(tcptls_session, -1); 03265 tcptls_session = NULL; 03266 } 03267 return NULL; 03268 }
| static int acf_channel_read | ( | struct ast_channel * | chan, | |
| const char * | funcname, | |||
| char * | preparse, | |||
| char * | buf, | |||
| size_t | buflen | |||
| ) | [static] |
Definition at line 21669 of file chan_sip.c.
References AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_inet_ntoa(), ast_log(), ast_rtp_get_peer(), ast_rtp_get_qos(), ast_rtp_get_quality(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), sip_pvt::from, IS_SIP_TECH, ast_rtp_quality::local_count, ast_rtp_quality::local_jitter, ast_rtp_quality::local_lostpackets, ast_rtp_quality::local_ssrc, LOG_ERROR, LOG_WARNING, parse(), sip_pvt::peername, sip_pvt::recv, ast_rtp_quality::remote_count, ast_rtp_quality::remote_jitter, ast_rtp_quality::remote_lostpackets, ast_rtp_quality::remote_ssrc, sip_pvt::rtp, RTPQOS_SUMMARY, ast_rtp_quality::rtt, sip_pvt::sa, t38properties::state, sip_pvt::t38, T38_DISABLED, ast_channel::tech, ast_channel::tech_pvt, sip_pvt::trtp, sip_pvt::uri, sip_pvt::useragent, and sip_pvt::vrtp.
21670 { 21671 struct sip_pvt *p = chan->tech_pvt; 21672 char *all = "", *parse = ast_strdupa(preparse); 21673 int res = 0; 21674 AST_DECLARE_APP_ARGS(args, 21675 AST_APP_ARG(param); 21676 AST_APP_ARG(type); 21677 AST_APP_ARG(field); 21678 ); 21679 AST_STANDARD_APP_ARGS(args, parse); 21680 21681 /* Sanity check */ 21682 if (!IS_SIP_TECH(chan->tech)) { 21683 ast_log(LOG_ERROR, "Cannot call %s on a non-SIP channel\n", funcname); 21684 return 0; 21685 } 21686 21687 memset(buf, 0, buflen); 21688 21689 if (p == NULL) { 21690 return -1; 21691 } 21692 21693 if (!strcasecmp(args.param, "peerip")) { 21694 ast_copy_string(buf, p->sa.sin_addr.s_addr ? ast_inet_ntoa(p->sa.sin_addr) : "", buflen); 21695 } else if (!strcasecmp(args.param, "recvip")) { 21696 ast_copy_string(buf, p->recv.sin_addr.s_addr ? ast_inet_ntoa(p->recv.sin_addr) : "", buflen); 21697 } else if (!strcasecmp(args.param, "from")) { 21698 ast_copy_string(buf, p->from, buflen); 21699 } else if (!strcasecmp(args.param, "uri")) { 21700 ast_copy_string(buf, p->uri, buflen); 21701 } else if (!strcasecmp(args.param, "useragent")) { 21702 ast_copy_string(buf, p->useragent, buflen); 21703 } else if (!strcasecmp(args.param, "peername")) { 21704 ast_copy_string(buf, p->peername, buflen); 21705 } else if (!strcasecmp(args.param, "t38passthrough")) { 21706 ast_copy_string(buf, (p->t38.state == T38_DISABLED) ? "0" : "1", buflen); 21707 } else if (!strcasecmp(args.param, "rtpdest")) { 21708 struct sockaddr_in sin; 21709 struct ast_rtp *stream = NULL; 21710 21711 if (ast_strlen_zero(args.type)) 21712 args.type = "audio"; 21713 21714 if (!strcasecmp(args.type, "audio")) { 21715 stream = p->rtp; 21716 } else if (!strcasecmp(args.type, "video")) { 21717 stream = p->vrtp; 21718 } else if (!strcasecmp(args.type, "text")) { 21719 stream = p->trtp; 21720 } else { 21721 return -1; 21722 } 21723 21724 if (!stream) { 21725 return -1; 21726 } 21727 21728 ast_rtp_get_peer(stream, &sin); 21729 snprintf(buf, buflen, "%s:%d", ast_inet_ntoa(sin.sin_addr), ntohs(sin.sin_port)); 21730 } else if (!strcasecmp(args.param, "rtpqos")) { 21731 struct ast_rtp_quality qos; 21732 struct ast_rtp *rtp = p->rtp; 21733 21734 memset(&qos, 0, sizeof(qos)); 21735 21736 if (ast_strlen_zero(args.type)) 21737 args.type = "audio"; 21738 if (ast_strlen_zero(args.field)) 21739 args.field = "all"; 21740 21741 if (!strcasecmp(args.type, "AUDIO")) { 21742 all = ast_rtp_get_quality(rtp = p->rtp, &qos, RTPQOS_SUMMARY); 21743 } else if (!strcasecmp(args.type, "VIDEO")) { 21744 all = ast_rtp_get_quality(rtp = p->vrtp, &qos, RTPQOS_SUMMARY); 21745 } else if (!strcasecmp(args.type, "TEXT")) { 21746 all = ast_rtp_get_quality(rtp = p->trtp, &qos, RTPQOS_SUMMARY); 21747 } else { 21748 return -1; 21749 } 21750 21751 if (!strcasecmp(args.field, "local_ssrc")) 21752 snprintf(buf, buflen, "%u", qos.local_ssrc); 21753 else if (!strcasecmp(args.field, "local_lostpackets")) 21754 snprintf(buf, buflen, "%u", qos.local_lostpackets); 21755 else if (!strcasecmp(args.field, "local_jitter")) 21756 snprintf(buf, buflen, "%.0f", qos.local_jitter * 1000.0); 21757 else if (!strcasecmp(args.field, "local_count")) 21758 snprintf(buf, buflen, "%u", qos.local_count); 21759 else if (!strcasecmp(args.field, "remote_ssrc")) 21760 snprintf(buf, buflen, "%u", qos.remote_ssrc); 21761 else if (!strcasecmp(args.field, "remote_lostpackets")) 21762 snprintf(buf, buflen, "%u", qos.remote_lostpackets); 21763 else if (!strcasecmp(args.field, "remote_jitter")) 21764 snprintf(buf, buflen, "%.0f", qos.remote_jitter * 1000.0); 21765 else if (!strcasecmp(args.field, "remote_count")) 21766 snprintf(buf, buflen, "%u", qos.remote_count); 21767 else if (!strcasecmp(args.field, "rtt")) 21768 snprintf(buf, buflen, "%.0f", qos.rtt * 1000.0); 21769 else if (!strcasecmp(args.field, "all")) 21770 ast_copy_string(buf, all, buflen); 21771 else if (!ast_rtp_get_qos(rtp, args.field, buf, buflen)) 21772 ; 21773 else { 21774 ast_log(LOG_WARNING, "Unrecognized argument '%s' to %s\n", preparse, funcname); 21775 return -1; 21776 } 21777 } else { 21778 res = -1; 21779 } 21780 return res; 21781 }
| static void add_blank | ( | struct sip_request * | req | ) | [static] |
add a blank line if no body
Definition at line 4425 of file chan_sip.c.
References ast_str_append(), ast_str_strlen(), sip_request::data, sip_request::len, and sip_request::lines.
Referenced by send_request(), and send_response().
04426 { 04427 if (!req->lines) { 04428 /* Add extra empty return. add_header() reserves 4 bytes so cannot be truncated */ 04429 ast_str_append(&req->data, 0, "\r\n"); 04430 req->len = ast_str_strlen(req->data); 04431 } 04432 }
| static void add_codec_to_sdp | ( | const struct sip_pvt * | p, | |
| int | codec, | |||
| struct ast_str ** | m_buf, | |||
| struct ast_str ** | a_buf, | |||
| int | debug, | |||
| int * | min_packet_size | |||
| ) | [static] |
Add codec offer to SDP offer/answer body in INVITE or 200 OK.
Definition at line 10408 of file chan_sip.c.
References ast_codec_pref_getsize(), AST_FORMAT_G723_1, AST_FORMAT_G729A, AST_FORMAT_ILBC, AST_FORMAT_SIREN14, AST_FORMAT_SIREN7, ast_getformatname(), ast_rtp_codec_getpref(), ast_rtp_lookup_code(), ast_rtp_lookup_mime_subtype(), ast_rtp_lookup_sample_rate(), AST_RTP_OPT_G726_NONSTANDARD, ast_str_append(), ast_test_flag, ast_verbose, ast_format_list::cur_ms, sip_pvt::flags, sip_pvt::rtp, and SIP_G726_NONSTANDARD.
Referenced by add_sdp().
10411 { 10412 int rtp_code; 10413 struct ast_format_list fmt; 10414 10415 10416 if (debug) 10417 ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec)); 10418 if ((rtp_code = ast_rtp_lookup_code(p->rtp, 1, codec)) == -1) 10419 return; 10420 10421 if (p->rtp) { 10422 struct ast_codec_pref *pref = ast_rtp_codec_getpref(p->rtp); 10423 fmt = ast_codec_pref_getsize(pref, codec); 10424 } else /* I dont see how you couldn't have p->rtp, but good to check for and error out if not there like earlier code */ 10425 return; 10426 ast_str_append(m_buf, 0, " %d", rtp_code); 10427 ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%d\r\n", rtp_code, 10428 ast_rtp_lookup_mime_subtype(1, codec, 10429 ast_test_flag(&p->flags[0], SIP_G726_NONSTANDARD) ? AST_RTP_OPT_G726_NONSTANDARD : 0), 10430 ast_rtp_lookup_sample_rate(1, codec)); 10431 10432 switch (codec) { 10433 case AST_FORMAT_G729A: 10434 /* Indicate that we don't support VAD (G.729 annex B) */ 10435 ast_str_append(a_buf, 0, "a=fmtp:%d annexb=no\r\n", rtp_code); 10436 break; 10437 case AST_FORMAT_G723_1: 10438 /* Indicate that we don't support VAD (G.723.1 annex A) */ 10439 ast_str_append(a_buf, 0, "a=fmtp:%d annexa=no\r\n", rtp_code); 10440 break; 10441 case AST_FORMAT_ILBC: 10442 /* Add information about us using only 20/30 ms packetization */ 10443 ast_str_append(a_buf, 0, "a=fmtp:%d mode=%d\r\n", rtp_code, fmt.cur_ms); 10444 break; 10445 case AST_FORMAT_SIREN7: 10446 /* Indicate that we only expect 32Kbps */ 10447 ast_str_append(a_buf, 0, "a=fmtp:%d bitrate=32000\r\n", rtp_code); 10448 break; 10449 case AST_FORMAT_SIREN14: 10450 /* Indicate that we only expect 48Kbps */ 10451 ast_str_append(a_buf, 0, "a=fmtp:%d bitrate=48000\r\n", rtp_code); 10452 break; 10453 } 10454 10455 if (fmt.cur_ms && (fmt.cur_ms < *min_packet_size)) 10456 *min_packet_size = fmt.cur_ms; 10457 10458 /* Our first codec packetization processed cannot be zero */ 10459 if ((*min_packet_size)==0 && fmt.cur_ms) 10460 *min_packet_size = fmt.cur_ms; 10461 }
| static int add_content | ( | struct sip_request * | req, | |
| const char * | line | |||
| ) | [static] |
Add content (not header) to SIP message.
Definition at line 9609 of file chan_sip.c.
References ast_log(), ast_str_append(), sip_request::content, sip_request::lines, and LOG_WARNING.
Referenced by add_digit(), add_sdp(), add_text(), add_vidupdate(), transmit_notify_with_mwi(), transmit_notify_with_sipfrag(), and transmit_state_notify().
09610 { 09611 if (req->lines) { 09612 ast_log(LOG_WARNING, "Can't add more content when the content has been finalized\n"); 09613 return -1; 09614 } 09615 09616 ast_str_append(&req->content, 0, "%s", line); 09617 return 0; 09618 }
| static int add_digit | ( | struct sip_request * | req, | |
| char | digit, | |||
| unsigned int | duration, | |||
| int | mode | |||
| ) | [static] |
Add DTMF INFO tone to sip message Mode = 0 for application/dtmf-relay (Cisco) 1 for application/dtmf.
Definition at line 10362 of file chan_sip.c.
References add_content(), and add_header().
Referenced by transmit_info_with_digit().
10363 { 10364 char tmp[256]; 10365 int event; 10366 if (mode) { 10367 /* Application/dtmf short version used by some implementations */ 10368 if (digit == '*') 10369 event = 10; 10370 else if (digit == '#') 10371 event = 11; 10372 else if ((digit >= 'A') && (digit <= 'D')) 10373 event = 12 + digit - 'A'; 10374 else 10375 event = atoi(&digit); 10376 snprintf(tmp, sizeof(tmp), "%d\r\n", event); 10377 add_header(req, "Content-Type", "application/dtmf"); 10378 add_content(req, tmp); 10379 } else { 10380 /* Application/dtmf-relay as documented by Cisco */ 10381 snprintf(tmp, sizeof(tmp), "Signal=%c\r\nDuration=%u\r\n", digit, duration); 10382 add_header(req, "Content-Type", "application/dtmf-relay"); 10383 add_content(req, tmp); 10384 } 10385 return 0; 10386 }
| static int add_header | ( | struct sip_request * | req, | |
| const char * | var, | |||
| const char * | value | |||
| ) | [static] |
Add header to SIP message.
Definition at line 9562 of file chan_sip.c.
References ast_log(), ast_str_append(), ast_str_strlen(), sip_settings::compactheaders, sip_request::data, find_alias(), sip_request::header, sip_request::headers, sip_request::len, sip_request::lines, LOG_WARNING, sip_cfg, and SIP_MAX_HEADERS.
09563 { 09564 if (req->headers == SIP_MAX_HEADERS) { 09565 ast_log(LOG_WARNING, "Out of SIP header space\n"); 09566 return -1; 09567 } 09568 09569 if (req->lines) { 09570 ast_log(LOG_WARNING, "Can't add more headers when lines have been added\n"); 09571 return -1; 09572 } 09573 09574 if (sip_cfg.compactheaders) { 09575 var = find_alias(var, var); 09576 } 09577 09578 ast_str_append(&req->data, 0, "%s: %s\r\n", var, value); 09579 req->header[req->headers] = req->len; 09580 09581 req->len = ast_str_strlen(req->data); 09582 req->headers++; 09583 09584 return 0; 09585 }
| static void add_noncodec_to_sdp | ( | const struct sip_pvt * | p, | |
| int | format, | |||
| struct ast_str ** | m_buf, | |||
| struct ast_str ** | a_buf, | |||
| int | debug | |||
| ) | [static] |
Add RFC 2833 DTMF offer to SDP.
Definition at line 10541 of file chan_sip.c.
References AST_RTP_DTMF, ast_rtp_lookup_code(), ast_rtp_lookup_mime_subtype(), ast_rtp_lookup_sample_rate(), ast_str_append(), ast_verbose, and sip_pvt::rtp.
Referenced by add_sdp().
10544 { 10545 int rtp_code; 10546 10547 if (debug) 10548 ast_verbose("Adding non-codec 0x%x (%s) to SDP\n", format, ast_rtp_lookup_mime_subtype(0, format, 0)); 10549 if ((rtp_code = ast_rtp_lookup_code(p->rtp, 0, format)) == -1) 10550 return; 10551 10552 ast_str_append(m_buf, 0, " %d", rtp_code); 10553 ast_str_append(a_buf, 0, "a=rtpmap:%d %s/%d\r\n", rtp_code, 10554 ast_rtp_lookup_mime_subtype(0,