2 * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
17 #define EAD_DEBUGLEVEL 1
26 #define EAD_PORT 56026UL
27 #define EAD_MAGIC 3671771902UL
28 #define EAD_CMD_TIMEOUT 10
30 #define EAD_MAX_IV_INCR 128
32 /* request/response types */
33 /* response id == request id + 1 */
38 EAD_TYPE_SET_USERNAME
,
39 EAD_TYPE_ACK_USERNAME
,
70 } __attribute__((packed
));
72 struct ead_msg_number
{
75 } __attribute__((packed
));
80 unsigned char salt
[MAXSALTLEN
];
81 unsigned char ext_salt
[MAXSALTLEN
];
82 } __attribute__((packed
));
86 } __attribute__((packed
));
89 unsigned char data
[20];
90 } __attribute__((packed
));
96 } __attribute__((packed
));
98 struct ead_msg_cmd_data
{
100 unsigned char data
[];
101 } __attribute__((packed
));
103 struct ead_msg_encrypted
{
108 struct ead_msg_cmd cmd
;
109 struct ead_msg_cmd_data cmd_data
;
111 } __attribute__((packed
));
114 #define EAD_DATA(_msg, _type) (&((_msg)->data[0]._type))
115 #define EAD_ENC_DATA(_msg, _type) (&((_msg)->data[0].enc.data[0]._type))
117 /* for ead_msg::sid */
118 #define EAD_INSTANCE_MASK 0xf000
119 #define EAD_INSTANCE_SHIFT 12
125 uint16_t nid
; /* node id */
126 uint16_t sid
; /* session id */
127 uint32_t ip
; /* source ip for responses from the server */
129 struct ead_msg_pong pong
;
130 struct ead_msg_user user
;
131 struct ead_msg_number number
;
132 struct ead_msg_auth auth
;
133 struct ead_msg_salt salt
;
134 struct ead_msg_encrypted enc
;
136 } __attribute__((packed
));