-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoriginal.patch
1368 lines (1349 loc) · 47.6 KB
/
original.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -rupN hwdb_orig//flowmonitor.c hwdb_new//flowmonitor.c
--- hwdb_orig//flowmonitor.c 2011-11-03 10:55:20.000000000 +0000
+++ hwdb_new//flowmonitor.c 2013-05-09 13:48:44.000000000 +0100
@@ -45,9 +45,8 @@
#include "protomap.h"
#define USAGE "./flowmonitor [-h host] [-p port] [-m ports] [-m hosts] [-m proto]"
-#define TIME_DELTA 5 /* in seconds */
+#define TIME_DELTA 10 /* in seconds */
-static struct timespec time_delay = {TIME_DELTA, 0};
static int must_exit = 0;
static int exit_status = 0;
static int sig_received;
@@ -55,7 +54,10 @@ static int mapPorts; /* true if mapping
static int mapHosts; /* true if mapping ip addresses to hostnames */
static int mapProto; /* true if mapping protocol numbers to protocol names */
-static tstamp_t processresults(char *buf, unsigned int len);
+
+/*function to print the incoming string in a meaningful fashion*/
+static void print_results(char *results);
+
static void signal_handler(int signum) {
must_exit = 1;
@@ -70,12 +72,13 @@ int main(int argc, char *argv[]) {
unsigned len;
char *host;
unsigned short port;
- int i, j;
- struct timeval expected, current;
- tstamp_t last = 0LL;
+ int i, j, turn=1; //the "turn" variable is set to 1 initially.
host = HWDB_SERVER_ADDR;
port = HWDB_SERVER_PORT;
+
+ int timestamp1=0, timestamp2=0;
+
mapPorts = 0;
mapHosts = 0;
mapProto = 0;
@@ -128,37 +131,44 @@ int main(int argc, char *argv[]) {
signal(SIGINT, SIG_IGN);
if (signal(SIGHUP, signal_handler) == SIG_IGN)
signal(SIGHUP, SIG_IGN);
- gettimeofday(&expected, NULL);
- expected.tv_usec = 0;
+
+ char *tok;
while (! must_exit) {
- tstamp_t last_seen;
- expected.tv_sec += TIME_DELTA;
- if (last) {
- char *s = timestamp_to_string(last);
- sprintf(query,
- "SQL:select * from Flows [ since %s ]\n", s);
- free(s);
- } else
- sprintf(query, "SQL:select * from Flows [ range %d seconds]\n",
- TIME_DELTA);
+
+ timestamp1 = timestamp2;
+
+ /* this loop is entered only once in the beginning to obtain the latest timestamp from the Flows table */
+ if (turn == 1)
+ {
+ sprintf(query, "MYSQL:select epoch from Flows order by epoch desc limit 1;\n");
+ qlen = strlen(query) + 1;
+ turn = turn+1;
+ if (! rpc_call(rpc, Q_Arg(query), qlen, resp, sizeof(resp), &len)) {
+ fprintf(stderr, "rpc_call() failed\n");
+ break;
+ }
+ resp[len] = '\0';
+ tok = strtok(resp, "!");
+ timestamp1 = atoi(tok);
+ }
+
+
+ sleep(TIME_DELTA);
+ timestamp2 = timestamp1 + TIME_DELTA; // then the Flows table is monitored every TIME_DELTA seconds.
+
+
+ sprintf(query, "MYSQL:select * from Flows where epoch > %d and epoch <= %d;\n", timestamp1, timestamp2);
qlen = strlen(query) + 1;
- gettimeofday(¤t, NULL);
- if (current.tv_usec > 0) {
- time_delay.tv_nsec = 1000 * (1000000 - current.tv_usec);
- time_delay.tv_sec = expected.tv_sec - current.tv_sec - 1;
- } else {
- time_delay.tv_nsec = 0;
- time_delay.tv_sec = expected.tv_sec - current.tv_sec;
- }
- nanosleep(&time_delay, NULL);
if (! rpc_call(rpc, Q_Arg(query), qlen, resp, sizeof(resp), &len)) {
fprintf(stderr, "rpc_call() failed\n");
break;
}
resp[len] = '\0';
- if ((last_seen = processresults(resp, len)))
- last = last_seen;
+
+ print_results(resp);
}
+
+
rpc_disconnect(rpc);
if (mapPorts) {
portmap_free(TCP);
@@ -173,117 +183,81 @@ int main(int argc, char *argv[]) {
exit(exit_status);
}
-/*
- * converts the returned Flows tuples into a dynamically-allocated array
- * of FlowData structures. after the user is finished with the array,
- * mon_free should be called to return the storage to the heap
- *
- * Assumes that the Flow tuple is as defined by hwdb.rc - i.e.
- *
- * create table Flows (proto integer, saddr varchar(16), sport integer,
- * daddr varchar(16), dport integer, npkts integer, nbytes integer)
- */
-FlowResults *mon_convert(Rtab *results) {
- FlowResults *ans;
- unsigned int i;
-
- if (! results || results->mtype != 0)
- return NULL;
- if (!(ans = (FlowResults *)malloc(sizeof(FlowResults))))
- return NULL;
- ans->nflows = results->nrows;
- ans->data = (FlowData **)calloc(ans->nflows, sizeof(FlowData *));
- if (! ans->data) {
- free(ans);
- return NULL;
- }
- for (i = 0; i < ans->nflows; i++) {
- char **columns;
- FlowData *p = (FlowData *)malloc(sizeof(FlowData));
- if (!p) {
- mon_free(ans);
- return NULL;
- }
- ans->data[i] = p;
- columns = rtab_getrow(results, i);
- p->tstamp = string_to_timestamp(columns[0]);
- p->proto = atoi(columns[1]) & 0xff;
- inet_aton(columns[2], (struct in_addr *)&p->ip_src);
- p->sport = atoi(columns[3]) & 0xffff;
- inet_aton(columns[4], (struct in_addr *)&p->ip_dst);
- p->dport = atoi(columns[5]) & 0xffff;
- p->packets = atol(columns[6]);
- p->bytes = atol(columns[7]);
- }
- return ans;
-}
-
-void mon_free(FlowResults *p) {
- unsigned int i;
+void print_results(char *results)
+{
+ char *proto, *src_ip, *src_port, *dst_ip, *dst_port, *npkts, *nbytes, *epoch;
+ printf("The results obtained are:\n");
+ char *ptr_results = results;
+ char *pointer1;
+ char *parse = NULL;
+
+
+ /* syntax of incoming string:
+ <proto>!<src_ip>!<src_port>!<dst_ip>!<dst_port>!<npkts>!<nbytes>!<epoch>\n
+ <proto>!<src_ip>!<src_port>!<dst_ip>!<dst_port>!<npkts>!<nbytes>!<epoch>\n
+ .
+ .
+ .
+ <proto>!<src_ip>!<src_port>!<dst_ip>!<dst_port>!<npkts>!<nbytes>!<epoch>\n
+ \0
+
+ an example of incoming string:
+ 6!10.2.0.21!55352!173.194.34.149!3!222!1367336895!
+ 17!10.2.0.21!48403!10.2.0.22!53!1!77!1367336895!
+
+ */
+
+
+ while((pointer1 = strsep(&ptr_results, "\n")) != NULL) //this statement parses the string line-wise, i.e., the newline char is the
+ // delimeter here.
+ {
+ /* each line (that indicates a single flow) is parsed next, the "!" being the delimeter between the fields */
+
+ char *ptr = pointer1; //ptr points to the beginning of each line.
+ //printf("%s\n", ptr);
+
+
+ /*printing in a readable format*/
+
+
+ parse = strtok(ptr, "!");
+ proto = parse;
+ printf("Protocol number: %s\n", proto);
+
+ parse = strtok(NULL, "!");
+ src_ip = parse;
+ printf("Source IP address: %s\n", src_ip);
+
+ parse = strtok(NULL, "!");
+ src_port = parse;
+ printf("Source port number: %s\n", src_port);
+
+ parse = strtok(NULL, "!");
+ dst_ip = parse;
+ printf("Destination IP address: %s\n", dst_ip);
+
+ parse = strtok(NULL,"!");
+ dst_port = parse;
+ printf("Destination port number: %s\n", dst_port);
+
+ parse = strtok(NULL, "!");
+ npkts = parse;
+ printf("Number of packets: %s\n", npkts);
+
+ parse = strtok(NULL, "!");
+ nbytes = parse;
+ printf("Number of bytes: %s\n", nbytes);
+
+ parse = strtok(NULL, "!");
+ epoch = parse;
+ printf("Timestamp: %s\n", epoch);
+
+
+ printf("-------------------------------------------------\n"); //the single-dashed line indicates the end of a single flow.
+ }
+ printf("===============================================================\n"); //the double-dashed line indicates the end of the last 5
+ // seconds worth of data.
- if (p) {
- for (i = 0; i < p->nflows && p->data[i]; i++)
- free(p->data[i]);
- free(p->data);
- free(p);
- }
}
-static tstamp_t processresults(char *buf, unsigned int len) {
- Rtab *results;
- char stsmsg[RTAB_MSG_MAX_LENGTH];
- FlowResults *p;
- unsigned long i;
- tstamp_t last = 0LL;
-
- results = rtab_unpack(buf, len);
- if (results && ! rtab_status(buf, stsmsg)) {
- p = mon_convert(results);
- /* do something with the data pointed to by p */
- printf("Retrieved %ld flow records from database\n", p->nflows);
- for (i = 0; i < p->nflows; i++) {
- FlowData *f = p->data[i];
- char *s = timestamp_to_string(f->tstamp);
- char *src;
- char *dst;
- char protocol[128];
- if (mapProto) {
- sprintf(protocol, "%s", protomap_classify(f->proto));
- } else {
- sprintf(protocol, "%u", f->proto);
- }
- if (mapHosts) {
- src = hostmap_resolve(f->ip_src);
- dst = hostmap_resolve(f->ip_dst);
- } else {
- src = strdup(inet_ntoa(*(struct in_addr *)(&(f->ip_src))));
- dst = strdup(inet_ntoa(*(struct in_addr *)(&(f->ip_dst))));
- }
- if (mapPorts) {
- char *app = portmap_classify(f->proto, f->sport, f->dport);
- printf("%s %s:%s:%s:%hu:%hu:%s:%lu:%lu\n", s,
- protocol,
- src, dst,
- f->sport, f->dport, app,
- f->packets, f->bytes);
- } else {
- printf("%s %s:%s:%s:%hu:%hu:%lu:%lu\n", s,
- protocol,
- src, dst,
- f->sport, f->dport,
- f->packets, f->bytes);
- }
-
- free(s);
- free(src);
- free(dst);
- }
- if (i > 0) {
- i--;
- last = p->data[i]->tstamp;
- }
- mon_free(p);
- }
- rtab_free(results);
- return (last);
-}
+
Binary files hwdb_orig//.flowmonitor.c.swp and hwdb_new//.flowmonitor.c.swp differ
diff -rupN hwdb_orig//flowmonitor.h hwdb_new//flowmonitor.h
--- hwdb_orig//flowmonitor.h 2013-05-09 13:47:23.985216362 +0100
+++ hwdb_new//flowmonitor.h 2013-05-09 13:01:38.205119506 +0100
@@ -16,13 +16,13 @@ typedef struct flow_results {
/*
* convert Rtab results into FlowResults
*/
-FlowResults *mon_convert(Rtab *results);
+//FlowResults *mon_convert(Rtab *results);
/*
* free heap storage associated with FlowResults
*/
-void mon_free(FlowResults *p);
+//void mon_free(FlowResults *p);
-void print_results(char *results);
+//void print_results(char *results);
#endif /* _FLOWMONITOR_H_INCLUDED_ */
diff -rupN hwdb_orig//flowmonitor.h~ hwdb_new//flowmonitor.h~
--- hwdb_orig//flowmonitor.h~ 2013-05-09 13:01:38.000000000 +0100
+++ hwdb_new//flowmonitor.h~ 1970-01-01 01:00:00.000000000 +0100
@@ -1,28 +0,0 @@
-/*
- * interface and data structures associated with flow monitor
- */
-#ifndef _FLOWMONITOR_H_INCLUDED_
-#define _FLOWMONITOR_H_INCLUDED_
-
-#include "flowrec.h"
-#include <netinet/ip.h> /* defines in_addr */
-#include "timestamp.h"
-
-typedef struct flow_results {
- unsigned long nflows;
- FlowData **data;
-} FlowResults;
-
-/*
- * convert Rtab results into FlowResults
- */
-//FlowResults *mon_convert(Rtab *results);
-
-/*
- * free heap storage associated with FlowResults
- */
-//void mon_free(FlowResults *p);
-
-//void print_results(char *results);
-
-#endif /* _FLOWMONITOR_H_INCLUDED_ */
diff -rupN hwdb_orig//genmakefile.sh hwdb_new//genmakefile.sh
--- hwdb_orig//genmakefile.sh 2013-05-09 13:41:28.557203825 +0100
+++ hwdb_new//genmakefile.sh 2013-05-09 13:02:11.725120688 +0100
@@ -99,6 +99,10 @@ ifeq (\$(OS),Darwin)
CFLAGS = \$(CFL_COMMON) -DHAVE_SOCKADDR_LEN
endif
+MYSQLCFLAGS= -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g
+
+MYSQLLIBS= -L/usr/lib/mysql -lmysqlclient -lpthread -lz -lm -lrt -ldl
+
OBJ = crecord.o ctable.o endpoint.o hashtable.o hwdb.o indextable.o list.o mb.o mem.o nodecrawler.o parser.o rtab.o sqlstmts.o srpc.o stable.o table.o tslist.o timestamp.o typetable.o portmap.o i8_parser.o hostmap.o dhcprec.o protomap.o y.tab.o lex.yy.o tshtable.o automaton.o dsemem.o linkedlist.o stack.o topic.o event.o ptable.o pubsub.o code.o agram.o
all: \$(CLIENTS) \$(SERVERS) \$(LOGGERS)
@@ -168,8 +172,8 @@ autoCompile\$(EXT): autoCompile.c code.o
# server applications
#
-hwdbserver\$(EXT): hwdbserver.c config.h util.h hwdb.h rtab.h srpc.h mb.h y.tab.h code.o agram.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o hwdbserver\$(EXT) hwdbserver.c y.tab.c lex.yy.c code.o agram.o libhwdb.a \$(LIBS)
+hwdbserver\$(EXT): hwdbserver.c config.h util.h hwdb.h rtab.h srpc.h mb.h y.tab.h homeflow.h code.o agram.o libhwdb.a
+ \$(CC) \$(CFLAGS) \$(LDFLAGS) -o hwdbserver\$(EXT) hwdbserver.c y.tab.c lex.yy.c homeflow.c \$(MYSQLCFLAGS) \$(MYSQLLIBS) code.o agram.o libhwdb.a \$(LIBS)
stdinserver\$(EXT): stdinserver.c config.h util.h hwdb.h rtab.h mb.h y.tab.h code.o agram.o libhwdb.a
\$(CC) \$(CFLAGS) \$(LDFLAGS) -o stdinserver\$(EXT) stdinserver.c y.tab.c lex.yy.c code.o agram.o libhwdb.a \$(LIBS)
@@ -253,6 +257,8 @@ pdb.o: pdb.c pdb.h rtab.h dir.h map.h sq
map.o: map.c map.h hashtable.h list.h util.h timestamp.h dir.h rtab.h filecrawler.h
dir.o: dir.c dir.h
filecrawler.o: filecrawler.c filecrawler.h timestamp.h rtab.h util.h list.h sqlstmts.h map.h
+homeflow.o: homeflow.c homeflow.h
+ \$(CC) \$(CFLAGS) \(LFLAGS) -c homeflow.c -o homeflow\$(EXT) \$(MYSQLCFLAGS) \$(MYSQLLIBS)
agram.o: agram.c
agram.c: agram.y
yacc -o agram.c -p a_ agram.y
diff -rupN hwdb_orig//genmakefile.sh~ hwdb_new//genmakefile.sh~
--- hwdb_orig//genmakefile.sh~ 2013-05-09 13:40:31.749201821 +0100
+++ hwdb_new//genmakefile.sh~ 1970-01-01 01:00:00.000000000 +0100
@@ -1,277 +0,0 @@
-#!/bin/sh
-#
-# shell script to generate the HWDB Makefile for the system upon which the
-# script is executed
-# usage: ./genmakefile.sh
-#
-# if a Makefile exists in the current directory, it is renamed to Makefile.save
-#
-# a Makefile customized to the system upon which the script is executed is
-# then generated
-#
-#
-
-if [ -e ./Makefile ]; then
- echo "Renaming Makefile to Makefile.save"
- mv Makefile Makefile.save
-fi
-echo "# Makefile for Homework HWDB system" >Makefile
-echo "# Customized for `uname -n` running `uname -s` on `date`" >>Makefile
-echo "# " >>Makefile
-echo "OS=`uname -s | sed '/^CYGWIN/s/^.*$/CYGWIN/'`" >>Makefile
-
-# check for libpcap on this system
-if [ -e /usr/lib/libpcap.a ]; then
- echo "HAVE_PCAP=yes" >>Makefile
-fi
-
-# check for libmysqlclient on this system
-if [ -e /usr/lib/libmysqlclient.a ]; then
- echo "HAVE_MYSQL=yes" >>Makefile
-fi
-
-# khwdb.h resides in kernel directory (this is the file included).
-# /dev/hwdb may get packets from OpenVSwitch, or directly from the
-# kernel.
-if [ -e kernel/khwdb.h ]; then
- echo "HAVE_OVS=yes" >>Makefile
-fi
-
-cat <<!endoftemplate! >>Makefile
-# Template makefile for Homework HWDB system
-#
-# Conditionalized upon the value of \$(OS) - if unspecified in the command
-# line, OS is assumed to be the value defined above
-#
-# e.g.
-# make # makes appropriate binaries for $OS
-# make OS=CYGWIN # makes appropriate binaries for Cygwin
-# make OS=Darwin # makes appropriate binaries for OSX
-# make OS=Linux # makes appropriate binaries for Linux
-
-# base definitions
-CC = gcc
-PCAP_LIB = /usr/lib/libpcap.a
-
-CFL_BASE = -W -Wall -DWARNING
-LFL_COMMON =
-CFL_COMMON = \$(CFL_BASE)
-# enable debugging with
-# CFL_COMMON = \$(CFL_BASE) -DLOG -DVLOG
-# CFL_COMMON = \$(CFL_BASE) -g -DLOG -DVLOG -DDEBUG -DVDEBUG
-# compile for valgrind with
-# CFL_COMMON = \$(CFL_BASE) -g
-
-MYSQL_LIBS = -lz -lmysqlclient -L /usr/lib/mysql/
-
-ifeq "\$(OS)" "CYGWIN"
- EXT=.exe
-else
- EXT=
-endif
-
-CLIENTS = hwdbclient\$(EXT) registercallback\$(EXT) subscribecallback\$(EXT) flowmonitor\$(EXT) dhcpmonitor\$(EXT) linkmonitor\$(EXT) usereventmonitor\$(EXT) httpmonitor\$(EXT) sysmonitor\$(EXT) kflowmonitor\$(EXT) kflowpersist\$(EXT) allowances\$(EXT) sigterm\$(EXT) collapws\$(EXT) autoCompile\$(EXT)
-
-SERVERS = hwdbserver\$(EXT) stdinserver\$(EXT) rpcserver\$(EXT) persistserver\$(EXT)
-
-LOGGERS =
-ifeq (\$(HAVE_OVS),yes)
- LOGGERS := \$(LOGGERS) kflowlogger\$(EXT) khttplogger\$(EXT)
-endif
-ifeq (\$(HAVE_PCAP),yes)
- LOGGERS := \$(LOGGERS) flowlogger\$(EXT) linklogger\$(EXT) dhcplogger\$(EXT) httplogger\$(EXT) nflowlogger\$(EXT) test_iface
-endif
-
-ifeq (\$(HAVE_MYSQL),yes)
- LOGGERS := \$(LOGGERS) persist\$(EXT) persistevent\$(EXT) reinstate\$(EXT)
-endif
-
-
-CFLAGS=\$(CFL_COMMON)
-LIBS = -lpthread -lm
-LDFLAGS = \$(LFL_COMMON)
-# OS-specific definitions
-ifeq (\$(OS),CYGWIN)
- LIBS = -lm
- LDFLAGS = \$(LFL_COMMON) -Wl,--enable-auto-import
-endif
-ifeq (\$(OS),Darwin)
- CFLAGS = \$(CFL_COMMON) -DHAVE_SOCKADDR_LEN
-endif
-
-OBJ = crecord.o ctable.o endpoint.o hashtable.o hwdb.o indextable.o list.o mb.o mem.o nodecrawler.o parser.o rtab.o sqlstmts.o srpc.o stable.o table.o tslist.o timestamp.o typetable.o portmap.o i8_parser.o hostmap.o dhcprec.o protomap.o y.tab.o lex.yy.o tshtable.o automaton.o dsemem.o linkedlist.o stack.o topic.o event.o ptable.o pubsub.o code.o agram.o
-
-all: \$(CLIENTS) \$(SERVERS) \$(LOGGERS)
-
-clients: \$(CLIENTS)
-
-servers: \$(SERVERS)
-
-loggers: \$(LOGGERS)
-
-#
-# client applications
-#
-
-hwdbclient\$(EXT): hwdbclient.c config.h util.h rtab.h srpc.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LFLAGS) -o hwdbclient\$(EXT) hwdbclient.c libhwdb.a \$(LIBS)
-
-registercallback\$(EXT): registercallback.c config.h util.h rtab.h srpc.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o registercallback\$(EXT) registercallback.c libhwdb.a \$(LIBS)
-
-subscribecallback\$(EXT): subscribecallback.c config.h util.h rtab.h srpc.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o subscribecallback\$(EXT) subscribecallback.c libhwdb.a \$(LIBS)
-
-flowmonitor\$(EXT): flowmonitor.c flowmonitor.h config.h util.h rtab.h srpc.h timestamp.h portmap.h hostmap.h protomap.h flowrec.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o flowmonitor\$(EXT) flowmonitor.c libhwdb.a \$(LIBS)
-
-kflowmonitor\$(EXT): kflowmonitor.c kflowmonitor.h config.h util.h rtab.h srpc.h timestamp.h flowrec.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o kflowmonitor\$(EXT) kflowmonitor.c libhwdb.a \$(LIBS)
-
-linkmonitor\$(EXT): linkmonitor.c linkmonitor.h config.h util.h rtab.h srpc.h timestamp.h i8_parser.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o linkmonitor\$(EXT) linkmonitor.c libhwdb.a \$(LIBS)
-
-httpmonitor\$(EXT): httpmonitor.c config.h util.h rtab.h srpc.h timestamp.h i8_parser.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o httpmonitor\$(EXT) httpmonitor.c libhwdb.a \$(LIBS)
-
-dhcpmonitor\$(EXT): dhcpmonitor.c config.h util.h rtab.h srpc.h timestamp.h dhcprec.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o dhcpmonitor\$(EXT) dhcpmonitor.c libhwdb.a \$(LIBS)
-
-usereventmonitor\$(EXT): usereventmonitor.c usereventmonitor.h config.h util.h rtab.h srpc.h timestamp.h usereventrec.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o usereventmonitor\$(EXT) usereventmonitor.c libhwdb.a \$(LIBS)
-
-sysmonitor\$(EXT): sysmonitor.c config.h util.h rtab.h srpc.h timestamp.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o sysmonitor\$(EXT) sysmonitor.c libhwdb.a \$(LIBS)
-
-kflowpersist\$(EXT): kflowpersist.c config.h util.h rtab.h srpc.h timestamp.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o kflowpersist\$(EXT) kflowpersist.c libhwdb.a \$(LIBS)
-
-persist\$(EXT): persist.c config.h util.h rtab.h srpc.h timestamp.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o persist\$(EXT) persist.c libhwdb.a \$(LIBS) \$(MYSQL_LIBS)
-
-persistevent\$(EXT): persistevent.c config.h util.h rtab.h srpc.h timestamp.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o persistevent\$(EXT) persistevent.c libhwdb.a \$(LIBS) \$(MYSQL_LIBS)
-
-reinstate\$(EXT): reinstate.c config.h util.h rtab.h srpc.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o reinstate\$(EXT) reinstate.c libhwdb.a \$(LIBS) \$(MYSQL_LIBS)
-
-sigterm\$(EXT): sigterm.c config.h util.h rtab.h srpc.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LFLAGS) -o sigterm\$(EXT) sigterm.c libhwdb.a \$(LIBS)
-
-collapws\$(EXT): collapws.c
- \$(CC) \$(CFLAGS) \$(LFLAGS) -o collapws\$(EXT) collapws.c
-
-autoCompile\$(EXT): autoCompile.c code.o agram.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o autoCompile\$(EXT) autoCompile.c code.o agram.o libhwdb.a \$(LIBS)
-
-#
-# server applications
-#
-
-hwdbserver\$(EXT): hwdbserver.c config.h util.h hwdb.h rtab.h srpc.h mb.h y.tab.h code.o agram.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o hwdbserver\$(EXT) hwdbserver.c y.tab.c lex.yy.c code.o agram.o libhwdb.a \$(LIBS)
-
-stdinserver\$(EXT): stdinserver.c config.h util.h hwdb.h rtab.h mb.h y.tab.h code.o agram.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o stdinserver\$(EXT) stdinserver.c y.tab.c lex.yy.c code.o agram.o libhwdb.a \$(LIBS)
-
-rpcserver\$(EXT): rpcserver.c config.h srpc.h code.o agram.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o rpcserver\$(EXT) rpcserver.c code.o agram.o libhwdb.a \$(LIBS)
-
-persistserver\$(EXT): persistserver.c config.h srpc.h y.tab.h pdb.o dir.o map.o rtab.o filecrawler.o
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o persistserver\$(EXT) persistserver.c pdb.o dir.o map.o filecrawler.o y.tab.c lex.yy.c libhwdb.a \$(LIBS)
-#
-# loggers
-#
-
-kflowlogger\$(EXT): kflowlogger.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o kflowlogger\$(EXT) kflowlogger.o libhwdb.a \$(LIBS)
-
-khttplogger\$(EXT): khttplogger.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o khttplogger\$(EXT) khttplogger.o libhwdb.a \$(LIBS)
-
-flowlogger\$(EXT): flowlogger.o flow_accumulator.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o flowlogger\$(EXT) flowlogger.o flow_accumulator.o libhwdb.a \$(LIBS) -lpcap
-
-nflowlogger\$(EXT): nflowlogger.o nflow_accumulator.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o nflowlogger\$(EXT) nflowlogger.o nflow_accumulator.o libhwdb.a \$(LIBS) -lpcap
-
-httplogger\$(EXT): httplogger.o http_accumulator.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o httplogger\$(EXT) httplogger.o http_accumulator.o libhwdb.a \$(LIBS) -lpcap
-
-linklogger\$(EXT): linklogger.o link_accumulator.o rt_parser.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o linklogger\$(EXT) linklogger.o link_accumulator.o rt_parser.o libhwdb.a \$(LIBS) -lpcap
-
-dhcplogger: dhcplogger.o libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o dhcplogger dhcplogger.o libhwdb.a \$(LIBS)
-
-test_iface: test_iface.o
- \$(CC) \$(CFLAGS) -o test_iface test_iface.o -lpcap
-
-allowances\$(EXT): allowances.c flowmonitor.h config.h util.h rtab.h srpc.h timestamp.h flowrec.h dhcprec.h i8_parser.h libhwdb.a
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -o allowances\$(EXT) allowances.c libhwdb.a \$(LIBS)
-
-y.tab.h: scan.l gram.y
- flex scan.l
- yacc -d gram.y
-
-clean:
- rm -f y.tab.c y.tab.h lex.yy.c agram.c
- rm -f *.o *~ \$(CLIENTS) \$(SERVERS) \$(LOGGERS)
- rm -f libhwdb.a
- rm -f libhwdb.so*
-
-crecord.o: crecord.c crecord.h ctable.h mem.h endpoint.h stable.h
-ctable.o: ctable.c ctable.h endpoint.h crecord.h
-endpoint.o: endpoint.c endpoint.h mem.h
-hashtable.o: hashtable.c hashtable.h
-hwdb.o: hwdb.c hwdb.h mb.h util.h rtab.h sqlstmts.h parser.h indextable.h table.h hashtable.h pubsub.h srpc.h tslist.h y.tab.h
-indextable.o: indextable.c indextable.h tuple.h hashtable.h table.h sqlstmts.h util.h nodecrawler.h typetable.h rtab.h srpc.h pubsub.h list.h
-list.o: list.c list.h mem.h util.h
-mb.o: mb.c mb.h node.h table.h tuple.h timestamp.h
-mem.o: mem.c mem.h
-nodecrawler.o: nodecrawler.c nodecrawler.h util.h list.h rtab.h sqlstmts.h table.h tuple.h timestamp.h node.h
-parser.o: parser.c parser.h typetable.h util.h sqlstmts.h y.tab.h
-rtab.o: rtab.c rtab.h util.h typetable.h sqlstmts.h config.h srpc.h
-sqlstmts.o: sqlstmts.c sqlstmts.h util.h timestamp.h y.tab.h typetable.h
-srpc.o: srpc.c srpc.h srpcdefs.h tslist.h endpoint.h ctable.h crecord.h mem.h stable.h
-stable.o: stable.c stable.h mem.h tslist.h
-table.o: table.c table.h util.h typetable.h sqlstmts.h list.h pubsub.h srpc.h node.h rtab.h
-tslist.o: tslist.c tslist.h mem.h
-timestamp.o: timestamp.c timestamp.h mem.h
-typetable.o: typetable.c typetable.h
-portmap.o: portmap.c portmap.h
-protomap.o: protomap.c protomap.h
-flow_accumulator.o: flow_accumulator.c flow_accumulator.h timestamp.h
-nflow_accumulator.o: nflow_accumulator.c nflow_accumulator.h timestamp.h
-http_accumulator.o: http_accumulator.c http_accumulator.h
-link_accumulator.o: link_accumulator.c link_accumulator.h
-hostmap.o: hostmap.c hostmap.h
-dhcprec.o: dhcprec.c dhcprec.h rtab.h timestamp.h
-y.tab.o: y.tab.c util.h timestamp.h sqlstmts.h list.h typetable.h mem.h
-lex.yy.o: lex.yy.c mem.h
-pdb.o: pdb.c pdb.h rtab.h dir.h map.h sqlstmts.h parser.h util.h
-map.o: map.c map.h hashtable.h list.h util.h timestamp.h dir.h rtab.h filecrawler.h
-dir.o: dir.c dir.h
-filecrawler.o: filecrawler.c filecrawler.h timestamp.h rtab.h util.h list.h sqlstmts.h map.h
-homeflow.o: homeflow.c homeflow.h
- \$(CC) \$(CFLAGS) \(LFLAGS) -c homeflow.c -o homeflow\$(EXT) \$(MYSQLCFLAGS) \$(MYSQLLIBS)
-agram.o: agram.c
-agram.c: agram.y
- yacc -o agram.c -p a_ agram.y
-
-libhwdb.a: \$(OBJ)
- rm -f libhwdb.a
- ar r libhwdb.a \$(OBJ)
- ranlib libhwdb.a
-
-shared: \$(OBJ)
- rm -f libhwdb.so*
- \$(CC) \$(CFLAGS) \$(LDFLAGS) -shared -W1,-soname,libhwdb.so.1 -o libhwdb.so.1.0.1 \$(OBJ) \$(LIBS)
- ln -s libhwdb.so.1* libhwdb.so
-
-install: shared
- cp libhwdb.so /usr/lib/
- mkdir -p /usr/include/hwdb/
- cp srpc.h endpoint.h rtab.h config.h timestamp.h /usr/include/hwdb/
-
-!endoftemplate!
Binary files hwdb_orig//homeflow and hwdb_new//homeflow differ
diff -rupN hwdb_orig//homeflow.c hwdb_new//homeflow.c
--- hwdb_orig//homeflow.c 1970-01-01 01:00:00.000000000 +0100
+++ hwdb_new//homeflow.c 2013-05-09 13:01:36.777119455 +0100
@@ -0,0 +1,83 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stddef.h>
+#include <time.h>
+#include <mysql/mysql.h>
+#include <mysql/my_global.h>
+#include "homeflow.h"
+
+//char tstamp_for_store[11] = {0};
+
+char* hf_query_parser(char *query_fired)
+{
+ MYSQL *conn;
+ char str[100], str_final[100000];
+ char *server = "localhost";
+ char *user = "root";
+ char *password = "mrl%1%x";
+ char *database = "homeflow";
+
+ MYSQL_RES *result;
+ MYSQL_ROW row;
+ int num_fields, num_rows, i, l, ll=0;
+ conn = mysql_init(NULL);
+
+ if (conn == NULL)
+ {
+ printf("Error %u: %s\n",mysql_errno(conn), mysql_error(conn));
+ exit(1);
+ }
+
+ if (mysql_real_connect(conn, server, user, password, database, 0, NULL, 0) == NULL)
+ {
+ printf("Error %u: %s\n",mysql_errno(conn), mysql_error(conn));
+ exit(1);
+ }
+ else
+ {
+ //mysql_query(conn, "select epoch from Flows order by epoch desc limit 1;");
+ //result = mysql_store_result(conn);
+ //row = mysql_fetch_row(result);
+ //printf("initial time value: %s\n", row[0]);
+
+ //for (i=0;i<strlen(row[0]);i++)
+ //{
+ // tstamp_for_store[i] = row[0][i];
+ //}
+ //tstamp_for_store[i] = '\0';
+ //mysql_free_result(result);
+
+ //sleep(2);
+
+ l = sprintf(str, query_fired);
+ //l += sprintf(str+l, " where epoch > %s;", tstamp_for_store);
+ printf("dispaly the full query now:\t %s\n", str);
+
+ mysql_query(conn, str);
+ result = mysql_store_result(conn);
+ num_fields = mysql_num_fields(result);
+ printf("Number of columns:%d\n", num_fields);
+ num_rows = mysql_num_rows(result);
+ printf("Number of rows:%d\n", num_rows);
+
+ while ((row = mysql_fetch_row(result)))
+ {
+ for (i=0; i<num_fields; i++)
+ {
+ printf("%s", row[i] ? row[i] : "NULL");
+ ll += sprintf(str_final+ll, row[i]);
+ ll += sprintf(str_final+ll, "!");
+ }
+ printf("\n");
+ ll += sprintf(str_final+ll, "\n");
+ }
+ str_final[ll-1] = '\0';
+ mysql_free_result(result);
+ mysql_close(conn);
+ }
+ return (str_final);
+
+}
+
+
diff -rupN hwdb_orig//homeflow.h hwdb_new//homeflow.h
--- hwdb_orig//homeflow.h 1970-01-01 01:00:00.000000000 +0100
+++ hwdb_new//homeflow.h 2013-05-09 13:01:30.885119248 +0100
@@ -0,0 +1,13 @@
+#ifndef HOMEFLOW_H
+#define HOMEFLOW_H
+
+//#include <mysql/mysql.h>
+//#include <mysql/my_global.h>
+
+//extern char tstamp_for_store[11];
+
+
+char* hf_query_parser(char *query_fired);
+
+
+#endif
diff -rupN hwdb_orig//hwdbserver.c hwdb_new//hwdbserver.c
--- hwdb_orig//hwdbserver.c 2013-05-09 13:36:06.413192461 +0100
+++ hwdb_new//hwdbserver.c 2013-05-09 13:01:17.413118773 +0100
@@ -195,6 +195,20 @@ int main(int argc, char *argv[]) {
}
rtab_free(results);
}
+
+ else if (strcmp(buf, "MYSQL") == 0) {
+ count++;
+ q = p;
+ p = strchr(q, '\n');
+ if (p)
+ *p++ = '\0';
+ string = hf_query_parser(q);
+ printf("caught this:\n%s",string);
+ strcpy(resp, string);
+ len = strlen(resp)+1;
+ }
+
+
else if (strcmp(buf, "BULK") == 0) {
q = p;
p = strchr(q, '\n');
diff -rupN hwdb_orig//hwdbserver.c~ hwdb_new//hwdbserver.c~
--- hwdb_orig//hwdbserver.c~ 2013-05-09 13:01:17.000000000 +0100
+++ hwdb_new//hwdbserver.c~ 1970-01-01 01:00:00.000000000 +0100
@@ -1,282 +0,0 @@
-/*
- * Homework DB server
- *
- * single-threaded provider of the Homework Database using SRPC
- *
- * expects SQL statement in input buffer, sends back results of
- * query in output buffer
- */
-
-#include "config.h"
-#include "util.h"
-#include "hwdb.h"
-#include "rtab.h"
-#include "srpc.h"
-#include "mb.h"
-#include "timestamp.h"
-#include "homeflow.h"
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#define USAGE "./hwdbserver [-p port] [-l packets|stats] [-c config-file]"
-#define LOG_STATS 1
-#define LOG_PACKETS 2
-#define STATS_COUNT 10000
-#define ILLEGAL_QUERY_RESPONSE "1<|>Illegal query<|>0<|>0<|>\n"
-
-//char tstamp_for_store[11]; //for homeflow
-
-extern int log_allocation;
-
-static char buf[SOCK_RECV_BUF_LEN];
-static char resp[SOCK_RECV_BUF_LEN];
-
-static void loadfile(char *file, int log, int isreadonly) {
- FILE *fd;
- int len;
- Rtab *results;
- char stsmsg[RTAB_MSG_MAX_LENGTH];
-
- if (!(fd = fopen(file, "r"))) {
- fprintf(stderr, "Unable to open configuration file %s\n", file);
- return;
- }
- while (fgets(buf, sizeof(buf), fd) != NULL) {
- len = strlen(buf) - 1; /* get rid of \n */
- if (len == 0)
- continue; /* ignore empty lines */
- if (buf[0] == '#')
- continue; /* ignore comments */
- buf[len] = '\0';
- if (log)
- printf(">> %s\n", buf);
- results = hwdb_exec_query(buf, isreadonly);
- if (! results)
- strcpy(resp, ILLEGAL_QUERY_RESPONSE);
- else
- (void) rtab_pack(results, resp, SOCK_RECV_BUF_LEN, &len);
- if (rtab_status(resp, stsmsg))
- printf("<< %s\n", stsmsg);
- else if (log)
- rtab_print(results);
- rtab_free(results);
- }
- fclose(fd);
-}
-
-int main(int argc, char *argv[]) {
- RpcEndpoint sender;
- unsigned len;
- RpcService rps;
- unsigned short port, snap;
- int i, j;
- Rtab *results;
- int log, count;
- char *p, *q, *r;
- int ninserts, sofar;
- char *cfile;
- tstamp_t start, finish;
- int isreadonly;
- char *string; //for homeflow
-
-
- port = HWDB_SERVER_PORT;
- snap = HWDB_SNAPSHOT_PORT;
- log = LOG_STATS;
- cfile = NULL;
- isreadonly = 0;
- for (i = 1; i < argc; ) {
- if ((j = i + 1) == argc) {
- fprintf(stderr, "usage: %s\n", USAGE);
- exit(1);
- }
- if (strcmp(argv[i], "-p") == 0) {
- port = atoi(argv[j]);
- snap = port + 1;
- } else if (strcmp(argv[i], "-l") == 0) {
- if (strcmp(argv[j], "packets") == 0)
- log = LOG_PACKETS;
- else if (strcmp(argv[j], "stats") == 0)
- log = LOG_STATS;
- else {
- fprintf(stderr, "usage: %s\n", USAGE);
- }
- } else if (strcmp(argv[i], "-c") == 0) {
- cfile = argv[j];
- } else {
- fprintf(stderr, "Unknown flag: %s %s\n", argv[i], argv[j]);
- }
- i = j + 1;
- }
- printf("initializing database\n");
- hwdb_init(1);
- if (cfile) {
- printf("processing configuration file %s\n", cfile);
- loadfile(cfile, log, isreadonly);
- }
- printf("initializing rpc system\n");
- if (!rpc_init(port)) {
- fprintf(stderr, "Failure to initialize rpc system\n");
- exit(-1);
- }
- printf("offering service\n");
- rps = rpc_offer("HWDB");
- if (! rps) {
- fprintf(stderr, "Failure offering HWDB service\n");
- exit(-1);
- }
- printf("starting to read queries from network\n");
- //log_allocation = 1;
- count = 0;
- /* legal queries are of the following form:
- *
- * SQL:<legal sql statement>\n
- *
- * BULK:<number>\n
- * insert into .....\n --+
- * insert into .....\n |
- * ... > <number> of these
- * ... |
- * insert into .....\n --+
- *
- * SNAPSHOT:\n
- *
- * For SQL queries, the response will consist of a line of the form
- *
- * status<|>Status comment<|>ncols<|>nrows<|>\n
- *
- * if nrows > 0, subsequent lines in the response will consist of
- * column descriptors, followed by column values for each row
- *
- * for BULK inserts, the response will consist of <number> lines, each
- * of the form
- *
- * status<|>Status comment<|>0<|>0<|>\n
- *
- * For SNAPSHOT commands, the response will consist of a line
- *
- * status<|>Status comment<|>0<|>0<|>\n
- */
- while ((len = rpc_query(rps, &sender, buf, SOCK_RECV_BUF_LEN)) > 0) {
- buf[len] = '\0';
- if (log >= LOG_PACKETS) {
- MSG("Received: %s", buf);
- }
- p = strchr(buf, ':');
- if (p == NULL) {
- printf("Illegal query: %s\n", buf);
- strcpy(resp, ILLEGAL_QUERY_RESPONSE);
- len = strlen(resp) + 1;
- rpc_response(rps, &sender, resp, len);
- continue;
- }
- *p++ = '\0';
- if (strcmp(buf, "SQL") == 0) {
- count++;
- q = p;
- p = strchr(q, '\n');
- if (p)
- *p++ ='\0';
- results = hwdb_exec_query(q, isreadonly);
- if (log >= LOG_PACKETS) {
- rtab_print(results);
- }
- if (! results) {
- strcpy(resp, "1<|>Error<|>0<|>0<|>\n");
- len = strlen(resp) + 1;
- } else {
- if (! rtab_pack(results, resp, SOCK_RECV_BUF_LEN, &i))
- printf("query results truncated\n");
- len = i;
- }