]> git.sesse.net Git - vlc/blob - modules/access/mms/mmstu.h
MMS integers handling fixes, including buffer overflow
[vlc] / modules / access / mms / mmstu.h
1 /*****************************************************************************
2  * mms.h: MMS access plug-in
3  *****************************************************************************
4  * Copyright (C) 2001, 2002 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program 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 program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef _MMSTU_H_
25 #define _MMSTU_H_ 1
26
27 #define MMS_PACKET_ANY          0
28 #define MMS_PACKET_CMD          1
29 #define MMS_PACKET_HEADER       2
30 #define MMS_PACKET_MEDIA        3
31 #define MMS_PACKET_UDP_TIMING   4
32
33 #define MMS_CMD_HEADERSIZE  48
34
35 #define MMS_BUFFER_SIZE 100000
36
37 typedef struct mmstu_keepalive_thread_t mmstu_keepalive_thread_t;
38
39 struct access_sys_t
40 {
41     int         i_proto;        /* MMS_PROTO_TCP, MMS_PROTO_UDP */
42     int         i_handle_tcp;   /* TCP socket for communication with server */
43     int         i_handle_udp;   /* Optional UDP socket for data(media/header packet) */
44                                 /* send by server */
45     char        sz_bind_addr[NI_MAXNUMERICHOST]; /* used by udp */
46
47     vlc_url_t   url;
48
49     asf_header_t    asfh;
50
51     unsigned    i_timeout;
52
53     /* */
54     uint8_t     buffer_tcp[MMS_BUFFER_SIZE];
55     int         i_buffer_tcp;
56
57     uint8_t     buffer_udp[MMS_BUFFER_SIZE];
58     int         i_buffer_udp;
59
60     /* data necessary to send data to server */
61     guid_t      guid;
62     int         i_command_level;
63     int         i_seq_num;
64     uint32_t    i_header_packet_id_type;
65     uint32_t    i_media_packet_id_type;
66
67     int         i_packet_seq_num;
68
69     uint8_t     *p_cmd;     /* latest command read */
70     size_t      i_cmd;      /* allocated at the begining */
71
72     uint8_t     *p_header;  /* allocated by mms_ReadPacket */
73     size_t      i_header;
74
75     uint8_t     *p_media;   /* allocated by mms_ReadPacket */
76     size_t      i_media;
77     size_t      i_media_used;
78
79     /* extracted information */
80     int         i_command;
81
82     /* from 0x01 answer (not yet set) */
83     char        *psz_server_version;
84     char        *psz_tool_version;
85     char        *psz_update_player_url;
86     char        *psz_encryption_type;
87
88     /* from 0x06 answer */
89     uint32_t    i_flags_broadcast;
90     uint32_t    i_media_length;
91     size_t      i_packet_length;
92     uint32_t    i_packet_count;
93     int         i_max_bit_rate;
94     size_t      i_header_size;
95
96     /* misc */
97     bool  b_seekable;
98
99     mmstu_keepalive_thread_t *p_keepalive_thread;
100     vlc_mutex_t lock_netwrite;
101 };
102
103 struct mmstu_keepalive_thread_t
104 {
105     VLC_COMMON_MEMBERS
106
107     access_t *p_access;
108     bool b_paused;
109     bool b_thread_error;
110 };
111
112 #endif