tftp
1# This file was automatically generated by SWIG (https://www.swig.org). 2# Version 4.2.1 3# 4# Do not make changes to this file unless you know what you are doing - modify 5# the SWIG interface file instead. 6 7from sys import version_info as _swig_python_version_info 8from mock_rtems import _tftp as _tftp 9 10try: 11 import builtins as __builtin__ 12except ImportError: 13 import __builtin__ 14 15def _swig_repr(self): 16 try: 17 strthis = "proxy of " + self.this.__repr__() 18 except __builtin__.Exception: 19 strthis = "" 20 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) 21 22 23def _swig_setattr_nondynamic_instance_variable(set): 24 def set_instance_attr(self, name, value): 25 if name == "this": 26 set(self, name, value) 27 elif name == "thisown": 28 self.this.own(value) 29 elif hasattr(self, name) and isinstance(getattr(type(self), name), property): 30 set(self, name, value) 31 else: 32 raise AttributeError("You cannot add instance attributes to %s" % self) 33 return set_instance_attr 34 35 36def _swig_setattr_nondynamic_class_variable(set): 37 def set_class_attr(cls, name, value): 38 if hasattr(cls, name) and not isinstance(getattr(cls, name), property): 39 set(cls, name, value) 40 else: 41 raise AttributeError("You cannot add class attributes to %s" % cls) 42 return set_class_attr 43 44 45def _swig_add_metaclass(metaclass): 46 """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" 47 def wrapper(cls): 48 return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) 49 return wrapper 50 51 52class _SwigNonDynamicMeta(type): 53 """Meta class to enforce nondynamic attributes (no new attributes) for a class""" 54 __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) 55 56 57 58def rtems_tftpfs_initialize(mt_entry, data): 59 r""" 60 Do not call directly, use mount(). 61 62 63 64 Filesystem Mount table entry. 65 """ 66 return _tftp.rtems_tftpfs_initialize(mt_entry, data) 67TFTP_RFC1350_BLOCK_SIZE = _tftp.TFTP_RFC1350_BLOCK_SIZE 68r""" 69 This block size meets RFC 1350 and avoids the sending of 70 the `blksize` option to the TFTP server. 71 """ 72TFTP_RFC1350_WINDOW_SIZE = _tftp.TFTP_RFC1350_WINDOW_SIZE 73r""" 74 This window size avoids the sending of the `windowsize` 75 option to the TFTP server. 76 77 This effectively mimics the operation defined in RFC 1350 which 78 does not know any window size. 79 """ 80TFTP_DEFAULT_BLOCK_SIZE = _tftp.TFTP_DEFAULT_BLOCK_SIZE 81r""" 82 This block size is suggested in RFC 2348 and is used as 83 default if no different block size is provided. 84 """ 85TFTP_DEFAULT_WINDOW_SIZE = _tftp.TFTP_DEFAULT_WINDOW_SIZE 86r""" 87 This window size is suggested in RFC 2348 and is used as 88 default if no different window size is provided. 89 """ 90class tftp_options(object): 91 r""" 92 This structure represents TFTP options negotiated between 93 client and server. 94 95 RFC 2347 is the basis for the TFTP option. 96 """ 97 98 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 99 __repr__ = _swig_repr 100 block_size = property(_tftp.tftp_options_block_size_get, _tftp.tftp_options_block_size_set, doc=r""" 101 This member represents the desired size of a data block. 102 103 The TFTP blocksize option is introduced in RFC 2348. It defines the 104 number of octets in the data packets transferred. Valid values 105 range between 8 and 65464 octets, inclusive. Values larger 106 than 1468 may cause packet fragmentation over standard Ethernet. 107 A value of 512 will prevent this option from being sent to 108 the server. 109 110 The default value is 1456. 111 """) 112 window_size = property(_tftp.tftp_options_window_size_get, _tftp.tftp_options_window_size_set, doc=r""" 113 This member represents the desired size of a window. 114 115 The TFTP windowsize option is introduced in RFC 7440. It defines the 116 number of data packets send before the receiver must send an 117 acknowledgment packet. Valid values range between 1 and 65535 118 packets, inclusive. Simple TFTP servers usually do not support this 119 option. This option may negatively contribute to network 120 congestion. This can be avoided by using a window size of 1. 121 A value of 1 will prevent this option from being sent to 122 the server. 123 124 The default value is 8. 125 """) 126 127 def __init__(self): 128 r"""__init__(tftp_options self) -> tftp_options""" 129 _tftp.tftp_options_swiginit(self, _tftp.new_tftp_options()) 130 __swig_destroy__ = _tftp.delete_tftp_options 131 132# Register tftp_options in _tftp: 133_tftp.tftp_options_swigregister(tftp_options) 134class tftp_net_config(object): 135 r""" 136 This structure represents configuration value used by the TFTP 137 client. 138 139 As defaults the values suggested in RFC 7440 are used. 140 """ 141 142 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 143 __repr__ = _swig_repr 144 retransmissions = property(_tftp.tftp_net_config_retransmissions_get, _tftp.tftp_net_config_retransmissions_set, doc=r""" 145 This member defines how many attempts are made to send a 146 network packet to the server. 147 148 Repetitions occur when the server does not response to a packet 149 send by the client within a timeout period. When the here defined 150 number of repetitions is reached and the server does still not 151 respond, the connection is considered broken and the file transfer 152 is ended with an error. 153 154 The default value is 6. 155 """) 156 server_port = property(_tftp.tftp_net_config_server_port_get, _tftp.tftp_net_config_server_port_set, doc=r""" 157 This member defines the port on which the server is listening 158 for incoming connections. 159 160 The default port number is 69. 161 """) 162 timeout = property(_tftp.tftp_net_config_timeout_get, _tftp.tftp_net_config_timeout_set, doc=r""" 163 This member defines the maximum time in milliseconds the 164 client waits for an answer packet from the server. 165 166 If the time out is exceeded, the client will re-transmit the last 167 packet it send to the server. In case ``window_size`` is larger one, 168 several packets may subject to re-transmission. 169 170 Note that this timeout applies only after the first re-transmission 171 of a packet. The timeout till the first re-transmission is 172 ``first_timeout``. 173 174 The default value is 1000ms. 175 """) 176 first_timeout = property(_tftp.tftp_net_config_first_timeout_get, _tftp.tftp_net_config_first_timeout_set, doc=r""" 177 This member defines the maximum time in milliseconds the 178 client waits for the first answer packet from the server. 179 180 The ``first_timeout`` is used instead of the regular ``timeout`` 181 for the first wait-period directly after the client sends a packet 182 for the first time to the server. That is, this is the timeout 183 of the first re-transmission. For any following re-transmissions 184 of the current packet the regular ``timeout`` is used. 185 186 The default value is 400ms. 187 """) 188 options = property(_tftp.tftp_net_config_options_get, _tftp.tftp_net_config_options_set, doc=r""" 189 This member represents the options to be sent to the server. 190 191 These option values are sent to the server. Yet, the server may 192 193 + ignore one or all options 194 + ask the client to use a different value for an option 195 + reject the whole request with an error 196 197 If the server rejects a request with options, the current client 198 implementation will automatically send a second request without 199 options. Hence, the user should be aware that the actual file 200 transfer may not use the option values specified here. 201 """) 202 203 def __init__(self): 204 r"""__init__(tftp_net_config self) -> tftp_net_config""" 205 _tftp.tftp_net_config_swiginit(self, _tftp.new_tftp_net_config()) 206 __swig_destroy__ = _tftp.delete_tftp_net_config 207 208# Register tftp_net_config in _tftp: 209_tftp.tftp_net_config_swigregister(tftp_net_config) 210 211def tftp_initialize_net_config(config): 212 r""" 213 Set all members of a ``tftp_net_config`` structure to their 214 default values. 215 216 :type config: :py:class:`tftp_net_config` 217 :param config: references a ``tftp_net_config`` structure. 218 The values are set to the defaults defined in 219 '`type tftp_net_config`'. 220 """ 221 return _tftp.tftp_initialize_net_config(config) 222 223def tftp_open(hostname, path, is_for_reading, config, tftp_handle): 224 r""" 225 Opens and starts a TFTP client session to read or write a 226 single file. 227 228 This directive resolves the hostname or IP address, establishes a connection 229 to the TFTP server and initiates the data transfer. It will not return 230 before an error is encountered or the TFTP server has responded to the 231 read or write request with a network packet. 232 233 TFTP uses timeouts (of unspecified length). It does not know keep-alive 234 messages. If the client does not respond to the server in due time, 235 the server sets the connection faulty and drops it. To avoid this 236 the user of this code must read or write enough data fast enough. 237 238 "Enough data" means at least so much data which fills a single data 239 packet or all packets of a window if windows are used. The data 240 can be read or written in anything from one single large chunk to 241 byte-by-byte pieces. The point is, one cannot pause the reading 242 or writing for longer periods of time. 243 244 :type hostname: string 245 :param hostname: is the IPv4 address as string or the name of the TFTP 246 server to connect to. 247 :type path: string 248 :param path: is the pathname at the TFTP server side of the file to 249 read or write. According to RFC 1350 the path must be in 250 NETASCII. This is ASCII as defined in "USA Standard Code for 251 Information Interchange" with the modifications specified in "Telnet 252 Protocol Specification". 253 :type is_for_reading: boolean 254 :param is_for_reading: indicated whether the file is to be read or written. 255 A value of ``true`` indicates that the file is intended to be read from 256 the server. A value of ``false`` indicates that the file is to be 257 written to the server. 258 :type config: :py:class:`tftp_net_config` 259 :param config: either references a structure defining the configuration 260 values for this file transfer or is ``NULL``. If it is ``NULL``, default 261 configuration values are used. See 'tftp_net_config' 262 "type tftp_net_config" for a description and the defaults values. 263 This function copies the data so that the memory pointed to by 264 ``config`` can be used for other purposes after the call returns. 265 :type tftp_handle: void, out 266 :param tftp_handle: references a place where a handle of the connection 267 can be stored. On success a pointer to a handle is stored. On failure 268 (return value other than 0) a ``NULL`` pointer is stored. This handle 269 must be provided to all further calls to ``tftp_read()``, 270 ``tftp_write()``, and ``tftp_close()``. 271 272 When this directive stores a non-NULL pointer in this place, a call 273 to ``tftp_close()`` is mandatory to release allocated resources. 274 This parameter cannot be ``NULL``. 275 276 :rtype: int 277 :return: Returns a POSIX ``errno`` value in case an error occurred. 278 """ 279 return _tftp.tftp_open(hostname, path, is_for_reading, config, tftp_handle) 280 281def tftp_read(tftp_handle, buffer, count): 282 r""" 283 Read data from a TFTP server. 284 285 This directive attempts to read data from a TFTP connection open for 286 reading. 287 288 Upon success, the buffer is always filled with ``count`` bytes of received 289 data with the exception when the end of the file has been reached. 290 291 TFTP cannot recover from errors. Once an error is reported, the 292 connection must be and can only be closed. 293 294 :type tftp_handle: void 295 :param tftp_handle: is the reference returned by a call to tftp_open(). 296 The file must be opened for reading. 297 :type buffer: void, out 298 :param buffer: references a memory area into which the received 299 data is written. 300 :type count: int 301 :param count: defines the size of the ``buffer`` in bytes. 302 303 :rtype: ssize_t 304 :return: If greater or equal to 0, returns the number of bytes written 305 into the buffer. If the return value is negative, an error occurred. 306 In this case the negated value is a POSIX ``errno`` value. 307 """ 308 return _tftp.tftp_read(tftp_handle, buffer, count) 309 310def tftp_write(tftp_handle, buffer, count): 311 r""" 312 Write data to a TFTP server. 313 314 This directive attempts to write data to a TFTP connection open for 315 writing. 316 317 On a successful call, all data in the ``buffer`` will be used. Yet, this 318 does not imply that all data is actually sent. This depends on 319 whether a whole data packet or window can be filled. 320 321 TFTP cannot recover from errors. Once an error is reported, the connection 322 must be and can only be closed. 323 324 :type tftp_handle: void 325 :param tftp_handle: is the reference returned by a call to tftp_open(). 326 The file must be opened for writing. 327 :type buffer: void 328 :param buffer: references a memory area which contains the data to be 329 sent. 330 :type count: int 331 :param count: defines the size of the data in ``buffer`` in bytes. 332 333 :rtype: ssize_t 334 :return: If greater or equal to 0, returns the number of bytes used 335 from the buffer. The value is always ``count`` on a successful call. 336 If the return value is negative, an error occurred. In this case 337 the negated value is a POSIX ``errno`` value. 338 """ 339 return _tftp.tftp_write(tftp_handle, buffer, count) 340 341def tftp_close(tftp_handle): 342 r""" 343 Close a TFTP client connection. 344 345 This directive sends all data which are still stored in a write buffer 346 to the server (if any), tells the server that the connection ends (if 347 required by RFC 1350) and releases any resources allocated at the 348 client side. 349 350 Notes: Especially, when writing a file to the server, the return 351 code of `tftp_close()` should be checked. Invoking 352 `tftp_close()` triggers the sending of the last -- not 353 completely filled -- data block. This may fail the same way as any 354 `tftp_write()` may fail. Therefore, an error returned by 355 `tftp_close()` likely indicates that the file was not 356 completely transferred. 357 358 :type tftp_handle: void 359 :param tftp_handle: is the reference returned by a call to tftp_open(). 360 If this parameter is ``NULL``, the directive call is a no-op. 361 362 :rtype: int 363 :return: Returns a POSIX ``errno`` value in case an error occurred. 364 """ 365 return _tftp.tftp_close(tftp_handle)
59def rtems_tftpfs_initialize(mt_entry, data): 60 r""" 61 Do not call directly, use mount(). 62 63 64 65 Filesystem Mount table entry. 66 """ 67 return _tftp.rtems_tftpfs_initialize(mt_entry, data)
Do not call directly, use mount().
Filesystem Mount table entry.
This block size meets RFC 1350 and avoids the sending of
the blksize option to the TFTP server.
This window size avoids the sending of the windowsize
option to the TFTP server.
This effectively mimics the operation defined in RFC 1350 which does not know any window size.
This block size is suggested in RFC 2348 and is used as default if no different block size is provided.
This window size is suggested in RFC 2348 and is used as default if no different window size is provided.
91class tftp_options(object): 92 r""" 93 This structure represents TFTP options negotiated between 94 client and server. 95 96 RFC 2347 is the basis for the TFTP option. 97 """ 98 99 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 100 __repr__ = _swig_repr 101 block_size = property(_tftp.tftp_options_block_size_get, _tftp.tftp_options_block_size_set, doc=r""" 102 This member represents the desired size of a data block. 103 104 The TFTP blocksize option is introduced in RFC 2348. It defines the 105 number of octets in the data packets transferred. Valid values 106 range between 8 and 65464 octets, inclusive. Values larger 107 than 1468 may cause packet fragmentation over standard Ethernet. 108 A value of 512 will prevent this option from being sent to 109 the server. 110 111 The default value is 1456. 112 """) 113 window_size = property(_tftp.tftp_options_window_size_get, _tftp.tftp_options_window_size_set, doc=r""" 114 This member represents the desired size of a window. 115 116 The TFTP windowsize option is introduced in RFC 7440. It defines the 117 number of data packets send before the receiver must send an 118 acknowledgment packet. Valid values range between 1 and 65535 119 packets, inclusive. Simple TFTP servers usually do not support this 120 option. This option may negatively contribute to network 121 congestion. This can be avoided by using a window size of 1. 122 A value of 1 will prevent this option from being sent to 123 the server. 124 125 The default value is 8. 126 """) 127 128 def __init__(self): 129 r"""__init__(tftp_options self) -> tftp_options""" 130 _tftp.tftp_options_swiginit(self, _tftp.new_tftp_options()) 131 __swig_destroy__ = _tftp.delete_tftp_options
This structure represents TFTP options negotiated between client and server.
RFC 2347 is the basis for the TFTP option.
128 def __init__(self): 129 r"""__init__(tftp_options self) -> tftp_options""" 130 _tftp.tftp_options_swiginit(self, _tftp.new_tftp_options())
__init__(tftp_options self) -> tftp_options
99 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
The membership flag
135class tftp_net_config(object): 136 r""" 137 This structure represents configuration value used by the TFTP 138 client. 139 140 As defaults the values suggested in RFC 7440 are used. 141 """ 142 143 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") 144 __repr__ = _swig_repr 145 retransmissions = property(_tftp.tftp_net_config_retransmissions_get, _tftp.tftp_net_config_retransmissions_set, doc=r""" 146 This member defines how many attempts are made to send a 147 network packet to the server. 148 149 Repetitions occur when the server does not response to a packet 150 send by the client within a timeout period. When the here defined 151 number of repetitions is reached and the server does still not 152 respond, the connection is considered broken and the file transfer 153 is ended with an error. 154 155 The default value is 6. 156 """) 157 server_port = property(_tftp.tftp_net_config_server_port_get, _tftp.tftp_net_config_server_port_set, doc=r""" 158 This member defines the port on which the server is listening 159 for incoming connections. 160 161 The default port number is 69. 162 """) 163 timeout = property(_tftp.tftp_net_config_timeout_get, _tftp.tftp_net_config_timeout_set, doc=r""" 164 This member defines the maximum time in milliseconds the 165 client waits for an answer packet from the server. 166 167 If the time out is exceeded, the client will re-transmit the last 168 packet it send to the server. In case ``window_size`` is larger one, 169 several packets may subject to re-transmission. 170 171 Note that this timeout applies only after the first re-transmission 172 of a packet. The timeout till the first re-transmission is 173 ``first_timeout``. 174 175 The default value is 1000ms. 176 """) 177 first_timeout = property(_tftp.tftp_net_config_first_timeout_get, _tftp.tftp_net_config_first_timeout_set, doc=r""" 178 This member defines the maximum time in milliseconds the 179 client waits for the first answer packet from the server. 180 181 The ``first_timeout`` is used instead of the regular ``timeout`` 182 for the first wait-period directly after the client sends a packet 183 for the first time to the server. That is, this is the timeout 184 of the first re-transmission. For any following re-transmissions 185 of the current packet the regular ``timeout`` is used. 186 187 The default value is 400ms. 188 """) 189 options = property(_tftp.tftp_net_config_options_get, _tftp.tftp_net_config_options_set, doc=r""" 190 This member represents the options to be sent to the server. 191 192 These option values are sent to the server. Yet, the server may 193 194 + ignore one or all options 195 + ask the client to use a different value for an option 196 + reject the whole request with an error 197 198 If the server rejects a request with options, the current client 199 implementation will automatically send a second request without 200 options. Hence, the user should be aware that the actual file 201 transfer may not use the option values specified here. 202 """) 203 204 def __init__(self): 205 r"""__init__(tftp_net_config self) -> tftp_net_config""" 206 _tftp.tftp_net_config_swiginit(self, _tftp.new_tftp_net_config()) 207 __swig_destroy__ = _tftp.delete_tftp_net_config
This structure represents configuration value used by the TFTP client.
As defaults the values suggested in RFC 7440 are used.
204 def __init__(self): 205 r"""__init__(tftp_net_config self) -> tftp_net_config""" 206 _tftp.tftp_net_config_swiginit(self, _tftp.new_tftp_net_config())
__init__(tftp_net_config self) -> tftp_net_config
143 thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
The membership flag
212def tftp_initialize_net_config(config): 213 r""" 214 Set all members of a ``tftp_net_config`` structure to their 215 default values. 216 217 :type config: :py:class:`tftp_net_config` 218 :param config: references a ``tftp_net_config`` structure. 219 The values are set to the defaults defined in 220 '`type tftp_net_config`'. 221 """ 222 return _tftp.tftp_initialize_net_config(config)
Set all members of a tftp_net_config structure to their
default values.
Parameters
- config: references a
tftp_net_configstructure. The values are set to the defaults defined in 'type tftp_net_config'.
224def tftp_open(hostname, path, is_for_reading, config, tftp_handle): 225 r""" 226 Opens and starts a TFTP client session to read or write a 227 single file. 228 229 This directive resolves the hostname or IP address, establishes a connection 230 to the TFTP server and initiates the data transfer. It will not return 231 before an error is encountered or the TFTP server has responded to the 232 read or write request with a network packet. 233 234 TFTP uses timeouts (of unspecified length). It does not know keep-alive 235 messages. If the client does not respond to the server in due time, 236 the server sets the connection faulty and drops it. To avoid this 237 the user of this code must read or write enough data fast enough. 238 239 "Enough data" means at least so much data which fills a single data 240 packet or all packets of a window if windows are used. The data 241 can be read or written in anything from one single large chunk to 242 byte-by-byte pieces. The point is, one cannot pause the reading 243 or writing for longer periods of time. 244 245 :type hostname: string 246 :param hostname: is the IPv4 address as string or the name of the TFTP 247 server to connect to. 248 :type path: string 249 :param path: is the pathname at the TFTP server side of the file to 250 read or write. According to RFC 1350 the path must be in 251 NETASCII. This is ASCII as defined in "USA Standard Code for 252 Information Interchange" with the modifications specified in "Telnet 253 Protocol Specification". 254 :type is_for_reading: boolean 255 :param is_for_reading: indicated whether the file is to be read or written. 256 A value of ``true`` indicates that the file is intended to be read from 257 the server. A value of ``false`` indicates that the file is to be 258 written to the server. 259 :type config: :py:class:`tftp_net_config` 260 :param config: either references a structure defining the configuration 261 values for this file transfer or is ``NULL``. If it is ``NULL``, default 262 configuration values are used. See 'tftp_net_config' 263 "type tftp_net_config" for a description and the defaults values. 264 This function copies the data so that the memory pointed to by 265 ``config`` can be used for other purposes after the call returns. 266 :type tftp_handle: void, out 267 :param tftp_handle: references a place where a handle of the connection 268 can be stored. On success a pointer to a handle is stored. On failure 269 (return value other than 0) a ``NULL`` pointer is stored. This handle 270 must be provided to all further calls to ``tftp_read()``, 271 ``tftp_write()``, and ``tftp_close()``. 272 273 When this directive stores a non-NULL pointer in this place, a call 274 to ``tftp_close()`` is mandatory to release allocated resources. 275 This parameter cannot be ``NULL``. 276 277 :rtype: int 278 :return: Returns a POSIX ``errno`` value in case an error occurred. 279 """ 280 return _tftp.tftp_open(hostname, path, is_for_reading, config, tftp_handle)
Opens and starts a TFTP client session to read or write a single file.
This directive resolves the hostname or IP address, establishes a connection to the TFTP server and initiates the data transfer. It will not return before an error is encountered or the TFTP server has responded to the read or write request with a network packet.
TFTP uses timeouts (of unspecified length). It does not know keep-alive messages. If the client does not respond to the server in due time, the server sets the connection faulty and drops it. To avoid this the user of this code must read or write enough data fast enough.
"Enough data" means at least so much data which fills a single data packet or all packets of a window if windows are used. The data can be read or written in anything from one single large chunk to byte-by-byte pieces. The point is, one cannot pause the reading or writing for longer periods of time.
Parameters
- hostname: is the IPv4 address as string or the name of the TFTP server to connect to.
- path: is the pathname at the TFTP server side of the file to read or write. According to RFC 1350 the path must be in NETASCII. This is ASCII as defined in "USA Standard Code for Information Interchange" with the modifications specified in "Telnet Protocol Specification".
- is_for_reading: indicated whether the file is to be read or written.
A value of
trueindicates that the file is intended to be read from the server. A value offalseindicates that the file is to be written to the server. - config: either references a structure defining the configuration
values for this file transfer or is
NULL. If it isNULL, default configuration values are used. See 'tftp_net_config' "type tftp_net_config" for a description and the defaults values. This function copies the data so that the memory pointed to byconfigcan be used for other purposes after the call returns. tftp_handle: references a place where a handle of the connection can be stored. On success a pointer to a handle is stored. On failure (return value other than 0) a
NULLpointer is stored. This handle must be provided to all further calls totftp_read(),tftp_write(), andtftp_close().When this directive stores a non-NULL pointer in this place, a call to
tftp_close()is mandatory to release allocated resources. This parameter cannot beNULL.
Returns
Returns a POSIX
errnovalue in case an error occurred.
282def tftp_read(tftp_handle, buffer, count): 283 r""" 284 Read data from a TFTP server. 285 286 This directive attempts to read data from a TFTP connection open for 287 reading. 288 289 Upon success, the buffer is always filled with ``count`` bytes of received 290 data with the exception when the end of the file has been reached. 291 292 TFTP cannot recover from errors. Once an error is reported, the 293 connection must be and can only be closed. 294 295 :type tftp_handle: void 296 :param tftp_handle: is the reference returned by a call to tftp_open(). 297 The file must be opened for reading. 298 :type buffer: void, out 299 :param buffer: references a memory area into which the received 300 data is written. 301 :type count: int 302 :param count: defines the size of the ``buffer`` in bytes. 303 304 :rtype: ssize_t 305 :return: If greater or equal to 0, returns the number of bytes written 306 into the buffer. If the return value is negative, an error occurred. 307 In this case the negated value is a POSIX ``errno`` value. 308 """ 309 return _tftp.tftp_read(tftp_handle, buffer, count)
Read data from a TFTP server.
This directive attempts to read data from a TFTP connection open for reading.
Upon success, the buffer is always filled with count bytes of received
data with the exception when the end of the file has been reached.
TFTP cannot recover from errors. Once an error is reported, the connection must be and can only be closed.
Parameters
- tftp_handle: is the reference returned by a call to tftp_open(). The file must be opened for reading.
- buffer: references a memory area into which the received data is written.
- count: defines the size of the
bufferin bytes.
Returns
If greater or equal to 0, returns the number of bytes written into the buffer. If the return value is negative, an error occurred. In this case the negated value is a POSIX
errnovalue.
311def tftp_write(tftp_handle, buffer, count): 312 r""" 313 Write data to a TFTP server. 314 315 This directive attempts to write data to a TFTP connection open for 316 writing. 317 318 On a successful call, all data in the ``buffer`` will be used. Yet, this 319 does not imply that all data is actually sent. This depends on 320 whether a whole data packet or window can be filled. 321 322 TFTP cannot recover from errors. Once an error is reported, the connection 323 must be and can only be closed. 324 325 :type tftp_handle: void 326 :param tftp_handle: is the reference returned by a call to tftp_open(). 327 The file must be opened for writing. 328 :type buffer: void 329 :param buffer: references a memory area which contains the data to be 330 sent. 331 :type count: int 332 :param count: defines the size of the data in ``buffer`` in bytes. 333 334 :rtype: ssize_t 335 :return: If greater or equal to 0, returns the number of bytes used 336 from the buffer. The value is always ``count`` on a successful call. 337 If the return value is negative, an error occurred. In this case 338 the negated value is a POSIX ``errno`` value. 339 """ 340 return _tftp.tftp_write(tftp_handle, buffer, count)
Write data to a TFTP server.
This directive attempts to write data to a TFTP connection open for writing.
On a successful call, all data in the buffer will be used. Yet, this
does not imply that all data is actually sent. This depends on
whether a whole data packet or window can be filled.
TFTP cannot recover from errors. Once an error is reported, the connection must be and can only be closed.
Parameters
- tftp_handle: is the reference returned by a call to tftp_open(). The file must be opened for writing.
- buffer: references a memory area which contains the data to be sent.
- count: defines the size of the data in
bufferin bytes.
Returns
If greater or equal to 0, returns the number of bytes used from the buffer. The value is always
counton a successful call. If the return value is negative, an error occurred. In this case the negated value is a POSIXerrnovalue.
342def tftp_close(tftp_handle): 343 r""" 344 Close a TFTP client connection. 345 346 This directive sends all data which are still stored in a write buffer 347 to the server (if any), tells the server that the connection ends (if 348 required by RFC 1350) and releases any resources allocated at the 349 client side. 350 351 Notes: Especially, when writing a file to the server, the return 352 code of `tftp_close()` should be checked. Invoking 353 `tftp_close()` triggers the sending of the last -- not 354 completely filled -- data block. This may fail the same way as any 355 `tftp_write()` may fail. Therefore, an error returned by 356 `tftp_close()` likely indicates that the file was not 357 completely transferred. 358 359 :type tftp_handle: void 360 :param tftp_handle: is the reference returned by a call to tftp_open(). 361 If this parameter is ``NULL``, the directive call is a no-op. 362 363 :rtype: int 364 :return: Returns a POSIX ``errno`` value in case an error occurred. 365 """ 366 return _tftp.tftp_close(tftp_handle)
Close a TFTP client connection.
This directive sends all data which are still stored in a write buffer to the server (if any), tells the server that the connection ends (if required by RFC 1350) and releases any resources allocated at the client side.
Notes: Especially, when writing a file to the server, the return
code of tftp_close() should be checked. Invoking
tftp_close() triggers the sending of the last -- not
completely filled -- data block. This may fail the same way as any
tftp_write() may fail. Therefore, an error returned by
tftp_close() likely indicates that the file was not
completely transferred.
Parameters
- tftp_handle: is the reference returned by a call to tftp_open().
If this parameter is
NULL, the directive call is a no-op.
Returns
Returns a POSIX
errnovalue in case an error occurred.