⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.c

📁 mcf5307实验源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*************************************************************************/
/*                                                                       */
/*       CopyrIght (c)  1993 - 1996 Accelerated Technology, Inc.         */
/*                                                                       */
/* PROPRIETARY RIGHTS of Accelerated Technology are involved in the      */
/* subject matter of this material.  All manufacturing, reproduction,    */
/* use, and sales rights pertaining to this subject matter are governed  */
/* by the license agreement.  The recipient of this software implicitly  */
/* accepts the terms of the license.                                     */
/*                                                                       */
/*************************************************************************/
/*
*
* Portions of this program were written by:       */
/*****************************************************************************
*                                                                           *
*     part of:                                                              *
*    TCP/IP kernel for NCSA Telnet                                          *
*     by Tim Krauskopf                                                      *
*                                                                           *
*     National Center for Supercomputing Applications                       *
*     152 Computing Applications Building                                   *
*     605 E. Springfield Ave.                                               *
*     Champaign, IL  61820                                                  *
*/
/****************************************************************************/
/*                                                                          */
/* FILENAME                                                 VERSION         */
/*                                                                          */
/*  util.c                                                     3.2          */
/*                                                                          */
/* DESCRIPTION                                                              */
/*                                                                          */
/*  Session interface routines                                              */
/*                                                                          */
/*                                                                          */
/* FUNCTIONS                                                                */
/*                                                                          */
/*  Snetinit                                                                */
/*  Smadd                                                                   */
/*  Slookip                                                                 */
/*  Shostlook                                                               */
/*  Snetopen                                                                */
/*  Stimerset                                                               */
/*  Stimerunset                                                             */
/*  Ssessioninit                                                            */
/*                                                                          */
/*                                                                          */
/* HISTORY                                                                  */
/*                                                                          */
/*	NAME				DATE		REMARKS 								*/
/*                                                                          */
/* Maiqi Qian      12/06/96         Fixed the time wrap up (spr0229)        */
/*                                                                          */
/****************************************************************************/
#include "hostform.h"
#include "protocol.h"
#include "data.h"
#include "target.h"
#include "externs.h"
#include "confile.h"
#ifdef PLUS
	#include "nucleus.h"
#else
	#include "nu_defs.h"    /* added during ATI mods - 10/20/92, bgh */
	#include "nu_extr.h"
#endif
#include "tcp.h"
#include "tcpdefs.h"
#include "tcp_errs.h"
#include "netevent.h"

extern const uint IN_TCP_IP_Host;       /* offset into machine def array */
extern struct machinfo defmachinfo [];	/* list of possible servers */

#ifdef PLUS
  extern NU_TASK           NU_EventsDispatcher_ptr;
#endif

uint my_current_time = 55555555;

/* Local Prototypes */
static  int16 Ssessioninit(void);
STATUS clear_matching_timer (struct tqhdr *tlist, UNSIGNED class,
                             UNSIGNED event, UNSIGNED dat, int32 ack_num);

/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      Snetinit(void)                                                   */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*   Handle all the network initialization, including reading up the     */
/*   config file.  This also starts up the hardware and gets arps on     */
/*   their merry way.                                                    */
/*                                                                       */
/* CALLED BY                                                             */
/*      NU_Init_Net                                                      */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      Ssessioninit                                                     */
/*      netsetip                                                         */
/*      netsetbroad                                                      */
/*      netinit                                                          */
/*      netgetip                                                         */
/*      comparen                                                         */
/*      netgetrarp                                                       */
/*      netarpme                                                         */
/*      Ssetgates                                                        */
/*                                                                       */
/*************************************************************************/
int16 Snetinit (void)
{
    int16 i;

    /* initialize the system clock */
    init_time ();

    /*  Copy the default information about potential hosts into the
        machine list.  */
    i = Ssessioninit ();

    /*  Set up nnipnum which will be globally throughout the system to
        identify us.  Scon is set up in TCPVARS.C.  */
    netsetip (Scon.myipnum);

    /*  Set the global broadcast address.  */

    /*  Initialize the drivers and the protocol stack templates.  */
    if ((i = netinit ()) == 0)
    {

        /*  Pick up our IP number.  It will be placed in Scon.myipnum.  */
        netgetip (Scon.myipnum);

#if 0
        /*  Check for the need to RARP and do it. */
        if (comparen (Scon.myipnum, "RARP", 4))
        {
            if (netgetrarp ())  /* stores in nnipnum at lower layer */
                return (-2);          /* failure return */
            netgetip (Scon.myipnum);
            netsetip (Scon.myipnum);
        }
#endif /* if 0 */

#ifndef POINT_TO_POINT
        /*  Give the lower layers a chance to check to see if anyone else
         *  is using the same ip number.  Usually generates an ARP packet.
         *  But first check to see if we have a valid IP number bootp.
         *  If the IP number is not valid, it is assumed that this is
         *  beacause either bootp or RARP will be used after initialization to
         *  obtain the correct IP number.
         */
        if (memcmp ((void *)Scon.myipnum, (void *)nullip, 4) != 0)
        {
            //netarpme (Scon.myipnum);   //  NO ARP
        }
#endif


        Ssetgates ();            /* finishes IP inits */
        return (NU_SUCCESS);

    }

    /* netinit() failed -- return the value specified by netinit */
    return (i);
}

/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      Smadd(int8 *)                                                    */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*   If machine is there, just returns pointer, else                     */
/*   Add a machine to the list. Increments machine number of machine.    */
/*   Puts in parameters copied from the "default" entry.                 */
/*                                                                       */
/* CALLED BY                                                             */
/*      parse_bootpacket                                                 */
/*      NU_Connect                                                       */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      Shostlook                                                        */
/*      NU_Allocate_Memory                                               */
/*      Scopyfrom                                                        */
/*                                                                       */
/*************************************************************************/
struct machinfo *Smadd(int8 *mname)
{
    int16 i;
	struct machinfo *m;
	/* added during ATI mods - 10/1/92, bgh */
#ifdef PLUS
    STATUS  status;
#else
    sint status;              /* status of memory allocation */
#endif
	uint *return_ptr;		/* pointer to memory block */

	/*
	*  First, do we have the name already?
	*/
	m = Shostlook (mname);
	if (m)
		return (m);

    /* added during ATI mods - 10/1/92, bgh */
#ifdef PLUS
    status = NU_Allocate_Memory(&System_Memory, (void *) &return_ptr,
                                (UNSIGNED)sizeof(struct machinfo),
                                (UNSIGNED)NU_NO_SUSPEND);
#else
    status = NU_Alloc_Memory (sizeof(struct machinfo),
                              (unsigned int **)&return_ptr, NU_WAIT_FOREVER);
#endif

    /* check status of memory allocation */
	if (status == NU_SUCCESS)
	{
        return_ptr = normalize_ptr(return_ptr);
        Smptr = (struct machinfo *)return_ptr;
	}
	else
	{
        NU_Tcp_Log_Error (TCP_SESS_MEM, TCP_RECOVERABLE, __FILE__, __LINE__);
        return (NU_NULL);
	}
	for (i = 0; i < (NUMSPECS - 99); i++)
	{
		Sflags[i] = 0;				   /* we have no parms */
	}
	Scopyfrom ("default");
    Smptr->sname[0] = 0;

    strcpy ((int8 *)&Smptr->hname, mname);     /* copy in name of machine */
    Smptr->mno = (uint16)++mno;
	Smptr->mstat = NOIP;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -