Daniele Lacamera / PicoTCP-Experimental_CDC_ECM_Branch

Fork of PicoTCP by Daniele Lacamera

Committer:
daniele
Date:
Sun Jun 16 20:19:44 2013 +0000
Revision:
29:1a47b7151851
Parent:
5:445d2fc04784
Updated from masterbranch;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tass 5:445d2fc04784 1 /*
tass 5:445d2fc04784 2 *
tass 5:445d2fc04784 3 * PicoTCP Socket interface for mbed.
tass 5:445d2fc04784 4 * Copyright (C) 2013 TASS Belgium NV
tass 5:445d2fc04784 5 *
tass 5:445d2fc04784 6 * Released under GPL v2
tass 5:445d2fc04784 7 *
tass 5:445d2fc04784 8 * Other licensing models might apply at the sole discretion of the copyright holders.
tass 5:445d2fc04784 9 *
tass 5:445d2fc04784 10 *
tass 5:445d2fc04784 11 * This software is based on the mbed.org EthernetInterface implementation:
tass 5:445d2fc04784 12 * Copyright (C) 2012 mbed.org, MIT License
tass 5:445d2fc04784 13 *
tass 5:445d2fc04784 14 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
tass 5:445d2fc04784 15 * and associated documentation files (the "Software"), to deal in the Software without restriction,
tass 5:445d2fc04784 16 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
tass 5:445d2fc04784 17 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
tass 5:445d2fc04784 18 * furnished to do so, subject to the following conditions:
tass 5:445d2fc04784 19 *
tass 5:445d2fc04784 20 * The above copyright notice and this permission notice shall be included in all copies or
tass 5:445d2fc04784 21 * substantial portions of the Software.
tass 5:445d2fc04784 22 *
tass 5:445d2fc04784 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
tass 5:445d2fc04784 24 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
tass 5:445d2fc04784 25 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
tass 5:445d2fc04784 26 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tass 5:445d2fc04784 27 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tass 5:445d2fc04784 28 */
tass 5:445d2fc04784 29
tass 5:445d2fc04784 30 #ifndef ETHERNETINTERFACE_H_
tass 5:445d2fc04784 31 #define ETHERNETINTERFACE_H_
tass 5:445d2fc04784 32
tass 5:445d2fc04784 33 #if !defined(TARGET_LPC1768)
tass 5:445d2fc04784 34 #error The Ethernet Interface library is supported only on the mbed NXP LPC1768
tass 5:445d2fc04784 35 #endif
tass 5:445d2fc04784 36
tass 5:445d2fc04784 37 #include "rtos.h"
tass 5:445d2fc04784 38
tass 5:445d2fc04784 39 #ifdef __cplusplus
tass 5:445d2fc04784 40 extern "C" {
tass 5:445d2fc04784 41 #endif
tass 5:445d2fc04784 42 extern void (*linkCb)(uint32_t link);
tass 5:445d2fc04784 43 #ifdef __cplusplus
tass 5:445d2fc04784 44 }
tass 5:445d2fc04784 45 #endif
tass 5:445d2fc04784 46 /** Interface using Ethernet to connect to an IP-based network
tass 5:445d2fc04784 47 *
tass 5:445d2fc04784 48 */
tass 5:445d2fc04784 49 class EthernetInterface {
tass 5:445d2fc04784 50 public:
tass 5:445d2fc04784 51 /** Initialize the interface with DHCP.
tass 5:445d2fc04784 52 * Initialize the interface and configure it to use DHCP (no connection at this point).
tass 5:445d2fc04784 53 * \return 0 on success, a negative number on failure
tass 5:445d2fc04784 54 */
tass 5:445d2fc04784 55 static int init(); //With DHCP
tass 5:445d2fc04784 56
tass 5:445d2fc04784 57 /** Initialize the interface with a static IP address.
tass 5:445d2fc04784 58 * Initialize the interface and configure it with the following static configuration (no connection at this point).
tass 5:445d2fc04784 59 * \param ip the IP address to use
tass 5:445d2fc04784 60 * \param mask the IP address mask
tass 5:445d2fc04784 61 * \param gateway the gateway to use
tass 5:445d2fc04784 62 * \return 0 on success, a negative number on failure
tass 5:445d2fc04784 63 */
tass 5:445d2fc04784 64 static int init(const char* ip, const char* mask, const char* gateway);
tass 5:445d2fc04784 65
tass 5:445d2fc04784 66 /** Connect
tass 5:445d2fc04784 67 * Bring the interface up, start DHCP if needed.
tass 5:445d2fc04784 68 * \param timeout_ms timeout in ms (default: (10)s).
tass 5:445d2fc04784 69 * \return 0 on success, a negative number on failure
tass 5:445d2fc04784 70 */
tass 5:445d2fc04784 71 static int connect(unsigned int timeout_ms=15000);
tass 5:445d2fc04784 72
tass 5:445d2fc04784 73 /** Disconnect
tass 5:445d2fc04784 74 * Bring the interface down
tass 5:445d2fc04784 75 * \return 0 on success, a negative number on failure
tass 5:445d2fc04784 76 */
tass 5:445d2fc04784 77 static int disconnect();
tass 5:445d2fc04784 78
tass 5:445d2fc04784 79 /** Get the MAC address of your Ethernet interface
tass 5:445d2fc04784 80 * \return a pointer to a string containing the MAC address
tass 5:445d2fc04784 81 */
tass 5:445d2fc04784 82 static char* getMACAddress();
tass 5:445d2fc04784 83
tass 5:445d2fc04784 84 /** Get the IP address of your Ethernet interface
tass 5:445d2fc04784 85 * \return a pointer to a string containing the IP address
tass 5:445d2fc04784 86 */
tass 5:445d2fc04784 87 static char* getIPAddress();
tass 5:445d2fc04784 88
tass 5:445d2fc04784 89
tass 5:445d2fc04784 90 /** Register a callback to tell the status of the link.
tass 5:445d2fc04784 91 * \return 0 if callback was registered.
tass 5:445d2fc04784 92 */
tass 5:445d2fc04784 93 static int registerLinkStatus(void (*cb)(uint32_t linkStatus));
tass 5:445d2fc04784 94
tass 5:445d2fc04784 95
tass 5:445d2fc04784 96 /** Register a callback to tell the status of the link.
tass 5:445d2fc04784 97 * \return 0 if callback was registered.
tass 5:445d2fc04784 98 */
tass 5:445d2fc04784 99 static int setDnsServer(const char *);
tass 5:445d2fc04784 100
tass 5:445d2fc04784 101 };
tass 5:445d2fc04784 102
tass 5:445d2fc04784 103 #include "TCPSocketConnection.h"
tass 5:445d2fc04784 104 #include "TCPSocketServer.h"
tass 5:445d2fc04784 105
tass 5:445d2fc04784 106 #include "Endpoint.h"
tass 5:445d2fc04784 107 #include "UDPSocket.h"
tass 5:445d2fc04784 108
tass 5:445d2fc04784 109 #endif /* ETHERNETINTERFACE_H_ */