Implementation of the NetworkSocketAPI for LWIP

Dependencies:   lwip-eth lwip-sys lwip

Dependents:   HelloLWIPInterface HelloLWIPInterfaceNonBlocking LWIPInterfaceTests SimpleHTTPExample ... more

Committer:
sam_grove
Date:
Wed Mar 09 05:58:19 2016 +0000
Revision:
7:08d5a40ae448
Parent:
5:2c7d2186543c
Child:
8:cef01e812975
change LWIPSocket from struct to class

Who changed what in which revision?

UserRevisionLine numberNew contents of line
geky 1:2fbcfc9c12dd 1 /* LWIP implementation of NetworkInterfaceAPI
geky 1:2fbcfc9c12dd 2 * Copyright (c) 2015 ARM Limited
geky 1:2fbcfc9c12dd 3 *
geky 1:2fbcfc9c12dd 4 * Licensed under the Apache License, Version 2.0 (the "License");
geky 1:2fbcfc9c12dd 5 * you may not use this file except in compliance with the License.
geky 1:2fbcfc9c12dd 6 * You may obtain a copy of the License at
geky 1:2fbcfc9c12dd 7 *
geky 1:2fbcfc9c12dd 8 * http://www.apache.org/licenses/LICENSE-2.0
geky 1:2fbcfc9c12dd 9 *
geky 1:2fbcfc9c12dd 10 * Unless required by applicable law or agreed to in writing, software
geky 1:2fbcfc9c12dd 11 * distributed under the License is distributed on an "AS IS" BASIS,
geky 1:2fbcfc9c12dd 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
geky 1:2fbcfc9c12dd 13 * See the License for the specific language governing permissions and
geky 1:2fbcfc9c12dd 14 * limitations under the License.
geky 1:2fbcfc9c12dd 15 */
geky 1:2fbcfc9c12dd 16
geky 1:2fbcfc9c12dd 17 #ifndef LWIP_INTERFACE_H
geky 1:2fbcfc9c12dd 18 #define LWIP_INTERFACE_H
geky 1:2fbcfc9c12dd 19
geky 1:2fbcfc9c12dd 20 #include "EthernetInterface.h"
Christopher Haster 2:7fb7e78cb17f 21 #include "rtos.h"
Christopher Haster 2:7fb7e78cb17f 22 #include "lwip/netif.h"
geky 1:2fbcfc9c12dd 23
geky 1:2fbcfc9c12dd 24
geky 1:2fbcfc9c12dd 25 /** LWIPInterface class
geky 1:2fbcfc9c12dd 26 * Implementation of the NetworkInterface for LWIP
geky 1:2fbcfc9c12dd 27 */
geky 1:2fbcfc9c12dd 28 class LWIPInterface : public EthernetInterface
geky 1:2fbcfc9c12dd 29 {
geky 1:2fbcfc9c12dd 30 public:
sam_grove 7:08d5a40ae448 31
geky 1:2fbcfc9c12dd 32 // Implementation of EthernetInterface
geky 1:2fbcfc9c12dd 33 virtual int32_t connect();
geky 1:2fbcfc9c12dd 34 virtual int32_t disconnect();
geky 1:2fbcfc9c12dd 35
geky 1:2fbcfc9c12dd 36 // Implementation of NetworkInterface
geky 5:2c7d2186543c 37 virtual const char *getIPAddress();
geky 1:2fbcfc9c12dd 38 virtual const char *getMACAddress();
geky 1:2fbcfc9c12dd 39
geky 3:774869068511 40 virtual SocketInterface *createSocket(ns_protocol_t proto);
geky 1:2fbcfc9c12dd 41 virtual void destroySocket(SocketInterface *socket);
sam_grove 7:08d5a40ae448 42
sam_grove 7:08d5a40ae448 43 private:
geky 4:a7349bd7776c 44
geky 4:a7349bd7776c 45 // Implementation of the TCP SocketInterface for LWIP
sam_grove 7:08d5a40ae448 46 class LWIPSocket : public SocketInterface
geky 4:a7349bd7776c 47 {
sam_grove 7:08d5a40ae448 48 public:
sam_grove 7:08d5a40ae448 49
geky 4:a7349bd7776c 50 LWIPSocket(int fd) : fd(fd) {}
geky 4:a7349bd7776c 51 int fd;
geky 4:a7349bd7776c 52
geky 4:a7349bd7776c 53 // Implementation of SocketInterface
geky 4:a7349bd7776c 54 virtual int32_t open(const char *ip, uint16_t port);
geky 4:a7349bd7776c 55 virtual int32_t close();
geky 4:a7349bd7776c 56
geky 4:a7349bd7776c 57 virtual int32_t send(const void *data, uint32_t size);
geky 4:a7349bd7776c 58 virtual int32_t recv(void *data, uint32_t size);
geky 4:a7349bd7776c 59 };
geky 1:2fbcfc9c12dd 60 };
geky 1:2fbcfc9c12dd 61
geky 1:2fbcfc9c12dd 62
geky 1:2fbcfc9c12dd 63 #endif