datatypes.c 26 KB

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