2 The oSIP library implements the Session Initiation Protocol (SIP -rfc3261-)
3 Copyright (C) 2001,2002,2003 Aymeric MOIZARD jack@atosc.org
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <osip2/internal.h>
21 #include <osip2/osip.h>
27 __osip_nist_init (osip_nist_t ** nist, osip_t * osip, osip_message_t * invite)
31 OSIP_TRACE (osip_trace
32 (__FILE__, __LINE__, OSIP_INFO2, NULL,
33 "allocating NIST context\n"));
35 *nist = (osip_nist_t *) osip_malloc (sizeof (osip_nist_t));
38 memset (*nist, 0, sizeof (osip_nist_t));
39 /* for INVITE retransmissions */
44 i = osip_message_get_via (invite, 0, &via); /* get top via */
47 proto = via_get_protocol (via);
51 i = osip_strncasecmp (proto, "TCP", 3);
54 (*nist)->timer_j_length = 64 * DEFAULT_T1;
55 (*nist)->timer_j_start.tv_sec = -1; /* not started */
59 (*nist)->timer_j_length = 0; /* MUST do the transition immediatly */
60 (*nist)->timer_j_start.tv_sec = -1; /* not started */
72 __osip_nist_free (osip_nist_t * nist)
76 OSIP_TRACE (osip_trace
77 (__FILE__, __LINE__, OSIP_INFO2, NULL,
78 "free nist ressource\n"));
87 __osip_nist_need_timer_j_event (osip_nist_t * nist, state_t state, int transactionid)
90 gettimeofday (&now, NULL);
94 if (state == NIST_COMPLETED)
96 if (nist->timer_j_start.tv_sec == -1)
98 if (timercmp (&now, &nist->timer_j_start, >))
99 return __osip_event_new (TIMEOUT_J, transactionid);