[kernel] revert 15922 - add back 2.6.29 kernel support
[openwrt.git] / package / ead / src / ead.h
1 /*
2 * Copyright (C) 2008 Felix Fietkau <nbd@openwrt.org>
3 *
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
7 *
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.
12 */
13
14 #ifndef __EAD_H
15 #define __EAD_H
16
17 #define EAD_DEBUGLEVEL 1
18
19 #include <stdint.h>
20 #include <stddef.h>
21
22 #ifndef MAXSALTLEN
23 #define MAXSALTLEN 32
24 #endif
25
26 #define EAD_PORT 56026UL
27 #define EAD_MAGIC 3671771902UL
28 #define EAD_CMD_TIMEOUT 10
29
30 #define EAD_MAX_IV_INCR 128
31
32 /* request/response types */
33 /* response id == request id + 1 */
34 enum ead_type {
35 EAD_TYPE_PING,
36 EAD_TYPE_PONG,
37
38 EAD_TYPE_SET_USERNAME,
39 EAD_TYPE_ACK_USERNAME,
40
41 EAD_TYPE_GET_PRIME,
42 EAD_TYPE_PRIME,
43
44 EAD_TYPE_SEND_A,
45 EAD_TYPE_SEND_B,
46
47 EAD_TYPE_SEND_AUTH,
48 EAD_TYPE_DONE_AUTH,
49
50 EAD_TYPE_SEND_CMD,
51 EAD_TYPE_RESULT_CMD,
52
53 EAD_TYPE_LAST
54 };
55
56 enum ead_auth_type {
57 EAD_AUTH_DEFAULT,
58 EAD_AUTH_MD5
59 };
60
61 enum ead_cmd_type {
62 EAD_CMD_NORMAL,
63 EAD_CMD_BACKGROUND,
64 EAD_CMD_LAST
65 };
66
67 struct ead_msg_pong {
68 uint16_t auth_type;
69 char name[];
70 } __attribute__((packed));
71
72 struct ead_msg_number {
73 uint8_t id;
74 unsigned char data[];
75 } __attribute__((packed));
76
77 struct ead_msg_salt {
78 uint8_t prime;
79 uint8_t len;
80 unsigned char salt[MAXSALTLEN];
81 unsigned char ext_salt[MAXSALTLEN];
82 } __attribute__((packed));
83
84 struct ead_msg_user {
85 char username[32];
86 } __attribute__((packed));
87
88 struct ead_msg_auth {
89 unsigned char data[20];
90 } __attribute__((packed));
91
92 struct ead_msg_cmd {
93 uint8_t type;
94 uint16_t timeout;
95 unsigned char data[];
96 } __attribute__((packed));
97
98 struct ead_msg_cmd_data {
99 uint8_t done;
100 unsigned char data[];
101 } __attribute__((packed));
102
103 struct ead_msg_encrypted {
104 uint32_t hash[5];
105 uint32_t iv;
106 uint8_t pad;
107 union {
108 struct ead_msg_cmd cmd;
109 struct ead_msg_cmd_data cmd_data;
110 } data[];
111 } __attribute__((packed));
112
113
114 #define EAD_DATA(_msg, _type) (&((_msg)->data[0]._type))
115 #define EAD_ENC_DATA(_msg, _type) (&((_msg)->data[0].enc.data[0]._type))
116
117 /* for ead_msg::sid */
118 #define EAD_INSTANCE_MASK 0xf000
119 #define EAD_INSTANCE_SHIFT 12
120
121 struct ead_msg {
122 uint32_t magic;
123 uint32_t len;
124 uint32_t type;
125 uint16_t nid; /* node id */
126 uint16_t sid; /* session id */
127 uint32_t ip; /* source ip for responses from the server */
128 union {
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;
135 } data[];
136 } __attribute__((packed));
137
138
139 #endif
This page took 0.049674 seconds and 5 git commands to generate.