forked from OpenSIPS/opensips
-
Notifications
You must be signed in to change notification settings - Fork 1
/
trans.h
122 lines (97 loc) · 2.85 KB
/
trans.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Copyright (C) 2015 OpenSIPS Project
*
* This file is part of opensips, a free SIP server.
*
* opensips 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.
*
* opensips 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*
* history:
* ---------
* 2015-01-xx created (razvanc)
*/
#ifndef _TRANS_TI_H_
#define _TRANS_TI_H_
#include "../ip_addr.h"
#include "api_proto.h"
#include "api_proto_net.h"
struct proto_info {
/* the name of the protocol */
char *name;
/* the default port according to RFC */
unsigned short default_rfc_port;
/* proto as ID */
enum sip_protos id;
/* the default port, in case it is missing in the listener */
unsigned short default_port;
/* bindings for the transport interface */
struct api_proto tran;
/* bindings for the net interface */
struct api_proto_net net;
/* listeners on this proto */
struct socket_info *listeners;
/* default sending interfaces */
struct socket_info *sendipv4;
struct socket_info *sendipv6;
};
/* XXX: here it would be nice to have a separate structure that only populates
* the necessary info, without having access to "private" fields like
* listeners */
typedef int (*api_proto_init)(struct proto_info *pi);
extern struct proto_info protos[];
#define is_tcp_based_proto(_p) \
(protos[_p].net.flags&PROTO_NET_USE_TCP)
#define is_udp_based_proto(_p) \
(protos[_p].net.flags&PROTO_NET_USE_UDP)
#define DST_FCNTL_SET_LIFETIME 1
#define trans_set_dst_attr( _rcv, _attr, _val) \
do { \
if (protos[(_rcv)->proto].tran.dst_attr) \
protos[(_rcv)->proto].tran.dst_attr(_rcv,_attr,_val);\
}while(0)
/*
* loads the transport protocol
*/
int trans_load(void);
/*
* adds a new listener
*/
int add_listener(struct socket_id *sock, enum si_flags flags);
/*
* adds a temporary listener
*/
int add_cmd_listener(char *name, int port, int proto);
/*
* fixes temporary listeners
*/
int fix_cmd_listeners(void);
/*
* fixes all socket lists
*/
int fix_all_socket_lists(void);
/*
* init all registered listeners
*/
int trans_init_all_listeners(void);
void print_all_socket_lists(void);
static inline char* get_proto_name(unsigned short proto)
{
if (proto == PROTO_NONE)
return "*";
if (proto >= PROTO_LAST || protos[proto].id == PROTO_NONE)
return "unknown";
return protos[proto].name;
}
#endif /* _TRANS_TI_H_ */