nb_ssn.c revision 15359501f7d4b9abebd7b7bf6efd5982a8e7eb27
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/*
* NetBIOS session service functions
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <libintl.h>
#include <xti.h>
#include <assert.h>
#include "private.h"
#include "charsets.h"
static int nb_ssn_pollin(struct smb_ctx *, int);
/*
* Send a data message.
*/
int
{
}
/*
* Send a NetBIOS message, after
* prepending the 4-byte header.
*/
static int
{
mbuf_t *m;
int err;
if (m == NULL)
return (EINVAL);
/*
* Prepend the NetBIOS header.
* Our mbufs leave space for this.
*/
m->m_data -= 4;
m->m_len += 4;
/*
* Get contiguous data (so TCP won't fragment)
* Note: replaces mb_top.
*/
if (err)
return (err);
/*
* Send it.
*/
else
return (err);
}
return (0);
}
/*
* Receive a data message. Discard anything else.
* Caller must deal with EAGAIN, EINTR.
*/
int
{
if (err)
return (err);
if (mtype != NB_SSN_MESSAGE) {
return (EAGAIN);
}
if (mlen == 0) {
DPRINT("zero length");
return (EAGAIN);
}
return (0);
}
/*
* Receive a NetBIOS message, any type.
* Give caller type and length.
*/
static int
{
char *buf;
/*
* Start by getting the header
* (four bytes)
*/
return (err);
}
moreflag = 0;
if (cnt < 0) {
return (err);
}
return (EPROTO);
}
/*
* Decode the header, get the length.
*/
if (mlen == 0)
return (0);
/*
* Get a message buffer, read the payload
*/
return (err);
while (len > 0) {
if (!moreflag) {
return (err);
}
}
moreflag = 0;
if (cnt < 0) {
return (err);
}
}
return (0);
}
int
get_xti_err(int fd)
{
int look;
return (errno);
switch (look) {
case T_DISCONNECT:
return (ECONNRESET);
case T_ORDREL:
/* Received orderly release indication */
/* Send orderly release indicator */
return (ECONNRESET);
}
}
return (EPROTO);
}
/*
* Wait for data we can receive.
* Timeout is mSec., as for poll(2)
*/
static int
{
switch (cnt) {
case 0:
break;
case -1:
break;
default:
err = 0;
break;
}
return (err);
}
/*
* Send a NetBIOS session request and
* wait for the response.
*/
int
{
char *ucwks;
goto errout;
goto errout;
}
/* Local NB name. */
/* Server NB name */
/*
* Build the request. Header is prepended later.
*/
goto errout;
goto errout;
/*
* Send it, wait for the reply.
*/
if (err) {
goto errout;
}
if (err) {
goto errout;
}
if (mtype != NB_SSN_POSRESP) {
err = ECONNREFUSED;
goto errout;
}
return (0);
return (err);
}