📄 odh.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 implicity accepts the terms */
/* of the license. */
/* */
/****************************************************************************/
/****************************************************************************/
/* */
/* FILENAME VERSION */
/* */
/* sockets.c 3.2 */
/* */
/* DESCRIPTION */
/* */
/* This file defines our interface to the functions using the Berkely */
/* socket standard TCP/IP interface. */
/* */
/* AUTHOR */
/* */
/* Craig L. Meredith, Accelerated Technology Inc. */
/* */
/* DATA STRUCTURES */
/* */
/* global compenent data stuctures defined in this file */
/* */
/* FUNCTIONS */
/* */
/* NU_Allocate_Buffer */
/* NU_Deallocate_Buffer */
/* NU_ODH_Recv */
/* */
/* DEPENDENCIES */
/* */
/* No other file dependencies */
/* */
/* HISTORY */
/* */
/* NAME DATE REMARKS */
/* */
/* Glen Johnosn 10/06/95 Initial version. */
/* */
/****************************************************************************/
#ifdef PLUS
#include "nucleus.h"
#else /* PLUS */
#include "nu_defs.h"
#include "nu_extr.h"
#endif /* !PLUS */
#include "target.h"
#include "protocol.h"
#include "tcpdefs.h"
#include "socketd.h"
#include "sockext.h"
#include "externs.h"
#include "data.h"
/****************************************************************************/
/* FUNCTION */
/* */
/* NU_Allocate_Buffer */
/* */
/* DESCRIPTION */
/* */
/* This fuction will allocate a buffer and return a pointer to the data */
/* section of the buffer. It can be used from the application level */
/* when ODH is enabled. */
/* */
/* AUTHOR */
/* */
/* Glen Johnson, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* User Applications */
/* */
/* CALLS */
/* */
/* NU_GetPnum */
/* NU_Obtain_Semaphore */
/* allocate_buffer */
/* */
/* 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_Allocate_Buffer(int16 socketd, char **buffer)
{
struct pqueue HUGE *buf_ptr;
int16 return_status;
int16 pnum;
/* Validate the socket number. */
if ((socketd < 0) || (socketd >= NSOCKETS) ||
(socket_list[socketd] == NU_NULL))
return(NU_INVALID_SOCKET);
if (!(socket_list[socketd]->odh_flag & NU_ODH_TRANSMIT))
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
/* get the portlist entry number for this connection */
if ((pnum = NU_GetPnum(socket_list[socketd])) >= 0)
{
/* Allocate a buffer. */
buf_ptr = allocate_buffer(portlist[pnum]);
/* Did the allocation fail. */
if (buf_ptr == NU_NULL)
return_status = NU_NO_BUFFERS;
else
{
return_status = MAX_SEGMENT_LEN;
*buffer = (char *)buf_ptr->packet + (sizeof(DLAYER) +
sizeof(IPLAYER) +
sizeof(TCPLAYER));
}
} /* end if port number exist. */
else return_status = NU_NO_PORT_NUMBER;
#ifdef PLUS
NU_Release_Semaphore(&TCP_Resource);
#else
NU_Release_Resource(TCP_Resource);
#endif
return(return_status);
} /* end NU_Allocate_Buffer */
/****************************************************************************/
/* FUNCTION */
/* */
/* NU_Deallocate_Buffer */
/* */
/* DESCRIPTION */
/* */
/* This fuction will deallocate a buffer. It should only be called when */
/* ODH is enabled. */
/* */
/* AUTHOR */
/* */
/* Glen Johnson, Accelerated Technology Inc. */
/* */
/* CALLED FROM */
/* */
/* User Applications */
/* */
/* CALLS */
/* */
/* dll_remove */
/* NU_Obtain_Semaphore */
/* dll_enqueue */
/* */
/* INPUTS */
/* */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -