IPStackInterface: removal of this layer

Use NetworkInterface that defines the same API (extended to cover some additional
requirements that comes from wifi).
pull/3975/head
Martin Kojtal 2016-09-29 18:01:38 +01:00
parent 780ec1ebe4
commit 7c8afa91fb
4 changed files with 20 additions and 140 deletions

View File

@ -1,57 +0,0 @@
/* LWIPIPStackInterface
* Copyright (c) 2015 - 2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "platform.h"
#if DEVICE_EMAC
#include "IPStackInterface.h"
#include "lwip_stack.h"
/** LWIP specific implementation of IPStackInterface */
void IPStackInterface::bringup(emac_interface_t *emac)
{
// no dhcp at this stage, neither other details
lwip_bringup(emac, false, 0, 0, 0);
}
void IPStackInterface::bringdown()
{
lwip_bringdown();
}
int IPStackInterface::start_dhcp(uint timeout)
{
return lwip_start_dhcp(timeout);
}
int IPStackInterface::start_static_ip(const char *ip, const char *netmask, const char *gw)
{
return lwip_start_static_ip(ip, netmask, gw);
}
const char * IPStackInterface::get_mac_address()
{
return lwip_get_mac_address();
}
const char * IPStackInterface::get_ip_address()
{
return lwip_get_ip_address(_ip_address, sizeof(_ip_address));
}
#endif /* DEVICE_EMAC */

View File

@ -1,83 +0,0 @@
/* IPStackInterface
* Copyright (c) 2015 - 2016 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef IP_STACK_INTERFACE_H
#define IP_STACK_INTERFACE_H
#include "platform.h"
#if DEVICE_EMAC
#include "emac_api.h"
/**
* IPStackInterface
*
* Abstraction class on top of IP stack, enables WiFiInterface implementation to setup IP stack
*/
class IPStackInterface
{
public:
/**
* Brings up the IP stack using provided @a emac interface
*
* @param emac Emack backend to use
*/
virtual void bringup(emac_interface_t *emac);
/**
* Brings down the IP stack
*/
virtual void bringdown();
/**
* Sends the dhcp request
*
* @param timeout Request timeout in ms
* @return NSAPI_ERROR_OK in case of success, error code otherwise
*/
virtual int start_dhcp(uint timeout = 15000);
/**
* Starts the interface with static IP
*
* @param ip Static IP to use (in XYZ.XYZ.XYZ.XYZ format)
* @param netmask Network mask to use (in XYZ.XYZ.XYZ.XYZ format)
* @param gw Gateway IP address (in XYZ.XYZ.XYZ.XYZ format)
* @return NSAPI_ERROR_OK in case of success, error code otherwise
*/
virtual int start_static_ip(const char *ip, const char *netmask, const char *gw);
/**
* Returns MAC address
*
* @return MAC address in "00:11:22:33:44:55" form
*/
virtual const char *get_mac_address();
/**
* Returns interfaces IP address
*
* @return IP address in "10.11.12.13" form
*/
virtual const char *get_ip_address();
private:
char _ip_address[16]; //IPv4
};
#endif /* DEVICE_EMAC */
#endif /* IP_STACK_INTERFACE_H */

View File

@ -19,6 +19,7 @@
#include "network-socket/nsapi_types.h"
#include "network-socket/SocketAddress.h"
#include "emac_api.h"
// Predeclared class
class NetworkStack;
@ -94,6 +95,24 @@ public:
*/
virtual int connect() = 0;
/**
* Sends the dhcp request
*
* @param timeout Request timeout in ms
* @return NSAPI_ERROR_OK in case of success, error code otherwise
*/
virtual int start_dhcp(uint timeout = 15000) = 0;
/**
* Starts the interface with static IP
*
* @param ip Static IP to use (in XYZ.XYZ.XYZ.XYZ format)
* @param netmask Network mask to use (in XYZ.XYZ.XYZ.XYZ format)
* @param gw Gateway IP address (in XYZ.XYZ.XYZ.XYZ format)
* @return NSAPI_ERROR_OK in case of success, error code otherwise
*/
virtual int start_static_ip(const char *ip, const char *netmask, const char *gw) = 0;
/** Stop the interface
*
* @return 0 on success, negative error code on failure

View File

@ -141,6 +141,7 @@ private:
char *_ssid;
char *_pass;
nsapi_security_t _security;
char _ip_address[16]; //IPv4 only thus 16
};
#endif