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