#91 DROUTING - function for checking that gateway group

modules (91)
Nick Altmann

I offer to add to drouting in addition to functions is_from_gw, goes_to_gw function, which can check any uri is from certain group.
Like ds_is_in_list in DISPATCHER.
is_from_gw and goes to gw now allow only to check from and destination uri, but not any uri.

For example,
is_gw(uri, [type, [flag]])


1 2 > >> (Page 1 of 2)
    • assigned_to: nobody --> bogdan_iancu
  • Hi Nick,

    Willing to do the patch ? as it is a nice functionality and it will be definitely accepted.


  • Nick Altmann
    Nick Altmann

    Okay, I will make patch.
    How do you think, should I make new functions, or add parameter to existing functions?
    Like is_from_gw( [type, [flag, [avp]]] ):
    is_from_gw(type, flag)
    is_from_gw(type, flag, avp)


  • I would say a new function, like "dr_is_gw() ", as you suggested

  • Nick Altmann
    Nick Altmann

    1.4.7. dr_is_gw(src_pv, [type, [flag]])

    The function checks if the ip address in pvar src_pv is a gateway
    from a certain group.

    This function can be used from REQUEST_ROUTE, ON_REPLY and FAILURE_ROUTE.

    Meaning of the parameters is as follows:
    * src_pv (mandatory) - pvar containing ip address.
    May be a script var or avp.
    * type (optional) - GW/destination type to be checked
    * flags (optional) - what operations should be performed when
    a GW matches:
    + 's' (Strip) - apply to the username of RURI the strip
    defined by the GW
    + 'p' (Prefix) - apply to the username of RURI the
    prefix defined by the GW
    + 'a' (Attributes) - return the attributes string
    defined by the GW

    Example 1.31. dr_is_gw usage
    if (dr_is_gw("$avp(uac)","3") {

  • Nick Altmann
    Nick Altmann

    Patch to the last trunk (rev. 9233) attached.

  • Nick Altmann
    Nick Altmann

  • Nick, do not want to be picky, but shouldn't be better to have a SIP URI for the first param, instead of a socket like definition? usually in script you play around with SIP URIs and it is simpler to just feed the URI into the function for checking.....

    my 2 cents here

  • Nick Altmann
    Nick Altmann

    Okay, I'll change it.

    I think also that it would be nice to add additional flag to this function and is_from_gw and goes to gw functions to ignore port number. What do you think?

  • Nick Altmann
    Nick Altmann

    Added dr_is_gw_v2.patch.
    In it:
    1. SIP URI instead of socket in pvar.
    2. Added 'n' flag to dr_is_gw and is_from_gw to ignore port number (I really need it, think it will be useful).
    3. Small fix for documentation (added 'i' flag to is_from_gw description).

1 2 > >> (Page 1 of 2)