[Asterisk-Dev] get register info from peer section in sip.conf ?

Luigi Rizzo rizzo at icir.org
Wed Nov 23 01:36:04 MST 2005


i think i have seen it mentioned before but cannot find a relevant
patch in mantis...

I was wondering if there is a way to grab the register info

	register => user[:secret[:authuser]]@host[:port][/contact]

from a peer section, e.g. using a syntax like

	register => peersectionname

If not, which sip_peer fields should i use for the register fields ?
I think

	register field		sip_peer field

	username		user
	secret			secret
	tohost			host
	authuser		???
	port			??? not available ?
	contact			???

I guess all of this can be implemented in sip_register().

BTW i am looking at this function and there are some things that do
not make sense to me. E.g. below:

   3205     stringp=username;
   3206     username = strsep(&stringp, ":");
   3207     if (username) {
   3208         secret = strsep(&stringp, ":");
   3209         if (secret)
   3210             authuser = strsep(&stringp, ":");
   3211     }
   3212     stringp = hostname;
   3213     hostname = strsep(&stringp, "/");
   3214     if (hostname)
   3215         contact = strsep(&stringp, "/");
   3216     if (ast_strlen_zero(contact))
   3217         contact = "s";
   3218     stringp=hostname;
   3219     hostname = strsep(&stringp, ":");
   3220     porta = strsep(&stringp, ":");
   3221

line 3207, the test always succeeds because shortly before we have insured
	that the initial value of username (hence stringp) is not NULL,
	and the strsep() in line 3206 returns the original argument;

line 3215: the only effect of the statement is to set contact=stringp,
	because, judging from the syntax, we do not have other fields
	in "contact" so stripping the additional slash (if any) is
	pointless and undocumented;

line 3220: as above, before the call stringp should only contain the "port"
	component, so stripping additional ":" etc is pointless and
	undocumented, and the statement should just become porta=stringp

I will sumbmit a patch on this, unless i am missing something.

	cheers
	luigi



More information about the asterisk-dev mailing list