But in my code I do the check: 

if (getCalleeStatus () == Connected)
{
  Start accounting ...
}


So problem must be fixed in AmB2BCallerSession::onB2Bevent  no ?

Laurent


void AmB2BCallerSession::onB2BEvent(B2BEvent* ev)
{
  bool processed = false;

  if(ev->event_id == B2BSipReply){

    AmSipReply& reply = ((B2BSipReplyEvent*)ev)->reply;

    if(other_id != reply.local_tag){
      DBG("Dialog missmatch!!\n");
      return;
    }

    DBG("reply received from other leg\n");

    switch(callee_status){
    case NoReply:
    case Ringing:

      if(reply.code < 200){

        callee_status = Ringing;
      }
      else if(reply.code < 300){

        callee_status  = Connected;

        if (!sip_relay_only) {
          sip_relay_only = true;
          reinviteCaller(reply);
        }
      }
      else {
//      DBG("received %i from other leg: other_id=%s;
reply.local_tag=%s\n",
//          reply.code,other_id.c_str(),reply.local_tag.c_str());

        terminateOtherLeg();
      }

      processed = onOtherReply(reply);
      break;

    default:

-----Original Message-----
From: Raphael Coeffic [mailto:[EMAIL PROTECTED] 
Sent: jeudi 10 juillet 2008 10:51
To: Laurent Schweizer
Cc: Stefan Sayer; [EMAIL PROTECTED]
Subject: Re: [Semsdev] [Sems] change reply in AmB2BSession and PRACK

Laurent Schweizer wrote:
> Yes your right, I will be carfull to only send to only 1 mailing list.
>
> Just, for the PRACK, how must we process them, actualy I see that if a
> device send a PRACK and the GW send back a 200 OK for this PRACK, sems
> takes this 200 OK for the INVITE. (so I start my billing).
>
>   

You should have a look at the original request. I guess that you have 
something like this:

bool onOtherReply(...)
{
  ...
  startBilling();
  ...
}


Then you should have a look at the original request, before you start 
the billing:

std::map<int,AmSipRequest>::iterator req_it =
recvd_req.find(reply.cseq);
if( (req_it != recvd_req.end())
    && (req_it->second->method == "INVITE") ){

   // maybe you should also make sure
   // that this was the orginal INVITE
   startBilling();
}


The second possibility would be to remember the cseq of the original 
INVITE, and compare it against the cseq in the reply at some point 
(maybe in onOtherReply).


Cheers,
-Raphael.
> Laurent
>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (parse_uri.cpp)(parse_sip_uri)(314): Converted URI port (5060) to int
> (5060)
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (trans_layer.cpp)(send_request)(558): Sending to 192.168.0.110:5060
> <PRACK sip:[EMAIL PROTECTED]:5060 SIP/2.0^M Via: SIP/2.0/UDP
> 212.203.123.91:5070;branch=z9hG4bKQS86GaGZ^M From:
>
<sip:[EMAIL PROTECTED]>;tag=0F43E446-48747CF5000CF6C7-B2AFBB90
> ^M To: <sip:[EMAIL PROTECTED]>;tag=1C809D50-1C0A^M CSeq: 11
> PRACK^M Call-ID: [EMAIL PROTECTED]
> Contact: <sip:[EMAIL PROTECTED]:5070>^M Max-Forwards: 69^M RAck:
9969
> 556 INVITE^M x-oriuri: 41798204104^M P-hint: rr-enforced lose rrrr^M
> Content-Length: 0^M ^M >
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(udp_trsp.cpp)(send)(244):
> send  msg --++-- PRACK sip:[EMAIL PROTECTED]:5060 SIP/2.0^M
> Via: SIP/2.0/UDP 212.203.123.91:5070;branch=z9hG4bKQS86GaGZ^M From:
>
<sip:[EMAIL PROTECTED]>;tag=0F43E446-48747CF5000CF6C7-B2AFBB90
> ^M To: <sip:[EMAIL PROTECTED]>;tag=1C809D50-1C0A^M CSeq: 11
> PRACK^M Call-ID: [EMAIL PROTECTED]
> Contact: <sip:[EMAIL PROTECTED]:5070>^M Max-Forwards: 69^M RAck:
9969
> 556 INVITE^M x-oriuri: 41798204104^M P-hint: rr-enforced lose rrrr^M
> Content-Length: 0^M ^M --++--
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_trans.cpp)(reset_timer)(149): New timer of type 0x4 at
time=158697
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_trans.cpp)(reset_timer)(149): New timer of type 0x5 at
time=160272
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_parser.cpp)(~sip_msg)(92): ~sip_msg()
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(processEvents)(72): event processed
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(410):
> [EMAIL PROTECTED]
> dlg.getUACTransPending() = 1
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(404):
> AmSession:: before wait for event
> [EMAIL PROTECTED]
> Jul  9 10:55:19 localhost sems[6425]: Debug: (udp_trsp.cpp)(run)(140):
> recvd msg --++-- SIP/2.0 200 OK^M Via: SIP/2.0/UDP
> 212.203.123.91:5070;branch=z9hG4bKQS86GaGZ^M From:
>
<sip:[EMAIL PROTECTED]>;tag=0F43E446-48747CF5000CF6C7-B2AFBB90
> ^M To: <sip:[EMAIL PROTECTED]>;tag=1C809D50-1C0A^M Date:
Wed,
> 09 Jul 2008 08:37:02 GMT^M Call-ID:
> [EMAIL PROTECTED] Server:
> Cisco-SIPGateway/IOS-12.x^M CSeq: 11 PRACK^M Content-Length: 0^M ^M
> --++--
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (trans_layer.cpp)(received_msg)(731): parse_sip_msg returned 0
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (trans_layer.cpp)(received_msg)(815): Reply matched an existing
> transaction
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (trans_layer.cpp)(update_uac_trans)(858): reply code = 200
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_trans.cpp)(reset_timer)(104): Clearing old timer of type 0x4
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_trans.cpp)(reset_timer)(149): New timer of type 0x6 at
time=158923
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(472): Received reply: 200 OK
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(473): rep.callid =
> <[EMAIL PROTECTED]>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(474): rep.local_tag =
> <0F43E446-48747CF5000CF6C7-B2AFBB90>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(475): rep.remote_tag =
> <1C809D50-1C0A>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(476): cseq = <11>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(postEvent)(48): AmEventQueue: trying to post event
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(postEvent)(56): AmEventQueue: event posted
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(406):
> AmSession:: after wait for event
> [EMAIL PROTECTED]
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_parser.cpp)(~sip_msg)(92): ~sip_msg()
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(processEvents)(70): before processing event
> Jul  9 10:55:19 localhost sems[6425]: Debug: (udp_trsp.cpp)(run)(118):
> before recvmsg (212.203.123.91:5070)
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSession.cpp)(process)(556): AmSession::process
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSession.cpp)(process)(560): Session received SIP Event
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onSipReply)(163): onSipReply: 200 OK (fwd=1)
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onSipReply)(164): onSipReply: content-type =
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSipDialog.cpp)(updateStatus)(187): updateStatus(reply): transaction
> found!
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(relayEvent)(185): AmB2BSession::relayEvent:
> id=04617FAC-48747CF5000C8654-B72FAB90
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(postEvent)(48): AmEventQueue: trying to post event
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(postEvent)(56): AmEventQueue: event posted
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(processEvents)(72): event processed
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(410):
> [EMAIL PROTECTED]
> dlg.getUACTransPending() = 1
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(404):
> AmSession:: before wait for event
> [EMAIL PROTECTED]
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(406):
> AmSession:: after wait for event
> [EMAIL PROTECTED]
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(processEvents)(70): before processing event
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onB2BEvent)(272): reply received from other leg
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (Billing_sip.cpp)(startAccounting)(827): start accounting at
1215593719
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (Billing_sip.cpp)(startAccounting)(842): price: 0, time 12000
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (Billing_sip.cpp)(onOtherReply)(686):       set credit 12000
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onB2BEvent)(108): B2BSipReply: 200 OK (fwd=1)
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onB2BEvent)(109): B2BSipReply: content-type =
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSipDialog.cpp)(updateStatusReply)(133): reply: transaction found!
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSipDialog.cpp)(updateStatusReply)(172): req.method = PRACK;
t.method
> = PRACK
> @              
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (parse_uri.cpp)(parse_sip_uri)(314): Converted URI port (5060) to int
> (5060)
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (trans_layer.cpp)(send_request)(558): Sending to 192.168.0.110:5060
> <PRACK sip:[EMAIL PROTECTED]:5060 SIP/2.0^M Via: SIP/2.0/UDP
> 212.203.123.91:5070;branch=z9hG4bKQS86GaGZ^M From:
>
<sip:[EMAIL PROTECTED]>;tag=0F43E446-48747CF5000CF6C7-B2AFBB90
> ^M To: <sip:[EMAIL PROTECTED]>;tag=1C809D50-1C0A^M CSeq: 11
> PRACK^M Call-ID: [EMAIL PROTECTED]
> Contact: <sip:[EMAIL PROTECTED]:5070>^M Max-Forwards: 69^M RAck:
9969
> 556 INVITE^M x-oriuri: 41798204104^M P-hint: rr-enforced lose rrrr^M
> Content-Length: 0^M ^M >
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(udp_trsp.cpp)(send)(244):
> send  msg --++-- PRACK sip:[EMAIL PROTECTED]:5060 SIP/2.0^M
> Via: SIP/2.0/UDP 212.203.123.91:5070;branch=z9hG4bKQS86GaGZ^M From:
>
<sip:[EMAIL PROTECTED]>;tag=0F43E446-48747CF5000CF6C7-B2AFBB90
> ^M To: <sip:[EMAIL PROTECTED]>;tag=1C809D50-1C0A^M CSeq: 11
> PRACK^M Call-ID: [EMAIL PROTECTED]
> Contact: <sip:[EMAIL PROTECTED]:5070>^M Max-Forwards: 69^M RAck:
9969
> 556 INVITE^M x-oriuri: 41798204104^M P-hint: rr-enforced lose rrrr^M
> Content-Length: 0^M ^M --++--
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_trans.cpp)(reset_timer)(149): New timer of type 0x4 at
time=158697
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_trans.cpp)(reset_timer)(149): New timer of type 0x5 at
time=160272
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_parser.cpp)(~sip_msg)(92): ~sip_msg()
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(processEvents)(72): event processed
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(410):
> [EMAIL PROTECTED]
> dlg.getUACTransPending() = 1
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(404):
> AmSession:: before wait for event
> [EMAIL PROTECTED]
> Jul  9 10:55:19 localhost sems[6425]: Debug: (udp_trsp.cpp)(run)(140):
> recvd msg --++-- SIP/2.0 200 OK^M Via: SIP/2.0/UDP
> 212.203.123.91:5070;branch=z9hG4bKQS86GaGZ^M From:
>
<sip:[EMAIL PROTECTED]>;tag=0F43E446-48747CF5000CF6C7-B2AFBB90
> ^M To: <sip:[EMAIL PROTECTED]>;tag=1C809D50-1C0A^M Date:
Wed,
> 09 Jul 2008 08:37:02 GMT^M Call-ID:
> [EMAIL PROTECTED] Server:
> Cisco-SIPGateway/IOS-12.x^M CSeq: 11 PRACK^M Content-Length: 0^M ^M
> --++--
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (trans_layer.cpp)(received_msg)(731): parse_sip_msg returned 0
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (trans_layer.cpp)(received_msg)(815): Reply matched an existing
> transaction
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (trans_layer.cpp)(update_uac_trans)(858): reply code = 200
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_trans.cpp)(reset_timer)(104): Clearing old timer of type 0x4
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_trans.cpp)(reset_timer)(149): New timer of type 0x6 at
time=158923
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(472): Received reply: 200 OK
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(473): rep.callid =
> <[EMAIL PROTECTED]>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(474): rep.local_tag =
> <0F43E446-48747CF5000CF6C7-B2AFBB90>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(475): rep.remote_tag =
> <1C809D50-1C0A>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (SipCtrlInterface.cpp)(handleSipMsg)(476): cseq = <11>
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(postEvent)(48): AmEventQueue: trying to post event
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(postEvent)(56): AmEventQueue: event posted
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(406):
> AmSession:: after wait for event
> [EMAIL PROTECTED]
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (sip_parser.cpp)(~sip_msg)(92): ~sip_msg()
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(processEvents)(70): before processing event
> Jul  9 10:55:19 localhost sems[6425]: Debug: (udp_trsp.cpp)(run)(118):
> before recvmsg (212.203.123.91:5070)
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSession.cpp)(process)(556): AmSession::process
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSession.cpp)(process)(560): Session received SIP Event
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onSipReply)(163): onSipReply: 200 OK (fwd=1)
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onSipReply)(164): onSipReply: content-type =
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSipDialog.cpp)(updateStatus)(187): updateStatus(reply): transaction
> found!
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(relayEvent)(185): AmB2BSession::relayEvent:
> id=04617FAC-48747CF5000C8654-B72FAB90
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(postEvent)(48): AmEventQueue: trying to post event
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(postEvent)(56): AmEventQueue: event posted
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(processEvents)(72): event processed
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(410):
> [EMAIL PROTECTED]
> dlg.getUACTransPending() = 1
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(404):
> AmSession:: before wait for event
> [EMAIL PROTECTED]
> Jul  9 10:55:19 localhost sems[6425]: Debug:
(AmSession.cpp)(run)(406):
> AmSession:: after wait for event
> [EMAIL PROTECTED]
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmEventQueue.cpp)(processEvents)(70): before processing event
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onB2BEvent)(272): reply received from other leg
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (Billing_sip.cpp)(startAccounting)(827): start accounting at
1215593719
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (Billing_sip.cpp)(startAccounting)(842): price: 0, time 12000
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (Billing_sip.cpp)(onOtherReply)(686):       set credit 12000
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onB2BEvent)(108): B2BSipReply: 200 OK (fwd=1)
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmB2BSession.cpp)(onB2BEvent)(109): B2BSipReply: content-type =
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSipDialog.cpp)(updateStatusReply)(133): reply: transaction found!
> Jul  9 10:55:19 localhost sems[6425]: Debug:
> (AmSipDialog.cpp)(updateStatusReply)(172): req.method = PRACK;
t.method
> = PRACK
> @              
>
> -----Original Message-----
> From: Stefan Sayer [mailto:[EMAIL PROTECTED] 
> Sent: mercredi 9 juillet 2008 21:49
> To: Laurent Schweizer
> Cc: [EMAIL PROTECTED]
> Subject: Re: [Sems] change reply in AmB2BSession and PRACK
>
> Hello,
>
> o Laurent Schweizer [07/09/08 21:28]:
>   
>> Hello,
>>
>>  
>>
>> I need to remove some header in reply (AmB2BSession). In  wich
funtion
>>     
>
>   
>> can I do it ?
>>     
>
> I think you need to make
>    void relaySip(const AmSipRequest& orig, const AmSipReply& reply);
> virtual, and then do like
> void MyB2BSession::relaySip(const AmSipRequest& orig, const
AmSipReply& 
> reply) {
>
>   if (some condition on reply or state) {
>       AmSipReply mod_reply(reply);
>       .. apply some modification to mod_reply, e.g. 
> reply.headers+="SomeHeader: someval\r\n"; ...
>
>       AmB2BSession::relaySip(orig, mod_reply);
>       return;
>   }
>
>   AmB2BSession::relaySip(orig, reply);
> }
>
> meybe there is a cleaner solution, depends on the type of reply you
need
>
> to modify.
>
> Stefan
>
> P.S. I think it is enough to post to either sems or semsdev, depending

> on the type of question, no ?
>
>   

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to