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

📄 util.c

📁 mcf5307实验源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*   class/event/dat.                                                    */
/*                                                                       */
/* CALLED BY                                                             */
/*      Stimerunset                                                      */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      dll_dequeue                                                      */
/*      dll_insert                                                       */
/*      dll_remove                                                       */
/*      dll_enqueue                                                      */
/*                                                                       */
/*************************************************************************/
STATUS clear_matching_timer (struct tqhdr *tlist, UNSIGNED class,
                             UNSIGNED event, UNSIGNED dat, int32 ack_num)
{
    tqe_t *ent,      /* Points to the current entry in the queue. */
          *tmpent,   /* Points to the item being promoted from the duplist. */
          *savent;   /* Preserves our position in the queue. */

    /* Search the list for matching timers. */
    for (ent = tlist->flink; ent; )
    {
      /* Does this match the entry we are looking for. */
      if ( (ent->tqe_class == class) && (ent->tqe_event == event) &&
           (ent->tqe_data == dat)    && (INT32_CMP(ack_num, ent->tqe_ext_data) > 0) )
      {
          /* We have found a matching entry.  Preserve a pointer to the next
           * entry. */
          savent = ent->flink;

          /* If this entry contains a duplist we need to search it to. */
          if (ent->duplist.flink)
          {
             /* Search the duplist for a match. */
             clear_matching_timer(&ent->duplist, class, event, dat, ack_num);

             /* Pull the first item, if one exists, off the duplist. */
             tmpent = dll_dequeue((tqe_t *)&ent->duplist);

             /* If the duplist still contained an item after we cleared it,
              * we want to promote one. */
             if(tmpent)
             {
                 /* Promote this item to the position that was held by the item
                  * we are removing. */
                 tmpent->duplist.flink = tmpent->flink;
                 tmpent->duplist.blink = ent->duplist.blink;
                 if (tmpent)
                     dll_insert((tqe_t *)tlist, tmpent, ent);
             }
          }

          /* Remove the item. */
          dll_remove((tqe_t *)tlist, ent);

          /* Place the item back on the free list. */
          dll_enqueue((tqe_t *)&tcptimer_freelist, ent);

          /* Point to the next item to be checked. */
          ent = savent;
      }
      else
      {
          /* We did not find a match.  Clear the duplist if it exists. */
          if (ent->duplist.flink)
          {
              clear_matching_timer(&ent->duplist, class, event, dat, ack_num);
          }

          /* Point to the next item to be checked. */
          ent = ent->flink;
      }
    }

  return (NU_SUCCESS);
}  /* end clear_matching_timer */


/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      Ssessioninit()                                                   */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*   Initializes a struct machinfo during setup.  These entries are      */
/*   associated with a session and may be established multiple times.    */
/*                                                                       */
/* CALLED BY                                                             */
/*      Snetinit                                                         */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*      NU_Allocate_Memory                                               */
/*                                                                       */
/*************************************************************************/
static int16 Ssessioninit()
{
    /* 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 */
	uint  init = IN_TCP_IP_Host;  /* contains the machine with which
                                             a connection will be
                                             established */

    /********************************************************************
    *                                                                   *
    *   The following code sets up a machine table which defines all    *
    *   of the parameters for a prospective host.  The data is copied   *
    *   from a predefined table (defmachinfo) found in INITDATA.H.      *
    *   All modifications to initial values for prospective hosts       *
    *   should be made in that file and not here.                       *
    *                                                                   *
    ********************************************************************/

    /*  Allocate memory for a machine list entry.  */
    if (Smachlist == NU_NULL)
    {
        /*  Allocate memory for a machine list entry.  The machine list
            contains information on hosts to which we will be dealing with.
            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);
            Smachlist = (struct machinfo *)return_ptr;
        }
        else
        {
            NU_Tcp_Log_Error (TCP_SESS_MEM, TCP_RECOVERABLE,
							  __FILE__, __LINE__);
            return (0);                /* don't die - helps backward
                                         compatibility */
        }

        /*  Set up pointer to currently used machinelist entry.  */
        Smptr = Smachlist;
    }   /*  Allocate memory for a machine list entry.  */

    /*  Move the session name from the predefined table into the current
        table.  */
    strcpy ((int8 *)&Smptr->sname, (const char *)&defmachinfo[init].sname);

    /*  Copy the host name from the predefined table into the current
        table.  */
    strcpy ((int8 *)&Smptr->hname, (const int8 *)&defmachinfo[init].hname);       /* host name */

    /*  Get the Host IP number from the predefined table.  */
    memcpy(Smptr->hostip.is_ip_addrs, defmachinfo[init].hostip.is_ip_addrs, 4);

    /*  Get the value to determine if this host is a gateway from the
        predefined table.  */
    Smptr->gateway = defmachinfo[init].gateway;

    /*  Get the value to determine if this host is a nameserver from the
     *  predefined table.
     */
    Smptr->nameserv = defmachinfo[init].nameserv;

    /*  Get the value to determine if this host runs in half duplex mode
     *  from the predefined table.  Generally only true if the machine is
     *  an IBM machine.
     */
    Smptr->halfdup = defmachinfo[init].halfdup;

    /*  Get the TELNET port number for this host from the predefined table,
        it should always be 23.  */
    Smptr->port = defmachinfo[init].port;

	/* machine number */
	Smptr->mno = defmachinfo[init].mno;

	/* status of this machine entry */
	Smptr->mstat = defmachinfo[init].mstat;

    /*  Get the default retransmit time from the predefined host table.  */
    Smptr->retrans = defmachinfo[init].retrans;

    /*  Get the maximum timeout value for connections from the predefined
        table.  The value is maintained in seconds.  */
    Smptr->conto = defmachinfo[init].conto;

    /*  Get the initial transmit window size from the predefined table.  */
    Smptr->window = defmachinfo[init].window;

    /*  Get the maximum size of a buffer from the predefined table.  */
    Smptr->maxseg = defmachinfo[init].maxseg;

    /*  Get the maximum transfer unit from the predefined table.  */
    Smptr->mtu = defmachinfo[init].mtu;

    /*  Clear out the pointer to the next link in the chain of machine
        list pointers.  */
    Smptr->next = 0;

    /*  Always successful. */
    return (0);
}

#ifndef MSC
/*************************************************************************/
/*                                                                       */
/* FUNCTION                                                              */
/*                                                                       */
/*      NU_TCP_Time                                                      */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*                                                                       */
/* CALLED BY                                                             */
/*      init_time                                                        */
/*                                                                       */
/* CALLS                                                                 */
/*                                                                       */
/*                                                                       */
/*************************************************************************/
long    NU_TCP_Time(uint32 *current_time)
{
    long    tcp_current_time;

    tcp_current_time = my_current_time;

    if (current_time != NU_NULL)
        *current_time = my_current_time;

    return(tcp_current_time);
}
#endif /* MSC */

⌨️ 快捷键说明

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