nbns_client.h
Go to the documentation of this file.
1 /**
2  * @file nbns_client.h
3  * @brief NBNS client (NetBIOS Name Service)
4  *
5  * @section License
6  *
7  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _NBNS_CLIENT_H
30 #define _NBNS_CLIENT_H
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "core/socket.h"
35 #include "core/udp.h"
36 #include "dns/dns_cache.h"
37 #include "dns/dns_common.h"
38 #include "netbios/nbns_common.h"
39 
40 //NBNS client support
41 #ifndef NBNS_CLIENT_SUPPORT
42  #define NBNS_CLIENT_SUPPORT ENABLED
43 #elif (NBNS_CLIENT_SUPPORT != ENABLED && NBNS_CLIENT_SUPPORT != DISABLED)
44  #error NBNS_CLIENT_SUPPORT parameter is not valid
45 #endif
46 
47 //Maximum number of retransmissions of NBNS queries
48 #ifndef NBNS_CLIENT_MAX_RETRIES
49  #define NBNS_CLIENT_MAX_RETRIES 3
50 #elif (NBNS_CLIENT_MAX_RETRIES < 1)
51  #error NBNS_CLIENT_MAX_RETRIES parameter is not valid
52 #endif
53 
54 //Initial retransmission timeout
55 #ifndef NBNS_CLIENT_INIT_TIMEOUT
56  #define NBNS_CLIENT_INIT_TIMEOUT 1000
57 #elif (NBNS_CLIENT_INIT_TIMEOUT < 1000)
58  #error NBNS_CLIENT_INIT_TIMEOUT parameter is not valid
59 #endif
60 
61 //Maximum retransmission timeout
62 #ifndef NBNS_CLIENT_MAX_TIMEOUT
63  #define NBNS_CLIENT_MAX_TIMEOUT 1000
64 #elif (NBNS_CLIENT_MAX_TIMEOUT < 1000)
65  #error NBNS_CLIENT_MAX_TIMEOUT parameter is not valid
66 #endif
67 
68 //Maximum cache lifetime for NBNS entries
69 #ifndef NBNS_MAX_LIFETIME
70  #define NBNS_MAX_LIFETIME 60000
71 #elif (NBNS_MAX_LIFETIME < 1000)
72  #error NBNS_MAX_LIFETIME parameter is not valid
73 #endif
74 
75 //C++ guard
76 #ifdef __cplusplus
77  extern "C" {
78 #endif
79 
80 //NBNS related functions
82 
84 
85 void nbnsProcessResponse(NetInterface *interface, const Ipv4PseudoHeader *pseudoHeader,
86  const UdpHeader *udpHeader, const NbnsHeader *message, size_t length);
87 
88 //C++ guard
89 #ifdef __cplusplus
90  }
91 #endif
92 
93 #endif
char char_t
Definition: compiler_port.h:41
TCP/IP stack core.
uint8_t message[]
Definition: chap.h:150
DNS cache management.
IP network address.
Definition: ip.h:57
#define Ipv4PseudoHeader
Definition: ipv4.h:37
uint8_t ipAddr[4]
Definition: mib_common.h:185
DNS cache entry.
Definition: dns_cache.h:94
char_t name[]
__start_packed struct @263 NbnsHeader
NBNS message header.
error_t nbnsSendQuery(DnsCacheEntry *entry)
Send a NBNS query message.
Definition: nbns_client.c:190
__start_packed struct @126 UdpHeader
UDP header.
error_t nbnsResolve(NetInterface *interface, const char_t *name, IpAddr *ipAddr)
Resolve a host name using NBNS.
Definition: nbns_client.c:50
error_t
Error codes.
Definition: error.h:40
void nbnsProcessResponse(NetInterface *interface, const Ipv4PseudoHeader *pseudoHeader, const UdpHeader *udpHeader, const NbnsHeader *message, size_t length)
Process NBNS response message.
Definition: nbns_client.c:274
#define NetInterface
Definition: net.h:34
Socket API.
uint8_t length
Definition: dtls_misc.h:140
Common DNS routines.
Definitions common to NBNS client and NBNS responder.
UDP (User Datagram Protocol)