|
| FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) |
|
| FEATURE (FEATURE_PROTOCOL, "TFTP", DHCP_EB_FEATURE_TFTP, 1) |
|
static void | tftp_free (struct refcnt *refcnt) |
| Free TFTP request. More...
|
|
static void | tftp_done (struct tftp_request *tftp, int rc) |
| Mark TFTP request as complete. More...
|
|
static int | tftp_reopen (struct tftp_request *tftp) |
| Reopen TFTP socket. More...
|
|
static int | tftp_reopen_mc (struct tftp_request *tftp, struct sockaddr *local) |
| Reopen TFTP multicast socket. More...
|
|
static int | tftp_presize (struct tftp_request *tftp, size_t filesize) |
| Presize TFTP receive buffers and block bitmap. More...
|
|
void | tftp_set_mtftp_address (struct in_addr address) |
| Set MTFTP multicast address. More...
|
|
void | tftp_set_mtftp_port (unsigned int port) |
| Set MTFTP multicast port. More...
|
|
static int | tftp_send_rrq (struct tftp_request *tftp) |
| Transmit RRQ. More...
|
|
static int | tftp_send_ack (struct tftp_request *tftp) |
| Transmit ACK. More...
|
|
static int | tftp_send_error (struct tftp_request *tftp, int errcode, const char *errmsg) |
| Transmit ERROR (Abort) More...
|
|
static int | tftp_send_packet (struct tftp_request *tftp) |
| Transmit next relevant packet. More...
|
|
static void | tftp_timer_expired (struct retry_timer *timer, int fail) |
| Handle TFTP retransmission timer expiry. More...
|
|
static int | tftp_process_blksize (struct tftp_request *tftp, char *value) |
| Process TFTP "blksize" option. More...
|
|
static int | tftp_process_tsize (struct tftp_request *tftp, char *value) |
| Process TFTP "tsize" option. More...
|
|
static int | tftp_process_multicast (struct tftp_request *tftp, char *value) |
| Process TFTP "multicast" option. More...
|
|
static int | tftp_process_option (struct tftp_request *tftp, const char *name, char *value) |
| Process TFTP option. More...
|
|
static int | tftp_rx_oack (struct tftp_request *tftp, void *buf, size_t len) |
| Receive OACK. More...
|
|
static int | tftp_rx_data (struct tftp_request *tftp, struct io_buffer *iobuf) |
| Receive DATA. More...
|
|
static int | tftp_errcode_to_rc (unsigned int errcode) |
| Convert TFTP error code to return status code. More...
|
|
static int | tftp_rx_error (struct tftp_request *tftp, void *buf, size_t len) |
| Receive ERROR. More...
|
|
static int | tftp_rx (struct tftp_request *tftp, struct io_buffer *iobuf, struct xfer_metadata *meta) |
| Receive new data. More...
|
|
static int | tftp_socket_deliver (struct tftp_request *tftp, struct io_buffer *iobuf, struct xfer_metadata *meta) |
| Receive new data via socket. More...
|
|
static size_t | tftp_xfer_window (struct tftp_request *tftp) |
| Check flow control window. More...
|
|
static void | tftp_close (struct tftp_request *tftp, int rc) |
| Terminate download. More...
|
|
static int | tftp_core_open (struct interface *xfer, struct uri *uri, unsigned int default_port, struct sockaddr *multicast, unsigned int flags) |
| Initiate TFTP/TFTM/MTFTP download. More...
|
|
static int | tftp_open (struct interface *xfer, struct uri *uri) |
| Initiate TFTP download. More...
|
|
static int | tftm_open (struct interface *xfer, struct uri *uri) |
| Initiate TFTM download. More...
|
|
static int | mtftp_open (struct interface *xfer, struct uri *uri) |
| Initiate MTFTP download. More...
|
|
static int | tftp_apply_settings (void) |
| Apply TFTP configuration settings. More...
|
|
TFTP protocol.
Definition in file tftp.c.
static void tftp_done |
( |
struct tftp_request * |
tftp, |
|
|
int |
rc |
|
) |
| |
|
static |
Mark TFTP request as complete.
- Parameters
-
tftp | TFTP connection |
rc | Return status code |
Definition at line 199 of file tftp.c.
201 DBGC ( tftp,
"TFTP %p finished with status %d (%s)\n",
struct interface socket
Transport layer interface.
struct arbelprm_rc_send_wqe rc
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
struct interface xfer
Data transfer interface.
struct interface mc_socket
Multicast transport layer interface.
char * strerror(int errno)
Retrieve string representation of error number.
struct retry_timer timer
Retransmission timer.
void stop_timer(struct retry_timer *timer)
Stop timer.
References DBGC, intf_shutdown(), tftp_request::mc_socket, rc, tftp_request::socket, stop_timer(), strerror(), tftp_request::timer, and tftp_request::xfer.
Referenced by tftp_close(), tftp_core_open(), tftp_rx_data(), tftp_rx_error(), tftp_rx_oack(), and tftp_timer_expired().
Reopen TFTP socket.
- Parameters
-
- Return values
-
Definition at line 219 of file tftp.c.
233 memset ( &server, 0,
sizeof ( server ) );
238 DBGC ( tftp,
"TFTP %p could not open socket: %s\n",
struct interface socket
Transport layer interface.
struct arbelprm_rc_send_wqe rc
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
unsigned int flags
Request flags.
Generalized socket address structure.
char * strerror(int errno)
Retrieve string representation of error number.
const char * host
Host name.
unsigned int port
Server port.
struct uri * uri
URI being fetched.
struct sockaddr_tcpip peer
Peer address.
#define NULL
NULL pointer (VOID *)
int xfer_open_named_socket(struct interface *xfer, int semantics, struct sockaddr *peer, const char *name, struct sockaddr *local)
Open named socket.
void * memset(void *dest, int character, size_t len) __nonnull
References DBGC, tftp_request::flags, uri::host, htons, intf_restart(), memset(), NULL, tftp_request::peer, tftp_request::port, rc, SOCK_DGRAM, tftp_request::socket, sockaddr_tcpip::st_port, strerror(), TFTP_FL_SEND_ACK, tftp_request::uri, and xfer_open_named_socket().
Referenced by tftp_core_open(), and tftp_timer_expired().
Presize TFTP receive buffers and block bitmap.
- Parameters
-
tftp | TFTP connection |
filesize | Known minimum file size |
- Return values
-
Definition at line 281 of file tftp.c.
282 unsigned int num_blocks;
286 if ( filesize <= tftp->filesize )
302 num_blocks = ( ( filesize / tftp->
blksize ) + 1 );
304 DBGC ( tftp,
"TFTP %p could not resize bitmap to %d blocks: " #define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
struct bitmap bitmap
Block bitmap.
unsigned int blksize
Data block size.
struct interface xfer
Data transfer interface.
int bitmap_resize(struct bitmap *bitmap, unsigned int new_length)
Resize bitmap.
int xfer_seek(struct interface *intf, off_t offset)
Seek to position.
char * strerror(int errno)
Retrieve string representation of error number.
size_t filesize
Maximum known length.
References tftp_request::bitmap, bitmap_resize(), tftp_request::blksize, DBGC, EINVAL, tftp_request::filesize, rc, strerror(), tftp_request::xfer, and xfer_seek().
Referenced by tftp_rx_data(), and tftp_rx_oack().
Transmit RRQ.
- Parameters
-
- Return values
-
Definition at line 347 of file tftp.c.
348 const char *path = ( tftp->
uri->
path + 1 );
354 DBGC ( tftp,
"TFTP %p requesting \"%s\"\n", tftp, path );
357 len = (
sizeof ( *rrq ) +
strlen ( path ) + 1
372 rrq =
iob_put ( iobuf,
sizeof ( *rrq ) );
375 "%s%coctet", path, 0 ) + 1 );
379 "blksize%c%zd%ctsize%c0",
385 "multicast%c", 0 ) + 1 );
struct interface socket
Transport layer interface.
#define iob_put(iobuf, len)
int xfer_deliver_iob(struct interface *intf, struct io_buffer *iobuf)
Deliver datagram as I/O buffer without metadata.
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
size_t xfer_window(struct interface *intf)
Check flow control window.
#define ENOMEM
Not enough space.
unsigned int flags
Request flags.
struct interface xfer
Data transfer interface.
Request blksize and tsize options.
const char * path
Path (after URI decoding)
static size_t iob_tailroom(struct io_buffer *iobuf)
Calculate available space at end of an I/O buffer.
size_t strlen(const char *src)
Get length of string.
A TFTP read request (RRQ) packet.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
uint32_t blksize
Cipher block size.
struct uri * uri
URI being fetched.
Request multicast option.
#define TFTP_RRQ
Read request opcode.
References blksize, DBGC, ENOMEM, tftp_request::flags, htons, iob_put, iob_tailroom(), len, tftp_rrq::opcode, uri::path, snprintf(), tftp_request::socket, strlen(), io_buffer::tail, TFTP_FL_RRQ_MULTICAST, TFTP_FL_RRQ_SIZES, TFTP_MAX_BLKSIZE, TFTP_RRQ, tftp_request::uri, tftp_request::xfer, xfer_alloc_iob(), xfer_deliver_iob(), and xfer_window().
Referenced by tftp_send_packet().
Transmit ACK.
- Parameters
-
- Return values
-
Definition at line 400 of file tftp.c.
410 DBGC2 ( tftp,
"TFTP %p sending ACK for block %d\n", tftp,
block );
418 ack =
iob_put ( iobuf,
sizeof ( *ack ) );
struct interface socket
Transport layer interface.
#define iob_put(iobuf, len)
struct bitmap bitmap
Block bitmap.
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
#define TFTP_ACK
Data block acknowledgement opcode.
#define ENOMEM
Not enough space.
Generalized socket address structure.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
uint8_t block[3][8]
DES-encrypted blocks.
static unsigned int bitmap_first_gap(struct bitmap *bitmap)
Get first gap within bitmap.
struct sockaddr_tcpip peer
Peer address.
A TFTP acknowledgement (ACK) packet.
References tftp_request::bitmap, bitmap_first_gap(), block, tftp_ack::block, DBGC2, ENOMEM, htons, iob_put, meta(), tftp_ack::opcode, tftp_request::peer, tftp_request::socket, TFTP_ACK, xfer_alloc_iob(), and xfer_deliver().
Referenced by tftp_send_packet().
static int tftp_send_error |
( |
struct tftp_request * |
tftp, |
|
|
int |
errcode, |
|
|
const char * |
errmsg |
|
) |
| |
|
static |
Transmit ERROR (Abort)
- Parameters
-
tftp | TFTP connection |
errcode | TFTP error code |
errmsg | Error message string |
- Return values
-
Definition at line 434 of file tftp.c.
443 DBGC2 ( tftp,
"TFTP %p sending ERROR %d: %s\n", tftp,
errcode,
453 err =
iob_put ( iobuf, msglen );
struct interface socket
Transport layer interface.
#define iob_put(iobuf, len)
struct io_buffer * xfer_alloc_iob(struct interface *intf, size_t len)
Allocate I/O buffer.
#define ENOMEM
Not enough space.
char * strcpy(char *dest, const char *src)
Copy string.
Generalized socket address structure.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
size_t strlen(const char *src)
Get length of string.
#define TFTP_ERROR
Error opcode.
struct sockaddr_tcpip peer
Peer address.
A TFTP error (ERROR) packet.
References DBGC2, ENOMEM, errcode, tftp_error::errcode, errmsg, tftp_error::errmsg, htons, iob_put, meta(), tftp_error::opcode, tftp_request::peer, tftp_request::socket, strcpy(), strlen(), TFTP_ERROR, xfer_alloc_iob(), and xfer_deliver().
Referenced by tftp_close().
Transmit next relevant packet.
- Parameters
-
- Return values
-
Definition at line 468 of file tftp.c.
struct interface socket
Transport layer interface.
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
sa_family_t st_family
Socket address family (part of struct sockaddr)
size_t xfer_window(struct interface *intf)
Check flow control window.
unsigned int flags
Request flags.
static int tftp_send_rrq(struct tftp_request *tftp)
Transmit RRQ.
void start_timer(struct retry_timer *timer)
Start timer.
static int tftp_send_ack(struct tftp_request *tftp)
Transmit ACK.
struct retry_timer timer
Retransmission timer.
void stop_timer(struct retry_timer *timer)
Stop timer.
struct sockaddr_tcpip peer
Peer address.
References tftp_request::flags, tftp_request::peer, tftp_request::socket, sockaddr_tcpip::st_family, start_timer(), start_timer_nodelay(), stop_timer(), TFTP_FL_SEND_ACK, tftp_send_ack(), tftp_send_rrq(), tftp_request::timer, and xfer_window().
Referenced by tftp_rx_data(), tftp_rx_oack(), and tftp_timer_expired().
static void tftp_timer_expired |
( |
struct retry_timer * |
timer, |
|
|
int |
fail |
|
) |
| |
|
static |
Handle TFTP retransmission timer expiry.
- Parameters
-
timer | Retry timer |
fail | Failure indicator |
Definition at line 499 of file tftp.c.
510 DBGC ( tftp,
"TFTP %p attempting reopen\n", tftp );
516 DBGC ( tftp,
"TFTP %p timeout %d waiting for MTFTP " 520 DBGC ( tftp,
"TFTP %p falling back to plain " 535 sizeof ( tftp->
bitmap ) );
unsigned int mtftp_timeouts
MTFTP timeout count.
struct arbelprm_rc_send_wqe rc
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
static int tftp_reopen(struct tftp_request *tftp)
Reopen TFTP socket.
static void bitmap_free(struct bitmap *bitmap)
Free bitmap resources.
sa_family_t st_family
Socket address family (part of struct sockaddr)
struct bitmap bitmap
Block bitmap.
#define MTFTP_MAX_TIMEOUTS
Maximum number of MTFTP open requests before falling back to TFTP.
unsigned int flags
Request flags.
#define container_of(ptr, type, field)
Get containing structure.
Request blksize and tsize options.
struct interface mc_socket
Multicast transport layer interface.
static void tftp_done(struct tftp_request *tftp, int rc)
Mark TFTP request as complete.
static int tftp_send_packet(struct tftp_request *tftp)
Transmit next relevant packet.
#define TFTP_PORT
Default TFTP server port.
Perform MTFTP recovery on timeout.
struct retry_timer timer
Retransmission timer.
unsigned int port
Server port.
struct sockaddr_tcpip peer
Peer address.
#define ETIMEDOUT
Connection timed out.
void * memset(void *dest, int character, size_t len) __nonnull
References tftp_request::bitmap, bitmap_free(), container_of, DBGC, ETIMEDOUT, tftp_request::flags, intf_restart(), tftp_request::mc_socket, memset(), MTFTP_MAX_TIMEOUTS, tftp_request::mtftp_timeouts, tftp_request::peer, tftp_request::port, rc, sockaddr_tcpip::st_family, start_timer_nodelay(), tftp_done(), TFTP_FL_MTFTP_RECOVERY, TFTP_FL_RRQ_SIZES, TFTP_PORT, tftp_reopen(), tftp_send_packet(), and tftp_request::timer.
Referenced by tftp_core_open().
static int tftp_process_multicast |
( |
struct tftp_request * |
tftp, |
|
|
char * |
value |
|
) |
| |
|
static |
Process TFTP "multicast" option.
- Parameters
-
tftp | TFTP connection |
value | Option value |
- Return values
-
Definition at line 608 of file tftp.c.
624 DBGC ( tftp,
"TFTP %p multicast missing port,mc\n", tftp );
630 DBGC ( tftp,
"TFTP %p multicast missing mc\n", tftp );
636 if (
strtoul ( mc, &mc_end, 0 ) == 0 )
639 DBGC ( tftp,
"TFTP %p multicast invalid mc %s\n", tftp, mc );
642 DBGC ( tftp,
"TFTP %p is%s the master client\n",
645 socket.sin.sin_family =
AF_INET;
647 DBGC ( tftp,
"TFTP %p multicast invalid IP address " 648 "%s\n", tftp,
addr );
651 DBGC ( tftp,
"TFTP %p multicast IP address %s\n",
652 tftp,
inet_ntoa ( socket.sin.sin_addr ) );
655 DBGC ( tftp,
"TFTP %p multicast invalid port %s\n",
659 DBGC ( tftp,
"TFTP %p multicast port %d\n",
660 tftp,
ntohs ( socket.sin.sin_port ) );
struct arbelprm_rc_send_wqe rc
unsigned long strtoul(const char *string, char **endp, int base)
Convert string to numeric value.
#define EINVAL_MC_INVALID_IP
#define EINVAL_MC_INVALID_PORT
unsigned int flags
Request flags.
pseudo_bit_t value[0x00020]
#define EINVAL_MC_NO_PORT
Generalized socket address structure.
char * strchr(const char *src, int character)
Find character within a string.
int inet_aton(const char *string, struct in_addr *in)
Parse IPv4 address.
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
#define EINVAL_MC_INVALID_MC
static int tftp_reopen_mc(struct tftp_request *tftp, struct sockaddr *local)
Reopen TFTP multicast socket.
#define AF_INET
IPv4 Internet addresses.
if(natsemi->flags &NATSEMI_64BIT) return 1
References addr, AF_INET, DBGC, EINVAL_MC_INVALID_IP, EINVAL_MC_INVALID_MC, EINVAL_MC_INVALID_PORT, EINVAL_MC_NO_MC, EINVAL_MC_NO_PORT, tftp_request::flags, htons, if(), inet_aton(), inet_ntoa(), ntohs, port, rc, sa, sin, strchr(), strtoul(), TFTP_FL_SEND_ACK, tftp_reopen_mc(), and value.
Receive OACK.
- Parameters
-
tftp | TFTP connection |
buf | Temporary data buffer |
len | Length of temporary data buffer |
- Return values
-
Definition at line 721 of file tftp.c.
730 if (
len <
sizeof ( *oack ) ) {
731 DBGC ( tftp,
"TFTP %p received underlength OACK packet " 732 "length %zd\n", tftp,
len );
749 DBGC ( tftp,
"TFTP %p received OACK with malformed " 750 "option name:\n", tftp );
755 DBGC ( tftp,
"TFTP %p received OACK missing value " 756 "for option \"%s\"\n", tftp,
name );
762 DBGC ( tftp,
"TFTP %p received OACK with malformed " 763 "value for option \"%s\":\n", tftp,
name );
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
A TFTP options acknowledgement (OACK) packet.
uint32_t next
Next descriptor address.
static int tftp_process_option(struct tftp_request *tftp, const char *name, char *value)
Process TFTP option.
static int tftp_presize(struct tftp_request *tftp, size_t filesize)
Presize TFTP receive buffers and block bitmap.
pseudo_bit_t value[0x00020]
static void tftp_done(struct tftp_request *tftp, int rc)
Mark TFTP request as complete.
static int tftp_send_packet(struct tftp_request *tftp)
Transmit next relevant packet.
size_t strnlen(const char *src, size_t max)
Get length of string.
uint32_t end
Ending offset.
unsigned long tsize
File size.
struct bofm_section_header done
References tftp_oack::data, DBGC, DBGC_HD, done, EINVAL, end, len, name, next, rc, strnlen(), tftp_done(), tftp_presize(), tftp_process_option(), tftp_send_packet(), tftp_request::tsize, and value.
Referenced by tftp_rx().
Receive DATA.
- Parameters
-
tftp | TFTP connection |
iobuf | I/O buffer |
- Return values
-
Takes ownership of I/O buffer.
Definition at line 797 of file tftp.c.
808 DBGC ( tftp,
"TFTP %p received underlength DATA packet " 809 "length %zd\n", tftp,
iob_len ( iobuf ) );
817 DBGC ( tftp,
"TFTP %p received data block 0\n", tftp );
832 DBGC ( tftp,
"TFTP %p received overlength DATA packet " 844 DBGC ( tftp,
"TFTP %p could not deliver data: %s\n",
#define iob_pull(iobuf, len)
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
#define XFER_FL_ABS_OFFSET
Offset is absolute.
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
struct bitmap bitmap
Block bitmap.
A TFTP data (DATA) packet.
uint32_t data_len
Microcode data size (or 0 to indicate 2000 bytes)
static int tftp_presize(struct tftp_request *tftp, size_t filesize)
Presize TFTP receive buffers and block bitmap.
static void profile_stop(struct profiler *profiler)
Stop profiling.
unsigned int blksize
Data block size.
#define iob_disown(iobuf)
Disown an I/O buffer.
struct interface xfer
Data transfer interface.
static void profile_start(struct profiler *profiler)
Start profiling.
static void tftp_done(struct tftp_request *tftp, int rc)
Mark TFTP request as complete.
static int tftp_send_packet(struct tftp_request *tftp)
Transmit next relevant packet.
char * strerror(int errno)
Retrieve string representation of error number.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
void bitmap_set(struct bitmap *bitmap, unsigned int bit)
Set bit in bitmap.
uint8_t block[3][8]
DES-encrypted blocks.
void * data
Start of data.
uint8_t data[48]
Additional event data.
static unsigned int bitmap_first_gap(struct bitmap *bitmap)
Get first gap within bitmap.
uint16_t offset
Offset to command line.
static int bitmap_full(struct bitmap *bitmap)
Check to see if bitmap is full.
struct bofm_section_header done
void * memset(void *dest, int character, size_t len) __nonnull
References tftp_request::bitmap, bitmap_first_gap(), bitmap_full(), bitmap_set(), tftp_request::blksize, block, data, io_buffer::data, data_len, DBGC, done, EINVAL, free_iob(), iob_disown, iob_len(), iob_pull, memset(), meta(), ntohs, offset, profile_start(), profile_stop(), rc, strerror(), tftp_done(), tftp_presize(), tftp_send_packet(), tftp_request::xfer, xfer_deliver(), and XFER_FL_ABS_OFFSET.
Referenced by tftp_rx().
Receive new data.
- Parameters
-
tftp | TFTP connection |
iobuf | I/O buffer |
meta | Transfer metadata |
- Return values
-
Definition at line 930 of file tftp.c.
943 DBGC ( tftp,
"TFTP %p received underlength packet length " 944 "%zd\n", tftp,
len );
948 DBGC ( tftp,
"TFTP %p received packet without source port\n",
957 DBGC ( tftp,
"TFTP %p using remote port %d\n", tftp,
960 sizeof ( tftp->
peer ) ) != 0 ) {
961 DBGC ( tftp,
"TFTP %p received packet from wrong source (got " 967 switch (
common->opcode ) {
978 DBGC ( tftp,
"TFTP %p received strange packet type %d\n",
#define EINVAL
Invalid argument.
struct arbelprm_rc_send_wqe rc
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
sa_family_t st_family
Socket address family (part of struct sockaddr)
#define iob_disown(iobuf)
Disown an I/O buffer.
static int tftp_rx_error(struct tftp_request *tftp, void *buf, size_t len)
Receive ERROR.
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static int tftp_rx_data(struct tftp_request *tftp, struct io_buffer *iobuf)
Receive DATA.
static void profile_start(struct profiler *profiler)
Start profiling.
uint16_t st_port
TCP/IP port.
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
The common header of all TFTP packets.
struct ib_cm_common common
#define TFTP_ERROR
Error opcode.
#define TFTP_OACK
Options acknowledgement opcode.
static int tftp_rx_oack(struct tftp_request *tftp, void *buf, size_t len)
Receive OACK.
void * data
Start of data.
uint8_t data[48]
Additional event data.
#define TFTP_DATA
Data block opcode.
struct sockaddr_tcpip peer
Peer address.
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
struct bofm_section_header done
if(natsemi->flags &NATSEMI_64BIT) return 1
References common, io_buffer::data, DBGC, done, EINVAL, free_iob(), htons, if(), iob_disown, iob_len(), len, memcmp(), memcpy(), meta(), ntohs, tftp_request::peer, profile_start(), rc, sockaddr_tcpip::st_family, sockaddr_tcpip::st_port, TFTP_DATA, TFTP_ERROR, TFTP_OACK, tftp_rx_data(), tftp_rx_error(), and tftp_rx_oack().
Referenced by tftp_socket_deliver().
static int tftp_core_open |
( |
struct interface * |
xfer, |
|
|
struct uri * |
uri, |
|
|
unsigned int |
default_port, |
|
|
struct sockaddr * |
multicast, |
|
|
unsigned int |
flags |
|
) |
| |
|
static |
Initiate TFTP/TFTM/MTFTP download.
- Parameters
-
xfer | Data transfer interface |
uri | Uniform Resource Identifier |
- Return values
-
Definition at line 1086 of file tftp.c.
1102 tftp =
zalloc (
sizeof ( *tftp ) );
1134 DBGC ( tftp,
"TFTP %p could not create request: %s\n",
#define EINVAL
Invalid argument.
struct interface socket
Transport layer interface.
struct arbelprm_rc_send_wqe rc
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
static int tftp_reopen(struct tftp_request *tftp)
Reopen TFTP socket.
#define ref_init(refcnt, free)
Initialise a reference counter.
static struct interface_descriptor tftp_xfer_desc
TFTP data transfer interface descriptor.
void intf_plug_plug(struct interface *a, struct interface *b)
Plug two object interfaces together.
struct refcnt refcnt
Reference count.
unsigned int blksize
Data block size.
static void tftp_timer_expired(struct retry_timer *timer, int fail)
Handle TFTP retransmission timer expiry.
#define ENOMEM
Not enough space.
static struct interface_descriptor tftp_socket_desc
TFTP socket interface descriptor.
unsigned int flags
Request flags.
struct interface xfer
Data transfer interface.
static struct interface_descriptor tftp_mc_socket_desc
TFTP multicast socket interface descriptor.
const char * path
Path (after URI decoding)
struct interface mc_socket
Multicast transport layer interface.
static void tftp_free(struct refcnt *refcnt)
Free TFTP request.
static void tftp_done(struct tftp_request *tftp, int rc)
Mark TFTP request as complete.
char * strerror(int errno)
Retrieve string representation of error number.
void * zalloc(size_t size)
Allocate cleared memory.
const char * host
Host name.
static int tftp_reopen_mc(struct tftp_request *tftp, struct sockaddr *local)
Reopen TFTP multicast socket.
struct retry_timer timer
Retransmission timer.
unsigned int port
Server port.
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
#define TFTP_DEFAULT_BLKSIZE
Default TFTP data block size.
A Uniform Resource Identifier.
struct uri * uri
URI being fetched.
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
#define ref_put(refcnt)
Drop reference to object.
References tftp_request::blksize, DBGC, EINVAL, ENOMEM, flags, tftp_request::flags, uri::host, intf_init(), intf_plug_plug(), tftp_request::mc_socket, uri::path, tftp_request::port, rc, ref_init, ref_put, tftp_request::refcnt, tftp_request::socket, start_timer_nodelay(), strerror(), TFTP_DEFAULT_BLKSIZE, tftp_done(), tftp_free(), tftp_mc_socket_desc, tftp_reopen(), tftp_reopen_mc(), tftp_socket_desc, tftp_timer_expired(), tftp_xfer_desc, tftp_request::timer, tftp_request::uri, uri_get(), uri_port(), tftp_request::xfer, and zalloc().
Referenced by mtftp_open(), tftm_open(), and tftp_open().
static int tftp_apply_settings |
( |
void |
| ) |
|
|
static |
Apply TFTP configuration settings.
- Return values
-
Definition at line 1211 of file tftp.c.
1212 static struct in_addr tftp_server = { 0 };
1213 struct in_addr new_tftp_server;
1214 char uri_string[32];
1227 if ( new_tftp_server.s_addr &&
1228 ( new_tftp_server.s_addr != tftp_server.
s_addr ) ) {
1229 DBGC ( &tftp_server,
"TFTP server changed %s => ",
1231 DBGC ( &tftp_server,
"%s\n",
inet_ntoa ( new_tftp_server ) );
1232 snprintf ( uri_string,
sizeof ( uri_string ),
1233 "tftp://%s/",
inet_ntoa ( new_tftp_server ) );
1239 tftp_server = new_tftp_server;
static void uri_put(struct uri *uri)
Decrement URI reference count.
int fetch_ipv4_setting(struct settings *settings, const struct setting *setting, struct in_addr *inp)
Fetch value of IPv4 address setting.
#define ENOMEM
Not enough space.
void churi(struct uri *uri)
Change working URI.
char * inet_ntoa(struct in_addr in)
Convert IPv4 address to dotted-quad notation.
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
A Uniform Resource Identifier.
#define NULL
NULL pointer (VOID *)
struct uri * parse_uri(const char *uri_string)
Parse URI.
References churi(), DBGC, ENOMEM, fetch_ipv4_setting(), inet_ntoa(), NULL, parse_uri(), in_addr::s_addr, snprintf(), and uri_put().