listeningpoint_internal.h 5.32 KB
Newer Older
jehan's avatar
jehan committed
1 2 3 4 5 6
/*
	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
7
    the Free Software Foundation, either version 2 of the License, or
jehan's avatar
jehan committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21
    (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_

22

jehan's avatar
jehan committed
23

24 25
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_listening_point_t,belle_sip_object_t)
const char *transport;
26
belle_sip_channel_t * (*create_channel)(belle_sip_listening_point_t *, const belle_sip_hop_t *hop);
27 28 29 30 31 32
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
33 34 35 36 37 38 39 40
/*
 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
41
	belle_sip_uri_t* listening_uri;
jehan's avatar
jehan committed
42
	belle_sip_source_t* keep_alive_timer;
43
	belle_sip_channel_listener_t* channel_listener; /*initial channel listener used for channel creation, specially for socket server*/
44
	int ai_family; /*AF_INET or AF_INET6*/
jehan's avatar
jehan committed
45 46
};

47
BELLE_SIP_BEGIN_DECLS
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);
49 50
belle_sip_channel_t *_belle_sip_listening_point_get_channel(belle_sip_listening_point_t *lp,const belle_sip_hop_t *hop, const struct addrinfo *addr);
belle_sip_channel_t *belle_sip_listening_point_create_channel(belle_sip_listening_point_t *ip, const belle_sip_hop_t *hop);
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
int belle_sip_listening_point_get_well_known_port(const char *transport);
53
belle_sip_channel_t *belle_sip_listening_point_get_channel(belle_sip_listening_point_t *lp, const belle_sip_hop_t *hop);
jehan's avatar
jehan committed
54
void belle_sip_listening_point_add_channel(belle_sip_listening_point_t *lp, belle_sip_channel_t *chan);
55
void belle_sip_listening_point_set_channel_listener(belle_sip_listening_point_t *lp,belle_sip_channel_listener_t* channel_listener);
56
BELLE_SIP_END_DECLS
jehan's avatar
jehan committed
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
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
65

jehan's avatar
jehan committed
66 67 68

/*stream*/
typedef struct belle_sip_stream_listening_point belle_sip_stream_listening_point_t;
69

70 71 72 73 74 75
struct belle_sip_stream_listening_point{
	belle_sip_listening_point_t base;
	belle_sip_socket_t server_sock;
	belle_sip_source_t *source;
};

jehan's avatar
jehan committed
76 77
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_stream_listening_point_t,belle_sip_listening_point_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
78

79

80 81 82
void belle_sip_stream_listening_point_setup_server_socket(belle_sip_stream_listening_point_t *obj, belle_sip_source_func_t on_new_connection_cb );
void belle_sip_stream_listening_point_destroy_server_socket(belle_sip_stream_listening_point_t *lp);
void belle_sip_stream_listening_point_init(belle_sip_stream_listening_point_t *obj, belle_sip_stack_t *s, const char *ipaddress, int port, belle_sip_source_func_t on_new_connection_cb );
83

jehan's avatar
jehan committed
84 85
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
86
/*tls*/
jehan's avatar
jehan committed
87 88

struct belle_sip_tls_listening_point{
89
	belle_sip_stream_listening_point_t base;
90
	belle_tls_crypto_config_t *crypto_config;
91 92
};

93 94
int belle_sip_tls_listening_point_available(void);

jehan's avatar
jehan committed
95 96 97 98
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);
99
belle_sip_channel_t * belle_sip_channel_new_tls(belle_sip_stack_t *s, belle_tls_verify_policy_t* verify_ctx, const char *bindip, int localport,const char *cname, const char *name, int port);
jehan's avatar
jehan committed
100

101

Ghislain MARY's avatar
Ghislain MARY committed
102 103 104 105 106 107 108 109 110
/*tunnel*/
#ifdef HAVE_TUNNEL
typedef struct belle_sip_tunnel_listening_point belle_sip_tunnel_listening_point_t;
BELLE_SIP_DECLARE_CUSTOM_VPTR_BEGIN(belle_sip_tunnel_listening_point_t,belle_sip_listening_point_t)
BELLE_SIP_DECLARE_CUSTOM_VPTR_END
#define BELLE_SIP_TUNNEL_LISTENING_POINT(obj) BELLE_SIP_CAST(obj,belle_sip_tunnel_listening_point_t)
belle_sip_channel_t * belle_sip_channel_new_tunnel(belle_sip_stack_t *s, void *tunnelclient, const char *bindip, int localport, const char *name, int port);
#endif

111
#include "transports/stream_channel.h"
jehan's avatar
jehan committed
112

jehan's avatar
jehan committed
113
#endif /* LISTENINGPOINT_INTERNAL_H_ */
114