You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tftp.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. /*
  2. * Copyright (C) 2006 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <stdint.h>
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <string.h>
  22. #include <strings.h>
  23. #include <byteswap.h>
  24. #include <errno.h>
  25. #include <assert.h>
  26. #include <gpxe/refcnt.h>
  27. #include <gpxe/xfer.h>
  28. #include <gpxe/open.h>
  29. #include <gpxe/uri.h>
  30. #include <gpxe/tcpip.h>
  31. #include <gpxe/retry.h>
  32. #include <gpxe/tftp.h>
  33. /** @file
  34. *
  35. * TFTP protocol
  36. *
  37. */
  38. /**
  39. * A TFTP request
  40. *
  41. * This data structure holds the state for an ongoing TFTP transfer.
  42. */
  43. struct tftp_request {
  44. /** Reference count */
  45. struct refcnt refcnt;
  46. /** Data transfer interface */
  47. struct xfer_interface xfer;
  48. /** URI being fetched */
  49. struct uri *uri;
  50. /** Transport layer interface */
  51. struct xfer_interface socket;
  52. /** Data block size
  53. *
  54. * This is the "blksize" option negotiated with the TFTP
  55. * server. (If the TFTP server does not support TFTP options,
  56. * this will default to 512).
  57. */
  58. unsigned int blksize;
  59. /** File size
  60. *
  61. * This is the value returned in the "tsize" option from the
  62. * TFTP server. If the TFTP server does not support the
  63. * "tsize" option, this value will be zero.
  64. */
  65. unsigned long tsize;
  66. /** Request state
  67. *
  68. * This is the block number to be used in the next ACK sent
  69. * back to the server, i.e. the number of the last received
  70. * data block. The value zero indicates that the last
  71. * received block was an OACK (i.e. that the next ACK will
  72. * contain a block number of zero), and any value less than
  73. * zero indicates that the connection has not yet been opened
  74. * (i.e. that no blocks have yet been received).
  75. */
  76. int state;
  77. /** Peer address
  78. *
  79. * The peer address is determined by the first response
  80. * received to the TFTP RRQ.
  81. */
  82. struct sockaddr_tcpip peer;
  83. /** Retransmission timer */
  84. struct retry_timer timer;
  85. };
  86. /**
  87. * Free TFTP request
  88. *
  89. * @v refcnt Reference counter
  90. */
  91. static void tftp_free ( struct refcnt *refcnt ) {
  92. struct tftp_request *tftp =
  93. container_of ( refcnt, struct tftp_request, refcnt );
  94. uri_put ( tftp->uri );
  95. free ( tftp );
  96. }
  97. /**
  98. * Mark TFTP request as complete
  99. *
  100. * @v tftp TFTP connection
  101. * @v rc Return status code
  102. */
  103. static void tftp_done ( struct tftp_request *tftp, int rc ) {
  104. /* Stop the retry timer */
  105. stop_timer ( &tftp->timer );
  106. /* Close all data transfer interfaces */
  107. xfer_nullify ( &tftp->socket );
  108. xfer_close ( &tftp->socket, rc );
  109. xfer_nullify ( &tftp->xfer );
  110. xfer_close ( &tftp->xfer, rc );
  111. }
  112. /**
  113. * TFTP requested blocksize
  114. *
  115. * This is treated as a global configuration parameter.
  116. */
  117. static unsigned int tftp_request_blksize = TFTP_MAX_BLKSIZE;
  118. /**
  119. * Set TFTP request blocksize
  120. *
  121. * @v blksize Requested block size
  122. */
  123. void tftp_set_request_blksize ( unsigned int blksize ) {
  124. if ( blksize < TFTP_DEFAULT_BLKSIZE )
  125. blksize = TFTP_DEFAULT_BLKSIZE;
  126. tftp_request_blksize = blksize;
  127. }
  128. /**
  129. * Transmit RRQ
  130. *
  131. * @v tftp TFTP connection
  132. * @ret rc Return status code
  133. */
  134. static int tftp_send_rrq ( struct tftp_request *tftp ) {
  135. struct tftp_rrq *rrq;
  136. const char *path = tftp->uri->path;
  137. size_t len = ( sizeof ( *rrq ) + strlen ( path ) + 1 /* NUL */
  138. + 5 + 1 /* "octet" + NUL */
  139. + 7 + 1 + 5 + 1 /* "blksize" + NUL + ddddd + NUL */
  140. + 5 + 1 + 1 + 1 /* "tsize" + NUL + "0" + NUL */ );
  141. struct io_buffer *iobuf;
  142. DBGC ( tftp, "TFTP %p requesting \"%s\"\n", tftp, path );
  143. /* Allocate buffer */
  144. iobuf = xfer_alloc_iob ( &tftp->socket, len );
  145. if ( ! iobuf )
  146. return -ENOMEM;
  147. /* Build request */
  148. rrq = iob_put ( iobuf, sizeof ( *rrq ) );
  149. rrq->opcode = htons ( TFTP_RRQ );
  150. iob_put ( iobuf,
  151. snprintf ( rrq->data, iob_tailroom ( iobuf ),
  152. "%s%coctet%cblksize%c%d%ctsize%c0", path, 0,
  153. 0, 0, tftp_request_blksize, 0, 0 ) + 1 );
  154. /* RRQ always goes to the address specified in the initial
  155. * xfer_open() call
  156. */
  157. return xfer_deliver_iob ( &tftp->socket, iobuf );
  158. }
  159. /**
  160. * Transmit ACK
  161. *
  162. * @v tftp TFTP connection
  163. * @ret rc Return status code
  164. */
  165. static int tftp_send_ack ( struct tftp_request *tftp ) {
  166. struct tftp_ack *ack;
  167. struct io_buffer *iobuf;
  168. struct xfer_metadata meta = {
  169. .dest = ( struct sockaddr * ) &tftp->peer,
  170. };
  171. /* Allocate buffer */
  172. iobuf = xfer_alloc_iob ( &tftp->socket, sizeof ( *ack ) );
  173. if ( ! iobuf )
  174. return -ENOMEM;
  175. /* Build ACK */
  176. ack = iob_put ( iobuf, sizeof ( *ack ) );
  177. ack->opcode = htons ( TFTP_ACK );
  178. ack->block = htons ( tftp->state );
  179. /* ACK always goes to the peer recorded from the RRQ response */
  180. return xfer_deliver_iob_meta ( &tftp->socket, iobuf, &meta );
  181. }
  182. /**
  183. * Transmit data
  184. *
  185. * @v tftp TFTP connection
  186. * @ret rc Return status code
  187. */
  188. static int tftp_send_packet ( struct tftp_request *tftp ) {
  189. /* Start retransmission timer */
  190. start_timer ( &tftp->timer );
  191. /* Send RRQ or ACK as appropriate */
  192. if ( tftp->state < 0 ) {
  193. return tftp_send_rrq ( tftp );
  194. } else {
  195. return tftp_send_ack ( tftp );
  196. }
  197. }
  198. /**
  199. * Handle TFTP retransmission timer expiry
  200. *
  201. * @v timer Retry timer
  202. * @v fail Failure indicator
  203. */
  204. static void tftp_timer_expired ( struct retry_timer *timer, int fail ) {
  205. struct tftp_request *tftp =
  206. container_of ( timer, struct tftp_request, timer );
  207. if ( fail ) {
  208. tftp_done ( tftp, -ETIMEDOUT );
  209. } else {
  210. tftp_send_packet ( tftp );
  211. }
  212. }
  213. /**
  214. * Mark TFTP block as received
  215. *
  216. * @v tftp TFTP connection
  217. * @v block Block number
  218. */
  219. static void tftp_received ( struct tftp_request *tftp, unsigned int block ) {
  220. /* Stop the retry timer */
  221. stop_timer ( &tftp->timer );
  222. /* Update state to indicate which block we're now waiting for */
  223. tftp->state = block;
  224. /* Send next packet */
  225. tftp_send_packet ( tftp );
  226. }
  227. /**
  228. * Process TFTP "blksize" option
  229. *
  230. * @v tftp TFTP connection
  231. * @v value Option value
  232. * @ret rc Return status code
  233. */
  234. static int tftp_process_blksize ( struct tftp_request *tftp,
  235. const char *value ) {
  236. char *end;
  237. tftp->blksize = strtoul ( value, &end, 10 );
  238. if ( *end ) {
  239. DBGC ( tftp, "TFTP %p got invalid blksize \"%s\"\n",
  240. tftp, value );
  241. return -EINVAL;
  242. }
  243. DBGC ( tftp, "TFTP %p blksize=%d\n", tftp, tftp->blksize );
  244. return 0;
  245. }
  246. /**
  247. * Process TFTP "tsize" option
  248. *
  249. * @v tftp TFTP connection
  250. * @v value Option value
  251. * @ret rc Return status code
  252. */
  253. static int tftp_process_tsize ( struct tftp_request *tftp,
  254. const char *value ) {
  255. char *end;
  256. tftp->tsize = strtoul ( value, &end, 10 );
  257. if ( *end ) {
  258. DBGC ( tftp, "TFTP %p got invalid tsize \"%s\"\n",
  259. tftp, value );
  260. return -EINVAL;
  261. }
  262. DBGC ( tftp, "TFTP %p tsize=%ld\n", tftp, tftp->tsize );
  263. /* Notify recipient of file size */
  264. xfer_seek ( &tftp->xfer, tftp->tsize, SEEK_SET );
  265. xfer_seek ( &tftp->xfer, 0, SEEK_SET );
  266. return 0;
  267. }
  268. /** A TFTP option */
  269. struct tftp_option {
  270. /** Option name */
  271. const char *name;
  272. /** Option processor
  273. *
  274. * @v tftp TFTP connection
  275. * @v value Option value
  276. * @ret rc Return status code
  277. */
  278. int ( * process ) ( struct tftp_request *tftp, const char *value );
  279. };
  280. /** Recognised TFTP options */
  281. static struct tftp_option tftp_options[] = {
  282. { "blksize", tftp_process_blksize },
  283. { "tsize", tftp_process_tsize },
  284. { NULL, NULL }
  285. };
  286. /**
  287. * Process TFTP option
  288. *
  289. * @v tftp TFTP connection
  290. * @v name Option name
  291. * @v value Option value
  292. * @ret rc Return status code
  293. */
  294. static int tftp_process_option ( struct tftp_request *tftp,
  295. const char *name, const char *value ) {
  296. struct tftp_option *option;
  297. for ( option = tftp_options ; option->name ; option++ ) {
  298. if ( strcasecmp ( name, option->name ) == 0 )
  299. return option->process ( tftp, value );
  300. }
  301. DBGC ( tftp, "TFTP %p received unknown option \"%s\" = \"%s\"\n",
  302. tftp, name, value );
  303. return -EINVAL;
  304. }
  305. /**
  306. * Receive OACK
  307. *
  308. * @v tftp TFTP connection
  309. * @v buf Temporary data buffer
  310. * @v len Length of temporary data buffer
  311. * @ret rc Return status code
  312. */
  313. static int tftp_rx_oack ( struct tftp_request *tftp, void *buf, size_t len ) {
  314. struct tftp_oack *oack = buf;
  315. char *end = buf + len;
  316. char *name;
  317. char *value;
  318. int rc;
  319. /* Sanity check */
  320. if ( len < sizeof ( *oack ) ) {
  321. DBGC ( tftp, "TFTP %p received underlength OACK packet "
  322. "length %d\n", tftp, len );
  323. return -EINVAL;
  324. }
  325. if ( end[-1] != '\0' ) {
  326. DBGC ( tftp, "TFTP %p received OACK missing final NUL\n",
  327. tftp );
  328. return -EINVAL;
  329. }
  330. /* Process each option in turn */
  331. name = oack->data;
  332. while ( name < end ) {
  333. value = ( name + strlen ( name ) + 1 );
  334. if ( value == end ) {
  335. DBGC ( tftp, "TFTP %p received OACK missing value "
  336. "for option \"%s\"\n", tftp, name );
  337. return -EINVAL;
  338. }
  339. if ( ( rc = tftp_process_option ( tftp, name, value ) ) != 0 )
  340. return rc;
  341. name = ( value + strlen ( value ) + 1 );
  342. }
  343. /* Mark as received block 0 (the OACK) */
  344. tftp_received ( tftp, 0 );
  345. return 0;
  346. }
  347. /**
  348. * Receive DATA
  349. *
  350. * @v tftp TFTP connection
  351. * @v iobuf I/O buffer
  352. * @ret rc Return status code
  353. *
  354. * Takes ownership of I/O buffer.
  355. */
  356. static int tftp_rx_data ( struct tftp_request *tftp,
  357. struct io_buffer *iobuf ) {
  358. struct tftp_data *data = iobuf->data;
  359. unsigned int block;
  360. size_t data_len;
  361. int rc;
  362. /* Sanity check */
  363. if ( iob_len ( iobuf ) < sizeof ( *data ) ) {
  364. DBGC ( tftp, "TFTP %p received underlength DATA packet "
  365. "length %d\n", tftp, iob_len ( iobuf ) );
  366. free_iob ( iobuf );
  367. return -EINVAL;
  368. }
  369. /* Extract data */
  370. block = ntohs ( data->block );
  371. iob_pull ( iobuf, sizeof ( *data ) );
  372. data_len = iob_len ( iobuf );
  373. /* Deliver data */
  374. if ( ( rc = xfer_deliver_iob ( &tftp->xfer, iobuf ) ) != 0 ) {
  375. DBGC ( tftp, "TFTP %p could not deliver data: %s\n",
  376. tftp, strerror ( rc ) );
  377. tftp_done ( tftp, rc );
  378. return rc;
  379. }
  380. /* Mark block as received */
  381. tftp_received ( tftp, block );
  382. /* Finish when final block received */
  383. if ( data_len < tftp->blksize )
  384. tftp_done ( tftp, 0 );
  385. return 0;
  386. }
  387. /** Translation between TFTP errors and internal error numbers */
  388. static const uint8_t tftp_errors[] = {
  389. [TFTP_ERR_FILE_NOT_FOUND] = PXENV_STATUS_TFTP_FILE_NOT_FOUND,
  390. [TFTP_ERR_ACCESS_DENIED] = PXENV_STATUS_TFTP_ACCESS_VIOLATION,
  391. [TFTP_ERR_ILLEGAL_OP] = PXENV_STATUS_TFTP_UNKNOWN_OPCODE,
  392. };
  393. /**
  394. * Receive ERROR
  395. *
  396. * @v tftp TFTP connection
  397. * @v buf Temporary data buffer
  398. * @v len Length of temporary data buffer
  399. * @ret rc Return status code
  400. */
  401. static int tftp_rx_error ( struct tftp_request *tftp, void *buf, size_t len ) {
  402. struct tftp_error *error = buf;
  403. unsigned int err;
  404. int rc = 0;
  405. /* Sanity check */
  406. if ( len < sizeof ( *error ) ) {
  407. DBGC ( tftp, "TFTP %p received underlength ERROR packet "
  408. "length %d\n", tftp, len );
  409. return -EINVAL;
  410. }
  411. DBGC ( tftp, "TFTP %p received ERROR packet with code %d, message "
  412. "\"%s\"\n", tftp, ntohs ( error->errcode ), error->errmsg );
  413. /* Determine final operation result */
  414. err = ntohs ( error->errcode );
  415. if ( err < ( sizeof ( tftp_errors ) / sizeof ( tftp_errors[0] ) ) )
  416. rc = -tftp_errors[err];
  417. if ( ! rc )
  418. rc = -PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION;
  419. /* Close TFTP request */
  420. tftp_done ( tftp, rc );
  421. return 0;
  422. }
  423. /**
  424. * Receive new data
  425. *
  426. * @v udp UDP connection
  427. * @v data Received data
  428. * @v len Length of received data
  429. * @v st_src Partially-filled source address
  430. * @v st_dest Partially-filled destination address
  431. */
  432. static int tftp_socket_deliver_iob ( struct xfer_interface *socket,
  433. struct io_buffer *iobuf,
  434. struct xfer_metadata *meta ) {
  435. struct tftp_request *tftp =
  436. container_of ( socket, struct tftp_request, socket );
  437. struct sockaddr_tcpip *st_src;
  438. struct tftp_common *common = iobuf->data;
  439. size_t len = iob_len ( iobuf );
  440. int rc = -EINVAL;
  441. /* Sanity checks */
  442. if ( len < sizeof ( *common ) ) {
  443. DBGC ( tftp, "TFTP %p received underlength packet length %d\n",
  444. tftp, len );
  445. goto done;
  446. }
  447. if ( ! meta ) {
  448. DBGC ( tftp, "TFTP %p received packet without metadata\n",
  449. tftp );
  450. goto done;
  451. }
  452. if ( ! meta->src ) {
  453. DBGC ( tftp, "TFTP %p received packet without source port\n",
  454. tftp );
  455. goto done;
  456. }
  457. /* Filter by TID. Set TID on first response received */
  458. st_src = ( struct sockaddr_tcpip * ) meta->src;
  459. if ( tftp->state < 0 ) {
  460. memcpy ( &tftp->peer, st_src, sizeof ( tftp->peer ) );
  461. DBGC ( tftp, "TFTP %p using remote port %d\n", tftp,
  462. ntohs ( tftp->peer.st_port ) );
  463. } else if ( memcmp ( &tftp->peer, st_src,
  464. sizeof ( tftp->peer ) ) != 0 ) {
  465. DBGC ( tftp, "TFTP %p received packet from wrong source (got "
  466. "%d, wanted %d)\n", tftp, ntohs ( st_src->st_port ),
  467. ntohs ( tftp->peer.st_port ) );
  468. goto done;
  469. }
  470. switch ( common->opcode ) {
  471. case htons ( TFTP_OACK ):
  472. rc = tftp_rx_oack ( tftp, iobuf->data, len );
  473. break;
  474. case htons ( TFTP_DATA ):
  475. rc = tftp_rx_data ( tftp, iobuf );
  476. iobuf = NULL;
  477. break;
  478. case htons ( TFTP_ERROR ):
  479. rc = tftp_rx_error ( tftp, iobuf->data, len );
  480. break;
  481. default:
  482. DBGC ( tftp, "TFTP %p received strange packet type %d\n",
  483. tftp, ntohs ( common->opcode ) );
  484. break;
  485. };
  486. done:
  487. free_iob ( iobuf );
  488. return rc;
  489. }
  490. /**
  491. * TFTP connection closed by network stack
  492. *
  493. * @v socket Transport layer interface
  494. * @v rc Reason for close
  495. */
  496. static void tftp_socket_close ( struct xfer_interface *socket, int rc ) {
  497. struct tftp_request *tftp =
  498. container_of ( socket, struct tftp_request, socket );
  499. DBGC ( tftp, "TFTP %p socket closed: %s\n",
  500. tftp, strerror ( rc ) );
  501. tftp_done ( tftp, rc );
  502. }
  503. /** TFTP socket operations */
  504. static struct xfer_interface_operations tftp_socket_operations = {
  505. .close = tftp_socket_close,
  506. .vredirect = xfer_vopen,
  507. .request = ignore_xfer_request,
  508. .seek = ignore_xfer_seek,
  509. .alloc_iob = default_xfer_alloc_iob,
  510. .deliver_iob = tftp_socket_deliver_iob,
  511. .deliver_raw = xfer_deliver_as_iob,
  512. };
  513. /**
  514. * Close TFTP data transfer interface
  515. *
  516. * @v xfer Data transfer interface
  517. * @v rc Reason for close
  518. */
  519. static void tftp_xfer_close ( struct xfer_interface *xfer, int rc ) {
  520. struct tftp_request *tftp =
  521. container_of ( xfer, struct tftp_request, xfer );
  522. DBGC ( tftp, "TFTP %p interface closed: %s\n",
  523. tftp, strerror ( rc ) );
  524. tftp_done ( tftp, rc );
  525. }
  526. /** TFTP data transfer interface operations */
  527. static struct xfer_interface_operations tftp_xfer_operations = {
  528. .close = tftp_xfer_close,
  529. .vredirect = ignore_xfer_vredirect,
  530. .request = ignore_xfer_request,
  531. .seek = ignore_xfer_seek,
  532. .alloc_iob = default_xfer_alloc_iob,
  533. .deliver_iob = xfer_deliver_as_raw,
  534. .deliver_raw = ignore_xfer_deliver_raw,
  535. };
  536. /**
  537. * Initiate TFTP download
  538. *
  539. * @v xfer Data transfer interface
  540. * @v uri Uniform Resource Identifier
  541. * @ret rc Return status code
  542. */
  543. int tftp_open ( struct xfer_interface *xfer, struct uri *uri ) {
  544. struct tftp_request *tftp;
  545. struct sockaddr_tcpip server;
  546. int rc;
  547. /* Sanity checks */
  548. if ( ! uri->host )
  549. return -EINVAL;
  550. if ( ! uri->path )
  551. return -EINVAL;
  552. /* Allocate and populate TFTP structure */
  553. tftp = malloc ( sizeof ( *tftp ) );
  554. if ( ! tftp )
  555. return -ENOMEM;
  556. memset ( tftp, 0, sizeof ( *tftp ) );
  557. tftp->refcnt.free = tftp_free;
  558. xfer_init ( &tftp->xfer, &tftp_xfer_operations, &tftp->refcnt );
  559. tftp->uri = uri_get ( uri );
  560. xfer_init ( &tftp->socket, &tftp_socket_operations, &tftp->refcnt );
  561. tftp->state = -1;
  562. tftp->timer.expired = tftp_timer_expired;
  563. /* Open socket */
  564. memset ( &server, 0, sizeof ( server ) );
  565. server.st_port = htons ( uri_port ( tftp->uri, TFTP_PORT ) );
  566. if ( ( rc = xfer_open_named_socket ( &tftp->socket, SOCK_DGRAM,
  567. ( struct sockaddr * ) &server,
  568. uri->host, NULL ) ) != 0 )
  569. goto err;
  570. /* Start timer to initiate RRQ */
  571. start_timer ( &tftp->timer );
  572. /* Attach to parent interface, mortalise self, and return */
  573. xfer_plug_plug ( &tftp->xfer, xfer );
  574. ref_put ( &tftp->refcnt );
  575. return 0;
  576. err:
  577. DBGC ( tftp, "TFTP %p could not create request: %s\n",
  578. tftp, strerror ( rc ) );
  579. tftp_done ( tftp, rc );
  580. ref_put ( &tftp->refcnt );
  581. return rc;
  582. }
  583. /** TFTP URI opener */
  584. struct uri_opener tftp_uri_opener __uri_opener = {
  585. .scheme = "tftp",
  586. .open = tftp_open,
  587. };