listeningpoint_internal.h 4.47 KB
Newer Older
jehan's avatar
jehan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
	belle-sip - SIP (RFC3261) library.
    Copyright (C) 2010  Belledonne Communications SARL

    This program 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 3 of the License, or
    (at your option) any later version.

    This program 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, see <http://www.gnu.org/licenses/>.
*/

#ifndef LISTENINGPOINT_INTERNAL_H_
#define LISTENINGPOINT_INTERNAL_H_

jehan's avatar
jehan committed
22 23 24
#ifdef HAVE_TLS
#include "gnutls/openssl.h"
#endif
Simon Morlat's avatar
Simon Morlat committed
25 26 27 28 29 30 31 32 33 34

BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_listening_point_t,belle_sip_object_t)
const char *transport;
belle_sip_channel_t * (*create_channel)(belle_sip_listening_point_t *,const char *dest_ip, int port);
BELLE_SIP_DECLARE_CUSTOM_VPTR_END


#define BELLE_SIP_LISTENING_POINT(obj) BELLE_SIP_CAST(obj,belle_sip_listening_point_t)


jehan's avatar
jehan committed
35 36 37 38 39 40 41 42
/*
 Listening points: base, udp
*/

struct belle_sip_listening_point{
	belle_sip_object_t base;
	belle_sip_stack_t *stack;
	belle_sip_list_t *channels;
jehan's avatar
jehan committed
43
	belle_sip_channel_listener_t* channel_listener; /*initial chennel listener used for channel creation*/
jehan's avatar
jehan committed
44
	belle_sip_uri_t* listening_uri;
jehan's avatar
jehan committed
45
	belle_sip_source_t* keep_alive_timer;
jehan's avatar
jehan committed
46 47
};

jehan's avatar
jehan committed
48
void belle_sip_listening_point_init(belle_sip_listening_point_t *lp, belle_sip_stack_t *s,  const char *address, int port);
jehan's avatar
jehan committed
49
belle_sip_channel_t *_belle_sip_listening_point_get_channel(belle_sip_listening_point_t *lp,const char *peer_name, int peer_port, const struct addrinfo *addr);
jehan's avatar
jehan committed
50
belle_sip_channel_t *belle_sip_listening_point_create_channel(belle_sip_listening_point_t *ip,const char *dest, int port);
Simon Morlat's avatar
Simon Morlat committed
51
void belle_sip_listening_point_remove_channel(belle_sip_listening_point_t *lp, belle_sip_channel_t *chan);
jehan's avatar
jehan committed
52 53 54
int belle_sip_listening_point_get_well_known_port(const char *transport);
belle_sip_channel_t *belle_sip_listening_point_get_channel(belle_sip_listening_point_t *lp,const char *peer_name, int peer_port);
void belle_sip_listening_point_add_channel(belle_sip_listening_point_t *lp, belle_sip_channel_t *chan);
jehan's avatar
jehan committed
55
void belle_sip_listener_set_channel_listener(belle_sip_listening_point_t *lp,belle_sip_channel_listener_t* channel_listener);
jehan's avatar
jehan committed
56 57


jehan's avatar
jehan committed
58 59
/**udp*/
typedef struct belle_sip_udp_listening_point belle_sip_udp_listening_point_t;
jehan's avatar
jehan committed
60 61
belle_sip_channel_t * belle_sip_channel_new_udp(belle_sip_stack_t *stack, int sock, const char *bindip, int localport, const char *peername, int peerport);
belle_sip_channel_t * belle_sip_channel_new_udp_with_addr(belle_sip_stack_t *stack, int sock, const char *bindip, int localport, const struct addrinfo *ai);
jehan's avatar
jehan committed
62 63 64 65 66 67 68
belle_sip_listening_point_t * belle_sip_udp_listening_point_new(belle_sip_stack_t *s, const char *ipaddress, int port);
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_udp_listening_point_t,belle_sip_listening_point_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
#define BELLE_SIP_UDP_LISTENING_POINT(obj) BELLE_SIP_CAST(obj,belle_sip_udp_listening_point_t)

/*stream*/
typedef struct belle_sip_stream_listening_point belle_sip_stream_listening_point_t;
jehan's avatar
jehan committed
69
belle_sip_channel_t * belle_sip_channel_new_tcp(belle_sip_stack_t *stack, const char *bindip, int localport,const char *name, int port);
jehan's avatar
jehan committed
70 71 72 73 74
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_stream_listening_point_t,belle_sip_listening_point_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
#define BELLE_SIP_STREAM_LISTENING_POINT(obj) BELLE_SIP_CAST(obj,belle_sip_stream_listening_point_t)
belle_sip_listening_point_t * belle_sip_stream_listening_point_new(belle_sip_stack_t *s, const char *ipaddress, int port);

jehan's avatar
jehan committed
75
/*tls*/
jehan's avatar
jehan committed
76

jehan's avatar
jehan committed
77
typedef struct belle_sip_tls_listening_point belle_sip_tls_listening_point_t;
78

jehan's avatar
jehan committed
79 80
struct belle_sip_tls_listening_point{
	belle_sip_listening_point_t base;
81
#ifdef HAVE_OPENSSL
jehan's avatar
jehan committed
82 83
	SSL_CTX *ssl_context;
#endif
84 85
};

jehan's avatar
jehan committed
86 87 88 89
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_tls_listening_point_t,belle_sip_listening_point_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
#define BELLE_SIP_TLS_LISTENING_POINT(obj) BELLE_SIP_CAST(obj,belle_sip_tls_listening_point_t)
belle_sip_listening_point_t * belle_sip_tls_listening_point_new(belle_sip_stack_t *s, const char *ipaddress, int port);
jehan's avatar
jehan committed
90
belle_sip_channel_t * belle_sip_channel_new_tls(belle_sip_tls_listening_point_t* lp, const char *bindip, int localport,const char *name, int port);
jehan's avatar
jehan committed
91 92


jehan's avatar
jehan committed
93
#endif /* LISTENINGPOINT_INTERNAL_H_ */
Simon Morlat's avatar
Simon Morlat committed
94