|
1 /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */ |
|
2 /* |
|
3 * Copyright (c) 2006 INRIA |
|
4 * All rights reserved. |
|
5 * |
|
6 * This program is free software; you can redistribute it and/or modify |
|
7 * it under the terms of the GNU General Public License version 2 as |
|
8 * published by the Free Software Foundation; |
|
9 * |
|
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. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program; if not, write to the Free Software |
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 * |
|
19 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
20 */ |
|
21 #ifndef MAC_NETWORK_INTERFACE_H |
|
22 #define MAC_NETWORK_INTERFACE_H |
|
23 |
|
24 #include <stdint.h> |
|
25 #include "yans/callback.h" |
|
26 #include "mac-address.h" |
|
27 #include "packet.h" |
|
28 |
|
29 namespace yans { |
|
30 |
|
31 class MacNetworkInterface { |
|
32 public: |
|
33 typedef Callback<void, Packet , MacNetworkInterface *> RxCallback; |
|
34 typedef Callback<void,MacNetworkInterface *> StatusChangeCallback; |
|
35 |
|
36 MacNetworkInterface (MacAddress self, uint16_t max_mtu); |
|
37 virtual ~MacNetworkInterface () = 0; |
|
38 |
|
39 MacAddress get_mac_address (void) const; |
|
40 void set_mtu (uint16_t mtu); |
|
41 uint16_t get_mtu (void) const; |
|
42 |
|
43 bool is_down (void) const; |
|
44 void set_up (void); |
|
45 void set_down (void); |
|
46 |
|
47 void set_status_change_callback (StatusChangeCallback callback); |
|
48 void set_rx_callback (RxCallback callback); |
|
49 void send (Packet packet, MacAddress to); |
|
50 protected: |
|
51 void forward_up (Packet packet); |
|
52 void notify_status_change (void); |
|
53 private: |
|
54 virtual void notify_up (void) = 0; |
|
55 virtual void notify_down (void) = 0; |
|
56 virtual void real_send (Packet packet, MacAddress to) = 0; |
|
57 |
|
58 StatusChangeCallback m_status_change_callback; |
|
59 RxCallback m_rx_callback; |
|
60 MacAddress m_self; |
|
61 uint16_t m_max_mtu; |
|
62 uint16_t m_mtu; |
|
63 bool m_is_down; |
|
64 }; |
|
65 |
|
66 }; // namespace yans |
|
67 |
|
68 #endif /* MAC_NETWORK_INTERFACE_H */ |