1 | //vio_dstr.h: |
---|
2 | |
---|
3 | /* |
---|
4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2009-2012 |
---|
5 | * |
---|
6 | * This file is part of libroar a part of RoarAudio, |
---|
7 | * a cross-platform sound system for both, home and professional use. |
---|
8 | * See README for details. |
---|
9 | * |
---|
10 | * This file is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License version 3 |
---|
12 | * as published by the Free Software Foundation. |
---|
13 | * |
---|
14 | * libroar is distributed in the hope that it will be useful, |
---|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | * GNU General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with this software; see the file COPYING. If not, write to |
---|
21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
22 | * Boston, MA 02110-1301, USA. |
---|
23 | * |
---|
24 | * NOTE for everyone want's to change something and send patches: |
---|
25 | * read README and HACKING! There a addition information on |
---|
26 | * the license of this document you need to read before you send |
---|
27 | * any patches. |
---|
28 | * |
---|
29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
30 | * or libpulse*: |
---|
31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
34 | */ |
---|
35 | |
---|
36 | #ifndef _LIBROARVIO_DSTR_H_ |
---|
37 | #define _LIBROARVIO_DSTR_H_ |
---|
38 | |
---|
39 | #include "libroar.h" |
---|
40 | |
---|
41 | #define ROAR_VIO_DEF_TYPE_EOL -1 |
---|
42 | #define ROAR_VIO_DEF_TYPE_NONE 0 |
---|
43 | #define ROAR_VIO_DEF_TYPE_FILE 1 |
---|
44 | #define ROAR_VIO_DEF_TYPE_SOCKET 2 |
---|
45 | #define ROAR_VIO_DEF_TYPE_FH 3 |
---|
46 | #define ROAR_VIO_DEF_TYPE_SOCKETFH 4 |
---|
47 | |
---|
48 | #define ROAR_VIO_DSTR_OBJGT_INTERNAL 0x0000 |
---|
49 | #define ROAR_VIO_DSTR_OBJGT_GEN 0x0100 |
---|
50 | #define ROAR_VIO_DSTR_OBJGT_SOCKET 0x0200 |
---|
51 | #define ROAR_VIO_DSTR_OBJGT_PROXY 0x0300 |
---|
52 | #define ROAR_VIO_DSTR_OBJGT_COMP 0x0400 /* compression */ |
---|
53 | #define ROAR_VIO_DSTR_OBJGT_CRYPT 0x0500 |
---|
54 | #define ROAR_VIO_DSTR_OBJGT_PROTO 0x0600 /* protocolls like HTTP and Gopher */ |
---|
55 | #define ROAR_VIO_DSTR_OBJGT_CONTENT 0x0700 /* things changeing the content of the data */ |
---|
56 | #define ROAR_VIO_DSTR_OBJGT_MUX 0x0800 /* muxers and demuxers */ |
---|
57 | #define ROAR_VIO_DSTR_OBJGT_SPECAL 0xff00 |
---|
58 | |
---|
59 | #define ROAR_VIO_DSTR_OBJT_EOL -1 |
---|
60 | #define ROAR_VIO_DSTR_OBJT_NONE 0 |
---|
61 | #define ROAR_VIO_DSTR_OBJT_INTERNAL 1 |
---|
62 | |
---|
63 | #define ROAR_VIO_DSTR_OBJT_FILE (0x01|ROAR_VIO_DSTR_OBJGT_GEN) |
---|
64 | #define ROAR_VIO_DSTR_OBJT_FH (0x02|ROAR_VIO_DSTR_OBJGT_GEN) |
---|
65 | #define ROAR_VIO_DSTR_OBJT_FD ROAR_VIO_DSTR_OBJT_FH |
---|
66 | #define ROAR_VIO_DSTR_OBJT_SOCKETFH (0x03|ROAR_VIO_DSTR_OBJGT_GEN) |
---|
67 | /* some space to add memory FHs and the like */ |
---|
68 | #define ROAR_VIO_DSTR_OBJT_PASS (0x10|ROAR_VIO_DSTR_OBJGT_GEN) |
---|
69 | #define ROAR_VIO_DSTR_OBJT_RE (0x11|ROAR_VIO_DSTR_OBJGT_GEN) |
---|
70 | #define ROAR_VIO_DSTR_OBJT_JUMBO (0x12|ROAR_VIO_DSTR_OBJGT_GEN) |
---|
71 | #define ROAR_VIO_DSTR_OBJT_EXEC (0x20|ROAR_VIO_DSTR_OBJGT_GEN) |
---|
72 | /* special devices */ |
---|
73 | #define ROAR_VIO_DSTR_OBJT_NULL (0x30|ROAR_VIO_DSTR_OBJGT_GEN) /* /dev/null */ |
---|
74 | #define ROAR_VIO_DSTR_OBJT_ZERO (0x31|ROAR_VIO_DSTR_OBJGT_GEN) /* /dev/zero */ |
---|
75 | #define ROAR_VIO_DSTR_OBJT_FULL (0x32|ROAR_VIO_DSTR_OBJGT_GEN) /* /dev/full */ |
---|
76 | |
---|
77 | #define ROAR_VIO_DSTR_OBJT_SOCKET (0x01|ROAR_VIO_DSTR_OBJGT_SOCKET) |
---|
78 | #define ROAR_VIO_DSTR_OBJT_UNIX (0x02|ROAR_VIO_DSTR_OBJGT_SOCKET) |
---|
79 | #define ROAR_VIO_DSTR_OBJT_DECNET (0x10|ROAR_VIO_DSTR_OBJGT_SOCKET) |
---|
80 | #define ROAR_VIO_DSTR_OBJT_TCP (0x21|ROAR_VIO_DSTR_OBJGT_SOCKET) |
---|
81 | #define ROAR_VIO_DSTR_OBJT_UDP (0x22|ROAR_VIO_DSTR_OBJGT_SOCKET) |
---|
82 | #define ROAR_VIO_DSTR_OBJT_TCP6 (0x31|ROAR_VIO_DSTR_OBJGT_SOCKET) |
---|
83 | #define ROAR_VIO_DSTR_OBJT_UDP6 (0x32|ROAR_VIO_DSTR_OBJGT_SOCKET) |
---|
84 | |
---|
85 | #define ROAR_VIO_DSTR_OBJT_SOCKS (0x10|ROAR_VIO_DSTR_OBJGT_PROXY) |
---|
86 | #define ROAR_VIO_DSTR_OBJT_SOCKS4 (0x14|ROAR_VIO_DSTR_OBJGT_PROXY) |
---|
87 | #define ROAR_VIO_DSTR_OBJT_SOCKS4A (0x1a|ROAR_VIO_DSTR_OBJGT_PROXY) |
---|
88 | #define ROAR_VIO_DSTR_OBJT_SOCKS4D (0x1d|ROAR_VIO_DSTR_OBJGT_PROXY) |
---|
89 | #define ROAR_VIO_DSTR_OBJT_SOCKS5 (0x15|ROAR_VIO_DSTR_OBJGT_PROXY) |
---|
90 | #define ROAR_VIO_DSTR_OBJT_SSH (0x21|ROAR_VIO_DSTR_OBJGT_PROXY) |
---|
91 | //#define ROAR_VIO_DSTR_OBJT_HTTP (0x31|ROAR_VIO_DSTR_OBJGT_PROXY) |
---|
92 | |
---|
93 | //#define ROAR_VIO_DSTR_OBJT_HTTP (0x10|ROAR_VIO_DSTR_OBJGT_PROTO) |
---|
94 | #define ROAR_VIO_DSTR_OBJT_HTTP09 (0x11|ROAR_VIO_DSTR_OBJGT_PROTO) |
---|
95 | #define ROAR_VIO_DSTR_OBJT_HTTP10 (0x12|ROAR_VIO_DSTR_OBJGT_PROTO) |
---|
96 | #define ROAR_VIO_DSTR_OBJT_HTTP11 (0x13|ROAR_VIO_DSTR_OBJGT_PROTO) |
---|
97 | #define ROAR_VIO_DSTR_OBJT_HTTP ROAR_VIO_DSTR_OBJT_HTTP11 |
---|
98 | #define ROAR_VIO_DSTR_OBJT_GOPHER (0x21|ROAR_VIO_DSTR_OBJGT_PROTO) |
---|
99 | #define ROAR_VIO_DSTR_OBJT_GOPHER_PLUS (0x22|ROAR_VIO_DSTR_OBJGT_PROTO) |
---|
100 | #define ROAR_VIO_DSTR_OBJT_ICY (0x31|ROAR_VIO_DSTR_OBJGT_PROTO) |
---|
101 | #define ROAR_VIO_DSTR_OBJT_RTP2 (0x42|ROAR_VIO_DSTR_OBJGT_PROTO) |
---|
102 | #define ROAR_VIO_DSTR_OBJT_RTP ROAR_VIO_DSTR_OBJT_RTP2 |
---|
103 | |
---|
104 | /* |
---|
105 | #define ROAR_VIO_DSTR_OBJGT_CRYPT 0x0500 |
---|
106 | */ |
---|
107 | |
---|
108 | #define ROAR_VIO_DSTR_OBJT_GZIP (0x10|ROAR_VIO_DSTR_OBJGT_COMP) |
---|
109 | #define ROAR_VIO_DSTR_OBJT_ZLIB (0x11|ROAR_VIO_DSTR_OBJGT_COMP) |
---|
110 | #define ROAR_VIO_DSTR_OBJT_BZIP2 (0x22|ROAR_VIO_DSTR_OBJGT_COMP) |
---|
111 | |
---|
112 | #define ROAR_VIO_DSTR_OBJT_PGP (0x10|ROAR_VIO_DSTR_OBJGT_CRYPT) |
---|
113 | #define ROAR_VIO_DSTR_OBJT_PGP_ENC (0x11|ROAR_VIO_DSTR_OBJGT_CRYPT) |
---|
114 | #define ROAR_VIO_DSTR_OBJT_PGP_STORE (0x12|ROAR_VIO_DSTR_OBJGT_CRYPT) |
---|
115 | #define ROAR_VIO_DSTR_OBJT_SSL1 (0x21|ROAR_VIO_DSTR_OBJGT_CRYPT) |
---|
116 | #define ROAR_VIO_DSTR_OBJT_SSL2 (0x22|ROAR_VIO_DSTR_OBJGT_CRYPT) |
---|
117 | #define ROAR_VIO_DSTR_OBJT_SSL3 (0x23|ROAR_VIO_DSTR_OBJGT_CRYPT) |
---|
118 | #define ROAR_VIO_DSTR_OBJT_TLS (0x2a|ROAR_VIO_DSTR_OBJGT_CRYPT) |
---|
119 | #define ROAR_VIO_DSTR_OBJT_SSLTLS ROAR_VIO_DSTR_OBJT_TLS |
---|
120 | /* Random numbers, 0x30+ROAR_RANDOM_* */ |
---|
121 | #define ROAR_VIO_DSTR_OBJT_NRANDOM (0x31|ROAR_VIO_DSTR_OBJGT_CRYPT) /* nonce */ |
---|
122 | #define ROAR_VIO_DSTR_OBJT_URANDOM (0x33|ROAR_VIO_DSTR_OBJGT_CRYPT) /* like urandom */ |
---|
123 | #define ROAR_VIO_DSTR_OBJT_SRANDOM (0x34|ROAR_VIO_DSTR_OBJGT_CRYPT) /* strong random */ |
---|
124 | |
---|
125 | #define ROAR_VIO_DSTR_OBJT_TRANSCODE (0x10|ROAR_VIO_DSTR_OBJGT_CONTENT) |
---|
126 | |
---|
127 | #define ROAR_VIO_DSTR_OBJT_RAUM (0x11|ROAR_VIO_DSTR_OBJGT_MUX) |
---|
128 | #define ROAR_VIO_DSTR_OBJT_OGG (0x12|ROAR_VIO_DSTR_OBJGT_MUX) |
---|
129 | #define ROAR_VIO_DSTR_OBJT_TAR (0x13|ROAR_VIO_DSTR_OBJGT_MUX) |
---|
130 | |
---|
131 | #define ROAR_VIO_DSTR_OBJT_MAGIC (0x01|ROAR_VIO_DSTR_OBJGT_SPECAL) |
---|
132 | #define ROAR_VIO_DSTR_OBJT_TANTALOS (0x02|ROAR_VIO_DSTR_OBJGT_SPECAL) |
---|
133 | |
---|
134 | |
---|
135 | struct roar_vio_defaults { |
---|
136 | int type; |
---|
137 | |
---|
138 | mode_t o_mode; |
---|
139 | int o_flags; |
---|
140 | |
---|
141 | union { |
---|
142 | const char * file; |
---|
143 | int fh; |
---|
144 | struct { |
---|
145 | int domain; |
---|
146 | int type; |
---|
147 | const char * host; |
---|
148 | union { |
---|
149 | struct sockaddr sa; |
---|
150 | #ifdef ROAR_HAVE_IPV4 |
---|
151 | struct sockaddr_in in; |
---|
152 | #endif |
---|
153 | #ifdef ROAR_HAVE_UNIX |
---|
154 | struct sockaddr_un un; |
---|
155 | #endif |
---|
156 | #ifdef ROAR_HAVE_LIBDNET |
---|
157 | struct sockaddr_dn dn; |
---|
158 | #endif |
---|
159 | #ifdef ROAR_HAVE_IPV6 |
---|
160 | struct sockaddr_in6 in6; |
---|
161 | #endif |
---|
162 | #ifdef ROAR_HAVE_IPX |
---|
163 | struct sockaddr_ipx ipx; |
---|
164 | #endif |
---|
165 | } sa; |
---|
166 | socklen_t len; |
---|
167 | } socket; |
---|
168 | } d; |
---|
169 | }; |
---|
170 | |
---|
171 | #define ROAR_VIO_DSTR_MAX_OBJ_PER_CHAIN 16 |
---|
172 | |
---|
173 | struct roar_vio_dstr_chain { |
---|
174 | int type; |
---|
175 | char * opts; |
---|
176 | char * dst; |
---|
177 | int need_vio; |
---|
178 | struct roar_vio_defaults * def; |
---|
179 | struct roar_vio_calls * vio; |
---|
180 | struct roar_vio_defaults store_def; |
---|
181 | }; |
---|
182 | |
---|
183 | int roar_vio_dstr_get_type(const char * str); |
---|
184 | const char * roar_vio_dstr_get_name(const int type); |
---|
185 | |
---|
186 | int roar_vio_dstr_register_type(int type, |
---|
187 | char *name, |
---|
188 | int (*setdef) (struct roar_vio_dstr_chain * cur, |
---|
189 | struct roar_vio_dstr_chain * next), |
---|
190 | int (*openvio)(struct roar_vio_calls * calls, |
---|
191 | struct roar_vio_calls * dst, |
---|
192 | struct roar_vio_dstr_chain * cur, |
---|
193 | struct roar_vio_dstr_chain * next)); |
---|
194 | |
---|
195 | int roar_vio_dstr_init_defaults (struct roar_vio_defaults * def, int type, int o_flags, mode_t o_mode); |
---|
196 | int roar_vio_dstr_init_defaults_c (struct roar_vio_defaults * def, int type, struct roar_vio_defaults * odef, int o_flags); |
---|
197 | |
---|
198 | int roar_vio_open_default (struct roar_vio_calls * calls, struct roar_vio_defaults * def, char * opts); |
---|
199 | |
---|
200 | int roar_vio_open_dstr_simple(struct roar_vio_calls * calls, const char * dstr, int o_flags); |
---|
201 | struct roar_vio_calls * roar_vio_open_dstr_simple_new(const char * dstr, int o_flags); |
---|
202 | |
---|
203 | int roar_vio_open_dstr (struct roar_vio_calls * calls, const char * dstr, struct roar_vio_defaults * def, int dnum); |
---|
204 | int roar_vio_open_dstr_vio(struct roar_vio_calls * calls, const char * dstr, struct roar_vio_defaults * def, int dnum, struct roar_vio_calls * vio); |
---|
205 | |
---|
206 | int roar_vio_dstr_parse_opts(struct roar_vio_dstr_chain * chain); |
---|
207 | int roar_vio_dstr_set_defaults(struct roar_vio_dstr_chain * chain, int len, struct roar_vio_defaults * def, int dnum); |
---|
208 | int roar_vio_dstr_build_chain(struct roar_vio_dstr_chain * chain, struct roar_vio_calls * calls, struct roar_vio_calls * vio); |
---|
209 | |
---|
210 | #endif |
---|
211 | |
---|
212 | //ll |
---|