Mbed OS Reference
Loading...
Searching...
No Matches
NanostackEthernetInterface.h
1/*
2 * Copyright (c) 2016 ARM Limited. All rights reserved.
3 * SPDX-License-Identifier: Apache-2.0
4 * Licensed under the Apache License, Version 2.0 (the License); you may
5 * not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef NANOSTACKETHERNETINTERFACE_H
18#define NANOSTACKETHERNETINTERFACE_H
19
20#include "EthInterface.h"
21#include "MeshInterfaceNanostack.h"
22#include "NanostackEthernetPhy.h"
23
25public:
26 nsapi_error_t bringup(bool dhcp, const char *ip,
27 const char *netmask, const char *gw,
28 nsapi_ip_stack_t stack = DEFAULT_STACK,
29 bool blocking = true) override;
31 void get_mac_address(uint8_t *buf) const override;
32 char *get_mac_address(char *buf, nsapi_size_t buflen) override;
33
34 char *get_interface_name(char *buf) override;
35private:
36 friend class Nanostack;
37 friend class NanostackEthernetInterface;
39 nsapi_error_t initialize();
40protected:
41 NanostackEthernetPhy &get_phy() const
42 {
43 return static_cast<NanostackEthernetPhy &>(Interface::get_phy());
44 }
45};
46
47/** Ethernet interface for Nanostack.
48 *
49 * Configure Nanostack to use Ethernet connectivity.
50 */
51class NanostackEthernetInterface : public InterfaceNanostack, public EthInterface, private mbed::NonCopyable<NanostackEthernetInterface> {
52public:
54
55 nsapi_error_t initialize(NanostackEthernetPhy *phy);
56
57protected:
58 Nanostack::EthernetInterface *get_interface() const
59 {
60 return static_cast<Nanostack::EthernetInterface *>(_interface);
61 }
62 nsapi_error_t do_initialize() override;
63
64};
65
66#endif // NANOSTACKETHERNETINTERFACE_H
Common interface between Ethernet hardware.
Definition: EthInterface.h:30
nsapi_error_t bringdown() override
Disconnect interface from the network.
nsapi_error_t bringup(bool dhcp, const char *ip, const char *netmask, const char *gw, nsapi_ip_stack_t stack=DEFAULT_STACK, bool blocking=true) override
Connect the interface to the network.
char * get_mac_address(char *buf, nsapi_size_t buflen) override
Return MAC address of the network interface.
char * get_interface_name(char *buf) override
Returns interface name.
Ethernet interface for Nanostack.
Ethernet PHY driver class for Nanostack.
Prevents generation of copy constructor and copy assignment operator in derived classes.
Definition: NonCopyable.h:162
signed int nsapi_error_t
Type used to represent error codes.
Definition: nsapi_types.h:142
unsigned int nsapi_size_t
Type used to represent the size of data passed through sockets.
Definition: nsapi_types.h:146