[asterisk-dev] [patch] adding username from registration to peer state ?

Luigi Rizzo rizzo at icir.org
Thu Oct 26 22:58:43 MST 2006


Any interest in adding the username from the REGISTER message
in the stored peer state ? It seems that we currently do not
learn this information, which is a useful one to display on a GUI.

Implementation is trivial (see the attached patch), i am only
uncertain on what is the appropriate field name to use for the
manager messages...

	cheers
	luigi

Index: channels/chan_sip.c
===================================================================
--- channels/chan_sip.c	(revision 46348)
+++ channels/chan_sip.c	(working copy)
@@ -1073,6 +1073,7 @@
 	char mohinterpret[MAX_MUSICCLASS];/*!<  Music on Hold class */
 	char mohsuggest[MAX_MUSICCLASS];/*!<  Music on Hold class */
 	char useragent[256];		/*!<  User agent in SIP request (saved from registration) */
+	char from_header[256];		/*!<  From header in registration */
 	struct ast_codec_pref prefs;	/*!<  codec prefs */
 	int lastmsgssent;
 	time_t	lastmsgcheck;		/*!<  Last time we checked for MWI */
@@ -7748,6 +7750,10 @@
 		if (option_verbose > 3)
 			ast_verbose(VERBOSE_PREFIX_3 "Saved useragent \"%s\" for peer %s\n", peer->useragent, peer->name);  
 	}
+	{ const char *from = get_header(req, "From");
+		if (!ast_strlen_zero(from))
+			get_calleridname(from, peer->from_header, sizeof(peer->from_header));
+	}
 	return PARSE_REGISTER_UPDATE;
 }
 
@@ -9612,6 +9623,7 @@
 			"VideoSupport: %s\r\n"
 			"ACL: %s\r\n"
 			"Status: %s\r\n"
+			"From: %s\r\n"
 			"RealtimeDevice: %s\r\n\r\n", 
 			idtext,
 			iterator->name, 
@@ -9622,6 +9634,7 @@
 			ast_test_flag(&iterator->flags[1], SIP_PAGE2_VIDEOSUPPORT) ? "yes" : "no",	/* VIDEOSUPPORT=yes? */
 			iterator->ha ? "yes" : "no",       /* permit/deny */
 			status,
+			iterator->from_header,
 			realtimepeers ? (ast_test_flag(&iterator->flags[0], SIP_REALTIME) ? "yes":"no") : "no");
 		}
 


More information about the asterisk-dev mailing list