![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
no working tcp
EthernetNetIf/LPC2368/if/lwip/lwipNetDnsRequest.h@0:39a067b5ae32, 2010-12-24 (annotated)
- Committer:
- brleme
- Date:
- Fri Dec 24 00:37:51 2010 +0000
- Revision:
- 0:39a067b5ae32
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
brleme | 0:39a067b5ae32 | 1 | |
brleme | 0:39a067b5ae32 | 2 | /* |
brleme | 0:39a067b5ae32 | 3 | Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) |
brleme | 0:39a067b5ae32 | 4 | |
brleme | 0:39a067b5ae32 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
brleme | 0:39a067b5ae32 | 6 | of this software and associated documentation files (the "Software"), to deal |
brleme | 0:39a067b5ae32 | 7 | in the Software without restriction, including without limitation the rights |
brleme | 0:39a067b5ae32 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
brleme | 0:39a067b5ae32 | 9 | copies of the Software, and to permit persons to whom the Software is |
brleme | 0:39a067b5ae32 | 10 | furnished to do so, subject to the following conditions: |
brleme | 0:39a067b5ae32 | 11 | |
brleme | 0:39a067b5ae32 | 12 | The above copyright notice and this permission notice shall be included in |
brleme | 0:39a067b5ae32 | 13 | all copies or substantial portions of the Software. |
brleme | 0:39a067b5ae32 | 14 | |
brleme | 0:39a067b5ae32 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
brleme | 0:39a067b5ae32 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
brleme | 0:39a067b5ae32 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
brleme | 0:39a067b5ae32 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
brleme | 0:39a067b5ae32 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
brleme | 0:39a067b5ae32 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
brleme | 0:39a067b5ae32 | 21 | THE SOFTWARE. |
brleme | 0:39a067b5ae32 | 22 | */ |
brleme | 0:39a067b5ae32 | 23 | |
brleme | 0:39a067b5ae32 | 24 | #ifndef LWIPNETDNSREQUEST_H |
brleme | 0:39a067b5ae32 | 25 | #define LWIPNETDNSREQUEST_H |
brleme | 0:39a067b5ae32 | 26 | |
brleme | 0:39a067b5ae32 | 27 | #define NET_LWIP_STACK 1 |
brleme | 0:39a067b5ae32 | 28 | #include "if/net/netdnsrequest.h" |
brleme | 0:39a067b5ae32 | 29 | |
brleme | 0:39a067b5ae32 | 30 | //struct ip_addr_t; |
brleme | 0:39a067b5ae32 | 31 | #include "lwip/ip_addr.h" |
brleme | 0:39a067b5ae32 | 32 | |
brleme | 0:39a067b5ae32 | 33 | class LwipNetDnsRequest : public NetDnsRequest |
brleme | 0:39a067b5ae32 | 34 | { |
brleme | 0:39a067b5ae32 | 35 | public: |
brleme | 0:39a067b5ae32 | 36 | LwipNetDnsRequest(const char* hostname); |
brleme | 0:39a067b5ae32 | 37 | LwipNetDnsRequest(Host* pHost); |
brleme | 0:39a067b5ae32 | 38 | virtual ~LwipNetDnsRequest(); |
brleme | 0:39a067b5ae32 | 39 | |
brleme | 0:39a067b5ae32 | 40 | //Execute request & return OK if found, NOTFOUND or ERROR on error, or PROCESSING if the request has not completed yet |
brleme | 0:39a067b5ae32 | 41 | virtual void poll(); |
brleme | 0:39a067b5ae32 | 42 | |
brleme | 0:39a067b5ae32 | 43 | virtual void close(); |
brleme | 0:39a067b5ae32 | 44 | |
brleme | 0:39a067b5ae32 | 45 | protected: |
brleme | 0:39a067b5ae32 | 46 | void foundCb(const char *name, ip_addr_t *ipaddr); |
brleme | 0:39a067b5ae32 | 47 | |
brleme | 0:39a067b5ae32 | 48 | private: |
brleme | 0:39a067b5ae32 | 49 | enum LwipNetDnsState |
brleme | 0:39a067b5ae32 | 50 | { |
brleme | 0:39a067b5ae32 | 51 | LWIPNETDNS_START, |
brleme | 0:39a067b5ae32 | 52 | LWIPNETDNS_PROCESSING, //Req has not completed |
brleme | 0:39a067b5ae32 | 53 | LWIPNETDNS_NOTFOUND, |
brleme | 0:39a067b5ae32 | 54 | LWIPNETDNS_ERROR, |
brleme | 0:39a067b5ae32 | 55 | LWIPNETDNS_OK |
brleme | 0:39a067b5ae32 | 56 | }; |
brleme | 0:39a067b5ae32 | 57 | |
brleme | 0:39a067b5ae32 | 58 | LwipNetDnsState m_state; |
brleme | 0:39a067b5ae32 | 59 | bool m_cbFired; |
brleme | 0:39a067b5ae32 | 60 | |
brleme | 0:39a067b5ae32 | 61 | //Static callbacks : Transforms into a C++ callback |
brleme | 0:39a067b5ae32 | 62 | static void sFoundCb(const char *name, ip_addr_t *ipaddr, void *arg); |
brleme | 0:39a067b5ae32 | 63 | |
brleme | 0:39a067b5ae32 | 64 | bool m_closing; |
brleme | 0:39a067b5ae32 | 65 | }; |
brleme | 0:39a067b5ae32 | 66 | |
brleme | 0:39a067b5ae32 | 67 | #endif |