[asterisk-commits] branch oej/sipregister r8827 - in
/team/oej/sipregister: ./ channels/chan_sip.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sat Jan 28 08:43:20 MST 2006
Author: oej
Date: Sat Jan 28 09:43:17 2006
New Revision: 8827
URL: http://svn.digium.com/view/asterisk?rev=8827&view=rev
Log:
Merged revisions 8825-8826 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r8825 | oej | 2006-01-28 16:28:58 +0100 (Sat, 28 Jan 2006) | 7 lines
- Moving forward declarations to one block
- Moving global variables to one block
- Moving global networking variables to one block
- Small whitespace changes
- Renaming a few more global channel settings to global_ for clarity
(No functional changes)
........
r8826 | oej | 2006-01-28 16:34:27 +0100 (Sat, 28 Jan 2006) | 2 lines
Doxygen updates
........
Modified:
team/oej/sipregister/ (props changed)
team/oej/sipregister/channels/chan_sip.c
Propchange: team/oej/sipregister/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sat Jan 28 09:43:17 2006
@@ -1,1 +1,1 @@
-/trunk:1-8823
+/trunk:1-8826
Modified: team/oej/sipregister/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/channels/chan_sip.c?rev=8827&r1=8826&r2=8827&view=diff
==============================================================================
--- team/oej/sipregister/channels/chan_sip.c (original)
+++ team/oej/sipregister/channels/chan_sip.c Sat Jan 28 09:43:17 2006
@@ -140,8 +140,6 @@
#define CALLERID_UNKNOWN "Unknown"
-
-
#define DEFAULT_MAXMS 2000 /*!< Qualification: Must be faster than 2 seconds by default */
#define DEFAULT_FREQ_OK 60 * 1000 /*!< Qualification: How often to check for the host to be up */
#define DEFAULT_FREQ_NOTOK 10 * 1000 /*!< Qualification: How often to check, if the host is down... */
@@ -152,12 +150,15 @@
#define SIP_MAX_HEADERS 64 /*!< Max amount of SIP headers to read */
#define SIP_MAX_LINES 64 /*!< Max amount of lines in SIP attachment (like SDP) */
+#define SIP_MAX_PACKET 4096 /*!< Also from RFC 3261 (2543), should sub headers tho */
static const char desc[] = "Session Initiation Protocol (SIP)";
static const char channeltype[] = "SIP";
static const char config[] = "sip.conf";
static const char notify_config[] = "sip_notify.conf";
+static int usecnt = 0;
+
#define RTP 1
#define NO_RTP 0
@@ -338,7 +339,6 @@
/*! \brief SIP Extensions we support */
#define SUPPORTED_EXTENSIONS "replaces"
-#define SIP_MAX_PACKET 4096 /*!< Also from RFC 3261 (2543), should sub headers tho */
/* Default values, set and reset in reload_config before reading configuration */
/* These are default values in the source. There are other recommended values in the
@@ -380,11 +380,12 @@
static char default_musicclass[MAX_MUSICCLASS]; /*!< Global music on hold class */
/* Global settings only apply to the channel */
+static int global_rtautoclear = 120;
static int global_notifyringing; /*!< Send notifications on ringing */
static int srvlookup; /*!< SRV Lookup on or off. Default is off, RFC behavior is on */
static int pedanticsipchecking; /*!< Extra checking ? Default off */
static int autocreatepeer; /*!< Auto creation of peers at registration? Default off. */
-static int relaxdtmf; /*!< Relax DTMF */
+static int global_relaxdtmf; /*!< Relax DTMF */
static int global_rtptimeout; /*!< Time out call if no RTP */
static int global_rtpholdtimeout;
static int global_rtpkeepalive; /*!< Send RTP keepalives */
@@ -401,6 +402,7 @@
static char regcontext[AST_MAX_CONTEXT]; /*!< Context for auto-extensions */
static char global_useragent[AST_MAX_EXTENSION]; /*!< Useragent for the SIP channel */
static int allow_external_domains; /*!< Accept calls to external SIP domains? */
+static int global_callevents; /*!< Whether we send manager events or not */
/*! \brief Codecs that we support by default: */
static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
@@ -417,8 +419,6 @@
static struct ast_flags global_flags = {0}; /*!< global SIP_ flags */
static struct ast_flags global_flags_page2 = {0}; /*!< more global SIP_ flags */
-static int usecnt =0;
-
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
AST_MUTEX_DEFINE_STATIC(rand_lock); /*!< Lock for thread-safe random generator */
@@ -432,28 +432,22 @@
AST_MUTEX_DEFINE_STATIC(monlock);
+AST_MUTEX_DEFINE_STATIC(sip_reload_lock);
+
/*! \brief This is the thread for the monitor which checks for input on the channels
which are not currently in use. */
static pthread_t monitor_thread = AST_PTHREADT_NULL;
-static int restart_monitor(void);
-
-
-static struct in_addr __ourip;
-static struct sockaddr_in outboundproxyip;
-static int ourport;
-static struct sockaddr_in debugaddr;
-
+static int sip_reloading = 0; /*!< Flag for avoiding multiple reloads at the same time */
+static enum channelreloadreason sip_reloadreason; /*!< Reason for last reload/load of configuration */
static struct sched_context *sched;
static struct io_context *io;
-
#define DEC_CALL_LIMIT 0
#define INC_CALL_LIMIT 1
static struct ast_codec_pref prefs;
-
/*! \brief sip_request: The data grabbed from the UDP socket */
struct sip_request {
@@ -521,6 +515,7 @@
struct sip_auth *next; /*!< Next auth structure in list */
};
+/*--- Various flags for the flags field in the pvt structure */
#define SIP_ALREADYGONE (1 << 0) /*!< Whether or not we've already been destroyed by our peer */
#define SIP_NEEDDESTROY (1 << 1) /*!< if we need to be destroyed */
#define SIP_NOVIDEO (1 << 2) /*!< Didn't get video in invite, don't offer */
@@ -573,7 +568,7 @@
/* Remote Party-ID Support */
#define SIP_SENDRPID (1 << 30)
/* Did this connection increment the counter of in-use calls? */
-#define SIP_INC_COUNT (1 << 31)
+#define SIP_INC_COUNT (1 << 31)
#define SIP_FLAGS_TO_COPY \
(SIP_PROMISCREDIR | SIP_TRUSTRPID | SIP_SENDRPID | SIP_DTMF | SIP_REINVITE | \
@@ -598,7 +593,6 @@
#define sipdebug_config ast_test_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONFIG)
#define sipdebug_console ast_test_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONSOLE)
-static int global_rtautoclear = 120;
/*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe */
static struct sip_pvt {
@@ -816,9 +810,6 @@
int lastmsg;
};
-AST_MUTEX_DEFINE_STATIC(sip_reload_lock);
-static int sip_reloading = 0;
-static enum channelreloadreason sip_reloadreason; /*!< Reason for last reload/load of configuration */
/* States for outbound registrations (with register= lines in sip.conf */
#define REG_STATE_UNREGISTERED 0 /*!< We are not registred */
@@ -863,6 +854,8 @@
char lastmsg[256]; /*!< Last Message sent/received */
};
+/* --- Linked lists of various objects --------*/
+
/*! \brief The user list: Users and friends */
static struct ast_user_list {
ASTOBJ_CONTAINER_COMPONENTS(struct sip_user);
@@ -879,23 +872,25 @@
int recheck;
} regl;
-
-static int __sip_do_register(struct sip_registry *r);
-
-static int sipsock = -1;
-
-
+/*! \todo Move the sip_auth list to AST_LIST */
+static struct sip_auth *authl = NULL; /*!< Authentication list for realm authentication */
+
+
+/* --- Sockets and networking --------------*/
+static int sipsock = -1; /*!< Main socket for SIP network communication */
static struct sockaddr_in bindaddr = { 0, }; /*!< The address we bind to */
static struct sockaddr_in externip; /*!< External IP address if we are behind NAT */
static char externhost[MAXHOSTNAMELEN]; /*!< External host name (possibly with dynamic DNS and DHCP */
static time_t externexpire = 0; /*!< Expiration counter for re-resolving external host name in dynamic DNS */
static int externrefresh = 10;
static struct ast_ha *localaddr; /*!< List of local networks, on the same side of NAT as this Asterisk */
-static int callevents; /*!< Whether we send manager events or not */
+static struct in_addr __ourip;
+static struct sockaddr_in outboundproxyip;
+static int ourport;
+static struct sockaddr_in debugaddr;
struct ast_config *notify_types; /*!< The list of manual NOTIFY types we know how to send */
-static struct sip_auth *authl = NULL; /*!< Authentication list for realm authentication */
/*---------------------------- Forward declarations of functions in chan_sip.c */
@@ -953,6 +948,8 @@
static int transmit_response_reliable(struct sip_pvt *p, char *msg, struct sip_request *req, int fatal);
static int transmit_register(struct sip_registry *r, int sipmethod, char *auth, char *authheader);
static int sip_poke_peer(struct sip_peer *peer);
+static int __sip_do_register(struct sip_registry *r);
+static int restart_monitor(void);
/*! \brief Definition of this channel for PBX channel registration */
static const struct ast_channel_tech sip_tech = {
@@ -2842,7 +2839,7 @@
if (ast_test_flag(i, SIP_DTMF) == SIP_DTMF_INBAND) {
i->vad = ast_dsp_new();
ast_dsp_set_features(i->vad, DSP_FEATURE_DTMF_DETECT);
- if (relaxdtmf)
+ if (global_relaxdtmf)
ast_dsp_digitmode(i->vad, DSP_DIGITMODE_DTMF | DSP_DIGITMODE_RELAXDTMF);
}
if (i->rtp) {
@@ -3756,7 +3753,7 @@
if (sin.sin_addr.s_addr && !sendonly) {
append_history(p, "Unhold", "%s", req->data);
- if (callevents && ast_test_flag(p, SIP_CALL_ONHOLD)) {
+ if (global_callevents && ast_test_flag(p, SIP_CALL_ONHOLD)) {
manager_event(EVENT_FLAG_CALL, "Unhold",
"Channel: %s\r\n"
"Uniqueid: %s\r\n",
@@ -3769,7 +3766,7 @@
/* No address for RTP, we're on hold */
append_history(p, "Hold", "%s", req->data);
- if (callevents && !ast_test_flag(p, SIP_CALL_ONHOLD)) {
+ if (global_callevents && !ast_test_flag(p, SIP_CALL_ONHOLD)) {
manager_event(EVENT_FLAG_CALL, "Hold",
"Channel: %s\r\n"
"Uniqueid: %s\r\n",
@@ -6055,6 +6052,7 @@
static void free_old_route(struct sip_route *route)
{
struct sip_route *next;
+
while (route) {
next = route->next;
free(route);
@@ -6062,7 +6060,7 @@
}
}
-/*! \brief list_route: List all routes - mostly for debugging */
+/*! \brief List all routes - mostly for debugging */
static void list_route(struct sip_route *route)
{
if (!route) {
@@ -6075,7 +6073,7 @@
}
}
-/*! \brief build_route: Build route list from Record-Route header */
+/*! \brief Build route list from Record-Route header */
static void build_route(struct sip_pvt *p, struct sip_request *req, int backwards)
{
struct sip_route *thishop, *head, *tail;
@@ -6418,9 +6416,9 @@
return res;
}
-/*! \brief cb_extensionstate: Callback for the devicestate notification (SUBSCRIBE) support subsystem */
-/* If you add an "hint" priority to the extension in the dial plan,
- you will get notifications on device state changes */
+/*! \brief Callback for the devicestate notification (SUBSCRIBE) support subsystem
+\note If you add an "hint" priority to the extension in the dial plan,
+ you will get notifications on device state changes */
static int cb_extensionstate(char *context, char* exten, int state, void *data)
{
struct sip_pvt *p = data;
@@ -6447,7 +6445,7 @@
return 0;
}
-/*! \brief register_verify: Verify registration of user */
+/*! \brief Verify registration of user */
static int register_verify(struct sip_pvt *p, struct sockaddr_in *sin, struct sip_request *req, char *uri, int ignore)
{
int res = -3;
@@ -6591,7 +6589,7 @@
return res;
}
-/*! \brief get_rdnis: get referring dnis */
+/*! \brief Get referring dnis */
static int get_rdnis(struct sip_pvt *p, struct sip_request *oreq)
{
char tmp[256], *c, *a;
@@ -6619,7 +6617,7 @@
return 0;
}
-/*! \brief get_destination: Find out who the call is for */
+/*! \brief Find out who the call is for */
static int get_destination(struct sip_pvt *p, struct sip_request *oreq)
{
char tmp[256] = "", *uri, *a;
@@ -6715,7 +6713,7 @@
return -1;
}
-/*! \brief get_sip_pvt_byid_locked: Lock interface lock and find matching pvt lock */
+/*! \brief Lock interface lock and find matching pvt lock */
static struct sip_pvt *get_sip_pvt_byid_locked(char *callid)
{
struct sip_pvt *sip_pvt_ptr = NULL;
@@ -6744,7 +6742,7 @@
return sip_pvt_ptr;
}
-/*! \brief get_refer_info: Call transfer support (the REFER method) */
+/*! \brief Call transfer support (the REFER method) */
static int get_refer_info(struct sip_pvt *sip_pvt, struct sip_request *outgoing_req)
{
@@ -7342,7 +7340,9 @@
return res;
}
-/*! \brief Find user */
+/*! \brief 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 int check_user(struct sip_pvt *p, struct sip_request *req, int sipmethod, char *uri, int reliable, struct sockaddr_in *sin, int ignore)
{
return check_user_full(p, req, sipmethod, uri, reliable, sin, ignore, NULL, 0);
@@ -7370,9 +7370,9 @@
}
-/*! \brief Receive SIP MESSAGE method messages */
-/* We only handle messages within current calls currently */
-/* Reference: RFC 3428 */
+/*! \brief Receive SIP MESSAGE method messages
+\note We only handle messages within current calls currently
+ Reference: RFC 3428 */
static void receive_message(struct sip_pvt *p, struct sip_request *req)
{
char buf[1024];
@@ -7475,8 +7475,8 @@
}
}
-/*! \brief Report Peer status in character string */
-/* returns 1 if peer is online, -1 if unmonitored */
+/*! \brief Report Peer status in character string
+ * \return 1 if peer is online, -1 if unmonitored */
static int peer_status(struct sip_peer *peer, char *status, int statuslen)
{
int res = 0;
@@ -8310,7 +8310,7 @@
ast_cli(fd, " Caller ID: %s\n", default_callerid);
ast_cli(fd, " From: Domain: %s\n", default_fromdomain);
ast_cli(fd, " Record SIP history: %s\n", recordhistory ? "On" : "Off");
- ast_cli(fd, " Call Events: %s\n", callevents ? "On" : "Off");
+ ast_cli(fd, " Call Events: %s\n", global_callevents ? "On" : "Off");
ast_cli(fd, " IP ToS: 0x%x\n", global_tos);
#ifdef OSP_SUPPORT
ast_cli(fd, " OSP Support: Yes\n");
@@ -8327,7 +8327,7 @@
ast_cli(fd, " Codecs: ");
print_codec_to_cli(fd, &prefs);
ast_cli(fd, "\n");
- ast_cli(fd, " Relax DTMF: %s\n", relaxdtmf ? "Yes" : "No");
+ ast_cli(fd, " Relax DTMF: %s\n", global_relaxdtmf ? "Yes" : "No");
ast_cli(fd, " Compact SIP headers: %s\n", compactheaders ? "Yes" : "No");
ast_cli(fd, " RTP Timeout: %d %s\n", global_rtptimeout, global_rtptimeout ? "" : "(Disabled)" );
ast_cli(fd, " RTP Hold Timeout: %d %s\n", global_rtpholdtimeout, global_rtpholdtimeout ? "" : "(Disabled)");
@@ -12444,8 +12444,8 @@
ast_clear_flag(&global_flags_page2, SIP_PAGE2_DEBUG_CONFIG);
/* Misc settings for the channel */
- relaxdtmf = 0;
- callevents = 0;
+ global_relaxdtmf = 0;
+ global_callevents = 0;
/* Read the [general] config section of sip.conf (or from realtime config) */
for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
@@ -12476,7 +12476,7 @@
} else if (!strcasecmp(v->name, "usereqphone")) {
ast_set2_flag((&global_flags), ast_true(v->value), SIP_USEREQPHONE);
} else if (!strcasecmp(v->name, "relaxdtmf")) {
- relaxdtmf = ast_true(v->value);
+ global_relaxdtmf = ast_true(v->value);
} else if (!strcasecmp(v->name, "checkmwi")) {
if ((sscanf(v->value, "%d", &global_mwitime) != 1) || (global_mwitime < 0)) {
ast_log(LOG_WARNING, "'%s' is not a valid MWI time setting at line %d. Using default (10).\n", v->value, v->lineno);
@@ -12633,7 +12633,7 @@
default_qualify = 0;
}
} else if (!strcasecmp(v->name, "callevents")) {
- callevents = ast_true(v->value);
+ global_callevents = ast_true(v->value);
}
}
More information about the asterisk-commits
mailing list