This chapter contains a description of all NetX Duo TFTP services (listed below) in alphabetic order. Unless otherwise specified, all services support IPv6 and IPv4 communications.
In the Return Values section in the following API descriptions, values in BOLD are not affected by the NX_DISABLE_ERROR_CHECKING define that is used to disable API error checking, while non-bold values are completely disabled.
Note
|
The IPv4 equivalents of all the services listed above are available in NetX Duo TFTP Client and Server e.g. nx_tftp_server_create and nx_tftp_client_file_open. Only the 'Duo' API descriptions, e.g. services beginning with nxd_, are provided in the following pages. Where an NXD_ADDRESS * input is specified, the IPv4 equivalent API calls for ULONG input. Otherwise there is no difference in using the API. |
Create a TFTP Client instance
UINT nxd_tftp_client_create(
NX_TFTP_CLIENT *tftp_client_ptr,
CHAR *tftp_client_name,
NX_IP *ip_ptr,
NX_PACKET_POOL *pool_ptr);
This service creates a TFTP Client instance for the previously created IP instance.
Important
|
The application must make certain the supplied IP and packet pool are already created. In addition, UDP must be enabled for the IP instance prior to calling this service. |
-
tftp_client_ptr: Pointer to TFTP Client control block.
-
tftp_client_name: Name of this TFTP Client instance
-
ip_ptr: Pointer to previously created IP instance.
-
pool_ptr: Pointer to packet pool TFTP Client instance.
-
NX_SUCCESS(0x00) Successful TFTP create.
-
NX_TFTP_INVALID_IP_VERSION (0x0C) Invalid or unsupported IP version
-
NX_TFTP_INVALID_SERVER_ADDRESS (0x08) Invalid Server IP address received
-
NX_TFTP_NO_ACK_RECEIVED (0x09) Server ACK not received
-
NX_PTR_ERROR (0x16) Invalid IP, pool, or TFTP pointer.
-
NX_INVALID_PARAMETERS (0x4D) Invalid non pointer input
-
NX_CALLER_ERROR (0x11) Invalid caller of this service.
Delete a TFTP Client instance
-
NX_SUCCESS (0x00) Successful TFTP Client delete.
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service.
Get client error information
UINT nxd_tftp_client_error_info_get(
NX_TFTP_CLIENT *tftp_client_ptr,
UINT *error_code,
CHAR **error_string);
This service returns the last error code received and sets the pointer to the client’s internal error string. In error conditions, the user can view the last error sent by the server. A null error string indicates no error is present.
-
tftp_client_ptr: Pointer to previously created TFTP Client instance.
-
error_code: Pointer to destination area for error code
-
error_string: Pointer to destination for error string
-
NX_SUCCESS (0x00) Successful TFTP error info get.
-
NX_PTR_ERROR (0x16) Invalid TFTP Client pointer.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service.
Close client file
This service closes the previously opened file by this TFTP Client instance. A TFTP Client instance is allowed to have only one file open at a time.
-
tftp_client_ptr: Pointer to previously created TFTP Client instance.
-
ip_type: Indicate which IP protocol to use. Valid options are IPv4 (4) or IPv6 (6).
-
NX_SUCCESS (0x00) Successful TFTP file close.
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service.
-
NX_INVALID_PARAMETERS (0x4D) Invalid non pointer input.
Open TFTP client file
UINT nx_tftp_client_file_open(
NX_TFTP_CLIENT *tftp_client_ptr,
CHAR *file_name,
NXD_ADDRESS *server_ip_address,
UINT open_type,
ULONG wait_option);
This service attempts to open the specified file on the TFTP Server at the specified IP address. The file will be opened for either reading or writing.
Note
|
This is limited to IPv4 packets only, and is intended for supporting NetX TFTP applications. Developers are encouraged to port their applications to using equivalent "duo" service nxd_tftp_client_file_open. |
-
tftp_client_ptr: Pointer to TFTP control block.
-
file_name: ASCII file name, NULL-terminated and with appropriate path information.
-
server_ip_address: Server TFTP address.
-
open_type: Type of open request, either:
-
NX_TFTP_OPEN_FOR_READ (0x01)
-
NX_TFTP_OPEN_FOR_WRITE (0x02)
-
-
wait_option: Defines how long the service will wait for the TFTP Client file open. The wait options are defined as follows:
-
timeout value (0x00000001 through 0xFFFFFFFE)
-
TX_WAIT_FOREVER (0xFFFFFFFF)
-
Selecting TX_WAIT_FOREVER causes the calling thread to suspend indefinitely until a TFTP Server responds to the request.
-
Selecting a numeric value (1-0xFFFFFFFE) specifies the maximum number of timer-ticks to stay suspended while waiting for the TFTP server response.
-
-
ip_type: Indicate which IP protocol to use. Valid options are IPv4 (4) or IPv6 (6).
-
NX_SUCCESS (0x00) Successful Client file open
-
NX_TFTP_NOT_CLOSED (0xC3) Client already has file open
-
NX_INVALID_TFTP_SERVER_ADDRESS (0x08) Invalid server address received
-
NX_TFTP_NO_ACK_RECEIVED (0x09) No ACK received from server
-
NX_TFTP_INVALID_SERVER_ADDRESS (0x08) Invalid Server IP received
-
NX_TFTP_CODE_ERROR (0x05) Received error code
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service
-
NX_IP_ADDRESS_ERROR (0x21) Invalid Server IP address
-
NX_OPTION_ERROR (0x0A) Invalid open type
/* Define the TFTP server address. */
NXD_ADDRESS server_ip_address;
server_ip_address.nxd_ip_version = NX_IP_VERSION_V6;
server _ip_address.nxd_ip_address.v6[0] = 0x20010db8;
server _ip_address.nxd_ip_address.v6[1] = 0xf101;
server _ip_address.nxd_ip_address.v6[2] = 0;
server _ip_address.nxd_ip_address.v6[3] = 0x101;
/* Open file "test.txt" for reading on the TFTP Server. */
status = nxd_tftp_client_file_open(&my_tftp_client, "test.txt",
& server_ip_address, NX_TFTP_OPEN_FOR_READ, 200);
/* If status is NX_SUCCESS the "test.txt" file is now open for reading. */
Open TFTP client file
UINT nxd_tftp_client_file_open(
NX_TFTP_CLIENT *tftp_client_ptr,
CHAR *file_name, NXD_ADDRESS *server_ip_address,
UINT open_type,
ULONG wait_option,
UINT ip_type);
This service attempts to open the specified file on the TFTP Server at the specified IPv6 address. The file will be opened for either reading or writing.
-
tftp_client_ptr: Pointer to TFTP control block.
-
file_name: ASCII file name, NULL-terminated and with appropriate path information.
-
server_ip_address: Server TFTP address.
-
open_type: Type of open request, either:
-
NX_TFTP_OPEN_FOR_READ (0x01)
-
NX_TFTP_OPEN_FOR_WRITE (0x02)
-
-
wait_option: Defines how long the service will wait for the TFTP Client file open. The wait options are defined as follows:
-
timeout value (0x00000001 through 0xFFFFFFFE)
-
TX_WAIT_FOREVER (0xFFFFFFFF)
-
Selecting TX_WAIT_FOREVER causes the calling thread to suspend indefinitely until a TFTP Server responds to the request.
-
Selecting a numeric value (1-0xFFFFFFFE) specifies the maximum number of timer-ticks to stay suspended while waiting for the TFTP server response.
-
-
ip_type: Indicate which IP protocol to use. Valid options are IPv4 (4) or IPv6 (6).
-
NX_SUCCESS (0x00) Successful Client file open
-
NX_TFTP_NOT_CLOSED (0xC3) Client already has file open
-
NX_INVALID_TFTP_SERVER_ADDRESS (0x08) Invalid server address received
-
NX_TFTP_NO_ACK_RECEIVED (0x09) No ACK received from server
-
NX_TFTP_INVALID_IP_VERSION (0x0C) Invalid IP version
-
NX_TFTP_INVALID_SERVER_ADDRESS (0x08) Invalid Server IP received
-
NX_TFTP_CODE_ERROR (0x05) Received error code
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service
-
NX_IP_ADDRESS_ERROR (0x21) Invalid Server IP address
-
NX_OPTION_ERROR (0x0A) Invalid open type
-
NX_INVALID_PARAMETERS (0x4D) Invalid non pointer input
/* Define the TFTP server address. */
NXD_ADDRESS server_ip_address;
server_ip_address.nxd_ip_version = NX_IP_VERSION_V6;
server _ip_address.nxd_ip_address.v6[0] = 0x20010db8;
server _ip_address.nxd_ip_address.v6[1] = 0xf101;
server _ip_address.nxd_ip_address.v6[2] = 0;
server _ip_address.nxd_ip_address.v6[3] = 0x101;
/* Open file "test.txt" for reading on the TFTP Server. */
status = nxd_tftp_client_file_open(&my_tftp_client, "test.txt",
& server_ip_address, NX_TFTP_OPEN_FOR_READ, 200);
/* If status is NX_SUCCESS the "test.txt" file is now open for reading. */
Read a block from client file
UINT nxd_tftp_client_file_read(
NX_TFTP_CLIENT *tftp_client_ptr,
NX_PACKET **packet_ptr,
ULONG wait_option,
UINT ip_type);
This service reads a 512-byte block from the previously opened TFTP Client file. A block containing fewer than 512 bytes signals the end of the file.
-
tftp_client_ptr: Pointer to TFTP Client control block.
-
packet_ptr: Destination for packet containing the block read from the file.
-
wait_option: Defines how long the service will wait for the read to complete. The wait options are defined as follows:
-
timeout value (0x00000001 through 0xFFFFFFFE)
-
TX_WAIT_FOREVER (0xFFFFFFFF)
-
Selecting TX_WAIT_FOREVER causes the calling thread to suspend indefinitely until the TFTP Server responds to the request.
-
Selecting a numeric value (1-0xFFFFFFFE) specifies the maximum number of timer-ticks to stay suspended while waiting for the TFTP server to send a block of the file.
-
-
ip_type: Indicate which IP protocol to use. Valid options are IPv4 (4) or IPv6 (6).
-
NX_SUCCESS (0x00) Successful Client block read
-
NX_TFTP_NOT_OPEN (0xC3) Specified Client file is not open for reading
-
NX_NO_PACKET (0x01) No Packet received from Server.
-
NX_INVALID_TFTP_SERVER_ADDRESS (0x08) Invalid server address received
-
NX_TFTP_NO_ACK_RECEIVED (0x09) No ACK received from Server
-
NX_TFTP_END_OF_FILE (0xC5) End of file detected (not an error).
-
NX_TFTP_INVALID_IP_VERSION (0x0C) Invalid IP version
-
NX_TFTP_CODE_ERROR (0x05) Received error code
-
NX_TFTP_FAILED (0xC2) Unknown TFTP code received
-
NX_TFTP_INVALID_BLOCK_NUMBER (0x0A) Invalid block number received
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service
-
NX_INVALID_PARAMETERS (0x4D) Invalid non pointer input
Write a block to Client file
UINT nxd_tftp_client_file_write(
NX_TFTP_CLIENT *tftp_client_ptr,
NX_PACKET *packet_ptr,
ULONG wait_option, UINT ip_type);
This service writes a 512-byte block to the previously opened TFTP Client file. Specifying a block containing fewer than 512 bytes signals the end of the file.
-
tftp_client_ptr: Pointer to TFTP Client control block.
-
packet_ptr: Packet containing the block to write to the file.
-
wait_option: Defines how long the service will wait for the write to complete. The wait options are defined as follows:
-
timeout value (0x00000001 through 0xFFFFFFFE)
-
TX_WAIT_FOREVER (0xFFFFFFFF)
-
Selecting TX_WAIT_FOREVER causes the calling thread to suspend indefinitely until the TFTP Server responds to the request.
-
Selecting a numeric value (1-0xFFFFFFFE) specifies the maximum number of timer-ticks to stay suspended while waiting for the TFTP server to send an ACK for the write request.
-
-
ip_type: Indicate which IP protocol to use. Valid options are IPv4 (4) or IPv6 (6).
-
NX_SUCCESS (0x00) Successful Client block write
-
NX_TFTP_NOT_OPEN (0xC3) Specified Client file is not open for writing
-
NX_TFTP_TIMEOUT (0xC1) Timeout waiting for Server ACK
-
NX_INVALID_TFTP_SERVER_ADDRESS (0x08) Invalid server address received
-
NX_TFTP_NO_ACK_RECEIVED (0x09) No ACK received from server
-
NX_TFTP_INVALID_IP_VERSION (0x0C) Invalid IP version
-
NX_INVALID_TFTP_SERVER_ADDRESS (0x08) Invalid server address received
-
NX_TFTP_CODE_ERROR (0x05) Received error code
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service
-
NX_INVALID_PARAMETERS (0x4D) Invalid non pointer input
Allocate packet for Client file write
UINT nxd_tftp_client_packet_allocate(
NX_PACKET_POOL *pool_ptr,
NX_PACKET **packet_ptr,
ULONG wait_option,
UINT ip_type);
This service allocates a UDP packet from the specified packet pool and makes room for the 4-byte TFTP header before the packet is returned to the caller. The caller can then build a buffer for writing to a client file.
-
pool_ptr: Pointer to packet pool.
-
packet_ptr: Destination for pointer to allocated packet.
-
wait_option: Defines how long the service will wait for the packet allocate to complete. The wait options are defined as follows:
-
timeout value (0x00000001 through 0xFFFFFFFE)
-
TX_WAIT_FOREVER (0xFFFFFFFF)
-
Selecting TX_WAIT_FOREVER causes the calling thread to suspend indefinitely until the allocation completes.
-
Selecting a numeric value (1-0xFFFFFFFE) specifies the maximum number of timer-ticks to stay suspended while waiting for the packet allocation.
-
-
ip_type: Indicate which IP protocol to use. Valid options are IPv4 (4) or IPv6 (6).
-
NX_SUCCESS (0x00) Successful packet allocate
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service
-
NX_INVALID_PARAMETERS (0x4D) Invalid non pointer input
Set physical interface for TFTP requests
This service uses the input interface index to set the physical interface for the TFTP Client to send and receive TFTP packets. The default value is zero, for the primary interface.
Note
|
NetX Duo must support multihome addressing (v5.6 or later) to use this service. |
-
tftp_client_ptr: Pointer to TFTP Client instance
-
if_index: Index of physical interface to use
-
NX_SUCCESS (0x00) Successfully set interface (0x0B) Invalid interface input
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service
-
NX_TFTP_INVALID_INTERFACE (0x0B) Invalid interface input
Create TFTP server
UINT nxd_tftp_server_create(
NX_TFTP_SERVER *tftp_server_ptr,
CHAR *tftp_server_name,
NX_IP *ip_ptr,
FX_MEDIA *media_ptr,
VOID *stack_ptr,
ULONG stack_size,
NX_PACKET_POOL *pool_ptr);
This service creates a TFTP Server that responds to TFTP Client requests on port 69. The Server must be started by a subsequent call to nxd_tftp_server_start.
Important
|
The application must make certain the supplied IP instance, packet pool, and FileX media instance are already created. In addition, UDP must be enabled for the IP instance prior to calling this service. |
-
tftp_server_ptr: Pointer to TFTP Server control block.
-
tftp_server_name: Name of this TFTP Server instance
-
ip_ptr: Pointer to previously created IP instance.
-
media_ptr: Pointer to FileX media instance.
-
stack_ptr: Pointer to TFTP Server stack area.
-
stack_size: Number of bytes in the TFTP Server stack.
-
pool_ptr: Pointer to TFTP packet pool.
Note
|
The supplied pool must have packet payloads at least 580 bytes in size.1 |
1 The data portion of a packet is exactly 512 bytes, but the packet payload size must be at least 572 bytes. The remaining bytes are used for the UDP, IPv6, and Ethernet headers and potential trailing bytes required by the driver for alignment.
-
NX_SUCCESS (0x00) Successful Server create
-
NX_TFTP_POOL_ERROR (0xC6) Packet pool has packet size of less than 560 bytes
-
NX_PTR_ERROR (0x16) Invalid pointer input.
Delete TFTP Server
-
NX_SUCCESS (0x00) Successful Server delete
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service
Start TFTP server
Stop TFTP Server
-
NX_SUCCESS (0x00) Successful Server stop
-
NX_PTR_ERROR (0x16) Invalid pointer input.
-
NX_CALLER_ERROR (0x11) Invalid caller of this service