Fixed ZDE build - missing header file
[ZeXOS.git] / kernel / include / net / ip.h
blob5ca9e31ef302fabb7472587c3ba2014936d89d3d
1 /*
2 * ZeX/OS
3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
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))
30 #define NET_PROTO_IP_TYPE_ICMP 0x1
31 #define NET_PROTO_IP_TYPE_ICMP6 0x3a
32 #define NET_PROTO_IP_TYPE_TCP 0x6
33 #define NET_PROTO_IP_TYPE_TCP6 0x6
34 #define NET_PROTO_IP_TYPE_UDP 0x11
35 #define NET_PROTO_IP_TYPE_UDP6 0x11
36 #define NET_PROTO_IP_TYPE_TUN6 0x29
38 #define NET_PROTO_IP_FLAG_TUNNEL 0x80
41 typedef struct proto_ip_t {
42 unsigned char head_len:4;
43 unsigned char ver:4;
45 unsigned char res0;
47 unsigned short total_len;
49 unsigned short ident;
51 unsigned char flags;
53 unsigned char frag;
55 unsigned char ttl;
57 unsigned char proto;
59 unsigned short checksum;
61 net_ipv4 ip_source;
62 net_ipv4 ip_dest;
63 } proto_ip_t;
65 typedef struct proto_ipv6_t {
66 unsigned char ver;
67 unsigned char tclass;
68 unsigned short flabel;
70 unsigned short pl_len;
72 unsigned char nhead;
74 unsigned char hop;
76 net_ipv6 ip_source;
77 net_ipv6 ip_dest;
78 } proto_ipv6_t;
80 extern void NET_IPV6_TO_ADDR (net_ipv6 ip, unsigned short a, unsigned short b, unsigned short c, unsigned short d,
81 unsigned short e, unsigned short f, unsigned short g, unsigned short h);
82 extern unsigned net_proto_ipv6_cmp (net_ipv6 ip, net_ipv6 ip2);
83 extern void net_proto_ip_print (net_ipv4 ip);
84 extern net_ipv4 net_proto_ip_convert (char *ip);
85 extern unsigned net_proto_ip_network (net_ipv4 ip);
86 extern unsigned net_proto_ip_convert2 (net_ipv4 ip, char *ip_addr);
87 //extern unsigned net_proto_ip_esend (netif_t *netif, packet_t *packet, proto_ip_t *ip, char *buf, unsigned len);
88 //extern unsigned net_proto_ip_send (netif_t *netif, net_ipv4 ip_addr, char *buf, unsigned len);
89 extern unsigned init_net_packet ();
91 #endif