Subversion Repositories HomeAutomation

Rev

Details | Last modification | View Log | SVN | RSS feed

Rev Author Line No. Line
198 arune 1
/*********************************************
2
 * vim:sw=8:ts=8:si:et
3
 * To use the above modeline in vim you must have "set modeline" in your .vimrc
4
 * Author: Guido Socher
5
 * Copyright: GPL V2
6
 *
7
 * Based on the net.h file from the AVRlib library by Pascal Stang.
8
 * For AVRlib See http://www.procyonengineering.com/
9
 * Used with explicit permission of Pascal Stang.
10
 *
11
 * Chip type           : ATMEGA88 with ENC28J60
12
 *********************************************/
13
 
14
// notation: _P = position of a field
15
//           _V = value of a field
16
 
17
//@{
18
 
19
#ifndef NET_H
20
#define NET_H
21
 
22
// ******* ETH *******
23
#define ETH_HEADER_LEN  14
24
// values of certain bytes:
25
#define ETHTYPE_ARP_H_V 0x08
26
#define ETHTYPE_ARP_L_V 0x06
27
#define ETHTYPE_IP_H_V  0x08
28
#define ETHTYPE_IP_L_V  0x00
29
// byte positions in the ethernet frame:
30
//
31
// Ethernet type field (2bytes):
32
#define ETH_TYPE_H_P 12
33
#define ETH_TYPE_L_P 13
34
//
35
#define ETH_DST_MAC 0
36
#define ETH_SRC_MAC 6
37
 
38
 
39
// ******* ARP *******
40
#define ETH_ARP_OPCODE_REPLY_H_V 0x0
41
#define ETH_ARP_OPCODE_REPLY_L_V 0x02
42
//
43
#define ETHTYPE_ARP_L_V 0x06
44
// arp.dst.ip
45
#define ETH_ARP_DST_IP_P 0x26
46
// arp.opcode
47
#define ETH_ARP_OPCODE_H_P 0x14
48
#define ETH_ARP_OPCODE_L_P 0x15
49
// arp.src.mac
50
#define ETH_ARP_SRC_MAC_P 0x16
51
#define ETH_ARP_SRC_IP_P 0x1c
52
#define ETH_ARP_DST_MAC_P 0x20
53
#define ETH_ARP_DST_IP_P 0x26
54
 
55
// ******* IP *******
56
#define IP_HEADER_LEN   20
57
// ip.src
58
#define IP_SRC_P 0x1a
59
#define IP_DST_P 0x1e
60
#define IP_HEADER_LEN_VER_P 0xe
61
#define IP_CHECKSUM_P 0x18
62
#define IP_TTL_P 0x16
63
#define IP_FLAGS_P 0x14
64
#define IP_P 0xe
65
#define IP_TOTLEN_H_P 0x10
66
#define IP_TOTLEN_L_P 0x11
67
 
68
#define IP_PROTO_P 0x17  
69
 
70
#define IP_PROTO_ICMP_V 1
71
#define IP_PROTO_TCP_V 6
72
// 17=0x11
73
#define IP_PROTO_UDP_V 17
74
// ******* ICMP *******
75
#define ICMP_TYPE_ECHOREPLY_V 0
76
#define ICMP_TYPE_ECHOREQUEST_V 8
77
//
78
#define ICMP_TYPE_P 0x22
79
#define ICMP_CHECKSUM_P 0x24
80
 
81
// ******* UDP *******
82
#define UDP_HEADER_LEN  8
83
//
84
#define UDP_SRC_PORT_H_P 0x22
85
#define UDP_SRC_PORT_L_P 0x23
86
#define UDP_DST_PORT_H_P 0x24
87
#define UDP_DST_PORT_L_P 0x25
88
//
89
#define UDP_LEN_H_P 0x26
90
#define UDP_LEN_L_P 0x27
91
#define UDP_CHECKSUM_H_P 0x28
92
#define UDP_CHECKSUM_L_P 0x29
93
#define UDP_DATA_P 0x2a
94
 
95
// ******* TCP *******
96
#define TCP_SRC_PORT_H_P 0x22
97
#define TCP_SRC_PORT_L_P 0x23
98
#define TCP_DST_PORT_H_P 0x24
99
#define TCP_DST_PORT_L_P 0x25
100
// the tcp seq number is 4 bytes 0x26-0x29
101
#define TCP_SEQ_H_P 0x26
102
#define TCP_SEQACK_H_P 0x2a
103
// flags: SYN=2
104
#define TCP_FLAGS_P 0x2f
105
#define TCP_FLAGS_SYN_V 2
106
#define TCP_FLAGS_FIN_V 1
107
#define TCP_FLAGS_PUSH_V 8
108
#define TCP_FLAGS_SYNACK_V 0x12
109
#define TCP_FLAGS_ACK_V 0x10
110
#define TCP_FLAGS_PSHACK_V 0x18
111
//  plain len without the options:
112
#define TCP_HEADER_LEN_PLAIN 20
113
#define TCP_HEADER_LEN_P 0x2e
114
#define TCP_CHECKSUM_H_P 0x32
115
#define TCP_CHECKSUM_L_P 0x33
116
#define TCP_OPTIONS_P 0x36
117
//
118
#endif
119
//@}
120