Sergey Pastor / 1

Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers dns_client.h Source File

dns_client.h

Go to the documentation of this file.
00001 /**
00002  * @file dns_client.h
00003  * @brief DNS client (Domain Name System)
00004  *
00005  * @section License
00006  *
00007  * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved.
00008  *
00009  * This file is part of CycloneTCP Open.
00010  *
00011  * This program is free software; you can redistribute it and/or
00012  * modify it under the terms of the GNU General Public License
00013  * as published by the Free Software Foundation; either version 2
00014  * of the License, or (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software Foundation,
00023  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00024  *
00025  * @author Oryx Embedded SARL (www.oryx-embedded.com)
00026  * @version 1.7.6
00027  **/
00028 
00029 #ifndef _DNS_CLIENT_H
00030 #define _DNS_CLIENT_H
00031 
00032 //Dependencies
00033 #include "core/net.h"
00034 #include "core/socket.h"
00035 #include "core/udp.h"
00036 #include "dns/dns_cache.h"
00037 
00038 //DNS client support
00039 #ifndef DNS_CLIENT_SUPPORT
00040    #define DNS_CLIENT_SUPPORT ENABLED
00041 #elif (DNS_CLIENT_SUPPORT != ENABLED && DNS_CLIENT_SUPPORT != DISABLED)
00042    #error DNS_CLIENT_SUPPORT parameter is not valid
00043 #endif
00044 
00045 //Maximum number of retransmissions of DNS queries
00046 #ifndef DNS_CLIENT_MAX_RETRIES
00047    #define DNS_CLIENT_MAX_RETRIES 3
00048 #elif (DNS_CLIENT_MAX_RETRIES < 1)
00049    #error DNS_CLIENT_MAX_RETRIES parameter is not valid
00050 #endif
00051 
00052 //Initial retransmission timeout
00053 #ifndef DNS_CLIENT_INIT_TIMEOUT
00054    #define DNS_CLIENT_INIT_TIMEOUT 1000
00055 #elif (DNS_CLIENT_INIT_TIMEOUT < 1000)
00056    #error DNS_CLIENT_INIT_TIMEOUT parameter is not valid
00057 #endif
00058 
00059 //Maximum retransmission timeout
00060 #ifndef DNS_CLIENT_MAX_TIMEOUT
00061    #define DNS_CLIENT_MAX_TIMEOUT 5000
00062 #elif (DNS_CLIENT_MAX_TIMEOUT < 1000)
00063    #error DNS_CLIENT_MAX_TIMEOUT parameter is not valid
00064 #endif
00065 
00066 //Minimum cache lifetime for DNS entries
00067 #ifndef DNS_MIN_LIFETIME
00068    #define DNS_MIN_LIFETIME 1000
00069 #elif (DNS_MIN_LIFETIME < 0)
00070    #error DNS_MIN_LIFETIME parameter is not valid
00071 #endif
00072 
00073 //Maximum cache lifetime for DNS entries
00074 #ifndef DNS_MAX_LIFETIME
00075    #define DNS_MAX_LIFETIME 3600000
00076 #elif (DNS_MAX_LIFETIME < 1000 || DNS_MAX_LIFETIME < DNS_MIN_LIFETIME)
00077    #error DNS_MAX_LIFETIME parameter is not valid
00078 #endif
00079 
00080 //DNS related functions
00081 error_t dnsResolve(NetInterface *interface,
00082    const char_t *name, HostType type, IpAddr *ipAddr);
00083 
00084 error_t dnsSendQuery(DnsCacheEntry *entry);
00085 
00086 void dnsProcessResponse(NetInterface *interface, const IpPseudoHeader *pseudoHeader,
00087    const UdpHeader *udpHeader, const NetBuffer *buffer, size_t offset, void *params);
00088 
00089 #endif
00090