[asterisk-dev] Question about ASTOBJ_CONTAINER_TRAVERSE

Juan Carlos Castro y Castro jcastro at instant.com.br
Fri Dec 22 07:19:52 MST 2006


I'm creating a dialplan app within chan_sip.c that tests the status of a 
connection to a registrar, like "sip show registry" does. The code 
snippet should work, but it stays needlessly in the loop once the 
correct item in the list is found. How do I abort an 
ASTOBJ_CONTAINER_TRAVERSE loop?

By the way, should anyone find such an app useful, I've received 
permission from my boss to submit it, disclaimer and all.

ASTOBJ_CONTAINER_TRAVERSE(&regl, 1, do {
        ASTOBJ_RDLOCK(iterator);
        snprintf(host, sizeof(host), "%s:%d", iterator->hostname, 
iterator->portno ? iterator->portno : DEFAULT_SIP_PORT);
        if (!strcasecmp(host, registrar)) {
                content = regstate2str(iterator->regstate);
        }
        ASTOBJ_UNLOCK(iterator);
} while(0));



More information about the asterisk-dev mailing list