nb.c (87867) | nb.c (150802) |
---|---|
1/* 2 * Copyright (c) 2000, 2001 Boris Popov 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * $Id: nb.c,v 1.4 2001/04/16 04:33:01 bp Exp $ | 1/* 2 * Copyright (c) 2000, 2001 Boris Popov 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 16 unchanged lines hidden (view full) --- 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * $Id: nb.c,v 1.4 2001/04/16 04:33:01 bp Exp $ |
33 * $FreeBSD: head/contrib/smbfs/lib/smb/nb.c 150802 2005-10-02 08:32:49Z bp $ |
|
33 */ 34#include <sys/param.h> 35#include <sys/socket.h> 36 37#include <ctype.h> 38#include <netdb.h> 39#include <err.h> 40#include <errno.h> --- 11 unchanged lines hidden (view full) --- 52nb_ctx_create(struct nb_ctx **ctxpp) 53{ 54 struct nb_ctx *ctx; 55 56 ctx = malloc(sizeof(struct nb_ctx)); 57 if (ctx == NULL) 58 return ENOMEM; 59 bzero(ctx, sizeof(struct nb_ctx)); | 34 */ 35#include <sys/param.h> 36#include <sys/socket.h> 37 38#include <ctype.h> 39#include <netdb.h> 40#include <err.h> 41#include <errno.h> --- 11 unchanged lines hidden (view full) --- 53nb_ctx_create(struct nb_ctx **ctxpp) 54{ 55 struct nb_ctx *ctx; 56 57 ctx = malloc(sizeof(struct nb_ctx)); 58 if (ctx == NULL) 59 return ENOMEM; 60 bzero(ctx, sizeof(struct nb_ctx)); |
61 ctx->nb_nmbtcpport = NMB_TCP_PORT; 62 ctx->nb_smbtcpport = SMB_TCP_PORT; 63 |
|
60 *ctxpp = ctx; 61 return 0; 62} 63 64void 65nb_ctx_done(struct nb_ctx *ctx) 66{ 67 if (ctx == NULL) --- 38 unchanged lines hidden (view full) --- 106 struct sockaddr *sap; 107 int error; 108 109 ctx->nb_flags &= ~NBCF_RESOLVED; 110 111 if (ctx->nb_nsname == NULL) { 112 ctx->nb_ns.sin_addr.s_addr = htonl(INADDR_BROADCAST); 113 } else { | 64 *ctxpp = ctx; 65 return 0; 66} 67 68void 69nb_ctx_done(struct nb_ctx *ctx) 70{ 71 if (ctx == NULL) --- 38 unchanged lines hidden (view full) --- 110 struct sockaddr *sap; 111 int error; 112 113 ctx->nb_flags &= ~NBCF_RESOLVED; 114 115 if (ctx->nb_nsname == NULL) { 116 ctx->nb_ns.sin_addr.s_addr = htonl(INADDR_BROADCAST); 117 } else { |
114 error = nb_resolvehost_in(ctx->nb_nsname, &sap); | 118 error = nb_resolvehost_in(ctx->nb_nsname, &sap, ctx->nb_smbtcpport); |
115 if (error) { 116 smb_error("can't resolve %s", error, ctx->nb_nsname); 117 return error; 118 } 119 if (sap->sa_family != AF_INET) { 120 smb_error("unsupported address family %d", 0, sap->sa_family); 121 return EINVAL; 122 } 123 bcopy(sap, &ctx->nb_ns, sizeof(ctx->nb_ns)); 124 free(sap); 125 } | 119 if (error) { 120 smb_error("can't resolve %s", error, ctx->nb_nsname); 121 return error; 122 } 123 if (sap->sa_family != AF_INET) { 124 smb_error("unsupported address family %d", 0, sap->sa_family); 125 return EINVAL; 126 } 127 bcopy(sap, &ctx->nb_ns, sizeof(ctx->nb_ns)); 128 free(sap); 129 } |
126 ctx->nb_ns.sin_port = htons(137); | 130 ctx->nb_ns.sin_port = htons(ctx->nb_nmbtcpport); |
127 ctx->nb_ns.sin_family = AF_INET; 128 ctx->nb_ns.sin_len = sizeof(ctx->nb_ns); 129 ctx->nb_flags |= NBCF_RESOLVED; 130 return 0; 131} 132 133/* 134 * used level values: --- 57 unchanged lines hidden --- | 131 ctx->nb_ns.sin_family = AF_INET; 132 ctx->nb_ns.sin_len = sizeof(ctx->nb_ns); 133 ctx->nb_flags |= NBCF_RESOLVED; 134 return 0; 135} 136 137/* 138 * used level values: --- 57 unchanged lines hidden --- |