Hi,
$dlg_var is not available at this stage of the dialog:

http://www.kamailio.org/docs/modules/devel/modules/dialog.html#idp19330392

To achieve your goal you can use there an avp or a flag, which are bound to transactions.
Something like:

#define INIT_FLAG

if (is_method("INVITE") && !has_totag()) {
        $avp(is_init_invite) = 1;
        # or
        # setflag(INIT_FLAG);
}

onreply_route {
    if (is_method("INVITE") && t_check_status("200") && $avp(is_init_invite) == "1") {
        # or 
        # if (is_method("INVITE") && t_check_status("200") && isflagset(INIT_FLAG))
        #
        # do somting     
    }
}

Regards,

Federico

On Thu, Mar 3, 2016 at 4:55 AM, 张顺通 <shuntongzhang@gmail.com> wrote:
I want to distingguish 200 OK is for INVITE or reINVITE。

so I do this:
request_route {
    if (is_method("INVITE") && !has_totag()) {
        $dlg_var(is_init_invite) = "1";
    }
}

onreply_route {
    xlog("L_INFO","[$rs-$rr][is_init_invite:$dlg_var(is_init_invite)]");
    if (is_method("INVITE") && t_check_status("200") && $dlg_var(is_init_invite) == "1") {
        # do somting
        $dlg_var(is_init_invite) = "0";
    }
    xlog("L_INFO","[$rs-$rr][is_init_invite:$dlg_var(is_init_invite)]");
}

What I confuse is:
When I recive 100 Trying LOG is
[100 - Trying][is_init_invite:0]
[100 - Trying][is_init_invite:1]

why is_init_invite is 0?

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users