[OpenSIPS-Devel] how to check isflagset in cmd_function

王端端 1779706607 at qq.com
Tue Nov 3 08:27:13 EST 2020


in the cmd_fucntion, i want to check whether the flag 4 is set.


```
static int update_zone_code (struct sip_msg* msg, char *param) {
    LM_DBG("update_zone_code %s\n", param);
    LM_DBG("========start print method src_ip dst_ip\n");
    LM_DBG("method: %s, ru: %s\n", msg->first_line.u.request.method.s, GET_RURI(msg)->s);
    LM_DBG("src_ip: %s, src_port: %d\n", ip_addr2a(&msg->rcv.src_ip), msg->rcv.src_port);
    LM_DBG("dst_ip: %s, dst_port: %d\n", ip_addr2a(&msg->rcv.dst_ip), msg->rcv.src_port);


    //
    LM_DBG("========start print Flags: %u\n", msg->flags);


    if (msg->flags & (1<<4)) {
        LM_DBG("Flag 4 is set\n");
    } else {
        LM_DBG("Flag 4 is not set\n");
    }

```


in the opensips.cfg


```
modparam("demo_module","static_zone_map", "1510217=0728")
modparam("demo_module","static_zone_map", "1510218=0720")
modparam("demo_module","static_zone_map", "1510219=0723")
modparam("demo_module","static_zone_map", "1510219=0723")


route{
    xlog("hello");
    setflag(4);
    setflag(5);
    setflag(6);
    if (isflagset(6)) {
        xlog("flag 6 is set");
    } else {
        xlog("flag 6 is set");
    }
    update_zone_code("1210219");
}

```


in the log


```
Nov  3 15:55:34 [6178] DBG:demo_module:update_zone_code: ========start print Flags: 7
Nov  3 15:55:34 [6178] DBG:demo_module:update_zone_code: Flag 4 is not set

```


it print the flag is not set,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20201103/03525af9/attachment-0001.html>


More information about the Devel mailing list