## Motivation
1. DOC says `setid` in mysql should be `UNSIGNED INT`: http://www.kamailio.org/docs/modules/4.4.x/modules/rtpengine.html#rtpengine.... http://www.kamailio.org/docs/modules/4.4.x/modules/rtpengine.html#rtpengine....
2. kamailio did report invalid value if `setid` less than 0.
3. kamailio rtpengine module declares setid as `int setid`, thus we can not use setid more than 2147483647
This PR changes declaration of `setid` from `int` to `unsigned int`
## UNSURE (REVIEW NEEDED):
I'm not sure about:
should `int_val` in `fixup_set_ip` at [rtpengine.c#L910](https://github.com/kamailio/kamailio/blob/master/src/modules/rtpengine/rtpen...) be declared as `unsigned int` as well?
not sure about the usage of `int pv_locate_name()` and `unsigned short str2s()` in the `fixup_set_ip()` function.
should we use `str2int` instead `str2s` ?
let me know if I'm on the wrong direction
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/999
-- Commit Summary --
* rtpengine: really do allow unsigned setid
-- File Changes --
M src/modules/rtpengine/rtpengine.c (4) M src/modules/rtpengine/rtpengine.h (2) M src/modules/rtpengine/rtpengine_db.c (4)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/999.patch https://github.com/kamailio/kamailio/pull/999.diff
Yes I think you're right. It should use `str2int` instead of `str2s`.
thanks! updated.
rfuchs requested changes on this pull request.
There's a few mismatches between signed and unsigned left, but I think they can be resolved only up to a certain point, as Kamailio doesn't have support for unsigned types in certain areas
pkg_free(*param);
- if((rtpp_list = select_rtpp_set(int_val)) ==0){ - LM_ERR("rtpp_proxy set %i not configured\n", int_val); + if((rtpp_list = select_rtpp_set(set_id)) ==0){ + LM_ERR("rtpp_proxy set %i not configured\n", set_id);
format should be %u here
@@ -1442,9 +1443,9 @@ mod_init(void)
/* select the default set */ default_rtpp_set = select_rtpp_set(setid_default); if (!default_rtpp_set) { - LM_NOTICE("Default rtpp set %d NOT found\n", setid_default); + LM_NOTICE("Default rtpp set %u NOT found\n", setid_default);
The type of `setid_default` itself also ought to be changed to unsigned accordingly
@rfuchs thanks for review, I have it updated and rebased accordingly.
it's true, I felt a little bit awkward while I was trying to turn `int` to `unsigned`.
just want to share my use case if anyone has similar purpose:
I was using `mediaproxy` module and have own load balancing/failover outside of `kamailio`. the id for media server was `ip address string` which will be put into `media_relay_avp`.
so for the uniqueness, I just need to convert `ip address string` into `unsigned int` as media server id to issue command to.
`int` variable only supports ip address that the first field is less than `127` use `unsigned int` can easily convert ip string/int back and forth while keeping uniqueness.
Merged #999.