📄 zbufsocklib.c
字号:
* is no longer in use by the TCP/IP network stack. Applications can* exploit this callback to receive notification that <buf> is free.* If <freeRtn> is NULL, the routine functions normally, except that the * application has no way of being notified when <buf> is released by the* network stack. The free routine runs in the context of the task that last* references the buffer. This is typically either the context of tNetTask, * or the context of the caller's task. Declare <freeRtn> as follows* (using whatever name is convenient):* .CS* void freeCallback* (* caddr_t buf, /@ pointer to user buffer @/* int freeArg /@ user-provided argument to free routine @/* )* .CE** 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* zbufSockSend(), send()**/int zbufSockBufSend ( int s, /* socket to send to */ char * buf, /* pointer to data buffer */ int bufLen, /* number of bytes to send */ VOIDFUNCPTR freeRtn, /* free routine callback */ int freeArg, /* argument to free routine */ 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->bufSendRtn == NULL) ? ERROR : (pZbufSockFunc->bufSendRtn) (s, buf, bufLen, freeRtn, freeArg, flags)); }/********************************************************************************* zbufSockBufSendto - create a zbuf from a user message and send it to a UDP socket** This routine creates a zbuf from the user buffer <buf>, and sends* it to the datagram socket named by <to>. The socket <s> is the* sending socket.** The user-provided free routine callback at <freeRtn> is called when <buf>* is no longer in use by the UDP/IP network stack. Applications can* exploit this callback to receive notification that <buf> is free.* If <freeRtn> is NULL, the routine functions normally, except that the * application has no way of being notified when <buf> is released by the* network stack. The free routine runs in the context of the task that last* references the buffer. This is typically either tNetTask context, * or the caller's task context. Declare <freeRtn> as follows* (using whatever name is convenient):* .CS* void freeCallback* (* caddr_t buf, /@ pointer to user buffer @/* int freeArg /@ user-provided argument to free routine @/* )* .CE** 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* zbufSockSendto(), sendto()*/int zbufSockBufSendto ( int s, /* socket to send to */ char * buf, /* pointer to data buffer */ int bufLen, /* number of bytes to send */ VOIDFUNCPTR freeRtn, /* free routine callback */ int freeArg, /* argument to free routine */ 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 || pSockFunc->zbufRtn == NULL || (pSockFunc->zbufRtn)() == FALSE) { netErrnoSet (ENOTSUP); return (ERROR); } return ((pZbufSockFunc->bufSendtoRtn == NULL) ? ERROR : (pZbufSockFunc->bufSendtoRtn) (s, buf, bufLen, freeRtn, freeArg, flags, to, tolen)); }/********************************************************************************* zbufSockRecv - receive data in a zbuf from a TCP socket** This routine receives data from a connection-based (stream) socket, and* returns the data to the user in a newly created zbuf.** The <pLen> parameter indicates the number of bytes requested by the caller.* If the operation is successful, the number of bytes received is* copied to <pLen>.** You may OR the following values into the <flags> parameter with this* operation:** .iP "MSG_OOB (0x1)" 26* Out-of-band data.* * .iP "MSG_PEEK (0x2)"* Return data without removing it from socket.* .LP* * Once the user application is finished with the zbuf, zbufDelete() should* be called to return the zbuf memory buffer to the VxWorks network stack.** 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 zbuf ID of a newly created zbuf containing the received data,* or NULL if the operation fails.** SEE ALSO* recv()*/ZBUF_ID zbufSockRecv ( int s, /* socket to receive data from */ int flags, /* flags to underlying protocols */ int * pLen /* number of bytes requested/returned */ ) { SOCK_FUNC * pSockFunc = sockFdtosockFunc(s); if (pSockFunc == NULL || pSockFunc->zbufRtn == NULL || (pSockFunc->zbufRtn)() == FALSE) { netErrnoSet (ENOTSUP); return (NULL); } return ((pZbufSockFunc->recvRtn == NULL) ? NULL : (ZBUF_ID) (pZbufSockFunc->recvRtn) (s, flags, pLen)); }/********************************************************************************* zbufSockRecvfrom - receive a message in a zbuf from a UDP socket** This routine receives a message from a datagram socket, and* returns the message to the user in a newly created zbuf.** The message is received regardless of whether the socket is connected.* If <from> is nonzero, the address of the sender's socket is copied to it.* Initialize the value-result parameter <pFromLen> to the size of* the <from> buffer. On return, <pFromLen> contains the actual size of the* address stored in <from>.** The <pLen> parameter indicates the number of bytes requested by the caller.* If the operation is successful, the number of bytes received is* copied to <pLen>.** You may OR the following values into the <flags> parameter with this* operation:** .iP "MSG_OOB (0x1)" 26* Out-of-band data.* * .iP "MSG_PEEK (0x2)" * Return data without removing it from socket. * .LP* * Once the user application is finished with the zbuf, zbufDelete() should* be called to return the zbuf memory buffer to the VxWorks network stack.** 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 zbuf ID of a newly created zbuf containing the received message,* or NULL if the operation fails.*/ZBUF_ID zbufSockRecvfrom ( int s, /* socket to receive from */ int flags, /* flags to underlying protocols */ int * pLen, /* number of bytes requested/returned */ struct sockaddr * from, /* where to copy sender's addr */ int * pFromLen /* value/result length of <from> */ ) { SOCK_FUNC * pSockFunc = sockFdtosockFunc(s); if (pSockFunc == NULL || pSockFunc->zbufRtn == NULL || (pSockFunc->zbufRtn)() == FALSE) { netErrnoSet (ENOTSUP); return (NULL); } return ((pZbufSockFunc->recvfromRtn == NULL) ? NULL : (ZBUF_ID) (pZbufSockFunc->recvfromRtn) (s, flags, pLen, from, pFromLen)); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -