1 /*
2  * uhub - A tiny ADC p2p connection hub
3  * Copyright (C) 2007-2014, Jan Vidar Krey
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  *
18  */
19 
20 #ifndef HAVE_UHUB_ADC_CONSTANTS_H
21 #define HAVE_UHUB_ADC_CONSTANTS_H
22 
23 #ifndef SID_T_DEFINED
24 typedef uint32_t sid_t;
25 #define SID_T_DEFINED
26 #endif
27 
28 typedef uint32_t fourcc_t;
29 
30 /* Internal uhub limit */
31 #define MAX_ADC_CMD_LEN 4096
32 
33 #define FOURCC(a,b,c,d) (fourcc_t) ((a << 24) | (b << 16) | (c << 8) | d)
34 
35 /* default welcome protocol support message, as sent by this server */
36 #define ADC_PROTO_SUPPORT "ADBASE ADTIGR ADPING ADUCMD"
37 
38 /* Server sent commands */
39 #define ADC_CMD_ISID FOURCC('I','S','I','D')
40 #define ADC_CMD_ISUP FOURCC('I','S','U','P')
41 #define ADC_CMD_IGPA FOURCC('I','G','P','A')
42 #define ADC_CMD_ISTA FOURCC('I','S','T','A')
43 #define ADC_CMD_IINF FOURCC('I','I','N','F')
44 #define ADC_CMD_IMSG FOURCC('I','M','S','G')
45 #define ADC_CMD_IQUI FOURCC('I','Q','U','I')
46 
47 /* Handshake and login/passwordstuff */
48 #define ADC_CMD_HSUP FOURCC('H','S','U','P')
49 #define ADC_CMD_HPAS FOURCC('H','P','A','S')
50 #define ADC_CMD_HINF FOURCC('H','I','N','F')
51 #define ADC_CMD_BINF FOURCC('B','I','N','F')
52 
53 /* This is a Admin extension */
54 #define ADC_CMD_HDSC FOURCC('H','D','S','C')
55 
56 /* Status/error messages */
57 #define ADC_CMD_HSTA FOURCC('H','S','T','A')
58 #define ADC_CMD_DSTA FOURCC('D','S','T','A')
59 
60 /* searches */
61 #define ADC_CMD_BSCH FOURCC('B','S','C','H')
62 #define ADC_CMD_DSCH FOURCC('D','S','C','H')
63 #define ADC_CMD_ESCH FOURCC('E','S','C','H')
64 #define ADC_CMD_FSCH FOURCC('F','S','C','H')
65 #define ADC_CMD_DRES FOURCC('D','R','E','S')
66 
67 /* invalid search results (spam) */
68 #define ADC_CMD_BRES FOURCC('B','R','E','S')
69 #define ADC_CMD_ERES FOURCC('E','R','E','S')
70 #define ADC_CMD_FRES FOURCC('F','R','E','S')
71 
72 /* connection setup */
73 #define ADC_CMD_DCTM FOURCC('D','C','T','M')
74 #define ADC_CMD_DRCM FOURCC('D','R','C','M')
75 #define ADC_CMD_ECTM FOURCC('E','C','T','M')
76 #define ADC_CMD_ERCM FOURCC('E','R','C','M')
77 
78 /* chat messages */
79 #define ADC_CMD_BMSG FOURCC('B','M','S','G')
80 #define ADC_CMD_DMSG FOURCC('D','M','S','G')
81 #define ADC_CMD_EMSG FOURCC('E','M','S','G')
82 #define ADC_CMD_FMSG FOURCC('F','M','S','G')
83 
84 /* disallowed messages */
85 #define ADC_CMD_DINF FOURCC('D','I','N','F')
86 #define ADC_CMD_EINF FOURCC('E','I','N','F')
87 #define ADC_CMD_FINF FOURCC('F','I','N','F')
88 #define ADC_CMD_BQUI FOURCC('B','Q','U','I')
89 #define ADC_CMD_DQUI FOURCC('D','Q','U','I')
90 #define ADC_CMD_EQUI FOURCC('E','Q','U','I')
91 #define ADC_CMD_FQUI FOURCC('F','Q','U','I')
92 
93 /* Extension messages */
94 #define ADC_CMD_HCHK FOURCC('H','C','H','K')
95 
96 /* UCMD Extension */
97 #define ADC_CMD_BCMD FOURCC('B','C','M','D')
98 #define ADC_CMD_DCMD FOURCC('D','C','M','D')
99 #define ADC_CMD_ECMD FOURCC('E','C','M','D')
100 #define ADC_CMD_FCMD FOURCC('F','C','M','D')
101 #define ADC_CMD_HCMD FOURCC('H','C','M','D')
102 #define ADC_CMD_ICMD FOURCC('I','C','M','D')
103 
104 
105 #define ADC_INF_FLAG_IPV4_ADDR          "I4" /* ipv4 address */
106 #define ADC_INF_FLAG_IPV6_ADDR          "I6" /* ipv6 address */
107 #define ADC_INF_FLAG_IPV4_UDP_PORT      "U4" /* port number */
108 #define ADC_INF_FLAG_IPV6_UDP_PORT      "U6" /* port number */
109 #define ADC_INF_FLAG_CLIENT_TYPE        "CT" /* client type */
110 #define ADC_INF_FLAG_PRIVATE_ID         "PD" /* private id, aka PID */
111 #define ADC_INF_FLAG_CLIENT_ID          "ID" /* client id, aka CID */
112 #define ADC_INF_FLAG_NICK               "NI" /* nick name */
113 #define ADC_INF_FLAG_DESCRIPTION        "DE" /* user description */
114 
115 #define ADC_INF_FLAG_USER_AGENT_PRODUCT "AP" /* software name */
116 #define ADC_INF_FLAG_USER_AGENT_VERSION "VE" /* software version */
117 
118 #define ADC_INF_FLAG_SUPPORT            "SU" /* support (extensions, feature cast) */
119 #define ADC_INF_FLAG_SHARED_SIZE        "SS" /* size of total files shared in bytes */
120 #define ADC_INF_FLAG_SHARED_FILES       "SF" /* number of files shared */
121 #define ADC_INF_FLAG_UPLOAD_SPEED       "US" /* maximum upload speed acheived in bytes/sec */
122 #define ADC_INF_FLAG_DOWNLOAD_SPEED     "DS" /* maximum download speed acheived in bytes/sec */
123 #define ADC_INF_FLAG_UPLOAD_SLOTS       "SL" /* maximum upload slots (concurrent uploads) */
124 #define ADC_INF_FLAG_AUTO_SLOTS         "AS" /* automatic slot if upload speed is less than this in bytes/sec */
125 #define ADC_INF_FLAG_AUTO_SLOTS_MAX     "AM" /* maximum number of automatic slots */
126 #define ADC_INF_FLAG_COUNT_HUB_NORMAL   "HN" /* user is logged into this amount of hubs as a normal user (guest) */
127 #define ADC_INF_FLAG_COUNT_HUB_REGISTER "HR" /* user is logged into this amount of hubs as a registered user (password) */
128 #define ADC_INF_FLAG_COUNT_HUB_OPERATOR "HO" /* user is logged into this amount of hubs as an operator */
129 #define ADC_INF_FLAG_AWAY               "AW" /* away flag, 1=away, 2=extended away */
130 #define ADC_INF_FLAG_REFERER            "RF" /* URL to referer in case of hub redirect */
131 #define ADC_INF_FLAG_EMAIL              "EM" /* E-mail address */
132 
133 #define ADC_MSG_FLAG_ACTION             "ME" /* message is an *action* message */
134 #define ADC_MSG_FLAG_PRIVATE            "PM" /* message is a private message */
135 
136 #define ADC_SCH_FLAG_INCLUDE            "AN" /* include given search term */
137 #define ADC_SCH_FLAG_EXCLUDE            "NO" /* exclude given serach term */
138 #define ADC_SCH_FLAG_FILE_EXTENSION     "EX" /* search only for files with the given file extension */
139 #define ADC_SCH_FLAG_FILE_TYPE          "TY" /* search only for files with this file type (separate type) */
140 #define ADC_SCH_FLAG_LESS_THAN          "LE" /* search for files with this size or less */
141 #define ADC_SCH_FLAG_GREATER_THAN       "GE" /* search for files with this size or greater */
142 #define ADC_SCH_FLAG_EQUAL              "EQ" /* search only for files with this exact size */
143 #define ADC_SCH_FLAG_TOKEN              "TO" /* use this token for search replies */
144 
145 #define ADC_RES_FLAG_FILE_NAME          "FN" /* file name */
146 #define ADC_RES_FLAG_FILE_SIZE          "SI" /* file size */
147 #define ADC_RES_FLAG_UPLOAD_SLOTS       "SL" /* number of upload slots available (if > 0, download is possible) */
148 #define ADC_RES_FLAG_TOKEN              "TO" /* token, same as the token in the search request */
149 
150 #define ADC_QUI_FLAG_TIME_LEFT          "TL" /* time in seconds before reconnect is allowed, or -1 forever */
151 #define ADC_QUI_FLAG_MESSAGE            "MS" /* kick/leave message */
152 #define ADC_QUI_FLAG_DISCONNECT         "DI" /* all further transfers with this user should be disconnected */
153 #define ADC_QUI_FLAG_REDIRECT           "RD" /* redirect to URL */
154 #define ADC_QUI_FLAG_KICK_OPERATOR      "ID" /* SID of operator who disconnected the user */
155 
156 #define ADC_SUP_FLAG_ADD                "AD"
157 #define ADC_SUP_FLAG_REMOVE             "RM"
158 
159 #define ADC_CLIENT_TYPE_BOT              "1"
160 #define ADC_CLIENT_TYPE_REGISTERED_USER  "2"
161 #define ADC_CLIENT_TYPE_OPERATOR         "4"
162 #define ADC_CLIENT_TYPE_HUBBOT           "5"  /* 1 + 4 */
163 #define ADC_CLIENT_TYPE_SUPER_USER      "12"  /* 8 + 4 */
164 #define ADC_CLIENT_TYPE_ADMIN           "20"  /* 16 + 4 = hub owner */
165 #define ADC_CLIENT_TYPE_HUB             "32"  /* the hub itself */
166 
167 
168 #endif /* HAVE_UHUB_ADC_CONSTANTS_H */
169