66// Licensed under the Apache License, Version 2.0 (the "License");
77// you may not use this file except in compliance with the License.
88// You may obtain a copy of the License at
9- //
9+ //
1010// http://www.apache.org/licenses/LICENSE-2.0
11- //
11+ //
1212// Unless required by applicable law or agreed to in writing, software
1313// distributed under the License is distributed on an "AS IS" BASIS,
1414// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,21 +39,21 @@ namespace net {
3939 /* * Nic names. Only used to bind nic to IP. */
4040 enum netdev {ETH0,ETH1,ETH2,ETH3,ETH4,ETH5,ETH6,ETH7,ETH8,ETH9};
4141
42- /* * A (supposed to be) complete IP4 and IP6 dual stack */
42+ /* * A (supposed to be) complete IP4 and IP6 dual stack */
4343 class Inet64 {
4444 public:
45- /* * Listen to a UDP port.
45+ /* * Listen to a UDP port.
4646 This is just a simple forwarder. @see UDP::listen. */
4747 inline void udp_listen (uint16_t port, UDP::listener l)
4848 { _udp.listen (port,l); }
49-
50- /* * Send a UDP datagram.
51-
52- @note the data buffer is the *whole* ethernet frame, so don't overwrite
49+
50+ /* * Send a UDP datagram.
51+
52+ @note the data buffer is the *whole* ethernet frame, so don't overwrite
5353 headers unless you own them (i.e. you *are* the IP object) */
5454 inline int udp_send (std::shared_ptr<Packet> pckt)
5555 { return _udp.transmit (pckt); }
56-
56+
5757 // / listen for UDPv6 packets on @port
5858 // / replaces existing listeners on the same port
5959 void udp6_listen (UDPv6::port_t port, UDPv6::listener_t func)
@@ -66,76 +66,76 @@ namespace net {
6666 {
6767 return _udp6.create (ether_dest, ip_dest, port);
6868 }
69-
69+
7070 // / send an UDPv6 packet, hopefully (please dont lie!)
7171 int udp6_send (std::shared_ptr<PacketUDP6> pckt)
7272 {
7373 return _udp6.transmit (pckt);
7474 }
75-
75+
7676 void ip6_ndp_discovery ()
7777 {
7878 _icmp6.discover ();
7979 }
80-
81- /* * Bind an IP and a netmask to a given device.
80+
81+ /* * Bind an IP and a netmask to a given device.
8282 The function expects the given device to exist.*/
8383 static void
8484 ifconfig (
8585 netdev nic,
8686 IP4::addr ip,
8787 IP4::addr netmask,
8888 IP6::addr ip6);
89-
89+
9090 inline static IP4::addr ip4 (netdev nic)
9191 { return _ip4_list[nic]; }
92-
92+
9393 inline static IP6::addr ip6 (netdev nic)
9494 { return _ip6_list[nic]; }
95-
95+
9696 static Inet& up ()
9797 {
9898 if (_ip4_list.size () < 1 )
99- WARN (" <Inet> Is bringing up an IP stack without any IP addresses" );
99+ printf (" <Inet> Is bringing up an IP stack without any IP addresses" );
100100 static Inet instance;
101101 return instance;
102102 }
103-
103+
104104 // typedef delegate<int(uint8_t*,int)> upstream_delg;
105-
106-
107-
105+
106+
107+
108108 private:
109-
109+
110110 /* * Physical routes. These map 1-1 with Dev:: interfaces. */
111111 static std::map<uint16_t ,IP4::addr> _ip4_list;
112112 static std::map<uint16_t ,IP4::addr> _netmask_list;
113113 static std::map<uint16_t ,IP6::addr> _ip6_list;
114114 static std::map<uint16_t ,Ethernet*> _ethernet_list;
115- static std::map<uint16_t ,Arp*> _arp_list;
116-
115+ static std::map<uint16_t ,Arp*> _arp_list;
116+
117117 // This is the actual stack
118118 IP4 _ip4;
119119 ICMPv4 _icmp;
120120 UDP _udp;
121121 IP6 _ip6;
122122 ICMPv6 _icmp6;
123123 UDPv6 _udp6;
124-
125-
124+
125+
126126 /* * Don't think we *want* copy construction.
127127 @todo: Fix this with a singleton or something.
128128 */
129129 Inet (Inet& UNUSED (cpy)) = delete;
130-
130+
131131 Inet (std::vector<IP4::addr> ips);
132-
132+
133133 /* * Initialize. For now IP and mac is passed on to Ethernet and Arp.
134- @todo For now, mac- and IP-addresses are hardcoded here.
134+ @todo For now, mac- and IP-addresses are hardcoded here.
135135 They should be user-definable
136136 */
137137 Inet ();
138-
138+
139139 };
140140
141141}
0 commit comments