- 论坛徽章:
- 0
|
确实是混的,这年头混口饭吃也不容易啊!
eXosip2的 src里面的文件, eXconf.c 里面有这些宏 OSIP_MT, IPV6_V6ONLY
http://www.koders.com/c/fid30E4A ... 4B3AF1ED.aspx?s=md5
这些地方都可以下载到
http://download.savannah.gnu.org/releases/exosip/
- /*
- eXosip - This is the eXtended osip library.
- Copyright (C) 2002,2003,2004,2005,2006,2007 Aymeric MOIZARD - [email]jack@atosc.org[/email]
-
- eXosip is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- eXosip is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- #ifdef ENABLE_MPATROL
- #include <mpatrol.h>
- #endif
- #include "eXosip2.h"
- #include <eXosip2/eXosip.h>
- #include <osip2/osip_mt.h>
- #include <osip2/osip_condv.h>
- extern eXosip_t eXosip;
- int ipv6_enable = 0;
- #ifdef OSIP_MT
- static void *_eXosip_thread (void *arg);
- #endif
- static void _eXosip_keep_alive (void);
- #ifndef MINISIZE
- void
- eXosip_enable_ipv6 (int _ipv6_enable)
- {
- ipv6_enable = _ipv6_enable;
- }
- #endif
- const char *
- eXosip_get_version(void)
- {
- return EXOSIP_VERSION;
- }
- void
- eXosip_masquerade_contact (const char *public_address, int port)
- {
- eXtl_udp.tl_masquerade_contact(public_address, port);
- eXtl_tcp.tl_masquerade_contact(public_address, port);
- #ifdef HAVE_OPENSSL_SSL_H
- eXtl_tls.tl_masquerade_contact(public_address, port);
- eXtl_dtls.tl_masquerade_contact(public_address, port);
- #endif
- return;
- }
- int
- eXosip_guess_localip (int family, char *address, int size)
- {
- return eXosip_guess_ip_for_via (family, address, size);
- }
- int
- eXosip_is_public_address (const char *c_address)
- {
- return (0 != strncmp (c_address, "192.168", 7)
- && 0 != strncmp (c_address, "10.", 3)
- && 0 != strncmp (c_address, "172.16.", 7)
- && 0 != strncmp (c_address, "172.17.", 7)
- && 0 != strncmp (c_address, "172.18.", 7)
- && 0 != strncmp (c_address, "172.19.", 7)
- && 0 != strncmp (c_address, "172.20.", 7)
- && 0 != strncmp (c_address, "172.21.", 7)
- && 0 != strncmp (c_address, "172.22.", 7)
- && 0 != strncmp (c_address, "172.23.", 7)
- && 0 != strncmp (c_address, "172.24.", 7)
- && 0 != strncmp (c_address, "172.25.", 7)
- && 0 != strncmp (c_address, "172.26.", 7)
- && 0 != strncmp (c_address, "172.27.", 7)
- && 0 != strncmp (c_address, "172.28.", 7)
- && 0 != strncmp (c_address, "172.29.", 7)
- && 0 != strncmp (c_address, "172.30.", 7)
- && 0 != strncmp (c_address, "172.31.", 7)
- && 0 != strncmp (c_address, "169.254", 7));
- }
- void
- eXosip_set_user_agent (const char *user_agent)
- {
- osip_free (eXosip.user_agent);
- eXosip.user_agent = osip_strdup (user_agent);
- }
- void
- eXosip_kill_transaction (osip_list_t * transactions)
- {
- osip_transaction_t *transaction;
- if (!osip_list_eol (transactions, 0))
- {
- /* some transaction are still used by osip,
- transaction should be released by modules! */
- OSIP_TRACE (osip_trace
- (__FILE__, __LINE__, OSIP_ERROR, NULL,
- "module sfp: _osip_kill_transaction transaction should be released by modules!\n"));
- }
- while (!osip_list_eol (transactions, 0))
- {
- transaction = osip_list_get (transactions, 0);
- __eXosip_delete_jinfo (transaction);
- osip_transaction_free (transaction);
- }
- }
- void
- eXosip_quit (void)
- {
- jauthinfo_t *jauthinfo;
- eXosip_call_t *jc;
- eXosip_reg_t *jreg;
- #ifndef MINISIZE
- eXosip_notify_t *jn;
- eXosip_subscribe_t *js;
- eXosip_pub_t *jpub;
- #endif
- #ifdef OSIP_MT
- int i;
- #endif
- if (eXosip.j_stop_ua==-1)
- {
- OSIP_TRACE (osip_trace
- (__FILE__, __LINE__, OSIP_WARNING, NULL,
- "eXosip: already stopped!\n"));
- return;
- }
- eXosip.j_stop_ua = 1; /* ask to quit the application */
- __eXosip_wakeup ();
- __eXosip_wakeup_event ();
- #ifdef OSIP_MT
- if (eXosip.j_thread!=NULL)
- {
- i = osip_thread_join ((struct osip_thread *) eXosip.j_thread);
- if (i != 0)
- {
- OSIP_TRACE (osip_trace
- (__FILE__, __LINE__, OSIP_ERROR, NULL,
- "eXosip: can't terminate thread!\n"));
- }
- osip_free ((struct osip_thread *) eXosip.j_thread);
- }
- jpipe_close (eXosip.j_socketctl);
- jpipe_close (eXosip.j_socketctl_event);
- #endif
- osip_free (eXosip.user_agent);
- for (jc = eXosip.j_calls; jc != NULL; jc = eXosip.j_calls)
- {
- REMOVE_ELEMENT (eXosip.j_calls, jc);
- eXosip_call_free (jc);
- }
- #ifndef MINISIZE
- for (js = eXosip.j_subscribes; js != NULL; js = eXosip.j_subscribes)
- {
- REMOVE_ELEMENT (eXosip.j_subscribes, js);
- eXosip_subscribe_free (js);
- }
- for (jn = eXosip.j_notifies; jn != NULL; jn = eXosip.j_notifies)
- {
- REMOVE_ELEMENT (eXosip.j_notifies, jn);
- eXosip_notify_free (jn);
- }
- #endif
- #ifdef OSIP_MT
- osip_mutex_destroy ((struct osip_mutex *) eXosip.j_mutexlock);
- #if !defined (_WIN32_WCE)
- osip_cond_destroy ((struct osip_cond *) eXosip.j_cond);
- #endif
- #endif
- for (jreg = eXosip.j_reg; jreg != NULL; jreg = eXosip.j_reg)
- {
- REMOVE_ELEMENT (eXosip.j_reg, jreg);
- eXosip_reg_free (jreg);
- }
- #ifndef MINISIZE
- for (jpub = eXosip.j_pub; jpub != NULL; jpub = eXosip.j_pub)
- {
- REMOVE_ELEMENT (eXosip.j_pub, jpub);
- _eXosip_pub_free (jpub);
- }
- #endif
- while (!osip_list_eol (eXosip.j_transactions, 0))
- {
- osip_transaction_t *tr =
- (osip_transaction_t *) osip_list_get (eXosip.j_transactions, 0);
- if (tr->state == IST_TERMINATED || tr->state == ICT_TERMINATED
- || tr->state == NICT_TERMINATED || tr->state == NIST_TERMINATED)
- {
- OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,
- "Release a terminated transaction\n"));
- osip_list_remove (eXosip.j_transactions, 0);
- __eXosip_delete_jinfo (tr);
- osip_transaction_free (tr);
- } else
- {
- osip_list_remove (eXosip.j_transactions, 0);
- __eXosip_delete_jinfo (tr);
- osip_transaction_free (tr);
- }
- }
- osip_free (eXosip.j_transactions);
- eXosip_kill_transaction (&eXosip.j_osip->osip_ict_transactions);
- eXosip_kill_transaction (&eXosip.j_osip->osip_nict_transactions);
- eXosip_kill_transaction (&eXosip.j_osip->osip_ist_transactions);
- eXosip_kill_transaction (&eXosip.j_osip->osip_nist_transactions);
- osip_release (eXosip.j_osip);
- {
- eXosip_event_t *ev;
- for (ev = osip_fifo_tryget (eXosip.j_events); ev != NULL;
- ev = osip_fifo_tryget (eXosip.j_events))
- eXosip_event_free (ev);
- }
- osip_fifo_free (eXosip.j_events);
- for (jauthinfo = eXosip.authinfos; jauthinfo != NULL;
- jauthinfo = eXosip.authinfos)
- {
- REMOVE_ELEMENT (eXosip.authinfos, jauthinfo);
- osip_free (jauthinfo);
- }
- eXtl_udp.tl_free();
- eXtl_tcp.tl_free();
- #ifdef HAVE_OPENSSL_SSL_H
- eXtl_dtls.tl_free();
- eXtl_tls.tl_free();
- #endif
- memset (&eXosip, 0, sizeof (eXosip));
- eXosip.j_stop_ua = -1;
- return;
- }
- int
- eXosip_set_socket (int transport, int socket, int port)
- {
- eXosip.eXtl = NULL;
- if (transport==IPPROTO_UDP)
- {
- eXtl_udp.proto_port = port;
- eXtl_udp.tl_set_socket(socket);
- eXosip.eXtl = &eXtl_udp;
- snprintf(eXosip.transport, sizeof(eXosip.transport), "%s", "UDP");
- }
- else if (transport==IPPROTO_UDP)
- {
- eXtl_tcp.proto_port = port;
- eXtl_tcp.tl_set_socket(socket);
- eXosip.eXtl = &eXtl_tcp;
- snprintf(eXosip.transport, sizeof(eXosip.transport), "%s", "TCP");
- }
- else
- return -1;
- #ifdef OSIP_MT
- eXosip.j_thread = (void *) osip_thread_create (20000, _eXosip_thread, NULL);
- if (eXosip.j_thread == NULL)
- {
- OSIP_TRACE (osip_trace
- (__FILE__, __LINE__, OSIP_ERROR, NULL,
- "eXosip: Cannot start thread!\n"));
- return -1;
- }
- #endif
- return 0;
- }
- #ifdef IPV6_V6ONLY
- int
- setsockopt_ipv6only (int sock)
- {
- int on = 1;
- return setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &on, sizeof (on));
- }
- #endif /* IPV6_V6ONLY */
复制代码 |
|