Browse Source

* Add comment to show how to determine settings_t padding

Bryan Drewery 16 years ago
parent
commit
9d2bf857c8
2 changed files with 5 additions and 3 deletions
  1. 1 1
      src/binary.c
  2. 4 2
      src/settings.h

+ 1 - 1
src/binary.c

@@ -28,7 +28,7 @@
 #include <termios.h>
 #include <termios.h>
 
 
 settings_t settings = {
 settings_t settings = {
-  "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200",
+  SETTINGS_HEADER,
   /* -- STATIC -- */
   /* -- STATIC -- */
   "", "", "", "", "", "", "", "", "", "",
   "", "", "", "", "", "", "", "", "", "",
   /* -- DYNAMIC -- */
   /* -- DYNAMIC -- */

+ 4 - 2
src/settings.h

@@ -1,6 +1,8 @@
 #ifndef _SETTINGS_H
 #ifndef _SETTINGS_H
 #define _SETTINGS_H
 #define _SETTINGS_H
-#define PREFIXLEN 16
+
+#define SETTINGS_HEADER "\200\200\200\200\200\200\200\200\200\200\200\200\200\200\200"
+#define PREFIXLEN sizeof(SETTINGS_HEADER)
 
 
 /* !!! THIS MUST BE CHANGED WHEN CHANGING THE PACK STRUCT OR ALGORITHMS !!! */
 /* !!! THIS MUST BE CHANGED WHEN CHANGING THE PACK STRUCT OR ALGORITHMS !!! */
 #define SETTINGS_VER 2
 #define SETTINGS_VER 2
@@ -34,7 +36,7 @@ typedef struct settings_struct {
   char portmin[17];       /* for hubs, the reserved port range for incoming connections */
   char portmin[17];       /* for hubs, the reserved port range for incoming connections */
   char portmax[17];       /* for hubs, the reserved port range for incoming connections */
   char portmax[17];       /* for hubs, the reserved port range for incoming connections */
   /* -- PADDING -- */
   /* -- PADDING -- */
-  char padding[9];
+  char padding[9];        // (16 - (sizeof(settings_t) % 16)) % 16]
 } settings_t;
 } settings_t;
 
 
 #define SALT1 {s1_1[0],s1_1[1],s1_5[0],s1_5[1],s1_8[0],s1_8[1],s1_4[0],s1_9[1],s1_2[0],s1_13[0],s1_6[0],s1_6[1],s1_7[0],s1_7[1],s1_3[0],s1_13[1],s1_16[1],s1_4[1],s1_15[0],s1_10[1],s1_14[0],s1_14[1],s1_12[0],s1_12[1],s1_2[1],s1_3[1],s1_11[0],s1_11[1],s1_10[0],s1_15[1],s1_16[0],s1_9[0],'\0'}
 #define SALT1 {s1_1[0],s1_1[1],s1_5[0],s1_5[1],s1_8[0],s1_8[1],s1_4[0],s1_9[1],s1_2[0],s1_13[0],s1_6[0],s1_6[1],s1_7[0],s1_7[1],s1_3[0],s1_13[1],s1_16[1],s1_4[1],s1_15[0],s1_10[1],s1_14[0],s1_14[1],s1_12[0],s1_12[1],s1_2[1],s1_3[1],s1_11[0],s1_11[1],s1_10[0],s1_15[1],s1_16[0],s1_9[0],'\0'}