📄 tport_internal.h
字号:
/* * This file is part of the Sofia-SIP package * * Copyright (C) 2005 Nokia Corporation. * * Contact: Pekka Pessi <pekka.pessi@nokia.com> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */#ifndef TPORT_INTERNAL_H/** Defined when <tport_internal.h> has been included. */#define TPORT_INTERNAL_H/**@internal * @file tport_internal.h * @brief Internal implementation of transport interface * * @author Pekka Pessi <Pekka.Pessi@nokia.com> * * @date Created: Thu Jun 29 15:58:06 2000 ppessi */#ifndef SU_H#include <sofia-sip/su.h>#endif#include <sofia-sip/su_uniqueid.h>#ifndef MSG_ADDR_H#include <sofia-sip/msg_addr.h>#endif#ifndef TPORT_H#include <sofia-sip/tport.h>#endif#if HAVE_SOFIA_STUN#include "sofia-sip/stun.h"#include "sofia-sip/stun_tag.h"#endif#include <sofia-sip/tport_plugins.h>#ifndef SU_DEBUG#define SU_DEBUG 3#endif#define SU_LOG tport_log#include <sofia-sip/su_debug.h>#if !defined(MSG_NOSIGNAL) || defined(__CYGWIN__) || defined(SYMBIAN)#undef MSG_NOSIGNAL#define MSG_NOSIGNAL (0)#endif#if (_WIN32_WINNT >= 0x0600)#ifndef HAVE_MSG_TRUNC#define HAVE_MSG_TRUNC 1#endif#endif#if !HAVE_MSG_TRUNC#define MSG_TRUNC (0)#endif#ifndef NONE#define NONE ((void *)-1)#endifSOFIA_BEGIN_DECLStypedef struct tport_master tport_master_t;typedef struct tport_pending_s tport_pending_t;typedef struct tport_primary tport_primary_t;typedef struct tport_vtable tport_vtable_t;struct sigcomp_state_handler;struct sigcomp_algorithm;struct sigcomp_udvm;struct sigcomp_magic;struct sigcomp_compartment;typedef long unsigned LU; /* for printf() and friends *//** @internal Transport parameters */typedef struct { unsigned tpp_mtu; /**< Maximum packet size */ unsigned tpp_idle; /**< Allowed connection idle time. */ unsigned tpp_timeout; /**< Allowed idle time for message. */ unsigned tpp_keepalive; /**< Keepalive PING interval */ unsigned tpp_pingpong; /**< PONG-to-PING interval */ unsigned tpp_sigcomp_lifetime; /**< SigComp compartment lifetime */ unsigned tpp_thrpsize; /**< Size of thread pool */ unsigned tpp_thrprqsize; /**< Length of per-thread recv queue */ unsigned tpp_qsize; /**< Size of queue */ unsigned tpp_drop; /**< Packet drop probablity */ int tpp_tos; /**< IP TOS */ unsigned tpp_conn_orient:1; /**< Connection-orienteded */ unsigned tpp_sdwn_error:1; /**< If true, shutdown is error. */ unsigned tpp_stun_server:1; /**< If true, use stun server */ unsigned tpp_pong2ping:1; /**< If true, respond with pong to ping */ unsigned :0;} tport_params_t;/** @internal Transport object. * * A transport object can be used in three roles, to represent transport * list (aka master transport), to represent available transports (aka * primary transport) and to represent actual transport connections (aka * secondary transport). */struct tport_s { su_home_t tp_home[1]; /**< Memory home */ ssize_t tp_refs; /**< Number of references to tport */ unsigned tp_black:1; /**< Used by red-black-tree */ unsigned tp_accepted:1; /**< Originally server? */ unsigned tp_conn_orient:1; /**< Is connection-oriented */ unsigned tp_has_connection:1; /**< Has real connection */ unsigned tp_reusable:1; /**< Can this connection be reused */ unsigned tp_closed : 1; /**< This transport is closed. * * A closed transport is inserted into pri_closed list. */ /** Remote end has sent FIN (2) or we should not just read */ unsigned tp_recv_close:2; /** We will send FIN (1) or have sent FIN (2) */ unsigned tp_send_close:2; unsigned tp_has_keepalive:1; unsigned tp_has_stun_server:1; unsigned tp_trunc:1; unsigned tp_is_connected:1; /**< Connection is established */ unsigned:0; tport_t *tp_left, *tp_right, *tp_dad; /**< Links in tport tree */ tport_master_t *tp_master; /**< Master transport */ tport_primary_t *tp_pri; /**< Primary transport */ tport_params_t *tp_params; /**< Transport parameters */ tp_magic_t *tp_magic; /**< Context provided by consumer */ su_timer_t *tp_timer; /**< Timer object */ su_time_t tp_ktime; /**< Keepalive timer updated */ su_time_t tp_ptime; /**< Ping sent */ tp_name_t tp_name[1]; /**< Transport name. * * This is either our name (if primary) * or peer name (if secondary). */#define tp_protoname tp_name->tpn_proto#define tp_canon tp_name->tpn_canon#define tp_host tp_name->tpn_host#define tp_port tp_name->tpn_port#define tp_ident tp_name->tpn_ident su_socket_t tp_socket; /**< Socket of this tport*/ int tp_index; /**< Root registration index */ int tp_events; /**< Subscribed events */ su_addrinfo_t tp_addrinfo[1]; /**< Peer/own address info */ su_sockaddr_t tp_addr[1]; /**< Peer/own address */#define tp_addrlen tp_addrinfo->ai_addrlen /* ==== Receive queue ================================================== */ msg_t *tp_msg; /**< Message being received */ msg_t const *tp_rlogged; /**< Last logged when receiving */ su_time_t tp_rtime; /**< Last time received data */ unsigned short tp_ping; /**< Whitespace ping being received */ /* ==== Pending messages =============================================== */ unsigned short tp_reported; /**< Report counter */ unsigned tp_plen; /**< Size of tp_pending */ unsigned tp_pused; /**< Used pends */ tport_pending_t *tp_pending; /**< Pending requests */ tport_pending_t *tp_released; /**< Released pends */ /* ==== Send queue ===================================================== */ msg_t **tp_queue; /**< Messages being sent */ unsigned short tp_qhead; /**< Head of queue */ msg_iovec_t *tp_unsent; /**< Pointer to first unsent iovec */ size_t tp_unsentlen; /**< Number of unsent iovecs */ msg_iovec_t *tp_iov; /**< Iovecs allocated for sending */ size_t tp_iovlen; /**< Number of allocated iovecs */ msg_t const *tp_slogged; /**< Last logged when sending */ su_time_t tp_stime; /**< Last time sent message */ /* ==== Extensions ===================================================== */ tport_compressor_t *tp_comp; /* ==== Statistics ===================================================== */ struct { uint64_t sent_msgs, sent_errors, sent_bytes, sent_on_line; uint64_t recv_msgs, recv_errors, recv_bytes, recv_on_line; } tp_stats;};/** @internal Primary structure */struct tport_primary { tport_t pri_primary[1]; /**< Transport part */#if DOXYGEN_ONLY su_home_t pri_home[1];#else#define pri_home pri_primary->tp_home#define pri_master pri_primary->tp_master#define pri_protoname pri_primary->tp_name->tpn_proto#endif tport_vtable_t const *pri_vtable; int pri_public; /**< Type of primary transport; * tport_type_local, * tport_type_stun, etc. */ tport_primary_t *pri_next; /**< Next primary tport */ tport_t *pri_open; /**< Open secondary tports */ tport_t *pri_closed; /**< Closed secondary tports */ unsigned pri_updating:1; /**< Currently updating address */ unsigned pri_natted:1; /**< Using natted address */ unsigned pri_has_tls:1; /**< Supports tls */ unsigned:0; void *pri_stun_handle; tport_params_t pri_params[1]; /**< Transport parameters */};/** @internal Master structure */struct tport_master { tport_t mr_master[1];#if DOXYGEN_ONLY su_home_t mr_home[1];#else#define mr_home mr_master->tp_home#endif int mr_stun_step_ready; /**< for stun's callback */ tp_stack_t *mr_stack; /**< Transport consumer */ tp_stack_class_t const *mr_tpac; /**< Methods provided by stack */ int mr_log; /**< Do logging of parsed messages */ su_root_t *mr_root; /**< SU root pointer */ /**< Timer reclaiming unused connections and compartment */ su_timer_t *mr_timer; /** FILE to dump received and sent data */ FILE *mr_dump_file; char *mr_dump; /**< Filename for dumping received/sent data */ tport_primary_t *mr_primaries; /**< List of primary contacts */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -