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

📄 zbufsocklib.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* zbufSockLib.c - zbuf socket interface library *//* Copyright 1984 - 2001 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01l,07may02,kbw  man page edits01k,15oct01,rae  merge from truestack ver 01l, base 01j (cleanup)01j,18oct00,zhu  check NULL for sockFdtosockFunc01i,29apr99,pul  Upgraded NPT phase3 code to tor2.0.001h,14mar99,jdi  doc: removed refs to config.h and/or configAll.h (SPR 25663).01h,02feb99,sgv  Added checks for zbuf support in the underlying backend in		 zbufSockSend,zbufSockSendto,zbufSockBufSend, zbufSockBufSendto,		 zbufSockRecv, zbufSockRecvfrom calls.01g,26oct95,rhp  doc: mention values for <flags> params in socket                 calls (SPR#4423)01f,10mar95,jdi  doc addn to zbufSockRecv(), zbufSockRecvfrom() as per dana.01e,11feb95,jdi  fixed doc style for `errno'.01d,23jan95,jdi  more doc tweaks.01c,12nov94,rhp  doc tweaks.01b,09nov94,rhp  library man page added, subroutine man pages edited.01a,08nov94,dzb  written.*//*DESCRIPTIONThis library contains routines that communicate over BSD sockets usingthe.I "zbuf interface"described in the zbufLib manual page.  These zbufsocket calls communicate over BSD sockets in a similar manner to thesocket routines in sockLib, but they avoid copying data unnecessarilybetween application buffers and network buffers.VXWORKS AE PROTECTION DOMAINSUnder VxWorks AE, this feature is accessible from the kernel protection domain only.  This restriction does not apply under non-AE versions of VxWorks.  To use this feature, include the INCLUDE_ZBUF_SOCK component.SEE ALSOzbufLib, sockLib *//* includes */#include "vxWorks.h"#include "zbufSockLib.h"#include "mbufSockLib.h"#include "sys/socket.h"#include "sockFunc.h"#include "netLib.h"/* locals */LOCAL ZBUF_SOCK_FUNC	zbufSockFuncNull =	/* null funcs for unconnected */    {    NULL,					/* zbufLibInit()	*/    NULL,					/* zbufSockSend()	*/    NULL,					/* zbufSockSendto()	*/    NULL,					/* zbufSockBufSend()	*/    NULL,					/* zbufSockBufSendto()	*/    NULL,					/* zbufSockRecv()	*/    NULL					/* zbufSockRecvfrom()	*/    };LOCAL ZBUF_SOCK_FUNC *	pZbufSockFunc = &zbufSockFuncNull;/* forward declarations */IMPORT SOCK_FUNC * sockFdtosockFunc (int s);/********************************************************************************* zbufSockLibInit - initialize the zbuf socket interface library** This routine initializes the zbuf socket interface* library.  It must be called before any zbuf socket routines are used.* It is called automatically when INCLUDE_ZBUF_SOCK is defined.** VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call this function from within the kernel * protection domain only.  In addition, all arguments to this function can  * reference only that data which is valid in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks.  ** RETURNS:* OK, or ERROR if the zbuf socket interface could not be initialized.*/STATUS zbufSockLibInit (void)    {    ZBUF_SOCK_FUNC *	pZbufSockFuncTemp;    /* call the back-end initialization routine */    if ((pZbufSockFuncTemp = _mbufSockLibInit()) == NULL)	return (ERROR);        pZbufSockFunc = pZbufSockFuncTemp;	/* connect socket back-end func table */    return (zbufLibInit (pZbufSockFunc->libInitRtn));    }/********************************************************************************* zbufSockSend - send zbuf data to a TCP socket** This routine transmits all of the data in <zbufId> to a previously* established connection-based (stream) socket.** The <zbufLen> parameter is used only for determining the amount of space* needed from the socket write buffer.  <zbufLen> has no effect on how many* bytes are sent; the entire zbuf is always transmitted.  If the length of* <zbufId> is not known, the caller must first determine it by calling* zbufLength().** This routine transfers ownership of the zbuf from the user application* to the VxWorks network stack.  The zbuf ID, <zbufId>, is deleted by this* routine, and should not be used after the routine is called, even if* an ERROR status is returned.  (Exceptions:  when the routine* fails because the zbuf socket interface library was not initialized or an* invalid zbuf ID was passed in, in which case there is no zbuf to delete.* Moreover, if the call fails during a non-blocking I/O socket write* with an `errno' of EWOULDBLOCK, then <zbufId> is not deleted; thus the* caller may send it again at a later time.)** You may OR the following values into the <flags> parameter with this* operation:** .iP "MSG_OOB (0x1)" 26* Out-of-band data.* * .iP "MSG_DONTROUTE (0x4)"* Send without using routing tables.* .LP* * VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call this function from within the kernel * protection domain only.  In addition, all arguments to this function can  * reference only that data which is valid in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks.  ** RETURNS* The number of bytes sent, or ERROR if the call fails.** SEE ALSO: zbufLength(), zbufSockBufSend(), send()*/int zbufSockSend    (    int			s,		/* socket to send to */    ZBUF_ID		zbufId,		/* zbuf to transmit */    int			zbufLen,	/* length of entire zbuf */    int			flags		/* flags to underlying protocols */    )    {    SOCK_FUNC * pSockFunc = sockFdtosockFunc(s);    if (pSockFunc == NULL || pSockFunc->zbufRtn == NULL ||	(pSockFunc->zbufRtn)() == FALSE)	{	netErrnoSet (ENOTSUP);	return (ERROR);	}    return ((pZbufSockFunc->sendRtn == NULL) ? ERROR :	(pZbufSockFunc->sendRtn) (s, zbufId, zbufLen, flags));    }/********************************************************************************* zbufSockSendto - send a zbuf message to a UDP socket** This routine sends the entire message in <zbufId> to the datagram socket* named by <to>.  The socket <s> is the sending socket.** The <zbufLen> parameter is used only for determining the amount of space* needed from the socket write buffer.  <zbufLen> has no effect on how many* bytes are sent; the entire zbuf is always transmitted.  If the length of* <zbufId> is not known, the caller must first determine it by calling* zbufLength().** This routine transfers ownership of the zbuf from the user application* to the VxWorks network stack.  The zbuf ID <zbufId> is deleted by this* routine, and should not be used after the routine is called, even if* an ERROR status is returned.  (Exceptions:  when the routine* fails because the zbuf socket interface library was not initialized or an* invalid zbuf ID was passed in, in which case there is no zbuf to delete.* Moreover, if the call fails during a non-blocking I/O socket write* with an `errno' of EWOULDBLOCK, then <zbufId> is not deleted; thus the* caller may send it again at a later time.)** You may OR the following values into the <flags> parameter with this* operation:** .iP "MSG_OOB (0x1)" 26* Out-of-band data.* * .iP "MSG_DONTROUTE (0x4)"* Send without using routing tables.* .LP* * VXWORKS AE PROTECTION DOMAINS* Under VxWorks AE, you can call this function from within the kernel * protection domain only.  In addition, all arguments to this function can  * reference only that data which is valid in the kernel protection domain. * This restriction does not apply under non-AE versions of VxWorks.  ** RETURNS* The number of bytes sent, or ERROR if the call fails.** SEE ALSO: zbufLength(), zbufSockBufSendto(), sendto()*/int zbufSockSendto    (    int			s,		/* socket to send to */    ZBUF_ID		zbufId,		/* zbuf to transmit */    int			zbufLen,	/* length of entire zbuf */    int			flags,		/* flags to underlying protocols */    struct sockaddr *	to,		/* recipient's address */    int			tolen		/* length of <to> socket addr */    )    {    SOCK_FUNC * pSockFunc = sockFdtosockFunc(s);        if (pSockFunc == NULL) 	{	netErrnoSet (ENOTSUP);	return (ERROR);	}    if ((pSockFunc->zbufRtn == NULL) || ((pSockFunc->zbufRtn)() == FALSE))	{	netErrnoSet (ENOTSUP);	return (ERROR);	}    return ((pZbufSockFunc->sendtoRtn == NULL) ? ERROR :	(pZbufSockFunc->sendtoRtn) (s, zbufId, zbufLen, flags, to, tolen));    }/********************************************************************************* zbufSockBufSend - create a zbuf from user data and send it to a TCP socket** This routine creates a zbuf from the user buffer <buf>, and transmits* it to a previously established connection-based (stream) socket.** The user-provided free routine callback at <freeRtn> is called when <buf>

⌨️ 快捷键说明

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