Browse Source

Refine packed alignment

pull/1022/head
Max Lv 8 years ago
parent
commit
b47d28920f
2 changed files with 11 additions and 21 deletions
  1. 19
      src/obfs_tls.h
  2. 13
      src/socks5.h

19
src/obfs_tls.h

@ -25,9 +25,6 @@
#include "obfs.h" #include "obfs.h"
#pragma pack(push)
#pragma pack(1)
struct tls_client_hello { struct tls_client_hello {
char content_type; char content_type;
short version; short version;
@ -47,7 +44,7 @@ struct tls_client_hello {
char comp_methods_len; char comp_methods_len;
char comp_methods[1]; char comp_methods[1];
short ext_len; short ext_len;
};
} __attribute__((packed));
struct tls_ext_server_name { struct tls_ext_server_name {
short ext_type; short ext_type;
@ -56,13 +53,13 @@ struct tls_ext_server_name {
char server_name_type; char server_name_type;
short server_name_len; short server_name_len;
// char server_name[server_name_len]; // char server_name[server_name_len];
};
} __attribute__((packed));
struct tls_ext_session_ticket { struct tls_ext_session_ticket {
short session_ticket_type; short session_ticket_type;
short session_ticket_ext_len; short session_ticket_ext_len;
// char session_ticket[session_ticket_ext_len]; // char session_ticket[session_ticket_ext_len];
};
} __attribute__((packed));
struct tls_ext_others { struct tls_ext_others {
short ec_point_formats_ext_type; short ec_point_formats_ext_type;
@ -85,7 +82,7 @@ struct tls_ext_others {
short extended_master_secret_type; short extended_master_secret_type;
short extended_master_secret_ext_len; short extended_master_secret_ext_len;
};
} __attribute__((packed));
struct tls_server_hello { struct tls_server_hello {
char content_type; char content_type;
@ -116,21 +113,21 @@ struct tls_server_hello {
short ec_point_formats_ext_len; short ec_point_formats_ext_len;
char ec_point_formats_len; char ec_point_formats_len;
char ec_point_formats[1]; char ec_point_formats[1];
};
} __attribute__((packed));
struct tls_change_cipher_spec { struct tls_change_cipher_spec {
char content_type; char content_type;
short version; short version;
short len; short len;
char msg; char msg;
};
} __attribute__((packed));
struct tls_encrypted_handshake { struct tls_encrypted_handshake {
char content_type; char content_type;
short version; short version;
short len; short len;
// char msg[len]; // char msg[len];
};
} __attribute__((packed));
typedef struct frame { typedef struct frame {
short idx; short idx;
@ -138,8 +135,6 @@ typedef struct frame {
char buf[2]; char buf[2];
} frame_t; } frame_t;
#pragma pack(pop)
extern obfs_para_t *obfs_tls; extern obfs_para_t *obfs_tls;
#endif #endif

13
src/socks5.h

@ -30,34 +30,29 @@
#define IPV6 0x04 #define IPV6 0x04
#define CMD_NOT_SUPPORTED 0x07 #define CMD_NOT_SUPPORTED 0x07
#pragma pack(push)
#pragma pack(1)
struct method_select_request { struct method_select_request {
char ver; char ver;
char nmethods; char nmethods;
char methods[255]; char methods[255];
};
} __attribute__((packed));
struct method_select_response { struct method_select_response {
char ver; char ver;
char method; char method;
};
} __attribute__((packed));
struct socks5_request { struct socks5_request {
char ver; char ver;
char cmd; char cmd;
char rsv; char rsv;
char atyp; char atyp;
};
} __attribute__((packed));
struct socks5_response { struct socks5_response {
char ver; char ver;
char rep; char rep;
char rsv; char rsv;
char atyp; char atyp;
};
#pragma pack(pop)
} __attribute__((packed));
#endif // _SOCKS5_H #endif // _SOCKS5_H
Loading…
Cancel
Save