[gPXE] [PATCH 4/4] [proto] Remove unsupported NMB protocol

Stefan Hajnoczi stefanha at gmail.com
Sat Jan 30 05:15:20 EST 2010


The NMB protocol code came from legacy Etherboot and was never updated
to work as a gPXE protocol.  There has been no demand for this protocol,
so this patch removes it.

Signed-off-by: Stefan Hajnoczi <stefanha at gmail.com>
---
 src/config/config.c  |    3 -
 src/config/general.h |    1 -
 src/include/nmb.h    |   22 ----------
 src/proto/nmb.c      |  110 --------------------------------------------------
 4 files changed, 0 insertions(+), 136 deletions(-)
 delete mode 100644 src/include/nmb.h
 delete mode 100644 src/proto/nmb.c

diff --git a/src/config/config.c b/src/config/config.c
index dd3b09a..a6e7622 100644
--- a/src/config/config.c
+++ b/src/config/config.c
@@ -146,9 +146,6 @@ REQUIRE_OBJECT ( ib_srpboot );
 #ifdef DNS_RESOLVER
 REQUIRE_OBJECT ( dns );
 #endif
-#ifdef NMB_RESOLVER
-REQUIRE_OBJECT ( nmb );
-#endif
 
 /*
  * Drag in all requested image formats
diff --git a/src/config/general.h b/src/config/general.h
index 3501846..0a9e625 100644
--- a/src/config/general.h
+++ b/src/config/general.h
@@ -83,7 +83,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
  */
 
 #define	DNS_RESOLVER		/* DNS resolver */
-#undef	NMB_RESOLVER		/* NMB resolver */
 
 /*
  * Image types
diff --git a/src/include/nmb.h b/src/include/nmb.h
deleted file mode 100644
index 3e551ff..0000000
--- a/src/include/nmb.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef NMB_H
-#define NMB_H
-
-#include <gpxe/dns.h>
-
-/*
- * NetBIOS name query packets are basically the same as DNS packets,
- * though the resource record format is different.
- *
- */
-
-#define DNS_TYPE_NB		0x20
-#define DNS_FLAG_BROADCAST	( 0x01 << 4 )
-#define NBNS_UDP_PORT		137
-
-struct dns_rr_info_nb {
-	struct dns_rr_info info;
-	uint16_t	nb_flags;
-	struct in_addr	nb_address;
-} __attribute__ (( packed ));
-
-#endif /* NMB_H */
diff --git a/src/proto/nmb.c b/src/proto/nmb.c
deleted file mode 100644
index e1fc911..0000000
--- a/src/proto/nmb.c
+++ /dev/null
@@ -1,110 +0,0 @@
-#if 0
-
-#include "resolv.h"
-#include "string.h"
-#include <gpxe/dns.h>
-#include "nic.h"
-#include "nmb.h"
-
-/*
- * Convert a standard NUL-terminated string to an NBNS query name.
- *
- * Returns a pointer to the character following the constructed NBNS
- * query name.
- *
- */
-static inline char * nbns_make_name ( char *dest, const char *name ) {
-	char nb_name[16];
-	char c;
-	int i;
-	uint16_t *d;
-
-	*(dest++) = 32; /* Length is always 32 */
-
-	/* Name encoding is as follows: pad the name with spaces to
-	 * length 15, and add a NUL.  Take this 16-byte string, split
-	 * it into nibbles and add 0x41 to each nibble to form a byte
-	 * of the resulting name string.
-	 */
-	memset ( nb_name, ' ', 15 );
-	nb_name[15] = '\0';
-	memcpy ( nb_name, name, strlen ( name ) ); /* Do not copy NUL */
-
-	d = ( uint16_t * ) dest;
-	for ( i = 0 ; i < 16 ; i++ ) {
-		c = nb_name[i];
-		*( d++ )  = htons ( ( ( c | ( c << 4 ) ) & 0x0f0f ) + 0x4141 );
-	}
-	dest = ( char * ) d;
-
-	*(dest++) = 0; /* Terminating 0-length name component */
-	return dest;
-}
-
-/*
- * Resolve a name using NMB
- *
- */
-static int nmb_resolv ( struct in_addr *addr, const char *name ) {
-	struct dns_query query;
-	struct dns_query_info *query_info;
-	struct dns_header *reply;
-	struct dns_rr_info *rr_info;
-	struct dns_rr_info_nb *rr_info_nb;
-	struct sockaddr_in nameserver;
-
-	DBG ( "NMB resolving %s\n", name );
-
-	/* Set up the query data */
-	nameserver.sin_addr.s_addr = INADDR_BROADCAST;
-	nameserver.sin_port = NBNS_UDP_PORT;
-	memset ( &query, 0, sizeof ( query ) );
-	query.dns.id = htons ( 1 );
-	query.dns.flags = htons ( DNS_FLAG_QUERY | DNS_FLAG_OPCODE_QUERY |
-				  DNS_FLAG_RD | DNS_FLAG_BROADCAST );
-	query.dns.qdcount = htons ( 1 );
-	query_info = ( void * )	nbns_make_name ( query.payload, name );
-	query_info->qtype = htons ( DNS_TYPE_NB );
-	query_info->qclass = htons ( DNS_CLASS_IN );
-
-	/* Issue query, wait for reply */
-	reply = dns_query ( &query,
-			    ( ( ( char * ) query_info )
-			      + sizeof ( *query_info )
-			      - ( ( char * ) &query ) ),
-			    &nameserver );
-	if ( ! reply ) {
-		DBG ( "NMB got no response via %@ (port %d)\n",
-		      nameserver.sin_addr.s_addr,
-		      nameserver.sin_port );
-		return 0;
-	}
-
-	/* Search through response for useful answers. */
-	rr_info = dns_find_rr ( &query, reply );
-	if ( ! rr_info ) {
-		DBG ( "NMB got invalid response\n" );
-		return 0;
-	}
-
-	/* Check type of response */
-	if ( ntohs ( rr_info->type ) != DNS_TYPE_NB ) {
-		DBG ( "NMB got answer type %hx (wanted %hx)\n",
-		      ntohs ( rr_info->type ), DNS_TYPE_NB );
-		return 0;
-	}
-
-	/* Read response */
-	rr_info_nb = ( struct dns_rr_info_nb * ) rr_info;
-	*addr = rr_info_nb->nb_address;
-	DBG ( "NMB found address %@\n", addr->s_addr );
-
-	return 1;
-}
-
-struct resolver nmb_resolver __resolver = {
-	.name = "NMB",
-	.resolv = nmb_resolv,
-};
-
-#endif
-- 
1.6.5



More information about the gPXE mailing list