Fork of NetServicesMin with some warnings removed

Dependencies:   lwip-sys lwip

Fork of NetServicesMin by Hendrik Lipka

Committer:
uci1
Date:
Tue Oct 30 05:20:56 2012 +0000
Revision:
2:9cc2c6e42ffd
Parent:
0:8b387bed54c2
Fix some code that gives warnings when compiling with gcc (forward declared enums and addresses of temporary objects).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hlipka 0:8b387bed54c2 1
hlipka 0:8b387bed54c2 2 /*
hlipka 0:8b387bed54c2 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
hlipka 0:8b387bed54c2 4
hlipka 0:8b387bed54c2 5 Permission is hereby granted, free of charge, to any person obtaining a copy
hlipka 0:8b387bed54c2 6 of this software and associated documentation files (the "Software"), to deal
hlipka 0:8b387bed54c2 7 in the Software without restriction, including without limitation the rights
hlipka 0:8b387bed54c2 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
hlipka 0:8b387bed54c2 9 copies of the Software, and to permit persons to whom the Software is
hlipka 0:8b387bed54c2 10 furnished to do so, subject to the following conditions:
hlipka 0:8b387bed54c2 11
hlipka 0:8b387bed54c2 12 The above copyright notice and this permission notice shall be included in
hlipka 0:8b387bed54c2 13 all copies or substantial portions of the Software.
hlipka 0:8b387bed54c2 14
hlipka 0:8b387bed54c2 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
hlipka 0:8b387bed54c2 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
hlipka 0:8b387bed54c2 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
hlipka 0:8b387bed54c2 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
hlipka 0:8b387bed54c2 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
hlipka 0:8b387bed54c2 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
hlipka 0:8b387bed54c2 21 THE SOFTWARE.
hlipka 0:8b387bed54c2 22 */
hlipka 0:8b387bed54c2 23
hlipka 0:8b387bed54c2 24 /** \file
hlipka 0:8b387bed54c2 25 DNS Request header file
hlipka 0:8b387bed54c2 26 */
hlipka 0:8b387bed54c2 27
hlipka 0:8b387bed54c2 28 #ifndef DNSREQUEST_H
hlipka 0:8b387bed54c2 29 #define DNSREQUEST_H
hlipka 0:8b387bed54c2 30
hlipka 0:8b387bed54c2 31 #include "core/net.h"
hlipka 0:8b387bed54c2 32 #include "core/ipaddr.h"
hlipka 0:8b387bed54c2 33 #include "core/host.h"
hlipka 0:8b387bed54c2 34 //Essentially it is a safe interface to NetDnsRequest
uci1 2:9cc2c6e42ffd 35 #include "if/net/netdnsrequest.h"
hlipka 0:8b387bed54c2 36
hlipka 0:8b387bed54c2 37 ///DNS Request error codes
hlipka 0:8b387bed54c2 38 enum DNSRequestErr
hlipka 0:8b387bed54c2 39 {
hlipka 0:8b387bed54c2 40 __DNS_MIN = -0xFFFF,
hlipka 0:8b387bed54c2 41 DNS_SETUP, ///<DNSRequest not properly configured
hlipka 0:8b387bed54c2 42 DNS_IF, ///<Interface has problems, does not exist or is not initialized
hlipka 0:8b387bed54c2 43 DNS_MEM, ///<Not enough mem
hlipka 0:8b387bed54c2 44 DNS_INUSE, ///<Interface / Port is in use
hlipka 0:8b387bed54c2 45 DNS_PROCESSING, ///<Request has not completed
hlipka 0:8b387bed54c2 46 //...
hlipka 0:8b387bed54c2 47 DNS_OK = 0 ///<Success
hlipka 0:8b387bed54c2 48 };
hlipka 0:8b387bed54c2 49
hlipka 0:8b387bed54c2 50 ///DNS Request Result Events
hlipka 0:8b387bed54c2 51 enum DNSReply
hlipka 0:8b387bed54c2 52 {
hlipka 0:8b387bed54c2 53 DNS_PRTCL,
hlipka 0:8b387bed54c2 54 DNS_NOTFOUND, ///Hostname is unknown
hlipka 0:8b387bed54c2 55 DNS_ERROR, ///Problem with DNS Service
hlipka 0:8b387bed54c2 56 //...
hlipka 0:8b387bed54c2 57 DNS_FOUND,
hlipka 0:8b387bed54c2 58 };
hlipka 0:8b387bed54c2 59
uci1 2:9cc2c6e42ffd 60 //class NetDnsRequest;
uci1 2:9cc2c6e42ffd 61 //enum NetDnsReply;
hlipka 0:8b387bed54c2 62
hlipka 0:8b387bed54c2 63 ///This is a simple DNS Request class
hlipka 0:8b387bed54c2 64 /**
hlipka 0:8b387bed54c2 65 This class exposes an API to deal with DNS Requests
hlipka 0:8b387bed54c2 66 */
hlipka 0:8b387bed54c2 67 class DNSRequest
hlipka 0:8b387bed54c2 68 {
hlipka 0:8b387bed54c2 69 public:
hlipka 0:8b387bed54c2 70 ///Creates a new request
hlipka 0:8b387bed54c2 71 DNSRequest();
hlipka 0:8b387bed54c2 72
hlipka 0:8b387bed54c2 73 ///Terminates and closes request
hlipka 0:8b387bed54c2 74 ~DNSRequest();
hlipka 0:8b387bed54c2 75
hlipka 0:8b387bed54c2 76 ///Resolves an hostname
hlipka 0:8b387bed54c2 77 /**
hlipka 0:8b387bed54c2 78 @param hostname : hostname to resolve
hlipka 0:8b387bed54c2 79 */
hlipka 0:8b387bed54c2 80 DNSRequestErr resolve(const char* hostname);
hlipka 0:8b387bed54c2 81
hlipka 0:8b387bed54c2 82 ///Resolves an hostname
hlipka 0:8b387bed54c2 83 /**
hlipka 0:8b387bed54c2 84 @param host : hostname to resolve, the result will be stored in the IpAddr field of this object
hlipka 0:8b387bed54c2 85 */
hlipka 0:8b387bed54c2 86 DNSRequestErr resolve(Host* pHost);
hlipka 0:8b387bed54c2 87
hlipka 0:8b387bed54c2 88 ///Setups callback
hlipka 0:8b387bed54c2 89 /**
hlipka 0:8b387bed54c2 90 The callback function will be called on result.
hlipka 0:8b387bed54c2 91 @param pMethod : callback function
hlipka 0:8b387bed54c2 92 */
hlipka 0:8b387bed54c2 93 void setOnReply( void (*pMethod)(DNSReply) );
hlipka 0:8b387bed54c2 94
hlipka 0:8b387bed54c2 95 class CDummy;
hlipka 0:8b387bed54c2 96 ///Setups callback
hlipka 0:8b387bed54c2 97 /**
hlipka 0:8b387bed54c2 98 The callback function will be called on result.
hlipka 0:8b387bed54c2 99 @param pItem : instance of class on which to execute the callback method
hlipka 0:8b387bed54c2 100 @param pMethod : callback method
hlipka 0:8b387bed54c2 101 */
hlipka 0:8b387bed54c2 102 template<class T>
hlipka 0:8b387bed54c2 103 void setOnReply( T* pItem, void (T::*pMethod)(DNSReply) )
hlipka 0:8b387bed54c2 104 {
hlipka 0:8b387bed54c2 105 m_pCbItem = (CDummy*) pItem;
hlipka 0:8b387bed54c2 106 m_pCbMeth = (void (CDummy::*)(DNSReply)) pMethod;
hlipka 0:8b387bed54c2 107 }
hlipka 0:8b387bed54c2 108
hlipka 0:8b387bed54c2 109 ///Gets IP address once it has been resolved
hlipka 0:8b387bed54c2 110 /**
hlipka 0:8b387bed54c2 111 @param pIp : pointer to an IpAddr instance in which to store the resolved IP address
hlipka 0:8b387bed54c2 112 */
hlipka 0:8b387bed54c2 113 DNSRequestErr getResult(IpAddr* pIp);
hlipka 0:8b387bed54c2 114
hlipka 0:8b387bed54c2 115 ///Closes DNS Request before completion
hlipka 0:8b387bed54c2 116 DNSRequestErr close();
hlipka 0:8b387bed54c2 117
hlipka 0:8b387bed54c2 118 protected:
hlipka 0:8b387bed54c2 119 void onNetDnsReply(NetDnsReply r);
hlipka 0:8b387bed54c2 120 DNSRequestErr checkInst();
hlipka 0:8b387bed54c2 121
hlipka 0:8b387bed54c2 122 private:
hlipka 0:8b387bed54c2 123 NetDnsRequest* m_pNetDnsRequest;
hlipka 0:8b387bed54c2 124
hlipka 0:8b387bed54c2 125 CDummy* m_pCbItem;
hlipka 0:8b387bed54c2 126 void (CDummy::*m_pCbMeth)(DNSReply);
hlipka 0:8b387bed54c2 127
hlipka 0:8b387bed54c2 128 void (*m_pCb)(DNSReply);
hlipka 0:8b387bed54c2 129
hlipka 0:8b387bed54c2 130 };
hlipka 0:8b387bed54c2 131
hlipka 0:8b387bed54c2 132 #endif