Implementation of the NetworkSocketAPI for LWIP

Dependencies:   lwip-eth lwip-sys lwip

Dependents:   HelloLWIPInterface HelloLWIPInterfaceNonBlocking LWIPInterfaceTests SimpleHTTPExample ... more

Committer:
geky
Date:
Wed Mar 02 17:21:54 2016 +0000
Revision:
5:2c7d2186543c
Parent:
4:a7349bd7776c
Child:
7:08d5a40ae448
Matched changes to NetworkSocketAPI

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:
geky 1:2fbcfc9c12dd 31 // Implementation of EthernetInterface
geky 1:2fbcfc9c12dd 32 virtual int32_t connect();
geky 1:2fbcfc9c12dd 33 virtual int32_t disconnect();
geky 1:2fbcfc9c12dd 34
geky 1:2fbcfc9c12dd 35 // Implementation of NetworkInterface
geky 5:2c7d2186543c 36 virtual const char *getIPAddress();
geky 1:2fbcfc9c12dd 37 virtual const char *getMACAddress();
geky 1:2fbcfc9c12dd 38
geky 3:774869068511 39 virtual SocketInterface *createSocket(ns_protocol_t proto);
geky 1:2fbcfc9c12dd 40 virtual void destroySocket(SocketInterface *socket);
geky 4:a7349bd7776c 41
geky 4:a7349bd7776c 42 private:
geky 4:a7349bd7776c 43 // Implementation of the TCP SocketInterface for LWIP
geky 4:a7349bd7776c 44 struct LWIPSocket : public SocketInterface
geky 4:a7349bd7776c 45 {
geky 4:a7349bd7776c 46 LWIPSocket(int fd) : fd(fd) {}
geky 4:a7349bd7776c 47 int fd;
geky 4:a7349bd7776c 48
geky 4:a7349bd7776c 49 // Implementation of SocketInterface
geky 4:a7349bd7776c 50 virtual int32_t open(const char *ip, uint16_t port);
geky 4:a7349bd7776c 51 virtual int32_t close();
geky 4:a7349bd7776c 52
geky 4:a7349bd7776c 53 virtual int32_t send(const void *data, uint32_t size);
geky 4:a7349bd7776c 54 virtual int32_t recv(void *data, uint32_t size);
geky 4:a7349bd7776c 55 };
geky 1:2fbcfc9c12dd 56 };
geky 1:2fbcfc9c12dd 57
geky 1:2fbcfc9c12dd 58
geky 1:2fbcfc9c12dd 59 #endif