00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <stdlib.h>
00019 #include <stdio.h>
00020 #include <string.h>
00021 #include <sys/types.h>
00022 #ifndef WIN32
00023 #include <sys/socket.h>
00024 #include <netinet/in.h>
00025 #include <arpa/inet.h>
00026 #endif
00027
00028 #include "hi_return_codes.h"
00029 #include "hi_util_xmalloc.h"
00030 #include "hi_ui_server_lookup.h"
00031 #include "hi_ui_config.h"
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 int hi_ui_config_init_global_conf(HTTPINSPECT_GLOBAL_CONF *GlobalConf)
00051 {
00052 int iRet;
00053
00054 memset(GlobalConf, 0x00, sizeof(HTTPINSPECT_GLOBAL_CONF));
00055
00056 if((iRet = hi_ui_server_lookup_init(&GlobalConf->server_lookup)))
00057 {
00058 return iRet;
00059 }
00060
00061 return HI_SUCCESS;
00062 }
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 int hi_ui_config_default(HTTPINSPECT_GLOBAL_CONF *GlobalConf)
00082 {
00083 if(GlobalConf == NULL)
00084 {
00085 return HI_INVALID_ARG;
00086 }
00087
00088
00089
00090
00091 GlobalConf->inspection_type = HI_UI_CONFIG_STATELESS;
00092
00093
00094
00095
00096 GlobalConf->global_server.port_count = 1;
00097 GlobalConf->global_server.ports[80] = 1;
00098
00099 GlobalConf->global_server.flow_depth = 300;
00100
00101 GlobalConf->global_server.chunk_length = 500000;
00102
00103 GlobalConf->global_server.ascii.on = 1;
00104
00105 GlobalConf->global_server.utf_8.on = 1;
00106
00107 GlobalConf->global_server.multiple_slash.on = 1;
00108
00109 GlobalConf->global_server.directory.on = 1;
00110
00111 GlobalConf->global_server.webroot.on = 1;
00112 GlobalConf->global_server.webroot.alert = 1;
00113
00114 GlobalConf->global_server.apache_whitespace.on = 1;
00115
00116 GlobalConf->global_server.iis_delimiter.on = 1;
00117
00118 GlobalConf->global_server.non_strict = 1;
00119
00120 return HI_SUCCESS;
00121 }
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 int hi_ui_config_reset_global(HTTPINSPECT_GLOBAL_CONF *GlobalConf)
00138 {
00139 GlobalConf->inspection_type = 0;
00140 GlobalConf->iis_unicode_map = 0;
00141
00142 return HI_SUCCESS;
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 int hi_ui_config_reset_server(HTTPINSPECT_CONF *ServerConf)
00159 {
00160 memset(ServerConf, 0x00, sizeof(HTTPINSPECT_CONF));
00161
00162 return HI_SUCCESS;
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 int hi_ui_config_set_profile_apache(HTTPINSPECT_CONF *ServerConf)
00185 {
00186
00187
00188
00189 hi_ui_config_reset_server(ServerConf);
00190
00191 ServerConf->flow_depth = 300;
00192
00193 ServerConf->non_strict = 1;
00194
00195 ServerConf->chunk_length = 500000;
00196
00197 ServerConf->ascii.on = 1;
00198
00199 ServerConf->multiple_slash.on = 1;
00200
00201 ServerConf->directory.on = 1;
00202
00203 ServerConf->webroot.on = 1;
00204 ServerConf->webroot.alert = 1;
00205
00206 ServerConf->apache_whitespace.on = 1;
00207
00208 ServerConf->utf_8.on = 1;
00209
00210 ServerConf->tab_uri_delimiter = 1;
00211
00212 return HI_SUCCESS;
00213 }
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 int hi_ui_config_set_profile_iis(HTTPINSPECT_CONF *ServerConf,
00235 int *iis_unicode_map)
00236 {
00237 if(iis_unicode_map == NULL)
00238 {
00239 return HI_INVALID_ARG;
00240 }
00241
00242
00243
00244
00245 hi_ui_config_reset_server(ServerConf);
00246
00247 ServerConf->flow_depth = 300;
00248
00249 ServerConf->chunk_length = 500000;
00250
00251 ServerConf->iis_unicode_map = iis_unicode_map;
00252
00253 ServerConf->ascii.on = 1;
00254
00255 ServerConf->multiple_slash.on = 1;
00256
00257 ServerConf->directory.on = 1;
00258
00259 ServerConf->webroot.on = 1;
00260 ServerConf->webroot.alert = 1;
00261
00262 ServerConf->double_decoding.on = 1;
00263 ServerConf->double_decoding.alert = 1;
00264
00265 ServerConf->u_encoding.on = 1;
00266 ServerConf->u_encoding.alert = 1;
00267
00268 ServerConf->bare_byte.on = 1;
00269 ServerConf->bare_byte.alert = 1;
00270
00271 ServerConf->iis_unicode.on = 1;
00272 ServerConf->iis_unicode.alert = 1;
00273
00274 ServerConf->iis_backslash.on = 1;
00275
00276 ServerConf->iis_delimiter.on = 1;
00277
00278 ServerConf->apache_whitespace.on = 1;
00279
00280 ServerConf->non_strict = 1;
00281
00282 return HI_SUCCESS;
00283 }
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302 int hi_ui_config_set_profile_all(HTTPINSPECT_CONF *ServerConf,
00303 int *iis_unicode_map)
00304 {
00305 if(iis_unicode_map == NULL)
00306 {
00307 return HI_INVALID_ARG;
00308 }
00309
00310
00311
00312
00313 hi_ui_config_reset_server(ServerConf);
00314
00315 ServerConf->flow_depth = 300;
00316
00317 ServerConf->chunk_length = 500000;
00318
00319 ServerConf->iis_unicode_map = iis_unicode_map;
00320
00321 ServerConf->ascii.on = 1;
00322
00323 ServerConf->multiple_slash.on = 1;
00324
00325 ServerConf->directory.on = 1;
00326
00327 ServerConf->webroot.on = 1;
00328 ServerConf->webroot.alert = 1;
00329
00330 ServerConf->double_decoding.on = 1;
00331 ServerConf->double_decoding.alert = 1;
00332
00333 ServerConf->u_encoding.on = 1;
00334 ServerConf->u_encoding.alert = 1;
00335
00336 ServerConf->bare_byte.on = 1;
00337 ServerConf->bare_byte.alert = 1;
00338
00339 ServerConf->iis_unicode.on = 1;
00340 ServerConf->iis_unicode.alert = 1;
00341
00342 ServerConf->iis_backslash.on = 1;
00343
00344 ServerConf->iis_delimiter.on = 1;
00345
00346 ServerConf->apache_whitespace.on = 1;
00347
00348 ServerConf->non_strict = 1;
00349
00350 ServerConf->tab_uri_delimiter = 1;
00351
00352 return HI_SUCCESS;
00353 }
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376 int hi_ui_config_add_server(HTTPINSPECT_GLOBAL_CONF *GlobalConf,
00377 unsigned long ServerIP, HTTPINSPECT_CONF *ServerConf)
00378 {
00379 int iRet;
00380
00381 if((iRet = hi_ui_server_lookup_add(GlobalConf->server_lookup, ServerIP,
00382 ServerConf)))
00383 {
00384
00385
00386
00387
00388 return iRet;
00389 }
00390
00391 return HI_SUCCESS;
00392
00393 }