ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Windows/router/router_types.h
Revision: 1.2
Committed: 2008-01-01T09:40:34Z (16 years, 6 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
Log Message:
Happy New Year!

File Contents

# User Rev Content
1 gbeauche 1.1 /*
2     * router_types.h - ip router
3     *
4 gbeauche 1.2 * Basilisk II (C) 1997-2008 Christian Bauer
5 gbeauche 1.1 *
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 _ROUTER_TYPES_H_
24     #define _ROUTER_TYPES_H_
25    
26     #pragma pack(1)
27    
28    
29     // --------------------------- MAC ---------------------------
30     typedef struct {
31     uint8 dest[6];
32     uint8 src[6];
33     uint16 type;
34     } ATTRIBUTE_PACKED mac_t;
35    
36     enum {
37     mac_type_llc_ipx_limit = 0x05DC, // <= mac_type_llc_ipx_limit -->> 802.3 MAC frame
38     mac_type_ip4 = 0x0800,
39     mac_type_arp = 0x0806,
40     mac_type_rarp = 0x8035,
41     mac_type_ip6 = 0x86DD,
42     mac_type_loopback = 0x9000
43     };
44    
45     // --------------------------- ARP ---------------------------
46     typedef struct {
47     mac_t mac;
48     uint16 htype;
49     uint16 ptype;
50     uint8 halen;
51     uint8 palen;
52     uint16 opcode;
53     uint8 srch[6]; // size for ethernet
54     uint8 srcp[4]; // size for ip
55     uint8 dsth[6]; // size for ethernet
56     uint8 dstp[4]; // size for ip
57     } ATTRIBUTE_PACKED arp_t;
58    
59     enum {
60     arp_request = 1,
61     arp_reply = 2
62     };
63     enum {
64     arp_hwtype_enet = 1
65     };
66    
67     // --------------------------- IP4 ---------------------------
68     typedef struct {
69     mac_t mac;
70     uint8 header_len:4;
71     uint8 version:4;
72     uint8 tos;
73     uint16 total_len;
74     uint16 ident;
75     uint16 flags_n_frag_offset; // foffset 0..11, flags 12..15
76     uint8 ttl;
77     uint8 proto;
78     uint16 checksum;
79     uint32 src;
80     uint32 dest;
81     // ip options, size = 4 * header_len - 20
82     } ATTRIBUTE_PACKED ip_t;
83    
84     // Protocol STD numbers
85     enum {
86     ip_proto_icmp = IPPROTO_ICMP,
87     ip_proto_tcp = IPPROTO_TCP,
88     ip_proto_udp = IPPROTO_UDP
89     };
90    
91     // --------------------------- ICMP ---------------------------
92     typedef struct {
93     ip_t ip;
94     uint8 type;
95     uint8 code;
96     uint16 checksum;
97     // data
98     } ATTRIBUTE_PACKED icmp_t;
99    
100     enum {
101     icmp_Echo_reply = 0,
102     icmp_Destination_unreachable = 3,
103     icmp_Source_quench = 4,
104     icmp_Redirect = 5,
105     icmp_Echo = 8,
106     icmp_Router_advertisement = 9,
107     icmp_Router_solicitation = 10,
108     icmp_Time_exceeded = 11,
109     icmp_Parameter_problem = 12,
110     icmp_Time_Stamp_request = 13,
111     icmp_Time_Stamp_reply = 14,
112     icmp_Information_request_obsolete = 15,
113     icmp_Information_reply_obsolete = 16,
114     icmp_Address_mask_request = 17,
115     icmp_Address_mask_reply = 18,
116     icmp_Traceroute = 30,
117     icmp_Datagram_conversion_error = 31,
118     icmp_Mobile_host_redirect = 32,
119     icmp_IPv6_Where_Are_You = 33,
120     icmp_IPv6_I_Am_Here = 34,
121     icmp_Mobile_registration_request = 35,
122     icmp_Mobile_registration_reply = 36,
123     icmp_Domain_name_request = 37,
124     icmp_Domain_name_reply = 38,
125     icmp_SKIP = 39,
126     icmp_Photuris = 40
127     };
128    
129     // --------------------------- TCP ---------------------------
130     typedef struct {
131     ip_t ip;
132     uint16 src_port;
133     uint16 dest_port;
134     uint32 seq;
135     uint32 ack;
136     uint8 header_len; // note: some reserved bits
137     uint8 flags; // note: some reserved bits
138     uint16 window;
139     uint16 checksum;
140     uint16 urgent_ptr;
141     // options + padding: size = dataoffset*4-20
142     // data
143     } ATTRIBUTE_PACKED tcp_t;
144    
145     enum {
146     tcp_flags_URG = 0x20, // The urgent pointer field is significant in this segment.
147     tcp_flags_ACK = 0x10, // The acknowledgment field is significant in this segment.
148     tcp_flags_PSH = 0x08, // Push function.
149     tcp_flags_RST = 0x04, // Resets the connection.
150     tcp_flags_SYN = 0x02, // Synchronizes the sequence numbers.
151     tcp_flags_FIN = 0x01 // No more data from sender.
152     };
153    
154     enum {
155     tcp_state_closed,
156     tcp_state_listen,
157     tcp_state_syn_sent,
158     tcp_state_syn_rcvd,
159     tcp_state_established,
160     tcp_state_close_wait,
161     tcp_state_last_ack,
162     tcp_state_finwait_1,
163     tcp_state_finwait_2,
164     tcp_state_closing,
165     tcp_state_time_wait
166     };
167    
168     // --------------------------- UDP ---------------------------
169     typedef struct {
170     ip_t ip;
171     uint16 src_port;
172     uint16 dest_port;
173     uint16 msg_len;
174     uint16 checksum;
175     // data
176     } ATTRIBUTE_PACKED udp_t;
177    
178     typedef struct {
179     uint16 src_lo, src_hi;
180     uint16 dest_lo, dest_hi;
181     uint16 proto;
182     uint16 msg_len;
183     } ATTRIBUTE_PACKED pseudo_ip_t;
184    
185     #pragma pack()
186    
187     #endif // _ROUTER_TYPES_H_