tftp.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2008 by Thermotemp GmbH. All rights reserved.
  3. * Copyright (C) 2002-2007 by egnite Software GmbH. All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the copyright holders nor the names of
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  19. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  21. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  22. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  24. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  25. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  26. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  27. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  28. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  29. * SUCH DAMAGE.
  30. *
  31. * For additional information see http://www.ethernut.de/
  32. */
  33. #ifndef _TFTP_H_
  34. #define _TFTP_H_
  35. typedef struct __attribute__ ((packed)) {
  36. short th_opcode; /* packet type */
  37. union __attribute__ ((packed)) {
  38. short tu_block; /* block # */
  39. short tu_code; /* error code */
  40. char tu_stuff[1]; /* request packet stuff */
  41. } th_u;
  42. u_char th_data[512]; /* data or error string */
  43. } tftp_header;
  44. #define TFTP_RRQ 01 /*!< \brief TFTP read request packet. */
  45. #define TFTP_WRQ 02 /*!< \brief TFTP write request packet. */
  46. #define TFTP_DATA 03 /*!< \brief TFTP data packet. */
  47. #define TFTP_ACK 04 /*!< \brief TFTP acknowledgement packet. */
  48. #define TFTP_ERROR 05 /*!< \brief TFTP error packet. */
  49. #define TFTP_OACK 06 /*!< \brief TFTP option acknowledgement packet. */
  50. #define SPORT 0x0004
  51. #define TPORT 0x4500
  52. #define TFTP_PORT 69
  53. int tftp_receive(char *filename, u_long tftp_ip, int (*callback)(u_char *buffer, u_short block_size, u_long offset, void* user_data), void* user_data);
  54. #endif