00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef __PANALIX_IP_HPP
00012 #define __PANALIX_IP_HPP
00013
00014 namespace Net {
00016 namespace IP {
00017
00019 struct ip_address my_ip_address();
00020 struct netmask_t my_netmask();
00023 #if 1
00024 struct pbuf {
00025 uint8 *data;
00026 uint32 eth_off;
00027 uint32 ip_off;
00028 uint32 ip_data_off;
00029 uint32 end;
00030 uint32 len;
00031 };
00032
00033 void onIpReception(struct netbuf *nb);
00034 void ip_onNewArpEntry(struct Net::Arp::arp_entry arp);
00035 int ip_poll(struct pbuf *& pb);
00036 enum route_flags {scope_link=0x01, scope_host=0x02};
00037
00038 struct route_t {
00039 struct ip_address target;
00040 struct netmask_t netmask;
00041 struct ip_address gateway;
00042 struct netif *nif;
00043 uint32 flags;
00044 route_t(struct ip_address target, struct netmask_t netmask, struct ip_address gateway, struct netif *nif, uint32 flags) : target(target),netmask(netmask),gateway(gateway),
00045 nif(nif),flags(flags) { }
00046 };
00047
00048 struct ip_header {
00049 uint8 hdr_len:4;
00050 uint8 version:4;
00051 uint8 tos;
00052 uint16 len;
00053 uint16 iden;
00054 uint16 flags_fo;
00055
00056
00057 uint8 ttl;
00058 uint8 prot;
00059 uint16 checksum;
00060 struct ip_address source_ip;
00061 struct ip_address target_ip;
00062 };
00063
00064 uint16 count_checksum_iph(struct ip_header *iph);
00065
00066 void ip_transmit(struct ip_address ip_addr, uint8 tos, uint8 prot, struct pbuf *pb);
00067 void ip_transmit(struct ip_address ip_addr, uint8 tos, uint8 prot, struct packet_t *pb);
00068 void route_add(struct route_t);
00069
00070 struct netif_and_ip {
00071 struct netif nif;
00072 struct ip_address ip;
00073 };
00074 bool route_find(struct ip_address ip, struct netif_and_ip &rt);
00075
00076 #endif
00077 void init();
00078
00079
00080
00081
00082
00083 }
00084 }
00085
00089 void print (struct Net::IP::ip_header iph);
00090 void print (struct Net::IP::pbuf pb);
00091 void print (struct Net::IP::route_t &route);
00092
00095 #endif
00096