[Home]

Summary:ASTERISK-15537: type=user and type=friend are no longer the same for chan_sip
Reporter:yarique (yarique)Labels:
Date Opened:2010-01-27 22:08:44.000-0600Date Closed:2012-01-25 10:46:01.000-0600
Priority:TrivialRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
is related toASTERISK-17763 sip.conf.sample incorrectly describes types (peer/user/friend)
Environment:Attachments:
Description:The comments in sip.conf as well as various on-line pages suggest that node types "user" and "friend" are synonyms for chan_sip.  However, since SVN rev 169791 they are treated differently.  In particular, a user node will not get the SIP_TYPE_PEER flag, which makes it impossible for it to REGISTER with chan_sip:
 
chan_sip.c: Registration from '"foo" <sip:foo@example.org>' failed for '192.0.2.101' - No matching peer found

As soon as the node type is changed to friend, it can register OK.

Perhaps this needs clarification.  Thanks!
Comments:By: Walter Doekes (wdoekes) 2010-01-28 01:42:47.000-0600

In trunk this was changed in sip.conf.sample:

r153983 | oej | 2008-11-03 19:02:14 +0100 (Mon, 03 Nov 2008) | 2 lines

+; * The type=friend is a device type that accepts both incoming and outbound calls,
+;   where Asterisk match on the From: username on incoming calls.
+;   (A synonym for friend is "user"). This is a type you use for your local
+;   SIP phones.
-; type = user        a device that authenticates to us by "from" field to place calls
-; type = peer        a device we place calls to or that calls us and we match by host
-; type = friend two configurations (peer+user) in one


This distinction in the code you mention was later:

r169791 | mmichelson | 2009-01-21 22:53:55 +0100 (Wed, 21 Jan 2009) | 18 lines

if (!strcasecmp(v->value, "peer")) {
 peer->type |= SIP_TYPE_PEER;
} else if (!strcasecmp(v->value, "user")) {
 peer->type |= SIP_TYPE_USER;
} else if (!strcasecmp(v->value, "friend")) {
 peer->type = SIP_TYPE_USER | SIP_TYPE_PEER;
}


That's odd :) It looks like a move to remove the user-type and then re-adding it again.

I've personally only ever used/needed friends though. But then again, my usage may be wrong(tm).

By: Leif Madsen (lmadsen) 2010-01-28 09:52:45.000-0600

Well, registrations are only against type=peer, and type=friend (which is user+peer). The type=peer also needs to have host=dynamic in order for registrations to be permitted for that peer.

A type=user, as it states in the documentation, only matched on the From, and not the IP address, thus a registration wouldn't be applied to the user structure.

I agree that documentation that states that a friend and user are synonyms seems wrong to me, or at the very least, not very clear.

I don't believe there is any bug here, other than confusing documentation.

By: Leif Madsen (lmadsen) 2010-01-28 09:53:23.000-0600

Pinging oej as this may be a commit he made, but which contains some confusing documentation. If you can clarify, I can make the change and commit it.

By: yarique (yarique) 2010-01-28 19:15:05.000-0600

Can a typical use case be suggested for each type in the documentation?  I think it would be a fairly good way to clarify the issue.  At the moment it seems to be done for peers and friends but not users.  E.g.:

peer - a SIP trunk, authenticated by its IP, any From is accepted, can initiate and receive calls.
friend - a SIP phone, authenticated by its From, can register as well as initiate and receive calls.
user - ???

Thanks!



By: Olle Johansson (oej) 2010-01-29 02:03:28.000-0600

Type=user and type=friend has never been the same and it has never been the intention with any patch whatsoever.

THe change was that type=friend and type=peer was now equal.

- User objects have been and still are only used for inbound calls. No registration, not outbound calls.
- Peer objects are for outbound calls in IAX2 and SIP. In SIP we add inbound calls, matched on port/ip.
- Friend is not an object at all. It's just a shorthand to say "create a user and a peer with the same name, please". A type=friend will show up in both "sip show users" and "sip show peers".

This is documented in many places already, but we can surely add to it.

In the process of removing the code structure for a user and replace it with one code structure for all objects, there was a mistake done by me, later fixed by other developers. Even though we changed the internals, the configuration stays exactly the same. No changes made at all.

By: Leif Madsen (lmadsen) 2010-01-29 12:30:47.000-0600

oej: ok, well the issue pointed out by the reporter is that (if accurate) the documention is wrong (you say "user" when I think you meant "peer"):

r153983 | oej | 2008-11-03 19:02:14 +0100 (Mon, 03 Nov 2008) | 2 lines

+; * The type=friend is a device type that accepts both incoming and outbound calls,
+; where Asterisk match on the From: username on incoming calls.
+; (A synonym for friend is "user"). This is a type you use for your local
+; SIP phones.

By: Olle Johansson (oej) 2010-01-30 02:32:50.000-0600

I don't think I've added that, but I certainly will correct it. Thanks.

By: Leif Madsen (lmadsen) 2010-02-01 10:27:49.000-0600

------------------------------------------------------------------------
r153983 | oej | 2008-11-03 12:02:14 -0600 (Mon, 03 Nov 2008) | 2 lines

Updating docs



That's where the typo came from.

By: Tim Osman (obeliks) 2011-06-15 12:20:19.306-0500

Did not see any updates to the docs regarding this issue. I also opened
ASTERISK-17763 (JIRA does not allow issues to be linked JA-424)

By: Sean Darcy (seandarcy) 2011-12-25 18:27:17.097-0600

Fell upon this same issue over this weekend.

Just checked svn trunk: "(A synonym for friend is "user")"

As I read this issue "friend" == "peer" and ! "user" .

Is that right??



By: Jonathan Rose (jrose) 2012-01-24 11:43:09.657-0600

From the code:

[...]
} else if (!strcasecmp(u->name, "type")) {
   if (!strcasecmp(u->value, "peer")) {
       peer->type |= SIP_TYPE_PEER;
   } else if (!strcasecmp(u->value, "user")) {
       peer->type |= SIP_TYPE_USER;
   } else if (!strcasecmp(u->value, "friend")) {
       peer->type = SIP_TYPE_USER | SIP_TYPE_PEER;
   }
} [...]

Clearly a friend is just both a user and a peer. The synonym comment in r153983 is just erroneous.  I'm working on it.