[sr-dev] [kamailio/kamailio] alias_db_lookup is returning `-1` if result is not found. Documentation implies it should return false. (#2517)

Ben Kaufman notifications at github.com
Mon Oct 19 20:33:02 CEST 2020


### Description

alias_db_lookup is returning `-1` if result is not found.  The documentation says "The function returns TRUE if R-URI is alias and it was replaced by user's SIP uri."  The implication is that it should return FALSE if that is not the case.  Sample code:

```
$vn(init_ruri)   = $ru;
$vn(alias_found) = alias_db_lookup("DbAliases");
xlogl("L_NOTIFY", "$$vn(alias_found) is [$vn(alias_found)]\n");
if ( !$vn(alias_found) ) {
    xlogl("L_NOTIFY", "No alias found for [$vn(init_ruri)]\n");
    return;
}

xlogl("L_NOTIFY", "Found alias [$ru] for [$vn(init_ruri)]\n");
```

The value for $vn(alias_found) is -1 if there is no alias, and thus the  condition never occurs. "Found alias" line always occurs, even if there is no record in the DB.

I think this should probably be considered a documentation issue, but I'm not sure what the other possible values are for return and their meanings.  Maybe there's a different value if an alias is found but not updated, etc?

### Troubleshooting

Example above

#### Reproduction

Example above.

#### Debugging Data

Not applicable

#### Log Messages

N/A

#### SIP Traffic

N/A

### Possible Solutions

Probably best to update documentation.  The statement,  "The function returns TRUE if R-URI is alias and it was replaced by user's SIP uri." implies that if that does not happen, then the return would be FALSE. 

### Additional Information

`5.4.1`

* **Operating System**:

Debian 10


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2517
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20201019/2bd71efe/attachment.htm>


More information about the sr-dev mailing list