net: data reception system, fixed bugs in rtl8139
[quarnos.git] / resources / net / ipv4.h
blobd267773bd615efd87546f610f675ea2c9ef9c8cf
1 #ifndef _IPV4_H_
2 #define _IPV4_H_
4 #include "link_layer.h"
5 #include "arp.h"
7 namespace net {
8 class ipv4 : public internet_layer {
9 private:
10 arp arp_prot;
12 ipv4_addr my_ip;
13 ipv4_addr mask;
14 ipv4_addr gateway;
16 struct ipv4_packet {
17 u8 version_size;
18 u8 service;
19 u16 length;
20 u16 id;
21 u16 flags_offset;
22 u8 ttl;
23 u8 prot;
24 u16 checksum;
25 u32 src;
26 u32 dst;
27 //u32 opt;
28 } __attribute__((packed));
30 protected:
31 // void receive_data(void *buf, int length);
33 public:
34 enum protocol {
35 icmp = 1,
36 tcp = 6,
37 udp = 17
40 void set_link_layer(p<link_layer> x);
42 void configure_ipv4(const ipv4_addr &ip, const ipv4_addr &netmask, const ipv4_addr &gate) {
43 my_ip = ip;
44 mask = netmask;
45 gateway = gate;
48 ipv4_addr get_my_ip() {
49 return my_ip;
52 void send_data(const ipv4_addr &addr, int prot, const buffer &x);
53 void receive_data(const buffer&);
57 #endif