1 |
/*
|
2 |
* ipsocket.h - ip router
|
3 |
*
|
4 |
* Basilisk II (C) 1997-2008 Christian Bauer
|
5 |
*
|
6 |
* Windows platform specific code copyright (C) Lauri Pesonen
|
7 |
*
|
8 |
* This program is free software; you can redistribute it and/or modify
|
9 |
* it under the terms of the GNU General Public License as published by
|
10 |
* the Free Software Foundation; either version 2 of the License, or
|
11 |
* (at your option) any later version.
|
12 |
*
|
13 |
* This program is distributed in the hope that it will be useful,
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
* GNU General Public License for more details.
|
17 |
*
|
18 |
* You should have received a copy of the GNU General Public License
|
19 |
* along with this program; if not, write to the Free Software
|
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
21 |
*/
|
22 |
|
23 |
#ifndef _IPSOCKET_H_
|
24 |
#define _IPSOCKET_H_
|
25 |
|
26 |
class socket_t {
|
27 |
public:
|
28 |
socket_t( int _proto );
|
29 |
~socket_t();
|
30 |
bool b_recfrom();
|
31 |
void set_ttl( uint8 ttl );
|
32 |
|
33 |
protected:
|
34 |
int WSARecvFrom();
|
35 |
|
36 |
public:
|
37 |
SOCKET s; // Always a valid socket
|
38 |
BOOL permanent; // T: a user-defined listening socket,
|
39 |
int proto; // udp/icmp
|
40 |
WSABUF buffers[1];
|
41 |
WSABUF out_buffers[1];
|
42 |
DWORD buffer_count;
|
43 |
DWORD bytes_received;
|
44 |
DWORD flags;
|
45 |
struct sockaddr_in from;
|
46 |
int from_len;
|
47 |
WSAOVERLAPPED overlapped;
|
48 |
uint32 ip_src;
|
49 |
uint32 ip_dest;
|
50 |
uint16 src_port;
|
51 |
uint16 dest_port;
|
52 |
DWORD socket_ttl;
|
53 |
};
|
54 |
|
55 |
|
56 |
int get_socket_index( uint16 src_port, uint16 dest_port, int proto );
|
57 |
int get_socket_index( uint16 src_port, int proto );
|
58 |
int get_socket_index( socket_t *cmpl );
|
59 |
void delete_socket( socket_t *cmpl );
|
60 |
socket_t *find_socket( uint16 src_port, uint16 dest_port, int proto );
|
61 |
void add_socket( socket_t *cmpl );
|
62 |
void close_old_sockets();
|
63 |
void close_all_sockets();
|
64 |
|
65 |
|
66 |
#endif // _IPSOCKET_H_
|