Example #1
0
int NCBSubmit(USHORT lana, PNCB Ncb)
{
#if defined(DOS) || defined(WIN32)
  return NetBIOS(Ncb);
#else /* !DOS */
  return (NetBIOS_API == NETBEUI)
         ? NetBIOS_Submit(NetBEUI_Handle[lana], 0, Ncb)
         : NetBIOS(Ncb);
#endif /* DOS */
}
Example #2
0
void RemoteUnLink( void )
{
    NCB     cancel;

    if( NetCtlBlk.ncb_cmd_cplt == 0xff ) {
        cancel.ncb_command = NCBCANCEL;
        cancel.ncb_buffer = (byte _FAR *)&NetCtlBlk;
        cancel.ncb_lana_num = LanaNum;
        cancel.ncb_post = 0;
        NetBIOS( &cancel );
    }
    NetCtlBlk.ncb_command = NCBDELNAME;
    NetBIOS( &NetCtlBlk );
}
Example #3
0
void RemoteDisco( void )
{
    NetCtlBlk.ncb_command = NCBHANGUP;
    NetBIOS( &NetCtlBlk );
#ifdef SERVER
    PostListen();
#endif
}
Example #4
0
trap_retval RemotePut( byte *rec, trap_elen len )
{
    NetCtlBlk.ncb_buffer = rec;
    NetCtlBlk.ncb_length = len;
    NetCtlBlk.ncb_command = NCBSEND;
    NetBIOS( &NetCtlBlk );
    return( NetCtlBlk.ncb_length );
}
Example #5
0
bool RemoteConnect( void )
{
#ifdef SERVER
    if( NetCtlBlk.ncb_cmd_cplt != 0xff ) {
        if( NetCtlBlk.ncb_retcode == NRC_GOODRET )
            return( TRUE );
        PostListen();
    }
#else
    NetCtlBlk.ncb_command = NCBCALL;
    NetBIOS( &NetCtlBlk );
    if( NetCtlBlk.ncb_retcode == NRC_GOODRET )
        return( TRUE );
#endif
    return( FALSE );
}
Example #6
0
/* On traditional NetBIOS 3.0 implementations, only lana numbers 0 and 1 are
 * valid, and lana 0 is almost guaranteed to be the one we want. On Windows NT,
 * things aren't so simple and there's a good chance lana number 0 cannot
 * be used. NT provides an ENUM command which provides a list of the available
 * lana numbers.
 *
 * Of course Microsoft had to go and make people's lives more complicated by
 * requiring DOS applications to use lana enumeration when running under NT
 * but having their own DOS client blow up when the ENUM NCB is submitted on
 * plain DOS. Sigh. We detect running under NT and behave accordingly.
 */
byte GetLanaNum( void )
{
    LANA_ENUM   l_enum;

    if( !SkipEnum ) {
        memset( &NetCtlBlk, 0, sizeof( NetCtlBlk ) );
        NetCtlBlk.ncb_buffer = (byte _FAR *)&l_enum;
        NetCtlBlk.ncb_length = sizeof( l_enum );
        NetCtlBlk.ncb_command = NCBENUM;
        NetBIOS( &NetCtlBlk );
        if( (NetCtlBlk.ncb_retcode == NRC_GOODRET) && l_enum.length ) {
            return( l_enum.lana[0] );
        }
    }
    return( 0 );    /* Default if not running on NT. */
}
Example #7
0
USHORT NCBReset(PNCB Ncb, USHORT lana,
		USHORT sessions, USHORT commands, USHORT names)
{
  int i, rc = NB_INADEQUATE_RESOURCES;

#ifdef OS2
  if (NetBIOS_API == NETBEUI)
  {
    if (!pNetinfo)
      rc = NetBEUI_Config(lana, &sessions, &commands, &names);

    if (pNetinfo)
    {
      if (lana <= Netentries)
      {
	if (pNetinfo[lana].nb1_max_sess >= sessions &&
	    pNetinfo[lana].nb1_max_ncbs >= commands &&
	    pNetinfo[lana].nb1_max_names >= names)
	  rc = NetBIOS_Open(pNetinfo[lana].nb1_net_name,
			       NULL, 1, &NetBEUI_Handle[lana]);
      }
      else
	rc = NB_INVALID_ADAPTER;
    }
  }
  else
#endif /* OS2 */
  {
    memset(Ncb, 0, NCBSIZE);

    Ncb -> reset.ncb_command = NB_RESET_WAIT;
    Ncb -> reset.ncb_lana_num = lana;
    Ncb -> reset.req_sessions = sessions;
    Ncb -> reset.req_commands = commands;
    Ncb -> reset.req_names = names;

    NetBIOS(Ncb);

    rc = Ncb -> reset.ncb_retcode;
  }

  return rc;
}
Example #8
0
USHORT NCBClose(PNCB Ncb, USHORT lana)
{
  USHORT rc;

#ifdef OS2
  if (NetBIOS_API == NETBEUI)
  {
    if (NetBEUI_Handle[lana])
      rc = NetBIOS_Close(NetBEUI_Handle[lana], 0);
    else
      rc = NB_ENVIRONMENT_NOT_DEFINED;
  }
  else
#endif /* OS2 */
  {
    memset (Ncb, 0, NCBSIZE);
    Ncb -> reset.ncb_command = NB_RESET_WAIT;
    Ncb -> reset.ncb_lsn = 255;
    Ncb -> reset.ncb_lana_num = lana;
    rc = NetBIOS(Ncb);
  }

  return rc;
}
Example #9
0
char *RemoteLink( char *name, bool server )
{
    unsigned    i;

    server = server;
    if( name == NULL || *name == '\0' )
        name = DefLinkName;
#if defined(__OS2__)
  #if defined(__386__)
    {
        HMODULE hmod;

        if( DosLoadModule( NULL, 0, "NETAPI32", &hmod ) != 0 ) {
            return( NotThere );
        }
        if( DosQueryProcAddr( hmod, 0, "NetBios32Submit", (PFN*)&NetBiosSubmit ) != 0 ) {
            return( NotThere );
        }
    }
  #else
    {
        HMODULE hmod;

        if( DosLoadModule( NULL, 0, "NETAPI", &hmod ) != 0 ) {
            return( NotThere );
        }
        if( DosGetProcAddr( hmod, "NETBIOSSUBMIT", &NetBiosSubmit ) != 0 ) {
            return( NotThere );
        }
    }
  #endif
#elif !defined( __WINDOWS__ ) && !defined( __NT__ )
    {
        byte                *net_bios;
        tiny_dos_version    dos_ver;
        int                 is_nt = 0;

        net_bios = (void *)TinyGetVect( NET_BIOS_INT );
        if( net_bios == 0 || *net_bios == 0xcf ) {
            return( NotThere );
        }

        /* Check if running under NT; based on MS KB 100290. */
        dos_ver = GetTrueDOSVersion();
        if( dos_ver.major == 5 && dos_ver.minor == 50 )
            is_nt = 1;
        if( !is_nt )
            SkipEnum = 1;
    }
#endif
    NetCtlBlk.ncb_command = NET_INVALID_CMD;
    NetBIOS( &NetCtlBlk );
    if( NetCtlBlk.ncb_retcode != NRC_ILLCMD ) {
        return( NotThere );
    }

    LanaNum = GetLanaNum();

    /* NetBIOS reset is required on NT, but kills connections on DOS. */
#ifdef __NT__
    memset( &NetCtlBlk, 0, sizeof( NetCtlBlk ) );
    NetCtlBlk.ncb_command = NCBRESET;
    NetCtlBlk.ncb_lana_num = LanaNum;
    NetBIOS( &NetCtlBlk );
    if( NetCtlBlk.ncb_retcode != NRC_GOODRET ) {
        return( NotThere );
    }
#endif

    memset( &NetCtlBlk, 0, sizeof( NetCtlBlk ) );
    for( i = 1; i < NCBNAMSZ; ++i ) {
        NetCtlBlk.ncb_name[i] = (*name != '\0') ? *name++ : ' ';
    }
    NetCtlBlk.ncb_name[0] = ( server ) ? 'S' : 'C';
    NetCtlBlk.ncb_command = NCBADDNAME;
    NetCtlBlk.ncb_lana_num = LanaNum;
    NetBIOS( &NetCtlBlk );
    if( NetCtlBlk.ncb_retcode == NRC_DUPNAME || NetCtlBlk.ncb_retcode == NRC_INUSE ) {
        return( TRP_ERR_server_name_already_in_use );
    } else if( NetCtlBlk.ncb_retcode != NRC_GOODRET ) {
        return( TRP_ERR_NetBIOS_name_add_failed ); 
    }
    memcpy( NetCtlBlk.ncb_callname, NetCtlBlk.ncb_name, NCBNAMSZ );
    NetCtlBlk.ncb_callname[0] = ( !server ) ? 'S' : 'C';
    if( server ) {
        if( !PostListen() ) {
            return( TRP_ERR_can_not_start_server );
        }
    }
    return( NULL );
}
Example #10
0
static char PostListen( void )
{
    NetCtlBlk.ncb_command = NCBLISTEN | ASYNCH;
    return( NetBIOS( &NetCtlBlk ) == 0 );
}