datatypes.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817
  1. /*
  2. * Copyright (c) 2000-2008 3APA3A
  3. *
  4. * please read License Agreement
  5. *
  6. */
  7. #include "proxy.h"
  8. static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){
  9. char buf[32];
  10. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value));
  11. }
  12. static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
  13. char buf[16];
  14. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%d", *(int *)node->value));
  15. }
  16. static void pr_short(struct node *node, CBFUNC cbf, void*cb){
  17. char buf[8];
  18. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%hu", *(unsigned short*)node->value));
  19. }
  20. static void pr_char(struct node *node, CBFUNC cbf, void*cb){
  21. if(node->value)(*cbf)(cb, (char *)node->value, 1);
  22. }
  23. static void pr_unsigned(struct node *node, CBFUNC cbf, void*cb){
  24. char buf[16];
  25. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%u", *(unsigned *)node->value));
  26. }
  27. static void pr_traffic(struct node *node, CBFUNC cbf, void*cb){
  28. char buf[16];
  29. unsigned long u1, u2;
  30. if(node->value){
  31. u1 = ((unsigned long *)node->value)[0];
  32. u2 = ((unsigned long *)node->value)[0];
  33. (*cbf)(cb, buf, sprintf(buf, "%lu", (u1>>20) + (u2<<10)));
  34. }
  35. }
  36. static void pr_port(struct node *node, CBFUNC cbf, void*cb){
  37. char buf[8];
  38. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%hu", ntohs(*(unsigned short*)node->value)));
  39. }
  40. static void pr_datetime(struct node *node, CBFUNC cbf, void*cb){
  41. char *s;
  42. if(node->value){
  43. s = ctime((time_t *)node->value);
  44. (*cbf)(cb, s, (int)strlen(s)-1);
  45. }
  46. }
  47. static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
  48. char buf[16];
  49. if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4));
  50. }
  51. static void pr_ip6(struct node *node, CBFUNC cbf, void*cb){
  52. char buf[64];
  53. if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET6, node -> value, buf, 16));
  54. }
  55. static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
  56. #ifdef NOIPV6
  57. if(node->value)return pr_ip(node, cbf, cb);
  58. #else
  59. char buf[64];
  60. buf[0] = '[';
  61. buf[1] = 0;
  62. inet_ntop(*SAFAMILY(node->value), node->value, buf+1, sizeof(buf)-10);
  63. sprintf(buf + strlen(buf), "]:hu", (unsigned short)*SAPORT(node->value));
  64. if(node->value)(*cbf)(cb, buf, strlen(buf));
  65. #endif
  66. }
  67. static void pr_wdays(struct node *node, CBFUNC cbf, void*cb){
  68. char buf[16];
  69. int i, found = 0;
  70. if(node -> value)for(i = 0; i<8; i++){
  71. if( (1<<i) & *(int *)node -> value ) {
  72. sprintf(buf, "%s%d", found?",":"", i);
  73. (*cbf)(cb, buf, found? 2:1);
  74. found = 1;
  75. }
  76. }
  77. }
  78. static void pr_time(struct node *node, CBFUNC cbf, void*cb){
  79. char buf[16];
  80. int t = *(int *)node;
  81. (*cbf)(cb, buf, sprintf(buf, "%02d:%02d:%02d", (t/3600)%24, (t/60)%60, t%60));
  82. }
  83. int cidrprint(char *buf, unsigned long u){
  84. unsigned long u1 = 0xffffffff;
  85. int i;
  86. u = ntohl(u);
  87. for(i = 32; i && (u1!=u); i--){
  88. u1 = (u1 << 1);
  89. }
  90. if (i == 32) {
  91. return 0;
  92. }
  93. return sprintf(buf, "/%d", i);
  94. }
  95. static void pr_cidr(struct node *node, CBFUNC cbf, void*cb){
  96. char buf[4];
  97. int i;
  98. if(node->value){
  99. if ((i = cidrprint(buf, *(unsigned *)node -> value)))
  100. (*cbf)(cb, buf, i);
  101. else (*cbf)(cb, "/32", 3);
  102. }
  103. }
  104. static void pr_string(struct node *node, CBFUNC cbf, void*cb){
  105. if(node->value){
  106. (*cbf)(cb, (char*)node->value, (int)strlen((char*)node->value));
  107. }
  108. else (*cbf)(cb, "(NULL)", 6);
  109. }
  110. static void pr_rotation(struct node *node, CBFUNC cbf, void*cb){
  111. char * lstrings[] = {
  112. "N", "C", "H", "D", "W", "M", "Y", "N"
  113. };
  114. int i;
  115. if(node->value && (i = *(int*)node->value) > 1 && i < 6){
  116. (*cbf)(cb, lstrings[i], 1);
  117. }
  118. }
  119. static void pr_operations(struct node *node, CBFUNC cbf, void*cb){
  120. char buf[64];
  121. int operation;
  122. int delim = 0;
  123. *buf = 0;
  124. if(!node->value || !(operation = *(int*)node->value)){
  125. (*cbf)(cb, "*", 1);
  126. return;
  127. }
  128. if(operation & HTTP){
  129. if((operation & HTTP) == HTTP)
  130. (*cbf)(cb, buf, sprintf(buf, "HTTP"));
  131. else
  132. (*cbf)(cb, buf, sprintf(buf, "%s%s%s%s%s%s%s%s%s",
  133. (operation & HTTP_GET)? "HTTP_GET" : "",
  134. ((operation & HTTP_GET) && (operation & (HTTP_PUT|HTTP_POST|HTTP_HEAD|HTTP_OTHER)))? "," : "",
  135. (operation & HTTP_PUT)? "HTTP_PUT" : "",
  136. ((operation & HTTP_PUT) && (operation & (HTTP_POST|HTTP_HEAD|HTTP_OTHER)))? "," : "",
  137. (operation & HTTP_POST)? "HTTP_POST" : "",
  138. ((operation & HTTP_POST) && (operation & (HTTP_HEAD|HTTP_OTHER)))? "," : "",
  139. (operation & HTTP_HEAD)? "HTTP_HEAD" : "",
  140. ((operation & HTTP_HEAD) && (operation & HTTP_OTHER))? "," : "",
  141. (operation & HTTP_OTHER)? "HTTP_OTHER" : ""));
  142. delim = 1;
  143. }
  144. if(operation & HTTP_CONNECT){
  145. (*cbf)(cb, buf, sprintf(buf, "%s%s", delim?",":"", "HTTP_CONNECT"));
  146. delim = 1;
  147. }
  148. if(operation & FTP) {
  149. if((operation & FTP) == FTP)
  150. (*cbf)(cb, buf, sprintf(buf, "%s%s", delim?",":"", "FTP"));
  151. else
  152. (*cbf)(cb, buf, sprintf(buf, "%s%s%s%s%s%s",
  153. delim? ",":"",
  154. (operation & FTP_GET)? "FTP_GET" : "",
  155. ((operation & FTP_GET) && (operation & (FTP_PUT|FTP_LIST)))? ",":"",
  156. (operation & FTP_PUT)? "FTP_PUT" : "",
  157. ((operation & FTP_PUT) && (operation & FTP_LIST))? ",":"",
  158. (operation & FTP_LIST)? "FTP_LIST" : ""));
  159. delim = 1;
  160. }
  161. if(operation & CONNECT){
  162. (*cbf)(cb, buf, sprintf(buf, "%s%s", delim?",":"", "CONNECT"));
  163. delim = 1;
  164. }
  165. if(operation & BIND){
  166. (*cbf)(cb, buf, sprintf(buf, "%s%s", delim?",":"", "BIND"));
  167. delim = 1;
  168. }
  169. if(operation & UDPASSOC){
  170. (*cbf)(cb, buf, sprintf(buf, "%s%s", delim?",":"", "UDPASSOC"));
  171. delim = 1;
  172. }
  173. if(operation & ICMPASSOC){
  174. (*cbf)(cb, buf, sprintf(buf, "%s%s", delim?",":"", "ICMPASSOC"));
  175. delim = 1;
  176. }
  177. if(operation & DNSRESOLVE){
  178. (*cbf)(cb, buf, sprintf(buf, "%s%s", delim?",":"", "DNSRESOLVE"));
  179. delim = 1;
  180. }
  181. if(operation & ADMIN){
  182. (*cbf)(cb, buf, sprintf(buf, "%s%s", delim?",":"", "ADMIN"));
  183. }
  184. }
  185. static void pr_portlist(struct node *node, CBFUNC cbf, void*cb){
  186. struct portlist *pl= (struct portlist *)node->value;
  187. char buf[16];
  188. if(!pl) {
  189. (*cbf)(cb, "*", 1);
  190. return;
  191. }
  192. for(; pl; pl = pl->next) {
  193. if(pl->startport == pl->endport)
  194. (*cbf)(cb, buf, sprintf(buf, "%hu", pl->startport));
  195. else
  196. (*cbf)(cb, buf, sprintf(buf, "%hu-%hu", pl->startport, pl->endport));
  197. if(pl->next)(*cbf)(cb, ",", 1);
  198. }
  199. }
  200. static void pr_userlist(struct node *node, CBFUNC cbf, void*cb){
  201. struct userlist *ul= (struct userlist *)node->value;
  202. if(!ul) {
  203. (*cbf)(cb, "*", 1);
  204. return;
  205. }
  206. for(; ul; ul = ul->next){
  207. (*cbf)(cb, (char *)ul->user, (int)strlen((char *)ul->user));
  208. if(ul->next)(*cbf)(cb, ",", 1);
  209. }
  210. }
  211. int printiple(char *buf, struct iplist* ipl){
  212. int addrlen = (ipl->family == AF_INET6)?16:4, i;
  213. i = myinet_ntop(ipl->family, &ipl->ip_from, buf, addrlen);
  214. if(memcmp(&ipl->ip_from, &ipl->ip_to, addrlen)){
  215. buf[i++] = '-';
  216. i += myinet_ntop(ipl->family, &ipl->ip_from, buf+i, addrlen);
  217. }
  218. if(ipl->next){
  219. buf[i++] = ',';
  220. buf[i++] = ' ';
  221. }
  222. return i;
  223. }
  224. static void pr_iplist(struct node *node, CBFUNC cbf, void*cb){
  225. char buf[128];
  226. struct iplist *il = (struct iplist *)node->value;
  227. if(!il) {
  228. (*cbf)(cb, "*", 1);
  229. return;
  230. }
  231. for(; il; il = il->next){
  232. (*cbf)(cb, buf, printiple(buf, il));
  233. }
  234. }
  235. static void * ef_portlist_next(struct node *node){
  236. return (((struct portlist *)node->value) -> next);
  237. }
  238. static void * ef_portlist_start(struct node *node){
  239. return &(((struct portlist *)node->value) -> startport);
  240. }
  241. static void * ef_portlist_end(struct node *node){
  242. return &(((struct portlist *)node->value) -> endport);
  243. }
  244. static void * ef_iplist_next(struct node *node){
  245. return (((struct iplist *)node->value) -> next);
  246. }
  247. static void * ef_userlist_next(struct node * node){
  248. return (((struct userlist *)node->value) -> next);
  249. }
  250. static void * ef_userlist_user(struct node * node){
  251. return (((struct userlist *)node->value) -> user);
  252. }
  253. static void * ef_pwlist_next(struct node * node){
  254. return (((struct passwords *)node->value) -> next);
  255. }
  256. static void * ef_pwlist_user(struct node * node){
  257. return (((struct passwords *)node->value) -> user);
  258. }
  259. static void * ef_pwlist_password(struct node * node){
  260. return (((struct passwords *)node->value) -> password);
  261. }
  262. static void * ef_pwlist_type(struct node * node){
  263. switch (((struct passwords *)node->value) -> pwtype) {
  264. case SYS:
  265. return "SYS";
  266. case CL:
  267. return "CL";
  268. case CR:
  269. return "CR";
  270. case NT:
  271. return "NT";
  272. case LM:
  273. return "LM";
  274. default:
  275. return "UNKNOWN";
  276. }
  277. }
  278. static void * ef_chain_next(struct node * node){
  279. return ((struct chain *)node->value) -> next;
  280. }
  281. static void * ef_chain_type(struct node * node){
  282. switch (((struct chain *)node->value) -> type) {
  283. case R_TCP:
  284. return "tcp";
  285. case R_CONNECT:
  286. return "connect";
  287. case R_SOCKS4:
  288. return "socks4";
  289. case R_SOCKS5:
  290. return "socks5";
  291. case R_HTTP:
  292. return "http";
  293. case R_FTP:
  294. return "ftp";
  295. case R_POP3:
  296. return "pop3";
  297. default:
  298. return "";
  299. }
  300. }
  301. static void * ef_chain_addr(struct node * node){
  302. return &((struct chain *)node->value) -> addr;
  303. }
  304. static void * ef_chain_weight(struct node * node){
  305. return &((struct chain *)node->value) -> weight;
  306. }
  307. static void * ef_chain_user(struct node * node){
  308. return ((struct chain *)node->value) -> extuser;
  309. }
  310. static void * ef_chain_password(struct node * node){
  311. return ((struct chain *)node->value) -> extpass;
  312. }
  313. static void * ef_ace_next(struct node * node){
  314. return ((struct ace *)node->value) -> next;
  315. }
  316. static void * ef_ace_type(struct node * node){
  317. switch (((struct ace *)node->value) -> action) {
  318. case ALLOW:
  319. case REDIRECT:
  320. return "allow";
  321. case DENY:
  322. return "deny";
  323. case BANDLIM:
  324. return "bandlim";
  325. case NOBANDLIM:
  326. return "nobandlim";
  327. case COUNTIN:
  328. return "countin";
  329. case NOCOUNTIN:
  330. return "nocountin";
  331. case COUNTOUT:
  332. return "countout";
  333. case NOCOUNTOUT:
  334. return "nocountout";
  335. default:
  336. return "unknown";
  337. }
  338. }
  339. static void * ef_ace_operations(struct node * node){
  340. if(!((struct ace *)node->value) -> operation) return NULL;
  341. return &((struct ace *)node->value) -> operation;
  342. }
  343. static void * ef_ace_users(struct node * node){
  344. return ((struct ace *)node->value) -> users;
  345. }
  346. static void * ef_ace_src(struct node * node){
  347. return ((struct ace *)node->value) -> src;
  348. }
  349. static void * ef_ace_dst(struct node * node){
  350. return ((struct ace *)node->value) -> dst;
  351. }
  352. static void * ef_ace_ports(struct node * node){
  353. return ((struct ace *)node->value) -> ports;
  354. }
  355. static void * ef_ace_chain(struct node * node){
  356. return ((struct ace *)node->value) -> chains;
  357. }
  358. static void * ef_ace_weekdays(struct node * node){
  359. return (((struct ace *)node->value) -> wdays) ? &((struct ace *)node->value) -> wdays : NULL;
  360. }
  361. static void * ef_ace_period(struct node * node){
  362. return ((struct ace *)node->value) -> periods;
  363. }
  364. static void * ef_bandlimit_next(struct node * node){
  365. return ((struct bandlim *)node->value) -> next;
  366. }
  367. static void * ef_bandlimit_ace(struct node * node){
  368. return ((struct bandlim *)node->value) -> ace;
  369. }
  370. static void * ef_bandlimit_rate(struct node * node){
  371. return &((struct bandlim *)node->value) -> rate;
  372. }
  373. static void * ef_trafcounter_next(struct node * node){
  374. return ((struct trafcount *)node->value) -> next;
  375. }
  376. static void * ef_trafcounter_ace(struct node * node){
  377. return ((struct trafcount *)node->value) -> ace;
  378. }
  379. static void * ef_trafcounter_number(struct node * node){
  380. return &((struct trafcount *)node->value) -> number;
  381. }
  382. static void * ef_trafcounter_type(struct node * node){
  383. return &((struct trafcount *)node->value) -> type;
  384. }
  385. static void * ef_trafcounter_traffic64(struct node * node){
  386. return &((struct trafcount *)node->value) -> traf64;
  387. }
  388. static void * ef_trafcounter_limit64(struct node * node){
  389. return &((struct trafcount *)node->value) -> traflim64;
  390. }
  391. static void * ef_client_maxtrafin64(struct node * node){
  392. return &((struct clientparam *)node->value) -> maxtrafin64;
  393. }
  394. static void * ef_client_maxtrafout64(struct node * node){
  395. return &((struct clientparam *)node->value) -> maxtrafout64;
  396. }
  397. static void * ef_client_bytesin64(struct node * node){
  398. return &((struct clientparam *)node->value) -> statssrv64;
  399. }
  400. static void * ef_client_bytesout64(struct node * node){
  401. return &((struct clientparam *)node->value) -> statscli64;
  402. }
  403. static void * ef_trafcounter_cleared(struct node * node){
  404. return &((struct trafcount *)node->value) -> cleared;
  405. }
  406. static void * ef_trafcounter_updated(struct node * node){
  407. return &((struct trafcount *)node->value) -> updated;
  408. }
  409. static void * ef_trafcounter_comment(struct node * node){
  410. return ((struct trafcount *)node->value) -> comment;
  411. }
  412. static void * ef_trafcounter_disabled(struct node * node){
  413. return &((struct trafcount *)node->value) -> disabled;
  414. }
  415. static void * ef_server_next(struct node * node){
  416. return ((struct srvparam *)node->value) -> next;
  417. }
  418. static void * ef_server_type(struct node * node){
  419. int service = ((struct srvparam *)node->value) -> service;
  420. return (service>=0 && service < 15)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
  421. }
  422. static void * ef_server_child(struct node * node){
  423. return ((struct srvparam *)node->value) -> child;
  424. }
  425. static void * ef_server_auth(struct node * node){
  426. AUTHFUNC af = ((struct srvparam *)node->value) -> authfunc;
  427. if(af == alwaysauth) return "none";
  428. if(af == ipauth) return "iponly";
  429. if(af == strongauth) return "strong";
  430. return "uknown";
  431. }
  432. static void * ef_server_childcount(struct node * node){
  433. return &((struct srvparam *)node->value) -> childcount;
  434. }
  435. static void * ef_server_log(struct node * node){
  436. if(((struct srvparam *)node->value) -> logfunc == lognone) return "none";
  437. else if(((struct srvparam *)node->value) -> logfunc == logstdout)
  438. return (((struct srvparam *)node->value) -> logtarget)?"file":"stdout";
  439. #ifndef _WIN32
  440. else if(((struct srvparam *)node->value) -> logfunc == logsyslog) return "syslog";
  441. #endif
  442. #ifndef NOODBC
  443. else if(((struct srvparam *)node->value) -> logfunc == logsql) return "odbc";
  444. #endif
  445. return NULL;
  446. }
  447. static void * ef_server_logformat(struct node * node){
  448. return ((struct srvparam *)node->value) -> logformat;
  449. }
  450. static void * ef_server_nonprintable(struct node * node){
  451. return ((struct srvparam *)node->value) -> nonprintable;
  452. }
  453. static void * ef_server_replacement(struct node * node){
  454. if(((struct srvparam *)node->value) -> nonprintable)return &((struct srvparam *)node->value) -> replace;
  455. return NULL;
  456. }
  457. static void * ef_server_logtarget(struct node * node){
  458. return ((struct srvparam *)node->value) -> logtarget;
  459. }
  460. static void * ef_server_target(struct node * node){
  461. return ((struct srvparam *)node->value) -> target;
  462. }
  463. static void * ef_server_targetport(struct node * node){
  464. return &((struct srvparam *)node->value) -> targetport;
  465. }
  466. static void * ef_server_intsa(struct node * node){
  467. return &((struct srvparam *)node->value) -> intsa;
  468. }
  469. static void * ef_server_extsa(struct node * node){
  470. return &((struct srvparam *)node->value) -> extsa;
  471. }
  472. #ifndef NOIPV6
  473. static void * ef_server_extsa6(struct node * node){
  474. return &((struct srvparam *)node->value) -> extsa6;
  475. }
  476. #endif
  477. static void * ef_server_acl(struct node * node){
  478. return ((struct srvparam *)node->value) -> acl;
  479. }
  480. static void * ef_server_singlepacket(struct node * node){
  481. return &((struct srvparam *)node->value) -> singlepacket;
  482. }
  483. static void * ef_server_usentlm(struct node * node){
  484. return &((struct srvparam *)node->value) -> usentlm;
  485. }
  486. static void * ef_server_starttime(struct node * node){
  487. return &((struct srvparam *)node->value) -> time_start;
  488. }
  489. static void * ef_client_next(struct node * node){
  490. return ((struct clientparam *)node->value) -> next;
  491. }
  492. static void * ef_client_type(struct node * node){
  493. int service = ((struct clientparam *)node->value) -> service;
  494. return (service>=0 && service < 15)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
  495. }
  496. static void * ef_client_operation(struct node * node){
  497. if(!((struct clientparam *)node->value) -> operation) return NULL;
  498. return &((struct clientparam *)node->value) -> operation;
  499. }
  500. static void * ef_client_redirected(struct node * node){
  501. return &((struct clientparam *)node->value) -> redirected;
  502. }
  503. static void * ef_client_hostname(struct node * node){
  504. return ((struct clientparam *)node->value) -> hostname;
  505. }
  506. static void * ef_client_username(struct node * node){
  507. return ((struct clientparam *)node->value) -> username;
  508. }
  509. static void * ef_client_password(struct node * node){
  510. return ((struct clientparam *)node->value) -> password;
  511. }
  512. static void * ef_client_extusername(struct node * node){
  513. return ((struct clientparam *)node->value) -> extusername;
  514. }
  515. static void * ef_client_extpassword(struct node * node){
  516. return ((struct clientparam *)node->value) -> extpassword;
  517. }
  518. static void * ef_client_clisa(struct node * node){
  519. return &((struct clientparam *)node->value) -> sincr;
  520. }
  521. static void * ef_client_srvsa(struct node * node){
  522. return &((struct clientparam *)node->value) -> sinsr;
  523. }
  524. static void * ef_client_reqsa(struct node * node){
  525. return &((struct clientparam *)node->value) -> req;
  526. }
  527. static void * ef_client_pwtype(struct node * node){
  528. return &((struct clientparam *)node->value) -> pwtype;
  529. }
  530. static void * ef_client_threadid(struct node * node){
  531. return &((struct clientparam *)node->value) -> threadid;
  532. }
  533. static void * ef_client_starttime(struct node * node){
  534. return &((struct clientparam *)node->value) -> time_start;
  535. }
  536. static void * ef_client_starttime_msec(struct node * node){
  537. return &((struct clientparam *)node->value) -> msec_start;
  538. }
  539. static void * ef_period_fromtime(struct node * node){
  540. return &((struct period *)node->value) -> fromtime;
  541. }
  542. static void * ef_period_totime(struct node * node){
  543. return &((struct period *)node->value) -> totime;
  544. }
  545. static void * ef_period_next(struct node * node){
  546. return ((struct period *)node->value) -> next;
  547. }
  548. static struct property prop_portlist[] = {
  549. {prop_portlist + 1, "start", ef_portlist_start, TYPE_PORT, "port range start"},
  550. {prop_portlist + 2, "end", ef_portlist_end, TYPE_PORT, "port range end"},
  551. {NULL, "next", ef_portlist_next, TYPE_PORTLIST, "next"}
  552. };
  553. static struct property prop_userlist[] = {
  554. {prop_userlist+1, "user", ef_userlist_user, TYPE_STRING, "user name"},
  555. {NULL, "next", ef_userlist_next, TYPE_USERLIST, "next"}
  556. };
  557. static struct property prop_pwlist[] = {
  558. {prop_pwlist + 1, "user", ef_pwlist_user, TYPE_STRING, "user name"},
  559. {prop_pwlist + 2, "password", ef_pwlist_password, TYPE_STRING, "password string"},
  560. {prop_pwlist + 3, "type", ef_pwlist_type, TYPE_STRING, "password type"},
  561. {NULL, "next", ef_pwlist_next, TYPE_PWLIST, "next"}
  562. };
  563. static struct property prop_chain[] = {
  564. {prop_chain + 1, "addr", ef_chain_addr, TYPE_SA, "parent address"},
  565. {prop_chain + 2, "type", ef_chain_type, TYPE_STRING, "parent type"},
  566. {prop_chain + 3, "weight", ef_chain_weight, TYPE_SHORT, "parent weight 0-1000"},
  567. {prop_chain + 4, "user", ef_chain_user, TYPE_STRING, "parent login"},
  568. {prop_chain + 5, "password", ef_chain_password, TYPE_STRING, "parent password"},
  569. {NULL, "next", ef_chain_next, TYPE_CHAIN, "next"}
  570. };
  571. static struct property prop_period[] = {
  572. {prop_period + 1, "fromtime", ef_period_fromtime, TYPE_TIME, "from time" },
  573. {prop_period + 2, "totime", ef_period_totime, TYPE_TIME, "to time" },
  574. {NULL, "next", ef_period_next, TYPE_PERIOD, "next"}
  575. };
  576. static struct property prop_ace[] = {
  577. {prop_ace + 1, "type", ef_ace_type, TYPE_STRING, "ace action"},
  578. {prop_ace + 2, "operations", ef_ace_operations, TYPE_OPERATIONS, "request type"},
  579. {prop_ace + 3, "users", ef_ace_users, TYPE_USERLIST, "list of users"},
  580. {prop_ace + 4, "src", ef_ace_src, TYPE_IPLIST, "list of source ips"},
  581. {prop_ace + 5, "dst", ef_ace_dst, TYPE_IPLIST, "list of destination ips"},
  582. {prop_ace + 6, "ports", ef_ace_ports, TYPE_PORTLIST, "list of destination ports"},
  583. {prop_ace + 7, "chain", ef_ace_chain, TYPE_CHAIN, "redirect to parent(s)"},
  584. {prop_ace + 8, "wdays", ef_ace_weekdays, TYPE_WEEKDAYS, "days of week"},
  585. {prop_ace + 9, "periods", ef_ace_period, TYPE_PERIOD, "time of the day"},
  586. {NULL, "next", ef_ace_next, TYPE_ACE, "next"}
  587. };
  588. static struct property prop_bandlimit[] = {
  589. {prop_bandlimit + 1, "ace", ef_bandlimit_ace, TYPE_ACE, "acl to apply"},
  590. {prop_bandlimit + 2, "rate", ef_bandlimit_rate, TYPE_UNSIGNED, "max allowed bandwidth"},
  591. {NULL, "next", ef_bandlimit_next, TYPE_BANDLIMIT, "next"}
  592. };
  593. static struct property prop_trafcounter[] = {
  594. {prop_trafcounter + 1, "disabled", ef_trafcounter_disabled, TYPE_INTEGER, "counter status"},
  595. {prop_trafcounter + 2, "ace", ef_trafcounter_ace, TYPE_ACE, "traffic to count"},
  596. {prop_trafcounter + 3, "number", ef_trafcounter_number, TYPE_UNSIGNED, "counter number"},
  597. {prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"},
  598. {prop_trafcounter + 5, "traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"},
  599. {prop_trafcounter + 6, "limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"},
  600. {prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"},
  601. {prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"},
  602. {prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
  603. {NULL, "next", ef_trafcounter_next, TYPE_TRAFCOUNTER}
  604. };
  605. /*
  606. */
  607. static struct property prop_server[] = {
  608. {prop_server + 1, "servicetype", ef_server_type, TYPE_STRING, "type of the service/client"},
  609. {prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
  610. {prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
  611. {prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
  612. {prop_server + 5, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
  613. {prop_server + 6, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
  614. {prop_server + 7, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
  615. {prop_server + 8, "acl", ef_server_acl, TYPE_ACE, "access control list"},
  616. {prop_server + 9, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
  617. {prop_server + 10, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
  618. {prop_server + 11, "log", ef_server_log, TYPE_STRING, "type of logging"},
  619. {prop_server + 12, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
  620. {prop_server + 13, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
  621. {prop_server + 14, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
  622. {prop_server + 15, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
  623. {prop_server + 16, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
  624. {prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
  625. #ifndef NOIPV6
  626. {prop_server + 18, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
  627. #endif
  628. {NULL, "next", ef_server_next, TYPE_SERVER, "next"}
  629. };
  630. static struct property prop_client[] = {
  631. {prop_client + 1, "servicetype", ef_client_type, TYPE_STRING, "type of the client"},
  632. {prop_client + 2, "threadid", ef_client_threadid, TYPE_INTEGER, "process thread id"},
  633. {prop_client + 3, "starttime", ef_client_starttime, TYPE_DATETIME, "client started seconds"},
  634. {prop_client + 4, "starttime_msec", ef_client_starttime_msec, TYPE_UNSIGNED, "client started milliseconds"},
  635. {prop_client + 5, "redirected", ef_client_redirected, TYPE_INTEGER, "number of redirections"},
  636. {prop_client + 6, "operation", ef_client_operation, TYPE_OPERATIONS, "action requested by client"},
  637. {prop_client + 7, "hostname", ef_client_hostname, TYPE_STRING, "name of the requested host"},
  638. {prop_client + 8, "extusername", ef_client_extusername, TYPE_STRING, "username for requested host"},
  639. {prop_client + 9, "extpassword", ef_client_extpassword, TYPE_STRING, "password for requested host"},
  640. {prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
  641. {prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
  642. {prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
  643. {prop_client + 13, "srvsa", ef_client_srvsa, TYPE_IP, "target server sa"},
  644. {prop_client + 14, "reqsa", ef_client_reqsa, TYPE_IP, "requested server sa"},
  645. {prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
  646. {prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
  647. {prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
  648. {prop_client + 18, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"},
  649. {prop_client + 19, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
  650. {NULL, "next", ef_client_next, TYPE_CLIENT, "next"}
  651. };
  652. struct datatype datatypes[64] = {
  653. {"integer", NULL, pr_integer, NULL},
  654. {"short", NULL, pr_short, NULL},
  655. {"char", NULL, pr_char, NULL},
  656. {"unsigned", NULL, pr_unsigned, NULL},
  657. {"unsigned64", NULL, pr_unsigned64, NULL},
  658. {"traffic", NULL, pr_traffic, NULL},
  659. {"port", NULL, pr_port, NULL},
  660. {"ip", NULL, pr_ip, NULL},
  661. {"sa", NULL, pr_sa, NULL},
  662. {"cidr", NULL, pr_cidr, NULL},
  663. {"string", NULL, pr_string, NULL},
  664. {"datetime", NULL, pr_datetime, NULL},
  665. {"operations", NULL, pr_operations, NULL},
  666. {"rotation", NULL, pr_rotation, NULL},
  667. {"portlist", ef_portlist_next, pr_portlist, prop_portlist},
  668. {"iplist", ef_iplist_next, pr_iplist, NULL},
  669. {"userlist", ef_userlist_next, pr_userlist, prop_userlist},
  670. {"pwlist", ef_pwlist_next, NULL, prop_pwlist},
  671. {"chain", ef_chain_next, NULL, prop_chain},
  672. {"ace", ef_ace_next, NULL, prop_ace},
  673. {"bandlimit", ef_bandlimit_next, NULL, prop_bandlimit},
  674. {"trafcounter", ef_trafcounter_next, NULL, prop_trafcounter},
  675. {"client", ef_client_next, NULL, prop_client},
  676. {"weekdays", NULL, pr_wdays, NULL},
  677. {"time", NULL, pr_time, NULL},
  678. {"period", ef_period_next, NULL, prop_period},
  679. {"server", ef_server_next, NULL, prop_server}
  680. };