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

📄 tftplib.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/tftpLib.html - generated by refgen from tftpLib.c --> <title> tftpLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual :  Libraries</i></a></p></blockquote><h1>tftpLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong>tftpLib</strong> - Trivial File Transfer Protocol (TFTP) client library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./tftpLib.html#tftpXfer">tftpXfer</a></i>(&nbsp;)</b>  -  transfer a file via TFTP using a stream interface<br><b><i><a href="./tftpLib.html#tftpCopy">tftpCopy</a></i>(&nbsp;)</b>  -  transfer a file via TFTP<br><b><i><a href="./tftpLib.html#tftpInit">tftpInit</a></i>(&nbsp;)</b>  -  initialize a TFTP session<br><b><i><a href="./tftpLib.html#tftpModeSet">tftpModeSet</a></i>(&nbsp;)</b>  -  set the TFTP transfer mode<br><b><i><a href="./tftpLib.html#tftpPeerSet">tftpPeerSet</a></i>(&nbsp;)</b>  -  set the TFTP server address<br><b><i><a href="./tftpLib.html#tftpPut">tftpPut</a></i>(&nbsp;)</b>  -  put a file to a remote system<br><b><i><a href="./tftpLib.html#tftpGet">tftpGet</a></i>(&nbsp;)</b>  -  get a file from a remote system<br><b><i><a href="./tftpLib.html#tftpInfoShow">tftpInfoShow</a></i>(&nbsp;)</b>  -  get TFTP status information<br><b><i><a href="./tftpLib.html#tftpQuit">tftpQuit</a></i>(&nbsp;)</b>  -  quit a TFTP session<br><b><i><a href="./tftpLib.html#tftpSend">tftpSend</a></i>(&nbsp;)</b>  -  send a TFTP message to the remote system<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library implements the VxWorks Trivial File Transfer Protocol (TFTP)client library.  TFTP is a simple file transfer protocol (hence the name "trivial") implemented over UDP.  TFTP was designed to be small and easy to implement; therefore it is limited in functionality in comparison with other file transfer protocols, such as FTP.  TFTP provides only the read/write capability to and from a remote server.  <p>TFTP provides no user authentication; therefore the remote files must have"loose" permissions before requests for file access will be granted by theremote TFTP server (i.e., files to be read must be publicly readable, andfiles to be written must exist and be publicly writeable).  Some TFTPservers offer a secure option (-s) that specifies a directory where theTFTP server is rooted.  Refer to the host manuals for more informationabout a particular TFTP server.<p></blockquote><h4>HIGH-LEVEL INTERFACE</h4><blockquote><p>The <b><a href="./tftpLib.html#top">tftpLib</a></b> library has two levels of interface.  The tasks <b><i><a href="./tftpLib.html#tftpXfer">tftpXfer</a></i>(&nbsp;)</b>and <b><i><a href="./tftpLib.html#tftpCopy">tftpCopy</a></i>(&nbsp;)</b> operate at the highest level and are the main callinterfaces.  The <b><i><a href="./tftpLib.html#tftpXfer">tftpXfer</a></i>(&nbsp;)</b> routine provides a stream interface to TFTP.That is, it spawns a task to perform the TFTP transfer and provides adescriptor from which data can be transferred interactively.  The<b><i><a href="./tftpLib.html#tftpXfer">tftpXfer</a></i>(&nbsp;)</b> interface is similar to <b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>(&nbsp;)</b> in ftpLib.  The <b><i><a href="./tftpLib.html#tftpCopy">tftpCopy</a></i>(&nbsp;)</b>routine transfers a remote file to or from a passed file (descriptor).<p></blockquote><h4>LOW-LEVEL INTERFACE</h4><blockquote><p>The lower-level interface is made up of various routines that act on a TFTPsession.  Each TFTP session is defined by a TFTP descriptor.   These routinesinclude:<p>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="./tftpLib.html#tftpInit">tftpInit</a></i>(&nbsp;)</b>&nbsp;to&nbsp;initialize&nbsp;a&nbsp;session;<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="./tftpLib.html#tftpModeSet">tftpModeSet</a></i>(&nbsp;)</b>&nbsp;to&nbsp;set&nbsp;the&nbsp;transfer&nbsp;mode;<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="./tftpLib.html#tftpPeerSet">tftpPeerSet</a></i>(&nbsp;)</b>&nbsp;to&nbsp;set&nbsp;a&nbsp;peer/server&nbsp;address;<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="./tftpLib.html#tftpPut">tftpPut</a></i>(&nbsp;)</b>&nbsp;to&nbsp;put&nbsp;a&nbsp;file&nbsp;to&nbsp;the&nbsp;remote&nbsp;system;<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="./tftpLib.html#tftpGet">tftpGet</a></i>(&nbsp;)</b>&nbsp;to&nbsp;get&nbsp;file&nbsp;from&nbsp;remote&nbsp;system;<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="./tftpLib.html#tftpInfoShow">tftpInfoShow</a></i>(&nbsp;)</b>&nbsp;to&nbsp;show&nbsp;status&nbsp;information;&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;<b><i><a href="./tftpLib.html#tftpQuit">tftpQuit</a></i>(&nbsp;)</b>&nbsp;to&nbsp;quit&nbsp;a&nbsp;TFTP&nbsp;session.<p></blockquote><h4>EXAMPLE</h4><blockquote><p>The following code provides an example of how to use the lower-levelroutines.  It implements roughly the same function as <b><i><a href="./tftpLib.html#tftpCopy">tftpCopy</a></i>(&nbsp;)</b>.<p><pre>    char *         pHost;    int            port;    char *         pFilename;    char *         pCommand;    char *         pMode;    int            fd;    TFTP_DESC *    pTftpDesc;    int            status;    if ((pTftpDesc = tftpInit ()) == NULL)        return (ERROR);    if ((tftpPeerSet (pTftpDesc, pHost, port) == ERROR) ||        (tftpModeSet (pTftpDesc, pMode) == ERROR))        {        (void) tftpQuit (pTftpDesc);        return (ERROR);        }    if (strcmp (pCommand, "get") == 0)        {        status = tftpGet (pTftpDesc, pFilename, fd, TFTP_CLIENT);        }    else if (strcmp (pCommand, "put") == 0)        {        status =  tftpPut (pTftpDesc, pFilename, fd, TFTP_CLIENT);        }    else        {        errno = S_tftpLib_INVALID_COMMAND;        status = ERROR;        }    (void) tftpQuit (pTftpDesc);</pre></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>tftpLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./tftpdLib.html#top">tftpdLib</a></b>,  <i>VxWorks Programmer's Guide: Network</i><p><hr><a name="tftpXfer"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>tftpXfer</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>tftpXfer</i>(&nbsp;)</strong> - transfer a file via TFTP using a stream interface</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS tftpXfer    (    char * pHost,     /* host name or address */    int    port,      /* port number */    char * pFilename, /* remote filename */    char * pCommand,  /* TFTP command */    char * pMode,     /* TFTP transfer mode */    int *  pDataDesc, /* return data desc. */    int *  pErrorDesc /* return error desc. */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine initiates a transfer to or from a remote file via TFTP.  Itspawns a task to perform the TFTP transfer and returns a descriptor fromwhich the data can be read (for "get") or to which it can be written (for"put") interactively.  The interface for this routine is similar to <b><i><a href="./ftpLib.html#ftpXfer">ftpXfer</a></i>(&nbsp;)</b>in ftpLib.<p><i>pHost</i> is the server name or Internet address.  A non-zero value for <i>port</i>specifies an alternate TFTP server port number (zero means use default TFTPport number (69)).  <i>pFilename</i> is the remote filename. <i>pCommand</i> specifiesthe TFTP command.  The command can be either "put" or "get".<p>The <b><i><a href="./tftpLib.html#tftpXfer">tftpXfer</a></i>(&nbsp;)</b> routine returns a data descriptor, in <i>pDataDesc</i>, fromwhich the TFTP data is read (for "get") or to which is it is written (for"put").  An error status descriptor gets returned in the variable<i>pErrorDesc</i>.  If an error occurs during the TFTP transfer, an errorstring can be read from this descriptor.  After returning successfullyfrom <b><i><a href="./tftpLib.html#tftpXfer">tftpXfer</a></i>(&nbsp;)</b>, the calling application is responsible for closing bothdescriptors.<p>If there are delays in reading or writing the data descriptor, it ispossible for the TFTP transfer to time out.<p></blockquote><h4>EXAMPLE</h4><blockquote><p>The following code demonstrates how <b><i><a href="./tftpLib.html#tftpXfer">tftpXfer</a></i>(&nbsp;)</b> may be used:<p><pre>    #include "tftpLib.h"    #define BUFFERSIZE        512    int  dataFd;    int  errorFd;    int  num;    char buf [BUFFERSIZE + 1];    if (tftpXfer ("congo", 0, "/usr/fred", "get", "ascii", &amp;dataFd,                  &amp;errorFd) == ERROR)        return (ERROR);    while ((num = read (dataFd, buf, sizeof (buf))) &gt; 0)        {        ....        }    close (dataFd);    num = read (errorFd, buf, BUFFERSIZE);    if (num &gt; 0)        {        buf [num] = '\0';        printf ("YIKES! An error occurred!:%s\n", buf);        .....        }    close (errorFd);</pre></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if unsuccessful.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_tftpLib_INVALID_ARGUMENT<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./tftpLib.html#top">tftpLib</a></b>, <b><a href="./ftpLib.html#top">ftpLib</a></b><hr><a name="tftpCopy"></a><p align=right><a href="rtnIndex.html"><i>Libraries :  Routines</i></a></p></blockquote><h1><i>tftpCopy</i>(&nbsp;)</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote>  <p><strong><i>tftpCopy</i>(&nbsp;)</strong> - transfer a file via TFTP</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS tftpCopy    (    char * pHost,     /* host name or address */    int    port,      /* optional port number */    char * pFilename, /* remote filename */    char * pCommand,  /* TFTP command */    char * pMode,     /* TFTP transfer mode */    int    fd         /* fd to put/get data */    )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine transfers a file using the TFTP protocol to or from a remotesystem.<i>pHost</i> is the remote server name or Internet address.  A non-zero valuefor <i>port</i> specifies an alternate TFTP server port (zero means use defaultTFTP port number (69)).  <i>pFilename</i> is the remote filename. <i>pCommand</i>specifies the TFTP command, which can be either "put" or "get".<i>pMode</i> specifies the mode of transfer, which can be "ascii","netascii",  "binary", "image", or "octet".<p><i>fd</i> is a file descriptor from which to read/write the data from or tothe remote system.  For example, if the command is "get", the remote datawill be written to <i>fd</i>.  If the command is "put", the data to be sent isread from <i>fd</i>.  The caller is responsible for managing <i>fd</i>.  That is, <i>fd</i>must be opened prior to calling <b><i><a href="./tftpLib.html#tftpCopy">tftpCopy</a></i>(&nbsp;)</b> and closed up on completion.<p></blockquote><h4>EXAMPLE</h4><blockquote><p>The following sequence gets an ASCII file "/folk/vw/xx.yy" on host"congo" and stores it to a local file called "localfile":<p><pre>    -&gt; fd = open ("localfile", 0x201, 0644)    -&gt; tftpCopy ("congo", 0, "/folk/vw/xx.yy", "get", "ascii", fd)    -&gt; close (fd)</pre></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if unsuccessful.<p></blockquote><h4>ERRNO</h4><blockquote><p>S_tftpLib_INVALID_COMMAND<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./tftpLib.html#top">tftpLib</a></b>, <b><a href="./ftpLib.html#top">ftpLib</a></b><hr><a name="tftpInit"></a><p align=right>

⌨️ 快捷键说明

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