Deprecated fork of old network stack source from github. Please use official library instead: https://mbed.org/users/mbed_official/code/EthernetInterface/

Committer:
AdamGreen
Date:
Sat Oct 26 08:51:36 2013 +0000
Revision:
1:eadc868c2acf
Parent:
0:3b00827bb0b7
Fix TCP checksum bug and stranded large TCP segments.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AdamGreen 0:3b00827bb0b7 1 /* EthernetInterface.h */
AdamGreen 0:3b00827bb0b7 2 /* Copyright (C) 2012 mbed.org, MIT License
AdamGreen 0:3b00827bb0b7 3 *
AdamGreen 0:3b00827bb0b7 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
AdamGreen 0:3b00827bb0b7 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
AdamGreen 0:3b00827bb0b7 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
AdamGreen 0:3b00827bb0b7 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
AdamGreen 0:3b00827bb0b7 8 * furnished to do so, subject to the following conditions:
AdamGreen 0:3b00827bb0b7 9 *
AdamGreen 0:3b00827bb0b7 10 * The above copyright notice and this permission notice shall be included in all copies or
AdamGreen 0:3b00827bb0b7 11 * substantial portions of the Software.
AdamGreen 0:3b00827bb0b7 12 *
AdamGreen 0:3b00827bb0b7 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
AdamGreen 0:3b00827bb0b7 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
AdamGreen 0:3b00827bb0b7 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
AdamGreen 0:3b00827bb0b7 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AdamGreen 0:3b00827bb0b7 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AdamGreen 0:3b00827bb0b7 18 */
AdamGreen 0:3b00827bb0b7 19
AdamGreen 0:3b00827bb0b7 20 #ifndef ETHERNETINTERFACE_H_
AdamGreen 0:3b00827bb0b7 21 #define ETHERNETINTERFACE_H_
AdamGreen 0:3b00827bb0b7 22
AdamGreen 0:3b00827bb0b7 23 #if !defined(TARGET_LPC1768) && !defined(TARGET_LPC4088)
AdamGreen 0:3b00827bb0b7 24 #error The Ethernet Interface library is supported only on the mbed NXP LPC1768
AdamGreen 0:3b00827bb0b7 25 #endif
AdamGreen 0:3b00827bb0b7 26
AdamGreen 0:3b00827bb0b7 27 #include "rtos.h"
AdamGreen 0:3b00827bb0b7 28 #include "lwip/netif.h"
AdamGreen 0:3b00827bb0b7 29
AdamGreen 0:3b00827bb0b7 30 /** Interface using Ethernet to connect to an IP-based network
AdamGreen 0:3b00827bb0b7 31 *
AdamGreen 0:3b00827bb0b7 32 */
AdamGreen 0:3b00827bb0b7 33 class EthernetInterface {
AdamGreen 0:3b00827bb0b7 34 public:
AdamGreen 0:3b00827bb0b7 35 /** Initialize the interface with DHCP.
AdamGreen 0:3b00827bb0b7 36 * Initialize the interface and configure it to use DHCP (no connection at this point).
AdamGreen 0:3b00827bb0b7 37 * \return 0 on success, a negative number on failure
AdamGreen 0:3b00827bb0b7 38 */
AdamGreen 0:3b00827bb0b7 39 static int init(); //With DHCP
AdamGreen 0:3b00827bb0b7 40
AdamGreen 0:3b00827bb0b7 41 /** Initialize the interface with a static IP address.
AdamGreen 0:3b00827bb0b7 42 * Initialize the interface and configure it with the following static configuration (no connection at this point).
AdamGreen 0:3b00827bb0b7 43 * \param ip the IP address to use
AdamGreen 0:3b00827bb0b7 44 * \param mask the IP address mask
AdamGreen 0:3b00827bb0b7 45 * \param gateway the gateway to use
AdamGreen 0:3b00827bb0b7 46 * \return 0 on success, a negative number on failure
AdamGreen 0:3b00827bb0b7 47 */
AdamGreen 0:3b00827bb0b7 48 static int init(const char* ip, const char* mask, const char* gateway);
AdamGreen 0:3b00827bb0b7 49
AdamGreen 0:3b00827bb0b7 50 /** Connect
AdamGreen 0:3b00827bb0b7 51 * Bring the interface up, start DHCP if needed.
AdamGreen 0:3b00827bb0b7 52 * \param timeout_ms timeout in ms (default: (15)s).
AdamGreen 0:3b00827bb0b7 53 * \return 0 on success, a negative number on failure
AdamGreen 0:3b00827bb0b7 54 */
AdamGreen 0:3b00827bb0b7 55 static int connect(unsigned int timeout_ms=15000);
AdamGreen 0:3b00827bb0b7 56
AdamGreen 0:3b00827bb0b7 57 /** Disconnect
AdamGreen 0:3b00827bb0b7 58 * Bring the interface down
AdamGreen 0:3b00827bb0b7 59 * \return 0 on success, a negative number on failure
AdamGreen 0:3b00827bb0b7 60 */
AdamGreen 0:3b00827bb0b7 61 static int disconnect();
AdamGreen 0:3b00827bb0b7 62
AdamGreen 0:3b00827bb0b7 63 /** Get the MAC address of your Ethernet interface
AdamGreen 0:3b00827bb0b7 64 * \return a pointer to a string containing the MAC address
AdamGreen 0:3b00827bb0b7 65 */
AdamGreen 0:3b00827bb0b7 66 static char* getMACAddress();
AdamGreen 0:3b00827bb0b7 67
AdamGreen 0:3b00827bb0b7 68 /** Get the IP address of your Ethernet interface
AdamGreen 0:3b00827bb0b7 69 * \return a pointer to a string containing the IP address
AdamGreen 0:3b00827bb0b7 70 */
AdamGreen 0:3b00827bb0b7 71 static char* getIPAddress();
AdamGreen 0:3b00827bb0b7 72 };
AdamGreen 0:3b00827bb0b7 73
AdamGreen 0:3b00827bb0b7 74 #include "TCPSocketConnection.h"
AdamGreen 0:3b00827bb0b7 75 #include "TCPSocketServer.h"
AdamGreen 0:3b00827bb0b7 76
AdamGreen 0:3b00827bb0b7 77 #include "Endpoint.h"
AdamGreen 0:3b00827bb0b7 78 #include "UDPSocket.h"
AdamGreen 0:3b00827bb0b7 79
AdamGreen 0:3b00827bb0b7 80 #endif /* ETHERNETINTERFACE_H_ */