zoukankan      html  css  js  c++  java
  • eXosip2代码分析

    主要类型定义:

    1、struct eXtl_protocol

    struct eXtl_protocol {
        int enabled;
    
        int proto_port;
        char proto_name[10];
        char proto_ifs[20];
        int proto_num;
        int proto_family;
        int proto_secure;
        int proto_reliable;
    
        int (*tl_init) (void);
        int (*tl_free) (void);
        int (*tl_open) (void);
        int (*tl_set_fdset) (fd_set * osip_fdset, fd_set * osip_wrset, int *fd_max);
        int (*tl_read_message) (fd_set * osip_fdset, fd_set * osip_wrset);
        int (*tl_send_message) (osip_transaction_t * tr, osip_message_t * sip,
                                char *host, int port, int out_socket);
        int (*tl_keepalive) (void);
        int (*tl_set_socket) (int socket);
        int (*tl_masquerade_contact) (const char *ip, int port);
        int (*tl_get_masquerade_contact) (char *ip, int ip_size, char *port,
                                          int port_size);
    };
    
    
    struct eXtl_protocol eXtl_udp = {
        1,
        5060,
        "UDP",
        "0.0.0.0",
        IPPROTO_UDP,
        AF_INET,
        0,
        0,
    
        &udp_tl_init,
        &udp_tl_free,
        &udp_tl_open,
        &udp_tl_set_fdset,
        &udp_tl_read_message,
        &udp_tl_send_message,
        &udp_tl_keepalive,
        &udp_tl_set_socket,
        &udp_tl_masquerade_contact,
        &udp_tl_get_masquerade_contact
    };
    
    
    
    struct eXtl_protocol eXtl_tcp = {
        1,
        5060,
        "TCP",
        "0.0.0.0",
        IPPROTO_TCP,
        AF_INET,
        0,
        0,
    
        &tcp_tl_init,
        &tcp_tl_free,
        &tcp_tl_open,
        &tcp_tl_set_fdset,
        &tcp_tl_read_message,
        &tcp_tl_send_message,
        &tcp_tl_keepalive,
        &tcp_tl_set_socket,
        &tcp_tl_masquerade_contact,
        &tcp_tl_get_masquerade_contact
    };
    
    
    struct eXtl_protocol eXtl_dtls = {
        1,
        5061,
        "DTLS-UDP",
        "0.0.0.0",
        IPPROTO_UDP,
        AF_INET,
        0,
        0,
    
        &dtls_tl_init,
        &dtls_tl_free,
        &dtls_tl_open,
        &dtls_tl_set_fdset,
        &dtls_tl_read_message,
        &dtls_tl_send_message,
        &dtls_tl_keepalive,
        &dtls_tl_set_socket,
        &dtls_tl_masquerade_contact,
        &dtls_tl_get_masquerade_contact
    };
    
    
    struct eXtl_protocol eXtl_tls = {
        1,
        5061,
        "TLS",
        "0.0.0.0",
        IPPROTO_TCP,
        AF_INET,
        0,
        0,
    
        &tls_tl_init,
        &tls_tl_free,
        &tls_tl_open,
        &tls_tl_set_fdset,
        &tls_tl_read_message,
        &tls_tl_send_message,
        &tls_tl_keepalive,
        &tls_tl_set_socket,
        &tls_tl_masquerade_contact,
        &tls_tl_get_masquerade_contact
    };

     2、typedef struct eXosip_t eXosip_t;

        struct eXosip_t {
            struct eXtl_protocol *eXtl;
            char transport[10];
            char *user_agent;
    
            eXosip_call_t *j_calls;    /* my calls        */
    #ifndef MINISIZE
            eXosip_subscribe_t *j_subscribes;    /* my friends      */
            eXosip_notify_t *j_notifies;    /* my susbscribers */
    #endif
            osip_list_t j_transactions;
    
            eXosip_reg_t *j_reg;    /* my registrations */
    #ifndef MINISIZE
            eXosip_pub_t *j_pub;    /* my publications  */
    #endif
    
    #ifdef OSIP_MT
            void *j_cond;
            void *j_mutexlock;
    #endif
    
            osip_t *j_osip;
            int j_stop_ua;
    #ifdef OSIP_MT
            void *j_thread;
            jpipe_t *j_socketctl;
            jpipe_t *j_socketctl_event;
    #endif
    
            osip_fifo_t *j_events;
    
            jauthinfo_t *authinfos;
    
            int keep_alive;
            int keep_alive_options;
            int learn_port;
    #ifndef MINISIZE
            int http_port;
            char http_proxy[256];
            char http_outbound_proxy[256];
            int dontsend_101;
    #endif
            int use_rport;
            int dns_capabilities;
            int dscp;
            char ipv4_for_gateway[256];
            char ipv6_for_gateway[256];
    #ifndef MINISIZE
            char event_package[256];
    #endif
            struct eXosip_dns_cache dns_entries[MAX_EXOSIP_DNS_ENTRY];
            struct eXosip_account_info account_entries[MAX_EXOSIP_ACCOUNT_INFO];
            struct eXosip_http_auth http_auths[MAX_EXOSIP_HTTP_AUTH];
    
            CbSipCallback cbsipCallback;
        };

     3、eXosip_event_t

     /**
     * Structure for event description
     * @struct eXosip_event
     */
      struct eXosip_event
      {
        eXosip_event_type_t type;               /**< type of the event */
        char textinfo[256];                     /**< text description of event */
        void *external_reference;               /**< external reference (for calls) */

        osip_message_t *request;       /**< request within current transaction */
        osip_message_t *response;      /**< last response within current transaction */
        osip_message_t *ack;           /**< ack within current transaction */

        int tid; /**< unique id for transactions (to be used for answers) */
        int did; /**< unique id for SIP dialogs */

        int rid; /**< unique id for registration */
        int cid; /**< unique id for SIP calls (but multiple dialogs!) */
        int sid; /**< unique id for outgoing subscriptions */
        int nid; /**< unique id for incoming subscriptions */

        int ss_status;  /**< current Subscription-State for subscription */
        int ss_reason;  /**< current Reason status for subscription */
      };

    主要函数说明:

    1、eXosip_init

    /**
     * Initiate the eXtented oSIP library.
     * 
     */
      int eXosip_init (void);

    2、eXosip_listen_addr

    /**
     * Listen on a specified socket.
     * 
     * @param transport IPPROTO_UDP for udp. (soon to come: TCP/TLS?)
     * @param addr      the address to bind (NULL for all interface)
     * @param port      the listening port. (0 for random port)
     * @param family    the IP family (AF_INET or AF_INET6).
     * @param secure    0 for UDP or TCP, 1 for TLS (with TCP).
     */
      int eXosip_listen_addr (int transport, const char *addr, int port, int family,
                              int secure);

    3、eXosip_execute

    /**
     * Process (non-threaded mode ONLY) eXosip events.
     * 
     */
      int eXosip_execute (void);

     4、eXosip_lock、eXosip_unlock

    #ifdef OSIP_MT
    
    /**
     * Lock the eXtented oSIP library.
     * 
     */
      int eXosip_lock (void);
    
    /**
     * UnLock the eXtented oSIP library.
     * 
     */
      int eXosip_unlock (void);
    
    #else

    5、__eXosip_wakeup_event

    /**
     * Wake Up the eXosip_event_wait method.
     * 
     */
    #ifdef OSIP_MT
      void __eXosip_wakeup_event (void);
    #else
    #define __eXosip_wakeup_event()   ;
    #endif

     6、eXosip_event_wait

    /**
     * Wait for an eXosip event.
     * 
     * @param tv_s      timeout value (seconds).
     * @param tv_ms     timeout value (mseconds).
     */
      eXosip_event_t *eXosip_event_wait (int tv_s, int tv_ms);

    aa

  • 相关阅读:
    js中return的作用及用法
    js数组、字符串常用方法
    关于Ajax知识点小节
    关于跨域,同源策略小节
    Javascript模块化编程(三):require.js的用法【转】
    Javascript模块化编程(二):AMD规范【转】
    Javascript模块化编程(一):模块的写法【转】
    AJAX——核心XMLHttpRequest对象
    clientX,screenX,pageX,offsetX的异同 【转载】
    原生js获取鼠标坐标方法全面讲解:clientX/Y,pageX/Y,offsetX/Y,layerX/Y,screenX/Y【转】
  • 原文地址:https://www.cnblogs.com/jingzhishen/p/6201640.html
Copyright © 2011-2022 走看看