[asterisk-commits] rizzo: branch rizzo/astobj2 r51222 - /team/rizzo/astobj2/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 18 06:23:10 MST 2007


Author: rizzo
Date: Thu Jan 18 07:23:08 2007
New Revision: 51222

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51222
Log:
update to the new callback and api changes over the
past month


Modified:
    team/rizzo/astobj2/channels/chan_sip.c

Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=51222&r1=51221&r2=51222
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Thu Jan 18 07:23:08 2007
@@ -1503,8 +1503,8 @@
 static const char *nat2str(int nat) attribute_const;
 static int peer_status(struct sip_peer *peer, char *status, int statuslen);
 static int sip_show_users(int fd, int argc, char *argv[]);
-static int _sip_show_peers(int fd, int *total, struct mansession *s, struct message *m, int argc, char *argv[]);
-static int manager_sip_show_peers( struct mansession *s, struct message *m );
+static int _sip_show_peers(int fd, int *total, struct mansession *s, const struct message *m, int argc, char *argv[]);
+static int manager_sip_show_peers(struct mansession *s, const struct message *m );
 static int sip_show_peers(int fd, int argc, char *argv[]);
 static int sip_show_objects(int fd, int argc, char *argv[]);
 static void  print_group(int fd, ast_group_t group, int crlf);
@@ -1514,10 +1514,9 @@
 static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
 static const char *domain_mode_to_text(const enum domain_mode mode);
 static int sip_show_domains(int fd, int argc, char *argv[]);
-static int _sip_show_peer(int type, int fd, struct mansession *s, struct message *m, int argc, char *argv[]);
-static int manager_sip_show_peer( struct mansession *s, struct message *m);
+static int _sip_show_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, char *argv[]);
+static int manager_sip_show_peer(struct mansession *s, const struct message *m);
 static int sip_show_peer(int fd, int argc, char *argv[]);
-static int _sip_show_peer(int type, int fd, struct mansession *s, struct message *m, int argc, char *argv[]);
 static int sip_show_user(int fd, int argc, char *argv[]);
 static int sip_show_registry(int fd, int argc, char *argv[]);
 static int sip_show_settings(int fd, int argc, char *argv[]);
@@ -1534,10 +1533,10 @@
 static int sip_notify(int fd, int argc, char *argv[]);
 static int sip_do_history(int fd, int argc, char *argv[]);
 static int sip_no_history(int fd, int argc, char *argv[]);
-static int func_header_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len);
-static int func_check_sipdomain(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len);
-static int function_sippeer(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len);
-static int function_sipchaninfo_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len);
+static int func_header_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
+static int func_check_sipdomain(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len);
+static int function_sippeer(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len);
+static int function_sipchaninfo_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len);
 static int sip_dtmfmode(struct ast_channel *chan, void *data);
 static int sip_addheader(struct ast_channel *chan, void *data);
 static int sip_reload(int fd, int argc, char *argv[]);
@@ -10023,9 +10022,9 @@
 
 /*! \brief  Show SIP peers in the manager API */
 /*    Inspired from chan_iax2 */
-static int manager_sip_show_peers( struct mansession *s, struct message *m )
-{
-	char *id = astman_get_header(m,"ActionID");
+static int manager_sip_show_peers(struct mansession *s, const struct message *m )
+{
+	const char *id = astman_get_header(m,"ActionID");
 	char *a[] = { "sip", "show", "peers" };
 	char idtext[256] = "";
 	int total = 0;
@@ -10053,7 +10052,7 @@
 }
 
 /*! \brief  _sip_show_peers: Execute sip show peers command */
-static int _sip_show_peers(int fd, int *total, struct mansession *s, struct message *m, int argc, char *argv[])
+static int _sip_show_peers(int fd, int *total, struct mansession *s, const struct message *m, int argc, char *argv[])
 {
 	regex_t regexbuf;
 	int havepattern = FALSE;
@@ -10067,7 +10066,7 @@
 	int peers_mon_offline = 0;
 	int peers_unmon_offline = 0;
 	int peers_unmon_online = 0;
-	char *id;
+	const char *id;
 	char idtext[256] = "";
 	int realtimepeers;
 
@@ -10491,11 +10490,11 @@
 "  ActionID: <id>	  Optional action ID for this AMI transaction.\n";
 
 /*! \brief Show SIP peers in the manager API  */
-static int manager_sip_show_peer( struct mansession *s, struct message *m)
-{
-	char *id = astman_get_header(m,"ActionID");
+static int manager_sip_show_peer(struct mansession *s, const struct message *m)
+{
+	const char *id = astman_get_header(m,"ActionID");
 	char *a[4];
-	char *peer;
+	const char *peer;
 	int ret;
 
 	peer = astman_get_header(m,"Peer");
@@ -10506,7 +10505,7 @@
 	a[0] = "sip";
 	a[1] = "show";
 	a[2] = "peer";
-	a[3] = peer;
+	a[3] = ast_strdupa(peer);
 
 	if (!ast_strlen_zero(id))
 		astman_append(s, "ActionID: %s\r\n",id);
@@ -10524,7 +10523,7 @@
 }
 
 /*! \brief Show one peer in detail (main function) */
-static int _sip_show_peer(int type, int fd, struct mansession *s, struct message *m, int argc, char *argv[])
+static int _sip_show_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, char *argv[])
 {
 	char status[30] = "";
 	char cbuf[256];
@@ -11854,7 +11853,7 @@
 "       Provides detailed list of the configuration of the SIP channel.\n";
 
 /*! \brief Read SIP header (dialplan function) */
-static int func_header_read(struct ast_channel *chan, char *function, char *data, char *buf, size_t len) 
+static int func_header_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len) 
 {
 	struct sip_pvt *p;
 	const char *content = NULL;
@@ -11918,7 +11917,7 @@
 };
 
 /*! \brief  Dial plan function to check if domain is local */
-static int func_check_sipdomain(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int func_check_sipdomain(struct ast_channel *chan,const  char *cmd, char *data, char *buf, size_t len)
 {
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "CHECKSIPDOMAIN requires an argument - A domain name\n");
@@ -11943,7 +11942,7 @@
 };
 
 /*! \brief  ${SIPPEER()} Dialplan function - reads peer data */
-static int function_sippeer(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int function_sippeer(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
 	struct sip_peer *peer;
 	char *colname;
@@ -12033,7 +12032,7 @@
 };
 
 /*! \brief ${SIPCHANINFO()} Dialplan function - reads sip channel data */
-static int function_sipchaninfo_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len)
+static int function_sipchaninfo_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
 	struct sip_pvt *p;
 
@@ -16417,6 +16416,7 @@
 	strcpy(user->mohinterpret, default_mohinterpret);
 	strcpy(user->mohsuggest, default_mohsuggest);
 	for (; v; v = v->next) {
+		int ha_error = 0;
 		M_START(v->name, v->value);
 		if (handle_common_options(&userflags[0], &mask[0], v))
 			continue;
@@ -16425,7 +16425,7 @@
 		M_STR("context", user->context)
 		M_STR("subscribecontext", user->subscribecontext)
 		M_F("setvar", user->chanvars = add_var(v->value, user->chanvars))
-		M_F("|permit|deny|", user->ha = ast_append_ha(v->name, v->value, user->ha))
+		M_F("|permit|deny|", user->ha = ast_append_ha(v->name, v->value, user->ha, &ha_error))
 		M_F("allowtransfer", user->allowtransfer = ast_true(v->value) ? TRANSFER_OPENFORALL : TRANSFER_CLOSED)
 		M_STR("secret", user->secret)
 		M_STR("md5secret", user->md5secret)
@@ -16656,7 +16656,8 @@
 				unref_peer(peer);
 				return NULL;	/* XXX why ? */
 			}} )
-		M_F("|permit|deny|", peer->ha = ast_append_ha(v->name, v->value, peer->ha) )
+		M_F("|permit|deny|", {int ha_error = 0;
+			peer->ha = ast_append_ha(v->name, v->value, peer->ha, &ha_error); } )
 		M_F("port", {
 			if (!realtime && ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC))
 				peer->defaddr.sin_port = htons(atoi(v->value));
@@ -16935,8 +16936,10 @@
 				memcpy(&bindaddr.sin_addr, hp->h_addr, sizeof(bindaddr.sin_addr));
 			} } )
 		M_F("localnet", {
+			int ha_error = 0;
 			struct ast_ha *na;
-			if (!(na = ast_append_ha("d", v->value, localaddr)))
+			na = ast_append_ha("d", v->value, localaddr, &ha_error);
+			if (ha_error)
 				ast_log(LOG_WARNING, "Invalid localnet value: %s\n", v->value);
 			else
 				localaddr = na; } )



More information about the asterisk-commits mailing list