TFTP Support Functions

These are the functions required by the PXE standard to support TFTP.

pxenv_tftp_open()

This open a TFTP session with the boot server. There can only be one open TFTP session at a time. If there is an existing TFTP session open, it must be closed before a new one can be started.

Note: The IP numbers and port numbers contained in the pxenv_tftp_open_t structure are stored in big endian (Motorola) format.

pxenv_ret_code_t pxenv_tftp_open(struct pxenv_tftp_open_s tftpopen);

tftpopen

This is a pointer to a pre-initialized pxenv_tftp_open_s structure. The negotiated size of the TFTP packet in bytes is written before returning. This size must be less than or equal to the requested size.

These are the fields in the pxenv_tftp_open_s structure that must be set before calling this function.

tftpopen.status

The exit status of this function. This is set to one of the PXENV_STATUS_xxx constants.

tftpopen.server_ip

the IP address of the TFTP server in Big Endian format.

tftpopen.gw_ip

the IP address of gateway in Big Endian format.

tftpopen.filename

a NULL terminated string represnting the boot file name.

tftpopen.tftpport

the port the TFTP server is listening on. This must be in Big Endian format.

tftpopen.packetsize

the requested size of the TFTP packets. This must be over 512 bytes.

These are the fields in the pxenv_tftp_open_s structure that get set by this function before returning.

tftpopen.status

The exit status of this function. This is set to one of the PXENV_STATUS_xxx constants.

tftpopen.packetsize

the requested size of the TFTP packets. This must be over 512 bytes.

These are all the fields of the pxenv_tftp_close_s structure.


      typedef struct pxenv_tftp_open_s {
      pxenv_status_t status;
          ip4_t server_ip;
	  ip4_t gw_ip;
	  u_int8_t filename[128];
	  tftp_port_t tftpport;
	  int16_t packetsize;
      } pxenv_tftp_open_t;

      

pxenv_tftp_close()

This function closes the previously opened TFTP session.

pxenv_ret_code_t pxenv_tftp_close(struct pxenv_tftp_close_s tftpclose);

tftpclose

This is a pointer to a pre-initialized pxenv_tftp_close_s structure.

These are the fields in the pxenv_tftp_close_s structure that must be set before calling this function.

tftpclose.server_ip

the IP address of the TFTP server in Big Endian format.

tftpclose.gw_ip

the IP address of gateway in Big Endian format.

tftpclose.filename

a NULL terminated string represnting the boot file name.

tftpclose.tftpport

the port the TFTP server is listening on. This must be in Big Endian format.

These are the fields in the pxenv_tftp_close_s structure that get set by this function before returning.

tftpclose.status

The exit status of this function. This is set to one of the PXENV_STATUS_xxx constants.

tftpclose.filesize

the size of the boot file in bytes.

These are all the fields of the pxenv_tftp_close_s structure.


      typedef struct pxenv_tftp_get_fsize_s {
          pxenv_status_t status;
          ip4_t server_ip;
	  ip4_t gw_ip;
	  u_int8_t filename[128];
	  u_int32_t filesize;
      } pxenv_tftp_get_fsize_t;

      

pxenv_tftp_read()

This function reads one packet from the open TFTP connection.

pxenv_ret_code_t pxenv_tftp_read(struct pxenv_tftp_read_s tftpread);

tftpread

This is a pointer to a pre-initialized pxenv_tftp_read_s structure. The packet number and buffer length (in bytes) are filled in before returning.

These are the fields in the pxenv_tftp_read_s structure that must be set before calling this function.

tftread.buffersize

the size of the receive buffer in bytes. This must be larger than 512.

tftread.buffer

the buffer address in offset:segment format.

These are the fields in the pxenv_tftp_read_s structure that get set by this function before returning.

tftpread.status

The exit status of this function. This is set to one of the PXENV_STATUS_xxx constants.

tftread.packetnum

the packet sequence number.

tftread.buffersize

the packet size in bytes. This must be less than the requested buffer size.

These are all the fields of the pxenv_tftp_read_s structure.

      
      typedef struct pxenv_tftp_read_s {
          pxenv_status_t status;
	  u_int16_t packetnum;
	  u_int16_t buffersize;
	  segoff16_t Buffer;
      } pxenv_tftp_read_t;

      

pxenv_tftp_read_file()

This function opens the connection, reads the entire file, and closes the connection. You must have suficient memory to hold the boot image if you expect this to work.

pxenv_ret_code_t pxenv_tftp_read_file(struct pxenv_tftp_read_file_s tftpfile);

tftpfile

This is a pointer to a pre-initialized pxenv_tftp_read_s structure. The number of bytes written into the receive buffer is filled in before returning.

These are the fields in the pxenv_tftp_read_file_s structure that must be set before calling this function.

tftfile.filename

a NULL terminated string represnting the boot file name.

tftpfile.buffersize

the size of the receive buffer in bytes.

tftpfile.buffer

the buffer address in offset:segment format.

tftpfile.server_ip

the IP address of the TFTP server in Big Endian format.

tftpfile.gw_ip

the IP address of gateway in Big Endian format.

tftpfile.mcast_ip

the multicast IP address in Big Endian format.

tftpfile.tftp_clnt_port

the port the client listens to for a multicast.

tftpfile.tftp_srv_port

the port the server listens to for a multicast.

tftpfile.tftp_open_timeout

the timeout value in seconds used for receiving data. If zero, the default of TFTP timeout is used.

tftpfile.tftp_reopen_delay

the maximum wait delay time in seconds between ACK of a fast packet and a new TFTP open.

These are the fields in the pxenv_tftp_read_file_s structure that get set by this function before returning.

tftpfile.status

The exit status of this function. This is set to one of the PXENV_STATUS_xxx constants.

tftpfile.packetnum

the packet sequence number.

tftpfile.buffersize

the packet size in bytes. This must be less than the requested buffer size.

These are all the fields of the pxenv_tftp_read_file_s structure.


      typedef struct pxenv_tftp_read_file_s {
          pxenv_status_t status;
	  u_int8_t filename[128];
	  u_int32_t buffersize;
	  addr32_t buffer;
	  ip4_t server_ip;
	  ip4_t gw_ip;
	  ip4_t mcast_ip;
	  udp_port_t tftp_clnt_port;
	  udp_port_t tftp_srv_port;
	  u_int16_t tftp_open_timeout;
	  u_int16_t tftp_reopen_delay;
      } pxenv_tftp_read_file_t;

      

pxenv_tftp_get_fsize()

This function asks the boot server for the size of the file to be loaded. This only gets the size of the file using a TFTP option, it does not open the connection.

pxenv_ret_code_t pxenv_tftp_get_fsize(struct pxenv_tftp_get_fsize_s tftpfsize);

tftpfsize

This is a pointer to a pre-initialized pxenv_tftp_get_fsize_s structure. The number of bytes in the file is filled in before returning.

These are the fields in the pxenv_tftp_get_fsize_s structure that must be set before calling this function.

tftfsize.server_ip

the IP address of the TFTP server in Big Endian format.

tftfsize.gw_ip

the IP address of gateway in Big Endian format.

tftpfsize.filename

a NULL terminated string represnting the boot file name.

tftpfsize.tftpport

the port the TFTP server is listening on. This must be in Big Endian format.

These are the fields in the pxenv_tftp_get_fsize_s structure that get set by this function before returning.

tftpfsize.status

The exit status of this function. This is set to one of the PXENV_STATUS_xxx constants.

tftpsize.filesize

the size of the boot file in bytes.

These are all the fields of the pxenv_tftp_get_fsize_s structure.


      typedef struct pxenv_tftp_get_fsize_s {
          pxenv_status_t status;
	  ip4_t server_ip;
	  ip4_t gw_ip;
	  u_int8_t filename[128];
	  u_int32_t filesize;
      } pxenv_tftp_get_fsize_t;