fw.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * * Copyright (C) 2007 Ubiquiti Networks, Inc.
  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 (at your option) 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. #ifndef FW_INCLUDED
  19. #define FW_INCLUDED
  20. #include <sys/types.h>
  21. #define MAGIC_HEADER "OPEN"
  22. #define MAGIC_PART "PART"
  23. #define MAGIC_END "END."
  24. #define MAGIC_ENDS "ENDS"
  25. #define MAGIC_LENGTH 4
  26. typedef struct header {
  27. char magic[MAGIC_LENGTH];
  28. char version[256];
  29. u_int32_t crc;
  30. u_int32_t pad;
  31. } __attribute__ ((packed)) header_t;
  32. typedef struct part {
  33. char magic[MAGIC_LENGTH];
  34. char name[16];
  35. char pad[12];
  36. u_int32_t memaddr;
  37. u_int32_t index;
  38. u_int32_t baseaddr;
  39. u_int32_t entryaddr;
  40. u_int32_t data_size;
  41. u_int32_t part_size;
  42. } __attribute__ ((packed)) part_t;
  43. typedef struct part_crc {
  44. u_int32_t crc;
  45. u_int32_t pad;
  46. } __attribute__ ((packed)) part_crc_t;
  47. typedef struct signature {
  48. char magic[MAGIC_LENGTH];
  49. u_int32_t crc;
  50. u_int32_t pad;
  51. } __attribute__ ((packed)) signature_t;
  52. typedef struct signature_rsa {
  53. char magic[MAGIC_LENGTH];
  54. // u_int32_t crc;
  55. unsigned char rsa_signature[256];
  56. u_int32_t pad;
  57. } __attribute__ ((packed)) signature_rsa_t;
  58. #define VERSION "1.2"
  59. #define INFO(...) fprintf(stdout, __VA_ARGS__)
  60. #define ERROR(...) fprintf(stderr, "ERROR: "__VA_ARGS__)
  61. #define WARN(...) fprintf(stderr, "WARN: "__VA_ARGS__)
  62. #define DEBUG(...) do {\
  63. if (debug) \
  64. fprintf(stdout, "DEBUG: "__VA_ARGS__); \
  65. } while (0);
  66. #endif