[Asterisk-Dev] chan_iax2.c: is IAX_COMMAND_REGREL implementation working?

Eugene Prokopiev prokopiev at stc.donpac.ru
Tue Dec 20 03:02:06 MST 2005


Hi,

I need to implement instant unregistering in my custom IAX client. There 
are no working unregistering in iaxclient and libiax2, so I create 
custom function with:

send_command(session, AST_FRAME_IAX, IAX_COMMAND_REGREL, 0,
NULL, 0, -1);

and call it. I see on Asterisk console:

Rx-Frame Retry[ No] -- OSeqno: 002 ISeqno: 002 Type: IAX     Subclass: 
REGREL
    Timestamp: 09686ms  SCall: 05216  DCall: 00001 [192.168.46.2:4569]

But release not forced and during 1 minute I can see my client in 'iax2 
show peers'.

So, I think I need to make some changes in chan_iax2.c. I see:

...
switch(f.subclass) {
...
case IAX_COMMAND_REGREQ:
case IAX_COMMAND_REGREL:
     /* For security, always ack immediately */
     if (delayreject)
         send_command_immediate(iaxs[fr.callno], AST_FRAME_IAX, 
IAX_COMMAND_ACK, fr.ts, NULL, 0,fr.iseqno);
     if (register_verify(fr.callno, &sin, &ies)) {
         /* Send delayed failure */
         auth_fail(fr.callno, IAX_COMMAND_REGREJ);
         break;
     }
     if ((ast_strlen_zero(iaxs[fr.callno]->secret) && 
ast_strlen_zero(iaxs[fr.callno]->inkeys)) || 
ast_test_flag(&iaxs[fr.callno]->state, IAX_STATE_AUTHENTICATED)) {
         if (f.subclass == IAX_COMMAND_REGREL)
             memset(&sin, 0, sizeof(sin));
         if (update_registry(iaxs[fr.callno]->peer, &sin, fr.callno, 
ies.devicetype, fd, ies.refresh))
             ast_log(LOG_WARNING, "Registry error\n");
         if (ies.provverpres && ies.serviceident && sin.sin_addr.s_addr)
             check_provisioning(&sin, fd, ies.serviceident, ies.provver);
         break;
     }
     registry_authrequest(iaxs[fr.callno]->peer, fr.callno);
     break;
case IAX_COMMAND_REGACK:
...

It seems a registration release should cause the peer address to
become (0) - but it is not erased from the registry. So rather then 
deleting the entry, the iax channel just zeros the IP structure of the 
peer. Even in this case I see client IP in 'iax2 show peers' during 1 
minute.

What can anybody say about this code? How can I change it to work with 
IAX_COMMAND_REGREL?

--
Thanks,
Eugene Prokopiev



More information about the asterisk-dev mailing list