1 | /**
|
2 |
|
3 | * This file implements a simple NetBios Server for the HostName.
|
4 | * All other NetBios querys are ignored
|
5 |
|
6 | * by Oliver Schindler November 2008
|
7 |
|
8 | * uIP version Copyright (c) 2002-2003, Adam Dunkels.
|
9 | * All rights reserved.
|
10 | *
|
11 | * Redistribution and use in source and binary forms, with or without
|
12 | * modification, are permitted provided that the following conditions
|
13 | * are met:
|
14 | * 1. Redistributions of source code must retain the above copyright
|
15 | * notice, this list of conditions and the following disclaimer.
|
16 | * 2. Redistributions in binary form must reproduce the above copyright
|
17 | * notice, this list of conditions and the following disclaimer in the
|
18 | * documentation and/or other materials provided with the distribution.
|
19 | * 3. The name of the author may not be used to endorse or promote
|
20 | * products derived from this software without specific prior
|
21 | * written permission.
|
22 | *
|
23 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
24 | * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
26 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
27 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
28 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
29 | * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
30 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
31 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
33 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34 | *
|
35 | *
|
36 | * NBNS.H
|
37 | *
|
38 | * The NetbiosNameService waiting on UDP-Port 137 for a NBNS-Query.
|
39 | * If this Query matches with the HostName, a respond is send.
|
40 | * All other NetBios Telegramms are ignored. ( like Samba, PrinterServices ,
|
41 | etc. )
|
42 | */
|
43 |
|
44 | /*-----------------------------------------------------------------------------
|
45 | * RFC 1001 - Protocol Standard for a NetBIOS Service on a TCP/UDP Transport:
|
46 | Concepts and methods
|
47 | * RFC 1002 - Protocol standard for a NetBIOS service on a TCP/UDP transport:
|
48 | Detailed specifications
|
49 | *----------------------------------------------------------------------------*/
|
50 |
|
51 | #ifndef __LWIP_NBNS_H__
|
52 | #define __LWIP_NBNS_H__
|
53 |
|
54 | #include "lwip/opt.h"
|
55 |
|
56 | #ifdef __cplusplus
|
57 | extern "C" {
|
58 | #endif
|
59 |
|
60 | #if LWIP_NBNS /* don't build if not configured for use in lwipopts.h */
|
61 |
|
62 | void nbns_init(struct netif *netif);
|
63 |
|
64 | /* Values of the opcode field */
|
65 |
|
66 | #define OPCODE_R 0x8000
|
67 |
|
68 | /*OPCODE 1-4 Operation specifier:
|
69 | 0 = query
|
70 | 5 = registration
|
71 | 6 = release
|
72 | 7 = WACK
|
73 | 8 = refresh */
|
74 |
|
75 | #define OPCODE_MASK 0x7800
|
76 | #define OPCODE_QUERY 0x0000
|
77 | #define OPCODE_REGISTRATION 0x2800
|
78 | #define OPCODE_RELEASE 0x3000
|
79 | #define OPCODE_WACK 0x3800
|
80 | #define OPCODE_REFRESH 0x4000
|
81 |
|
82 |
|
83 | /* NM_FLAGS subfield bits */
|
84 | #define NM_AA_BIT 0x0400 /* Authoritative Answer */
|
85 | #define NM_TR_BIT 0x0200 /* TRuncation flag */
|
86 | #define NM_RD_BIT 0x0100 /* Recursion Desired */
|
87 | #define NM_RA_BIT 0x0080 /* Recursion Available */
|
88 | #define NM_B_BIT 0x0010 /* Broadcast flag */
|
89 |
|
90 | /* Return Codes */
|
91 | #define RCODE_POS_RSP 0x0000 /* Positive Response */
|
92 | #define RCODE_FMT_ERR 0x0001 /* Format Error */
|
93 | #define RCODE_SRV_ERR 0x0002 /* Server failure */
|
94 | #define RCODE_NAM_ERR 0x0003 /* Name Not Found */
|
95 | #define RCODE_IMP_ERR 0x0004 /* Unsupported request */
|
96 | #define RCODE_RFS_ERR 0x0005 /* Refused */
|
97 | #define RCODE_ACT_ERR 0x0006 /* Active error */
|
98 | #define RCODE_CFT_ERR 0x0007 /* Name in conflict */
|
99 | #define RCODE_MASK 0x0007 /* Mask */
|
100 |
|
101 | /* Used to set the record count fields. */
|
102 | #define QUERYREC 0x1000 /* Query Record */
|
103 | #define ANSREC 0x0100 /* Answer Record */
|
104 | #define NSREC 0x0010 /* NS Rec (never used) */
|
105 | #define ADDREC 0x0001 /* Additional Record */
|
106 |
|
107 |
|
108 | /* RDATA NB_FLAGS. */
|
109 | #define GROUP_BIT 0x8000 /* Group indicator */
|
110 | #define ONT_B 0x0000 /* Broadcast node */
|
111 | #define ONT_P 0x2000 /* Point-to-point node */
|
112 | #define ONT_M 0x4000 /* Mixed mode node */
|
113 | #define ONT_H 0x6000 /* MS Hybrid mode node */
|
114 | #define ONT_MASK 0x6000 /* Mask */
|
115 |
|
116 | /* RDATA NAME_FLAGS. */
|
117 | #define DRG 0x0100 /* Deregister. */
|
118 | #define CNF 0x0800 /* Conflict. */
|
119 | #define ACT 0x0400 /* Active. */
|
120 | #define PRM 0x0200 /* Permanent. */
|
121 |
|
122 | /* QUESTION_TYPE */
|
123 | #define NB 0x0020
|
124 | #define NBSTAT 0x0021
|
125 |
|
126 | /* QUESTION_CLASS */
|
127 | #define IN 0x0001
|
128 |
|
129 |
|
130 | #endif /* LWIP_NBNS */
|
131 |
|
132 | #ifdef __cplusplus
|
133 | }
|
134 | #endif
|
135 |
|
136 | #endif /* __LWIP_NBNS_H__ */
|