-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathproxy.h
167 lines (148 loc) · 4.09 KB
/
proxy.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1999-2008 Apple Inc. All Rights Reserved.
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*
*/
/*
* proxy.h
*
*
*/
#ifndef __PROXY_H__
#define __PROXY_H__
#include "shared_udp.h"
/**********************************************/
enum {
stIdle,
stError,
stRecvClientCommand,
stWaitingForIPAddress,
stParseClientCommand,
stSendClientResponse,
stServerTransactionSend,
stServerTransactionRecv,
stClientShutdown,
stServerShutdown,
stBadServerName,
stCantConnectToServer,
stDone
}; // rtsp session states
enum {
ttNone,
ttDescribe,
ttSetup,
ttPlay,
ttPause,
ttStop,
ttTeardown,
ttOptions,
ttAnnounce,
ttRedirect,
ttGetParameter,
ttSetParameter
}; // rtsp command types
enum {
kPermissionDenied,
kTooManyUsers,
kServerNotFound,
kUnknownError
}; // refusal type
typedef struct {
char *cmd;
int type;
} t_cmd_map;
#define MAX_TRACKS 32
typedef struct {
int ID;
shok *RTP_S2P;
shok *RTCP_S2P;
shok *RTP_P2C;
shok *RTCP_P2C;
int ClientRTPPort;
int ServerRTPPort;
trans_pb RTP_S2C_tpb;
trans_pb RTCP_S2C_tpb;
trans_pb RTCP_C2S_tpb;
} track_info;
/* This size will fit nicely in a standard ethernet frame */
#define RTSP_SESSION_BUF_SIZE 4096
typedef struct rtsp_session {
struct rtsp_session *next;
int die;
int newSession;
int client_skt;
int client_ip;
char *server_address;
int server_skt;
int server_interface_addr;
int client_interface_addr;
int server_ip;
int server_port;
int server_skt_pending_connection;
int state;
int transaction_type;
char *sessionID;
int cur_trk;
int numTracks;
track_info trk[MAX_TRACKS];
char cinbuf[RTSP_SESSION_BUF_SIZE];
int amtInClientInBuffer;
char coutbuf[RTSP_SESSION_BUF_SIZE];
int amtInClientOutBuffer;
char sinbuf[RTSP_SESSION_BUF_SIZE];
int amtInServerInBuffer;
char soutbuf[RTSP_SESSION_BUF_SIZE];
int amtInServerOutBuffer;
int totalContentLength;
int haveParsedServerReplyHeaders;
int contentLength;
char* responseBodyP;
int tempIP;
} rtsp_session;
typedef struct subnet_allow {
struct subnet_allow *next;
int ip;
int range;
} subnet_allow;
typedef struct rtsp_listener {
struct rtsp_listener *next;
int port;
int skt;
} rtsp_listener;
/**********************************************/
int service_listeners();
int service_sessions();
void add_rtsp_port_listener(int address,int port);
void cleanup_listeners(void);
void answer_new_connection(rtsp_listener *listener);
void add_session(rtsp_session *session);
void remove_session(rtsp_session *session);
rtsp_session *new_session(void);
void cleanup_sessions(void);
void cleanup_session(rtsp_session *session);
void service_session(rtsp_session *session);
void service_session_rtp(rtsp_session *session);
void read_config(void);
void add_allow_subnet(int ip, int range);
bool allow_ip(int ip);
void send_rtsp_error(int skt, int refusal);
#endif // __PROXY_H__