/src/opensips/net/trans.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (C) 2015 OpenSIPS Project |
3 | | * |
4 | | * This file is part of opensips, a free SIP server. |
5 | | * |
6 | | * opensips is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 2 of the License, or |
9 | | * (at your option) any later version. |
10 | | * |
11 | | * opensips is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | | * |
20 | | * |
21 | | * history: |
22 | | * --------- |
23 | | * 2015-01-xx created (razvanc) |
24 | | */ |
25 | | |
26 | | #ifndef _TRANS_TI_H_ |
27 | | #define _TRANS_TI_H_ |
28 | | |
29 | | #include "../ip_addr.h" |
30 | | #include "api_proto.h" |
31 | | #include "api_proto_net.h" |
32 | | |
33 | | struct proto_info { |
34 | | /* the name of the protocol */ |
35 | | char *name; |
36 | | |
37 | | /* the default port according to RFC */ |
38 | | unsigned short default_rfc_port; |
39 | | |
40 | | /* proto as ID */ |
41 | | enum sip_protos id; |
42 | | |
43 | | /* the default port, in case it is missing in the listener */ |
44 | | unsigned short default_port; |
45 | | |
46 | | /* bindings for the transport interface */ |
47 | | struct api_proto tran; |
48 | | |
49 | | /* bindings for the net interface */ |
50 | | struct api_proto_net net; |
51 | | |
52 | | /* listeners on this proto */ |
53 | | struct socket_info_full *listeners; |
54 | | |
55 | | /* default sending interfaces */ |
56 | | struct socket_info *sendipv4; |
57 | | struct socket_info *sendipv6; |
58 | | }; |
59 | | |
60 | | /* XXX: here it would be nice to have a separate structure that only populates |
61 | | * the necessary info, without having access to "private" fields like |
62 | | * listeners */ |
63 | | typedef int (*api_proto_init)(struct proto_info *pi); |
64 | | |
65 | | extern struct proto_info protos[]; |
66 | | |
67 | | #define is_tcp_based_proto(_p) \ |
68 | 0 | ((_p==PROTO_WS)||(protos[_p].net.flags&PROTO_NET_USE_TCP)) |
69 | | /* XXX: this ^ is an ugly hack to detect that WebSocket connections |
70 | | * are TCP based, even though the module is not loaded. We need this |
71 | | * in scenarios where a WSS client sends transport=ws in the URI's |
72 | | * params according to RFC 7118 - razvanc |
73 | | */ |
74 | | |
75 | | /* NOTE: make sure trans_load() is called, or you will get false negatives! */ |
76 | | #define is_udp_based_proto(_p) \ |
77 | 0 | (protos[_p].net.flags&PROTO_NET_USE_UDP) |
78 | | |
79 | | #define proto_has_listeners(_p) \ |
80 | 0 | (protos[_p].listeners != NULL) |
81 | | |
82 | 0 | #define DST_FCNTL_SET_LIFETIME 1 |
83 | | |
84 | | #define trans_set_dst_attr( _rcv, _attr, _val) \ |
85 | | do { \ |
86 | | if (protos[(_rcv)->proto].tran.dst_attr) \ |
87 | | protos[(_rcv)->proto].tran.dst_attr(_rcv,_attr,_val);\ |
88 | | }while(0) |
89 | | |
90 | | /* |
91 | | * loads the transport protocol |
92 | | */ |
93 | | int trans_load(void); |
94 | | |
95 | | /* |
96 | | * adds a new listening socket |
97 | | */ |
98 | | int add_listening_socket(struct socket_id *sock); |
99 | | |
100 | | /* |
101 | | * adds a temporary listening socket |
102 | | */ |
103 | | int add_cmd_listening_socket(char *name, int port, int proto); |
104 | | |
105 | | /* |
106 | | * fixes temporary listening sockets |
107 | | */ |
108 | | int fix_cmd_listening_sockets(void); |
109 | | |
110 | | /* |
111 | | * fixes all socket lists |
112 | | */ |
113 | | int fix_all_socket_lists(void); |
114 | | |
115 | | /* |
116 | | * init all registered listening sockets |
117 | | */ |
118 | | int trans_init_udp_listeners(void); |
119 | | |
120 | | void print_all_socket_lists(void); |
121 | | |
122 | | static inline char* get_proto_name(unsigned short proto) |
123 | 0 | { |
124 | 0 | if (proto == PROTO_NONE) |
125 | 0 | return "*"; |
126 | 0 | if (proto >= PROTO_LAST || protos[proto].id == PROTO_NONE) |
127 | 0 | return "unknown"; |
128 | 0 | return protos[proto].name; |
129 | 0 | } Unexecuted instantiation: msg_parser.c:get_proto_name Unexecuted instantiation: parse_uri.c:get_proto_name Unexecuted instantiation: parse_to.c:get_proto_name Unexecuted instantiation: dprint.c:get_proto_name Unexecuted instantiation: pt.c:get_proto_name Unexecuted instantiation: strcommon.c:get_proto_name Unexecuted instantiation: statistics.c:get_proto_name Unexecuted instantiation: pvar.c:get_proto_name Unexecuted instantiation: route.c:get_proto_name Unexecuted instantiation: socket_info.c:get_proto_name Unexecuted instantiation: ipc.c:get_proto_name Unexecuted instantiation: core_stats.c:get_proto_name Unexecuted instantiation: pt_scaling.c:get_proto_name Unexecuted instantiation: pt_load.c:get_proto_name Unexecuted instantiation: sr_module.c:get_proto_name Unexecuted instantiation: action.c:get_proto_name Unexecuted instantiation: db_insertq.c:get_proto_name Unexecuted instantiation: proto_tcp.c:get_proto_name Unexecuted instantiation: proto_udp.c:get_proto_name Unexecuted instantiation: trans.c:get_proto_name Unexecuted instantiation: net_tcp_proc.c:get_proto_name Unexecuted instantiation: net_tcp.c:get_proto_name Unexecuted instantiation: tcp_common.c:get_proto_name Unexecuted instantiation: net_udp.c:get_proto_name Unexecuted instantiation: net_tcp_report.c:get_proto_name Unexecuted instantiation: parse_ppi.c:get_proto_name Unexecuted instantiation: parse_from.c:get_proto_name Unexecuted instantiation: event_interface.c:get_proto_name Unexecuted instantiation: receive.c:get_proto_name Unexecuted instantiation: async.c:get_proto_name Unexecuted instantiation: daemonize.c:get_proto_name Unexecuted instantiation: timer.c:get_proto_name Unexecuted instantiation: reactor.c:get_proto_name Unexecuted instantiation: forward.c:get_proto_name Unexecuted instantiation: xlog.c:get_proto_name Unexecuted instantiation: blacklists.c:get_proto_name Unexecuted instantiation: resolve.c:get_proto_name Unexecuted instantiation: io_wait.c:get_proto_name Unexecuted instantiation: transformations.c:get_proto_name Unexecuted instantiation: sr_module_deps.c:get_proto_name Unexecuted instantiation: cfg_reload.c:get_proto_name Unexecuted instantiation: signals.c:get_proto_name Unexecuted instantiation: msg_translator.c:get_proto_name Unexecuted instantiation: cfg.tab.c:get_proto_name Unexecuted instantiation: shutdown.c:get_proto_name Unexecuted instantiation: core_cmds.c:get_proto_name |
130 | | |
131 | | #endif /* _TRANS_TI_H_ */ |