📄 dll.c
字号:
/*************************************************************************/
/* */
/* 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. */
/* */
/*************************************************************************/
/*************************************************************************/
/* */
/* FILE NAME VERSION */
/* */
/* DLL.C NET 3.2 */
/* */
/* */
/* DESCRIPTION */
/* */
/* Linked list routines used by tcp/ip */
/* */
/* FUNCTIONS */
/* */
/* dll_insert Address resolution */
/* dll_enqueue Send out an arp request packet */
/* dll_dequeue Interpret ARP Packets */
/* dll_remove Request local IP number */
/* dll_cleanup Clear a list. */
/* */
/* DEPENDENCIES */
/* */
/* externs.h External definitions for functions in NCSA */
/* Telnet. */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* */
/*************************************************************************/
/*
* These routines all reference a linked-list header, used to point to
* a particular list. Each entry in the list is prefixed by two pointer
* values, namely a forward pointer and a backward pointer:
*
* struct *flink,*blink;
* <Application-specific structure fields>
* .
* .
* .
* <end of structure>
*
* Internally, the linked list routines operate on only the first two
* entries in the structure, the "flink" or forward link, and the "blink"
* the backward link.
*
* A linked list header that identifies the beginning of a particular list
* is a single pointer value. This pointer value contains a pointer to
* the first entry ("head") on the list. The "blink" value of the first entry
* on the list points to the last entry on the list.
*/
#include "protocol.h"
#include "tcpdefs.h"
#include "socketd.h"
#include "externs.h"
#include "data.h"
#include "tcp_errs.h"
uint16 count_trans = 0;
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* dll_insert */
/* */
/* DESCRIPTION */
/* */
/* Insert an item into a linked list just before lpos. */
/* */
/* CALLED BY */
/* tqpost */
/* */
/* CALLS */
/* */
/* none */
/* */
/*************************************************************************/
tqe_t *dll_insert(tqe_t *hdr, tqe_t *item, tqe_t *lpos)
{
/* Make item's flink point to lpos */
item->flink = lpos;
/* Set item's blink to point to the node that currently precedes lpos */
item->blink = lpos->blink;
/* If there is already a node in front of lpos, we want its flink to
* point to item.
*/
if (lpos->blink)
lpos->blink->flink = item;
/* Set lpos's blink to point at item */
lpos->blink = item;
/* If lpos was the first node in the linked list. We need to make
* hdr's flink point to item, which is the new first node.
*/
if (lpos == hdr->flink)
hdr->flink = item;
return(item);
}
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* dll_enqueue */
/* */
/* DESCRIPTION */
/* */
/* Insert an item at the end of a linked list. */
/* */
/* CALLED BY */
/* NU_EventsDispatcher */
/* tqpost */
/* Stimerunset */
/* */
/* CALLS */
/* */
/* none */
/* */
/*************************************************************************/
tqe_t *dll_enqueue(tqe_t *hdr, tqe_t *item)
{
#ifdef PLUS
INT old_level;
#else
int old_level;
#endif
/* Temporarily lockout interrupts to protect the global buffer variables. */
old_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS);
//Tao_SaveOldSR();
/* Set item's flink to point at NULL */
item->flink = (tqe_t *)NU_NULL;
/* If there is currently a node in the linked list, we want add
* item after that node
*/
if (hdr->flink) {
/* Make the last node's flink point to item */
hdr->blink->flink = item;
/* Make item's blink point to the old last node */
item->blink = hdr->blink;
/* Make hdr's blink point to the new last node, item */
hdr->blink = item;
}
/* if the linked list was empty, we want both the hdr's flink and
* the hdr's blink to point to item. Both of item's links will
* point to NULL, as there are no other nodes in the list
*/
else {
hdr->flink = hdr->blink = item;
item->blink = (tqe_t *)NU_NULL;
}
/* If a buffer is being moved back onto the buffer free list, then decrement
the the number of buffers that are currently used. */
if ((hdr == (tqe_t *)&buffer_freelist) && (item != (tqe_t*)NU_NULL))
{
Buffers_Used--;
}
/* Restore the previous interrupt lockout level. */
NU_Control_Interrupts(old_level);
//Tao_LoadOldSR();
return(item);
} /* end dll_enqueue */
/*************************************************************************/
/* */
/* FUNCTION */
/* */
/* dll_dequeue */
/* */
/* DESCRIPTION */
/* */
/* Remove and return the first node in a linked list. */
/* */
/* CALLED BY */
/* NU_EventsDispatcher */
/* Stimerset */
/* Stimerunset */
/* dll_remove */
/* */
/* CALLS */
/* */
/* none */
/* */
/*************************************************************************/
tqe_t *dll_dequeue(tqe_t *hdr)
{
tqe_t *ent;
#ifdef PLUS
INT old_level;
#else
int old_level;
#endif
/* Temporarily lockout interrupts to protect the global buffer variables. */
old_level = NU_Control_Interrupts(NU_DISABLE_INTERRUPTS);
// Tao_SaveOldSR();
/* Create a pointer to the first node in the linked list */
ent = hdr->flink;
/* If there is a node in the list we want to remove it. */
if (ent) {
/* Make the hdr point the second node in the list */
hdr->flink = ent->flink;
/* If there was a second node, we want that node's blink to at 0. */
if (hdr->flink)
hdr->flink->blink = (tqe_t *)0;
/* Is a buffer being removed from the buffer_freelist. If so increment
the buffers_used conter. */
if (hdr == (tqe_t *)&buffer_freelist)
{
Buffers_Used++;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -