Implementation of the NetworkSocketAPI for LWIP
Dependencies: lwip-eth lwip-sys lwip
Dependents: HelloLWIPInterface HelloLWIPInterfaceNonBlocking LWIPInterfaceTests SimpleHTTPExample ... more
LWIPInterface.h@4:a7349bd7776c, 2016-02-29 (annotated)
- Committer:
- geky
- Date:
- Mon Feb 29 23:01:54 2016 +0000
- Revision:
- 4:a7349bd7776c
- Parent:
- 3:774869068511
- Child:
- 5:2c7d2186543c
Moved LWIPSocket into private class in LWIPInterface
Who changed what in which revision?
User | Revision | Line number | New 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 | 1:2fbcfc9c12dd | 36 | virtual const char *getMACAddress(); |
geky | 1:2fbcfc9c12dd | 37 | |
geky | 3:774869068511 | 38 | virtual SocketInterface *createSocket(ns_protocol_t proto); |
geky | 1:2fbcfc9c12dd | 39 | virtual void destroySocket(SocketInterface *socket); |
geky | 4:a7349bd7776c | 40 | |
geky | 4:a7349bd7776c | 41 | private: |
geky | 4:a7349bd7776c | 42 | // Implementation of the TCP SocketInterface for LWIP |
geky | 4:a7349bd7776c | 43 | struct LWIPSocket : public SocketInterface |
geky | 4:a7349bd7776c | 44 | { |
geky | 4:a7349bd7776c | 45 | LWIPSocket(int fd) : fd(fd) {} |
geky | 4:a7349bd7776c | 46 | int fd; |
geky | 4:a7349bd7776c | 47 | |
geky | 4:a7349bd7776c | 48 | // Implementation of SocketInterface |
geky | 4:a7349bd7776c | 49 | virtual int32_t open(const char *ip, uint16_t port); |
geky | 4:a7349bd7776c | 50 | virtual int32_t close(); |
geky | 4:a7349bd7776c | 51 | |
geky | 4:a7349bd7776c | 52 | virtual int32_t send(const void *data, uint32_t size); |
geky | 4:a7349bd7776c | 53 | virtual int32_t recv(void *data, uint32_t size); |
geky | 4:a7349bd7776c | 54 | }; |
geky | 1:2fbcfc9c12dd | 55 | }; |
geky | 1:2fbcfc9c12dd | 56 | |
geky | 1:2fbcfc9c12dd | 57 | |
geky | 1:2fbcfc9c12dd | 58 | #endif |