datatypes.c 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. /*
  2. (c) 2002-2016 by Vladimir Dubrovin <3proxy@3proxy.ru>
  3. please read License Agreement
  4. */
  5. #include "proxy.h"
  6. static void pr_unsigned64(struct node *node, CBFUNC cbf, void*cb){
  7. char buf[32];
  8. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%"PRINTF_INT64_MODIFIER"u", *(uint64_t *)node->value));
  9. }
  10. static void pr_integer(struct node *node, CBFUNC cbf, void*cb){
  11. char buf[16];
  12. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%d", *(int *)node->value));
  13. }
  14. static void pr_short(struct node *node, CBFUNC cbf, void*cb){
  15. char buf[8];
  16. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%hu", *(unsigned short*)node->value));
  17. }
  18. static void pr_char(struct node *node, CBFUNC cbf, void*cb){
  19. if(node->value)(*cbf)(cb, (char *)node->value, 1);
  20. }
  21. static void pr_unsigned(struct node *node, CBFUNC cbf, void*cb){
  22. char buf[16];
  23. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%u", *(unsigned *)node->value));
  24. }
  25. static void pr_traffic(struct node *node, CBFUNC cbf, void*cb){
  26. char buf[16];
  27. unsigned long u1, u2;
  28. if(node->value){
  29. u1 = ((unsigned long *)node->value)[0];
  30. u2 = ((unsigned long *)node->value)[0];
  31. (*cbf)(cb, buf, sprintf(buf, "%lu", (u1>>20) + (u2<<10)));
  32. }
  33. }
  34. static void pr_port(struct node *node, CBFUNC cbf, void*cb){
  35. char buf[8];
  36. if(node->value)(*cbf)(cb, buf, sprintf(buf, "%hu", ntohs(*(unsigned short*)node->value)));
  37. }
  38. static void pr_datetime(struct node *node, CBFUNC cbf, void*cb){
  39. char *s;
  40. if(node->value){
  41. s = ctime((time_t *)node->value);
  42. (*cbf)(cb, s, (int)strlen(s)-1);
  43. }
  44. }
  45. static void pr_ip(struct node *node, CBFUNC cbf, void*cb){
  46. char buf[16];
  47. if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET, node -> value, buf, 4));
  48. }
  49. #ifndef NOIPV6
  50. static void pr_ip6(struct node *node, CBFUNC cbf, void*cb){
  51. char buf[64];
  52. if(node->value)(*cbf)(cb, buf, myinet_ntop(AF_INET6, node -> value, buf, 16));
  53. }
  54. #endif
  55. static void pr_sa(struct node *node, CBFUNC cbf, void*cb){
  56. #ifdef NOIPV6
  57. if(node->value)pr_ip(node, cbf, cb);
  58. #else
  59. char buf[64];
  60. buf[0] = '[';
  61. buf[1] = 0;
  62. inet_ntop(*SAFAMILY(node->value), SAADDR(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. case COUNTALL:
  336. return "countall";
  337. case NOCOUNTALL:
  338. return "nocountall";
  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 == NULL) return "none";
  441. #ifndef NORADIUS
  442. else if(((struct srvparam *)node->value) -> logfunc == logradius) return "radius";
  443. #endif
  444. else if(((struct srvparam *)node->value) -> logfunc == logstdout)
  445. return (((struct srvparam *)node->value) -> logtarget)?"file":"stdout";
  446. #ifndef _WIN32
  447. else if(((struct srvparam *)node->value) -> logfunc == logsyslog) return "syslog";
  448. #endif
  449. #ifndef NOODBC
  450. else if(((struct srvparam *)node->value) -> logfunc == logsql) return "odbc";
  451. #endif
  452. return NULL;
  453. }
  454. static void * ef_server_logformat(struct node * node){
  455. return ((struct srvparam *)node->value) -> logformat;
  456. }
  457. static void * ef_server_nonprintable(struct node * node){
  458. return ((struct srvparam *)node->value) -> nonprintable;
  459. }
  460. static void * ef_server_replacement(struct node * node){
  461. if(((struct srvparam *)node->value) -> nonprintable)return &((struct srvparam *)node->value) -> replace;
  462. return NULL;
  463. }
  464. static void * ef_server_logtarget(struct node * node){
  465. return ((struct srvparam *)node->value) -> logtarget;
  466. }
  467. static void * ef_server_target(struct node * node){
  468. return ((struct srvparam *)node->value) -> target;
  469. }
  470. static void * ef_server_targetport(struct node * node){
  471. return &((struct srvparam *)node->value) -> targetport;
  472. }
  473. static void * ef_server_intsa(struct node * node){
  474. return &((struct srvparam *)node->value) -> intsa;
  475. }
  476. static void * ef_server_extsa(struct node * node){
  477. return &((struct srvparam *)node->value) -> extsa;
  478. }
  479. #ifndef NOIPV6
  480. static void * ef_server_extsa6(struct node * node){
  481. return &((struct srvparam *)node->value) -> extsa6;
  482. }
  483. #endif
  484. static void * ef_server_acl(struct node * node){
  485. return ((struct srvparam *)node->value) -> acl;
  486. }
  487. static void * ef_server_singlepacket(struct node * node){
  488. return &((struct srvparam *)node->value) -> singlepacket;
  489. }
  490. static void * ef_server_usentlm(struct node * node){
  491. return &((struct srvparam *)node->value) -> usentlm;
  492. }
  493. static void * ef_server_starttime(struct node * node){
  494. return &((struct srvparam *)node->value) -> time_start;
  495. }
  496. static void * ef_client_next(struct node * node){
  497. return ((struct clientparam *)node->value) -> next;
  498. }
  499. static void * ef_client_type(struct node * node){
  500. int service = ((struct clientparam *)node->value) -> service;
  501. return (service>=0 && service < 15)? (void *)conf.stringtable[SERVICES + service] : (void *)"unknown";
  502. }
  503. static void * ef_client_operation(struct node * node){
  504. if(!((struct clientparam *)node->value) -> operation) return NULL;
  505. return &((struct clientparam *)node->value) -> operation;
  506. }
  507. static void * ef_client_redirected(struct node * node){
  508. return &((struct clientparam *)node->value) -> redirected;
  509. }
  510. static void * ef_client_hostname(struct node * node){
  511. return ((struct clientparam *)node->value) -> hostname;
  512. }
  513. static void * ef_client_username(struct node * node){
  514. return ((struct clientparam *)node->value) -> username;
  515. }
  516. static void * ef_client_password(struct node * node){
  517. return ((struct clientparam *)node->value) -> password;
  518. }
  519. static void * ef_client_extusername(struct node * node){
  520. return ((struct clientparam *)node->value) -> extusername;
  521. }
  522. static void * ef_client_extpassword(struct node * node){
  523. return ((struct clientparam *)node->value) -> extpassword;
  524. }
  525. static void * ef_client_clisa(struct node * node){
  526. return &((struct clientparam *)node->value) -> sincr;
  527. }
  528. static void * ef_client_srvsa(struct node * node){
  529. return &((struct clientparam *)node->value) -> sinsr;
  530. }
  531. static void * ef_client_reqsa(struct node * node){
  532. return &((struct clientparam *)node->value) -> req;
  533. }
  534. static void * ef_client_pwtype(struct node * node){
  535. return &((struct clientparam *)node->value) -> pwtype;
  536. }
  537. static void * ef_client_threadid(struct node * node){
  538. return &((struct clientparam *)node->value) -> threadid;
  539. }
  540. static void * ef_client_clisock(struct node * node){
  541. return &((struct clientparam *)node->value) -> clisock;
  542. }
  543. static void * ef_client_remsock(struct node * node){
  544. return &((struct clientparam *)node->value) -> remsock;
  545. }
  546. static void * ef_client_starttime(struct node * node){
  547. return &((struct clientparam *)node->value) -> time_start;
  548. }
  549. static void * ef_client_starttime_msec(struct node * node){
  550. return &((struct clientparam *)node->value) -> msec_start;
  551. }
  552. static void * ef_period_fromtime(struct node * node){
  553. return &((struct period *)node->value) -> fromtime;
  554. }
  555. static void * ef_period_totime(struct node * node){
  556. return &((struct period *)node->value) -> totime;
  557. }
  558. static void * ef_period_next(struct node * node){
  559. return ((struct period *)node->value) -> next;
  560. }
  561. static struct property prop_portlist[] = {
  562. {prop_portlist + 1, "start", ef_portlist_start, TYPE_PORT, "port range start"},
  563. {prop_portlist + 2, "end", ef_portlist_end, TYPE_PORT, "port range end"},
  564. {NULL, "next", ef_portlist_next, TYPE_PORTLIST, "next"}
  565. };
  566. static struct property prop_userlist[] = {
  567. {prop_userlist+1, "user", ef_userlist_user, TYPE_STRING, "user name"},
  568. {NULL, "next", ef_userlist_next, TYPE_USERLIST, "next"}
  569. };
  570. static struct property prop_pwlist[] = {
  571. {prop_pwlist + 1, "user", ef_pwlist_user, TYPE_STRING, "user name"},
  572. {prop_pwlist + 2, "password", ef_pwlist_password, TYPE_STRING, "password string"},
  573. {prop_pwlist + 3, "type", ef_pwlist_type, TYPE_STRING, "password type"},
  574. {NULL, "next", ef_pwlist_next, TYPE_PWLIST, "next"}
  575. };
  576. static struct property prop_chain[] = {
  577. {prop_chain + 1, "addr", ef_chain_addr, TYPE_SA, "parent address"},
  578. {prop_chain + 2, "type", ef_chain_type, TYPE_STRING, "parent type"},
  579. {prop_chain + 3, "weight", ef_chain_weight, TYPE_SHORT, "parent weight 0-1000"},
  580. {prop_chain + 4, "user", ef_chain_user, TYPE_STRING, "parent login"},
  581. {prop_chain + 5, "password", ef_chain_password, TYPE_STRING, "parent password"},
  582. {NULL, "next", ef_chain_next, TYPE_CHAIN, "next"}
  583. };
  584. static struct property prop_period[] = {
  585. {prop_period + 1, "fromtime", ef_period_fromtime, TYPE_TIME, "from time" },
  586. {prop_period + 2, "totime", ef_period_totime, TYPE_TIME, "to time" },
  587. {NULL, "next", ef_period_next, TYPE_PERIOD, "next"}
  588. };
  589. static struct property prop_ace[] = {
  590. {prop_ace + 1, "type", ef_ace_type, TYPE_STRING, "ace action"},
  591. {prop_ace + 2, "operations", ef_ace_operations, TYPE_OPERATIONS, "request type"},
  592. {prop_ace + 3, "users", ef_ace_users, TYPE_USERLIST, "list of users"},
  593. {prop_ace + 4, "src", ef_ace_src, TYPE_IPLIST, "list of source ips"},
  594. {prop_ace + 5, "dst", ef_ace_dst, TYPE_IPLIST, "list of destination ips"},
  595. {prop_ace + 6, "ports", ef_ace_ports, TYPE_PORTLIST, "list of destination ports"},
  596. {prop_ace + 7, "chain", ef_ace_chain, TYPE_CHAIN, "redirect to parent(s)"},
  597. {prop_ace + 8, "wdays", ef_ace_weekdays, TYPE_WEEKDAYS, "days of week"},
  598. {prop_ace + 9, "periods", ef_ace_period, TYPE_PERIOD, "time of the day"},
  599. {NULL, "next", ef_ace_next, TYPE_ACE, "next"}
  600. };
  601. static struct property prop_bandlimit[] = {
  602. {prop_bandlimit + 1, "ace", ef_bandlimit_ace, TYPE_ACE, "acl to apply"},
  603. {prop_bandlimit + 2, "rate", ef_bandlimit_rate, TYPE_UNSIGNED, "max allowed bandwidth"},
  604. {NULL, "next", ef_bandlimit_next, TYPE_BANDLIMIT, "next"}
  605. };
  606. static struct property prop_trafcounter[] = {
  607. {prop_trafcounter + 1, "disabled", ef_trafcounter_disabled, TYPE_INTEGER, "counter status"},
  608. {prop_trafcounter + 2, "ace", ef_trafcounter_ace, TYPE_ACE, "traffic to count"},
  609. {prop_trafcounter + 3, "number", ef_trafcounter_number, TYPE_UNSIGNED, "counter number"},
  610. {prop_trafcounter + 4, "type", ef_trafcounter_type, TYPE_ROTATION, "rotation type"},
  611. {prop_trafcounter + 5, "traffic", ef_trafcounter_traffic64, TYPE_UNSIGNED64, "counter value"},
  612. {prop_trafcounter + 6, "limit", ef_trafcounter_limit64, TYPE_UNSIGNED64, "counter limit"},
  613. {prop_trafcounter + 7, "cleared", ef_trafcounter_cleared, TYPE_DATETIME, "last rotated"},
  614. {prop_trafcounter + 8, "updated", ef_trafcounter_updated, TYPE_DATETIME, "last updated"},
  615. {prop_trafcounter + 9, "comment", ef_trafcounter_comment, TYPE_STRING, "counter comment"},
  616. {NULL, "next", ef_trafcounter_next, TYPE_TRAFCOUNTER}
  617. };
  618. /*
  619. */
  620. static struct property prop_server[] = {
  621. {prop_server + 1, "servicetype", ef_server_type, TYPE_STRING, "type of the service/client"},
  622. {prop_server + 2, "target", ef_server_target, TYPE_STRING, "portmapper target ip"},
  623. {prop_server + 3, "targetport", ef_server_targetport, TYPE_PORT, "portmapper target port"},
  624. {prop_server + 4, "starttime", ef_server_starttime, TYPE_DATETIME, "service started seconds"},
  625. {prop_server + 5, "auth", ef_server_auth, TYPE_STRING, "service authentication type"},
  626. {prop_server + 6, "acl", ef_server_acl, TYPE_ACE, "access control list"},
  627. {prop_server + 7, "singlepacket", ef_server_singlepacket, TYPE_INTEGER, "is single packet redirection"},
  628. {prop_server + 8, "usentlm", ef_server_usentlm, TYPE_INTEGER, "allow NTLM authentication"},
  629. {prop_server + 9, "log", ef_server_log, TYPE_STRING, "type of logging"},
  630. {prop_server + 10, "logtarget", ef_server_logtarget, TYPE_STRING, "log target options"},
  631. {prop_server + 11, "logformat", ef_server_logformat, TYPE_STRING, "logging format string"},
  632. {prop_server + 12, "nonprintable", ef_server_nonprintable, TYPE_STRING, "non printable characters"},
  633. {prop_server + 13, "replacement", ef_server_replacement, TYPE_CHAR, "replacement character"},
  634. {prop_server + 14, "childcount", ef_server_childcount, TYPE_INTEGER, "number of servers connected"},
  635. {prop_server + 15, "intsa", ef_server_intsa, TYPE_SA, "ip address of internal interface"},
  636. {prop_server + 16, "extsa", ef_server_extsa, TYPE_SA, "ip address of external interface"},
  637. #ifndef NOIPV6
  638. {prop_server + 17, "extsa6", ef_server_extsa6, TYPE_SA, "ipv6 address of external interface"},
  639. {prop_server + 18, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
  640. #else
  641. {prop_server + 17, "child", ef_server_child, TYPE_CLIENT, "connected clients"},
  642. #endif
  643. {NULL, "next", ef_server_next, TYPE_SERVER, "next"}
  644. };
  645. static struct property prop_client[] = {
  646. {prop_client + 1, "servicetype", ef_client_type, TYPE_STRING, "type of the client"},
  647. {prop_client + 2, "threadid", ef_client_threadid, TYPE_INTEGER, "process thread id"},
  648. {prop_client + 3, "starttime", ef_client_starttime, TYPE_DATETIME, "client started seconds"},
  649. {prop_client + 4, "starttime_msec", ef_client_starttime_msec, TYPE_UNSIGNED, "client started milliseconds"},
  650. {prop_client + 5, "redirected", ef_client_redirected, TYPE_INTEGER, "number of redirections"},
  651. {prop_client + 6, "operation", ef_client_operation, TYPE_OPERATIONS, "action requested by client"},
  652. {prop_client + 7, "hostname", ef_client_hostname, TYPE_STRING, "name of the requested host"},
  653. {prop_client + 8, "extusername", ef_client_extusername, TYPE_STRING, "username for requested host"},
  654. {prop_client + 9, "extpassword", ef_client_extpassword, TYPE_STRING, "password for requested host"},
  655. {prop_client + 10, "username", ef_client_username, TYPE_STRING, "client username"},
  656. {prop_client + 11, "password", ef_client_password, TYPE_STRING, "client password"},
  657. {prop_client + 12, "clisa", ef_client_clisa, TYPE_SA, "client sa"},
  658. {prop_client + 13, "srvsa", ef_client_srvsa, TYPE_SA, "target server sa"},
  659. {prop_client + 14, "reqsa", ef_client_reqsa, TYPE_SA, "requested server sa"},
  660. {prop_client + 15, "bytesin", ef_client_bytesin64, TYPE_UNSIGNED64, "bytes from server to client"},
  661. {prop_client + 16, "bytesout", ef_client_bytesout64, TYPE_UNSIGNED64, "bytes from client to server"},
  662. {prop_client + 17, "maxtrafin", ef_client_maxtrafin64, TYPE_UNSIGNED64, "maximum traffic allowed for download"},
  663. {prop_client + 18, "maxtrafout", ef_client_maxtrafout64, TYPE_UNSIGNED64, "maximum traffic allowed for upload"},
  664. {prop_client + 19, "pwtype", ef_client_pwtype, TYPE_INTEGER, "type of client password"},
  665. {prop_client + 20, "clisock", ef_client_clisock, TYPE_INTEGER, "client socket"},
  666. {prop_client + 21, "remsock", ef_client_remsock, TYPE_INTEGER, "remote socket"},
  667. {NULL, "next", ef_client_next, TYPE_CLIENT, "next"}
  668. };
  669. struct datatype datatypes[64] = {
  670. {"integer", NULL, pr_integer, NULL},
  671. {"short", NULL, pr_short, NULL},
  672. {"char", NULL, pr_char, NULL},
  673. {"unsigned", NULL, pr_unsigned, NULL},
  674. {"unsigned64", NULL, pr_unsigned64, NULL},
  675. {"traffic", NULL, pr_traffic, NULL},
  676. {"port", NULL, pr_port, NULL},
  677. {"ip", NULL, pr_ip, NULL},
  678. {"sa", NULL, pr_sa, NULL},
  679. {"cidr", NULL, pr_cidr, NULL},
  680. {"string", NULL, pr_string, NULL},
  681. {"datetime", NULL, pr_datetime, NULL},
  682. {"operations", NULL, pr_operations, NULL},
  683. {"rotation", NULL, pr_rotation, NULL},
  684. {"portlist", ef_portlist_next, pr_portlist, prop_portlist},
  685. {"iplist", ef_iplist_next, pr_iplist, NULL},
  686. {"userlist", ef_userlist_next, pr_userlist, prop_userlist},
  687. {"pwlist", ef_pwlist_next, NULL, prop_pwlist},
  688. {"chain", ef_chain_next, NULL, prop_chain},
  689. {"ace", ef_ace_next, NULL, prop_ace},
  690. {"bandlimit", ef_bandlimit_next, NULL, prop_bandlimit},
  691. {"trafcounter", ef_trafcounter_next, NULL, prop_trafcounter},
  692. {"client", ef_client_next, NULL, prop_client},
  693. {"weekdays", NULL, pr_wdays, NULL},
  694. {"time", NULL, pr_time, NULL},
  695. {"period", ef_period_next, NULL, prop_period},
  696. {"server", ef_server_next, NULL, prop_server}
  697. };