Kernel 0.6.0-r3; TCPv6 and UDPv6 support, new kernel noeth parameter, what cause...
[ZeXOS.git] / kernel / include / net / ip.h
blobc06e5c2e1d255cfbb5fde76492c9b9ea4ec94640
1 /*
2 * ZeX/OS
3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _IP_H
20 #define _IP_H
22 #include <net/if.h>
24 typedef unsigned net_ipv4;
25 typedef unsigned short net_ipv6[8];
27 #define NET_IPV4_TO_ADDR(a, b, c, d) \
28 (((net_ipv4)(d) << 24) | (((net_ipv4)(c) & 0xff) << 16) | (((net_ipv4)(b) & 0xff) << 8) | ((net_ipv4)(a) & 0xff))
31 #define NET_PROTO_IP_TYPE_ICMP 0x1
32 #define NET_PROTO_IP_TYPE_ICMP6 0x3a
33 #define NET_PROTO_IP_TYPE_TCP 0x6
34 #define NET_PROTO_IP_TYPE_TCP6 0x6
35 #define NET_PROTO_IP_TYPE_UDP 0x11
36 #define NET_PROTO_IP_TYPE_UDP6 0x11
38 typedef struct proto_ip_t {
39 unsigned char head_len:4;
40 unsigned char ver:4;
42 unsigned char res0;
44 unsigned short total_len;
46 unsigned short ident;
48 unsigned char flags;
50 unsigned char frag;
52 unsigned char ttl;
54 unsigned char proto;
56 unsigned short checksum;
58 net_ipv4 ip_source;
59 net_ipv4 ip_dest;
60 } proto_ip_t;
62 typedef struct proto_ipv6_t {
63 unsigned char ver;
64 unsigned char tclass;
65 unsigned short flabel;
67 unsigned short pl_len;
69 unsigned char nhead;
71 unsigned char hop;
73 net_ipv6 ip_source;
74 net_ipv6 ip_dest;
75 } proto_ipv6_t;
77 extern void NET_IPV6_TO_ADDR (net_ipv6 ip, unsigned short a, unsigned short b, unsigned short c, unsigned short d,
78 unsigned short e, unsigned short f, unsigned short g, unsigned short h);
79 extern unsigned net_proto_ipv6_cmp (net_ipv6 ip, net_ipv6 ip2);
80 extern void net_proto_ip_print (net_ipv4 ip);
81 extern net_ipv4 net_proto_ip_convert (char *ip);
82 extern unsigned net_proto_ip_network (net_ipv4 ip);
83 extern unsigned net_proto_ip_convert2 (net_ipv4 ip, char *ip_addr);
84 //extern unsigned net_proto_ip_esend (netif_t *netif, packet_t *packet, proto_ip_t *ip, char *buf, unsigned len);
85 //extern unsigned net_proto_ip_send (netif_t *netif, net_ipv4 ip_addr, char *buf, unsigned len);
86 extern unsigned init_net_packet ();
88 #endif