📄 odh.c
字号:
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Glen Johnson 03/13/95 Initial version. */
/* */
/****************************************************************************/
int16 NU_Deallocate_Buffer(int16 socketd, char *buffer)
{
struct pqueue HUGE * item;
struct pqueue HUGE * buf_ptr;
int16 return_status;
/* Validate the socket number. */
if ((socketd < 0) || (socketd >= NSOCKETS) ||
(socket_list[socketd] == NU_NULL))
return(NU_INVALID_SOCKET);
/* Make sure that ODH for recv is enabled. */
if (!(socket_list[socketd]->odh_flag & NU_ODH_RECEIVE))
return (NU_ODH_DISABLED);
/* Don't let anyone else in until we are through. */
#ifdef PLUS
NU_Obtain_Semaphore(&TCP_Resource, NU_SUSPEND);
#else
NU_Request_Resource(TCP_Resource, NU_WAIT_FOREVER);
#endif
/* Calculate the starting address of the buffer. */
buf_ptr = (struct pqueue HUGE *)(buffer - sizeof(DLAYER)
- sizeof(IPLAYER)
- sizeof(TCPLAYER)
- PQ_HEADER_SIZE);
/* Search the linked list until item is found or the end of the list
* is reached. */
for(item = odh_list.head; ( (item) && (item != buf_ptr) );
item = item->next)
;
/* If the item was not found then return an error status. */
if (!item) {
return_status = NU_INVALID_BUF_PTR;
}
/* The item was found, so move it from the ODH list to the
buffer_freelist. */
else
{
dll_remove((tqe_t *)&odh_list, (tqe_t *)buf_ptr);
dll_enqueue((tqe_t *)&buffer_freelist, (tqe_t *)buf_ptr);
return_status = NU_SUCCESS;
}
#ifdef PLUS
NU_Release_Semaphore(&TCP_Resource);
#else
NU_Release_Resource(TCP_Resource);
#endif
return(return_status);
} /* end NU_Deallocate_Buffer */
/****************************************************************************/
/* FUNCTION */
/* */
/* NU_ODH_Recv */
/* */
/* DESCRIPTION */
/* */
/* This fuction is responsible for recving data when ODH is being used. */
/* */
/* AUTHOR */
/* */
/* Glen Johnson, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* User Applications */
/* */
/* CALLS */
/* */
/* NU_Recv */
/* */
/* INPUTS */
/* */
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Glen Johnson 03/13/95 Initial version. */
/* */
/****************************************************************************/
int16 NU_ODH_Recv (int16 socketd, char **buff, int16 flags)
{
int32 addr;
int16 bytes_returned;
int16 nbytes = 1;
/* Validate the socket number. */
if ((socketd < 0) || (socketd >= NSOCKETS) ||
(socket_list[socketd] == NU_NULL))
return(NU_INVALID_SOCKET);
/* Make sure that ODH for recv is enabled. */
if (!(socket_list[socketd]->odh_flag & NU_ODH_RECEIVE))
return(NU_ODH_DISABLED);
/* Get the pointer to a buffer. */
bytes_returned = NU_Recv (socketd, (char *)&addr, nbytes, flags);
/* Convert the int32 to a memory address. */
*buff = (char *)addr;
/* return the number of bytes in the buffer. */
return(bytes_returned);
} /* end NU_ODH_Recv */
/******************************************************************************/
/* FUNCTION */
/* */
/* ODH_Init */
/* */
/* DESCRIPTION */
/* */
/* Performs initialization required by the ODH module. */
/* */
/* AUTHOR */
/* */
/* Glen Johnson, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* protinit */
/* */
/* CALLS */
/* */
/* none */
/* */
/* INPUTS */
/* */
/* No inputs to the function */
/* */
/* OUTPUTS */
/* */
/* No outputs from this function */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Glen Johnson 09/26/96 Initial version. */
/* */
/******************************************************************************/
STATUS ODH_Init(VOID)
{
odh_list.head = odh_list.tail = NU_NULL;
return (NU_SUCCESS);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -