source: genesis/tools/nodechk/nodechk.c@ 3280

Last change on this file since 3280 was 3280, checked in by rudolf, 20 years ago
  • Property svn:executable set to *
File size: 38.6 KB
Line 
1// (c) Copyright 2004 Stichting Wireless Leiden, all
2// rights reserved. More information can be found on
3// http://wwww.wirelessleiden.nl and the license is at:
4// http://wleiden.webweaving.org:8080/svn/node-config/LICENSE
5//
6// Nodechck - Programma om wleiden.conf files te lezen
7// en te vergelijken met actuele informatie uit de nodes
8//
9// Rev.0.5 23/11/2004 RO
10// Fout verbeterd: 172.1.1.223 en 172.1.1.22 werden gelijk geacht, zodat lijsten niet klopten
11// Uitvoer uit nodes aan alle lijsten gekoppeld
12// Lijst toegevoegd: outputs1.csv, uitgaande van nodeuitvoer, waaraan genesis data toegevoegd is.
13//
14// Rev.0.4 22/11/2004 RO
15// compatibility:
16// io.h verwijderd
17// memicmp() voor unix toegevoegd
18// getest op unix
19//
20// Rev.0.3 22/11/2004 RO
21// niet-ANSI functies eruit gegooid, voorbereid met #ifdef voor linux padnamen (niet getest)
22// input ./nnames: tekstfile, lijst van nodenamen
23// input ./confs: tekstfile, actuele output van nodes, gegenereerd door extern script
24// input ./location: tekstfile: pad naar nodemappen in bv. svn
25// code en structures toegevoegd om node output in te lezen
26// in configip1 kolommen toegevoegd met actuele node-info. o.a. macadres
27// ip-adres in interfaceconfig van wleiden.conf is bepalend voor koppeling met actuele data
28//
29// Rev.0.2 14/11/2004 RO
30// $master_ip bij interface ingevuld
31// komma's vervangen door ; in plaats van weglaten
32// structures IPADDRESS en IPRANGE toegevoegd voor eenvoudiger vergelijken
33// rekening houden met ontbrekende sprintf bij sommige $config-regels
34// uitvoer naar configs1.csv, configs2.csv(gesorteerd op ip)
35// configip1.csv(ipstart en ipend toegevoegd,overbodige kolommen verwijderd, comment in .csv toegevoegd
36//
37// Rev.0.1 12/11/2004 RO
38// dimensies van desc, point_to_point, ospfneighbors verhoogd
39// gegevens van hoofd interface in aliassen overgenomen
40// komma's uit velden geskipt ivm csv-lijst (3e regel node-som heeft ',' in desc-veld)
41//
42// Rev.0.0 10/11/2004 initial revision Rudolf Oosterhuis
43
44#include <stdio.h>
45#include <time.h>
46#include <string.h>
47#include <ctype.h>
48#include <stdlib.h>
49
50#define BOOL unsigned int
51#define FALSE (0==1)
52#define TRUE (0==0)
53
54typedef struct
55{
56 unsigned char ip0;
57 unsigned char ip1;
58 unsigned char ip2;
59 unsigned char ip3;
60} IPADDRESS;
61
62typedef struct
63{
64 IPADDRESS ip;
65 unsigned char mask;
66} IPRANGE;
67
68typedef struct
69{
70 char volgnr[4];
71 char name[20];
72 char present[2];
73} CNODEOUTPUT;
74
75typedef struct
76{
77 char volgnr[4];
78 char nodenr[4];
79 char configname[10];
80 char ether[20];
81 char status[20];
82 char ssid[40];
83 char stationname[40];
84 char channel[4];
85} CARDOUTPUT;
86
87typedef struct
88{
89 char cardnr[4];
90 char ip[18];
91 char netmask[12];
92 char broadcast[18];
93} IFOUTPUT;
94
95typedef struct
96{
97 char volgnr[4];
98 char name[20];
99 char location[100];
100 char master_ip[20];
101 char gw_open[10];
102 char nodetype[10];
103 char nodename[30];
104 char status[10];
105 char OS[20];
106 char labelpos[30];
107 char X[10];
108 char Y[10];
109 char N[10];
110 char E[10];
111 char ESSID[34];
112} CNODE;
113
114typedef struct
115{
116 char volgnr[4];
117 char nodenr[4];
118 char configname[10];
119 char sprintfname[10];
120 char type[10];
121 char ip[20];
122 char desc[46];
123 char sdesc[20];
124 char speed[20];
125
126 char pointtopoint[35];
127
128 char ospfbroadcast[6];
129 char ospfneighbors[35];
130
131 char mode[10];
132 char essid[34];
133 char channel[3];
134
135 char polar[6];
136 char antenna[10];
137 char gain[10];
138 char direction[6];
139 char beamwidth[6];
140 char cable[3];
141 char heigth[4];
142
143 char dhcp[8];
144 IPRANGE ipr;
145 IPADDRESS ipstart;
146 IPADDRESS ipend;
147 IPADDRESS ptp1;
148 IPADDRESS ptp2;
149 IPADDRESS on1;
150 IPADDRESS on2;
151} CARD;
152
153
154void LeesNode(void);
155void LeesNodeOutput(void);
156void BehandelRegel(void);
157void BehandelOutputRegel(void);
158void FormatRegel(void);
159void MaakCSV(int code);
160void MaakCSV2(int code);
161void MaakCSV3(int code);
162void MaakIpOverzicht(void);
163void AddKomma(void);
164void AddTekst(void);
165void VulIpAdressen(void);
166void SwapCards(int i);
167int CompareIp(IPADDRESS *ad1,IPADDRESS *ad2);
168
169char nnamesbuf[2000];
170char location[64];
171char fn[64];
172char buf[50];
173#define BUFLEN 1000
174char Tekstbuf[BUFLEN];
175char Regelbuf[BUFLEN];
176char Formatbuf[BUFLEN];
177FILE *hConf;
178size_t numread,toread;
179CNODEOUTPUT CNodeOutput[100];
180CNODE CNode[100];
181IFOUTPUT IfOutput[600];
182CARDOUTPUT CardOutput[400];
183CARD Card[600];
184int NodeTeller;
185int CardTeller;
186int NodeOutputTeller;
187int CardOutputTeller;
188int IfOutputTeller;
189BOOL bNodeBezig;
190BOOL bCardBezig;
191
192#ifndef WIN32
193int memicmp(char *a,char *b,size_t c);
194int memicmp(char *a,char *b,size_t c)
195{
196 int i;
197 char ba[200],bb[200];
198 memcpy(ba,a,c);
199 memcpy(bb,b,c);
200 for (i=0;i<c;i++)
201 {
202 ba[i]=toupper(ba[i]);
203 bb[i]=toupper(bb[i]);
204 }
205 return memcmp(ba,bb,c);
206}
207
208#endif
209
210main()
211{
212 FILE *hFile;
213 NodeTeller=0;
214 CardTeller=0;
215
216 if (hFile=fopen("location","r"))
217 {
218 fread(location,sizeof(char),64,hFile);
219 fclose(hFile);
220 {
221 char *pos=&location[strlen(location)-1];
222 while (*pos=='\n'||*pos=='\r'||*pos=='\t'||*pos==' ')
223 {
224 *pos='\0';
225 pos--;
226 }
227 }
228 if (hFile=fopen("nnames","r"))
229 {
230 char *pos;
231 numread=fread(nnamesbuf,sizeof(char),2000,hFile);
232 fclose(hFile);
233 pos=strtok(nnamesbuf,"\n\r");
234 while(pos)
235 {
236 memset((char*)&(CNode[NodeTeller]),'\0',sizeof(CNode[NodeTeller]));
237 strcpy(CNode[NodeTeller++].name,pos);
238 pos=strtok(NULL,"\n\r");
239 }
240 NodeTeller=0;
241 while (*(CNode[NodeTeller].name))
242 {
243#ifdef WIN32
244 sprintf(fn,"%s%s\\wleiden.conf",location,CNode[NodeTeller].name);
245#else
246 sprintf(fn,"%s%s/wleiden.conf",location,CNode[NodeTeller].name);
247#endif
248 printf(fn);
249 printf("\n");
250
251 if (hConf=fopen(fn,"r"))
252 {
253 LeesNode();
254 fclose(hConf);
255 }
256 NodeTeller++;
257 }
258 }
259 }
260 sprintf(buf,"\naantal nodes: %i\n\r",NodeTeller);
261 printf(buf);
262
263 if (hConf=fopen("confs","r"))
264 {
265 LeesNodeOutput();
266 fclose(hConf);
267 }
268 MaakCSV(1);
269 MaakIpOverzicht();
270 MaakCSV3(1);
271
272 return 0;
273}
274
275void LeesNodeOutput(void)
276{
277 char *pos;
278 int regels=0;
279 int rest;
280 memset((char*)&(CNodeOutput),'\0',sizeof(CNodeOutput));
281 NodeOutputTeller=-1;
282 CardOutputTeller=-1;
283 IfOutputTeller=-1;
284
285 toread=BUFLEN;
286 numread=fread(Tekstbuf,sizeof(char),toread,hConf);
287
288 pos=strtok(Tekstbuf,"\n\r" );
289 while (pos)
290 {
291 unsigned j;
292 strcpy(Regelbuf,Tekstbuf);
293 rest=strlen(Regelbuf);
294 for (j=0;j<numread-rest-1;j++)
295 {
296 Tekstbuf[j]=Tekstbuf[j+rest+1]; //tekst naar links schuiven
297 }
298 if (numread==BUFLEN)
299 {
300 numread-=(rest+1);
301 numread+=fread(Tekstbuf+numread,sizeof(char),rest+1,hConf);
302 if (numread<BUFLEN) Tekstbuf[numread]='\0';
303 }
304 else
305 {
306 numread-=(rest+1);
307 Tekstbuf[numread]='\0';
308 }
309
310 BehandelOutputRegel();
311 strcat(Regelbuf,"\n");
312 printf("%s",Regelbuf);
313 regels++;
314 pos=strtok(Tekstbuf,"\n\r" );
315 }
316 sprintf(buf,"\naantal regels: %i\n\r",regels);
317 printf(buf);
318}
319
320void BehandelOutputRegel(void)
321{
322 char *pos=Regelbuf;
323 CNODEOUTPUT *pCNO;
324 CARDOUTPUT *pCDO;
325 IFOUTPUT *pIO;
326 while (*pos=='\n'||*pos=='\r') pos++;
327 if (!memicmp(pos,"CONFIG FOR ",11))
328 {
329 pCNO=&CNodeOutput[++NodeOutputTeller];
330 strncpy(pCNO->name,pos+11,sizeof(pCNO->name));
331 sprintf(pCNO->volgnr,"%3d",NodeOutputTeller);
332 strcpy(pCNO->present,"0");
333 }
334 else if (*pos!=' '&&*pos!='\t')
335 {
336 //interface naam
337 unsigned int len;
338 char *pos1=pos;
339 pCDO=&CardOutput[++CardOutputTeller];
340 pCNO=&CNodeOutput[NodeOutputTeller];
341 strcpy(pCNO->present,"1");
342 while(*pos1++!=':');
343 len=pos1-pos-1;
344 if (len>9) len=9;
345 memcpy(pCDO->configname,pos,len);
346 pCDO->configname[len]='\0';
347 sprintf(pCDO->volgnr,"%3d",CardOutputTeller);
348 sprintf(pCDO->nodenr,"%3d",NodeOutputTeller);
349 }
350 else
351 {
352 pCDO=&CardOutput[CardOutputTeller];
353 while (*pos==' '||*pos=='\t'||*pos=='\n'||*pos=='\r') pos++;//skip leading spaces
354 if (!memicmp(pos,"inet ",5))
355 {
356 unsigned int len;
357 char *pos1=pos+5;
358 pIO=&IfOutput[++IfOutputTeller];
359 while(*pos1++!=' ');
360 len=pos1-pos-6;
361 if (len>17) len=17;
362 memcpy(pIO->ip,pos+5,len);
363 pIO->ip[len]='\0';
364 memcpy(pIO->netmask,pos1+8,10);
365 pIO->netmask[10]='\0';
366 if (*(pos1+19)=='b') //broadcast
367 {
368 strcpy(pIO->broadcast,pos1+29);
369 }
370 sprintf(pIO->cardnr,"%3d",CardOutputTeller);
371 }
372 else if (!memicmp(pos,"ether ",6)) strcpy(pCDO->ether,pos+6);
373 else if (!memicmp(pos,"status: ",8)) strcpy(pCDO->status,pos+8);
374 else if (!memicmp(pos,"ssid ",5))
375 {
376 unsigned int len;
377 char *pos1=pos+5;
378 while(*pos1++!=' ');
379 len=pos1-pos-6;
380 if (len>38) len=38;
381 memcpy(pCDO->ssid,pos+5,len);
382 pCDO->ssid[len]='\0';
383 }
384 else if (!memicmp(pos,"channel ",8))
385 {
386 unsigned int len;
387 char *pos1=pos+8;
388 while(*pos1++!=' ');
389 len=pos1-pos-9;
390 if (len>3) len=3;
391 memcpy(pCDO->channel,pos+8,len);
392 pCDO->channel[len]='\0';
393 }
394 else if (!memicmp(pos,"stationname ",12)) strcpy(pCDO->stationname,pos+12);
395 }
396}
397
398void LeesNode(void)
399{
400 char *pos;
401 int regels=0;
402 int rest;
403 bCardBezig=FALSE;
404
405 toread=BUFLEN;
406 numread=fread(Tekstbuf,sizeof(char),toread,hConf);
407
408 pos=strtok(Tekstbuf,"\n\r" );
409 while (pos)
410 {
411 unsigned j;
412 strcpy(Regelbuf,Tekstbuf);
413 rest=strlen(Regelbuf);
414 for (j=0;j<numread-rest-1;j++)
415 {
416 Tekstbuf[j]=Tekstbuf[j+rest+1]; //tekst naar links schuiven
417 }
418 if (numread==BUFLEN)
419 {
420 numread-=(rest+1);
421 numread+=fread(Tekstbuf+numread,sizeof(char),rest+1,hConf);
422 if (numread<BUFLEN) Tekstbuf[numread]='\0';
423 }
424 else
425 {
426 numread-=(rest+1);
427 Tekstbuf[numread]='\0';
428 }
429
430 BehandelRegel();
431 strcat(Formatbuf,"\n");
432 printf(Formatbuf);
433 regels++;
434 pos=strtok(Tekstbuf,"\n\r" );
435 }
436 sprintf(buf,"\naantal regels: %i\n\r",regels);
437 printf(buf);
438}
439
440void FormatRegel(void)
441{
442 char *pos=Regelbuf;
443 char *pose=Formatbuf;
444 BOOL bDescFlag;
445 BOOL bDubbelIpFlag;
446 {
447 //vervang # door \0
448 char *posd=pos;
449 while (*posd!='#'&&*posd!='\0') posd++;
450 *posd='\0';
451 }
452 {
453 //vervang /" door /'
454 char *posd=pos;
455 while (*posd!='\0')
456 {
457 if (*posd=='\"') *posd='\'';
458 posd++;
459 }
460 }
461 while (pos[strlen(pos)-1]==' ') //skip trailing spaces
462 {
463 pos[strlen(pos)-1]='\0';
464 }
465 if (pos[strlen(pos)-1]==';') //skip trailing ;
466 {
467 pos[strlen(pos)-1]='\0';
468 }
469 if (pos[strlen(pos)-1]=='\'') //skip trailing '
470 {
471 pos[strlen(pos)-1]='\0';
472 }
473 while (pos[strlen(pos)-1]==' ') //skip trailing spaces
474 {
475 pos[strlen(pos)-1]='\0';
476 }
477 while (*pos==' '||*pos=='\t'||*pos=='\n'||*pos=='\r') pos++;//skip leading spaces
478
479 bDescFlag=(!memicmp(pos,"DESC",4)); //bij DESC spaties laten
480 bDubbelIpFlag=(!memicmp(pos,"POINT_TO_POINT=",15)||!memicmp(pos,"OSPF_NEIGHBORS=",15)); //spaties vervangen door ;
481 for (;*pos!='\0';pos++)
482 {
483 if (bDubbelIpFlag&&(*pos==' '||*pos=='\t'))
484 {
485 while (*pos==' '||*pos=='\t') pos++;//skip overige spaces
486 *(--pos)=';';
487 }
488 while (!bDescFlag&&(*pos==' '||*pos=='\t')) pos++;//skip spaces
489 if (*pos=='\'') //neem tekst tussen quotes letterlijk over
490 { //tot volgende quote of eind
491 *pose++=*pos++;
492 while (*pos!='\''&&*pos!='\0')
493 {
494 if (*pos==',') *pos=';'; //geen komma's ivm csv-list
495 *pose++=*pos++;
496 }
497 }
498 if (*pos==',') *pos=';'; //geen komma's ivm csv-list
499 *pose++=*pos;
500 }
501 *pose='\0';
502 strcpy(Regelbuf,Formatbuf);
503}
504
505void BehandelRegel(void)
506{
507 char *pos=Regelbuf;
508 CNODE *pCN=&CNode[NodeTeller];
509 CARD *pCd=&Card[CardTeller];
510 FormatRegel();
511
512 if (!bCardBezig)
513 {
514 if (!memicmp(pos,"$location='",11)) strncpy(pCN->location,pos+11,sizeof(pCN->location));
515 else if (!memicmp(pos,"$master_ip='",12))
516 {
517 sprintf(pCN->volgnr,"%3d",NodeTeller); //hier want t hoeft maar 1 keer
518 strncpy(pCN->master_ip,pos+12,sizeof(pCN->master_ip));
519 }
520 else if (!memicmp(pos,"$gw_open='",10)) strncpy(pCN->gw_open,pos+10,sizeof(pCN->gw_open));
521 else if (!memicmp(pos,"$nodetype='",11)) strncpy(pCN->nodetype,pos+11,sizeof(pCN->nodetype));
522 else if (!memicmp(pos,"$nodename='",11)) strncpy(pCN->nodename,pos+11,sizeof(pCN->nodename));
523 else if (!memicmp(pos,"$status='",9)) strncpy(pCN->status,pos+9,sizeof(pCN->status));
524 else if (!memicmp(pos,"$OS='",5)) strncpy(pCN->OS,pos+5,sizeof(pCN->OS));
525 else if (!memicmp(pos,"$labelpos='",11)) strncpy(pCN->labelpos,pos+11,sizeof(pCN->labelpos));
526 else if (!memicmp(pos,"$X='",4)) strncpy(pCN->X,pos+4,sizeof(pCN->X));
527 else if (!memicmp(pos,"$Y='",4)) strncpy(pCN->Y,pos+4,sizeof(pCN->Y));
528 else if (!memicmp(pos,"$N='",4)) strncpy(pCN->N,pos+4,sizeof(pCN->N));
529 else if (!memicmp(pos,"$E='",4)) strncpy(pCN->E,pos+4,sizeof(pCN->E));
530 else if (!memicmp(pos,"$ESSID='",8)) strncpy(pCN->ESSID,pos+8,sizeof(pCN->ESSID));
531
532 else if (!memicmp(pos,"$config{'",9))
533 {
534 unsigned int len;
535 char *pos1=pos+9;
536 while(*pos1++!='\'');
537 len=pos1-pos-10;
538 if (len>9) len=9;
539 memcpy(pCd->configname,pos+9,len);
540 pCd->configname[len]='\0';
541 sprintf(pCd->volgnr,"%3d",CardTeller); //hier want t hoeft maar 1 keer
542 sprintf(pCd->nodenr,"%3d",NodeTeller); //hier want t hoeft maar 1 keer
543 //opvang voor ontbreken van 'sprintf' bij sommige configs
544 if (*(pos+12+len)=='<')
545 {
546 strncpy(pCd->sprintfname,pos+len+14,sizeof(pCd->sprintfname));
547 }
548 else strncpy(pCd->sprintfname,pos+len+21,sizeof(pCd->sprintfname));
549 bCardBezig=TRUE;
550 if (*(pCd->configname+strlen(pCd->configname)-2)==':')
551 { //alias, dan hoofdgegevens overnemen, ga ervan uit dat hoofd-interface altijd direct aan aliassen voorafgaat
552 int j=0;
553 while (*((pCd-j)->configname+strlen((pCd-j)->configname)-2)==':'&&(j<=CardTeller)) j++;
554 if (j<=CardTeller)
555 {
556 strncpy(pCd->mode,(pCd-j)->mode,sizeof(pCd->mode));
557 strncpy(pCd->essid,(pCd-j)->essid,sizeof(pCd->essid));
558 strncpy(pCd->channel,(pCd-j)->channel,sizeof(pCd->channel));
559 strncpy(pCd->polar,(pCd-j)->polar,sizeof(pCd->polar));
560 strncpy(pCd->antenna,(pCd-j)->antenna,sizeof(pCd->antenna));
561 strncpy(pCd->gain,(pCd-j)->gain,sizeof(pCd->gain));
562 strncpy(pCd->direction,(pCd-j)->direction,sizeof(pCd->direction));
563 strncpy(pCd->beamwidth,(pCd-j)->beamwidth,sizeof(pCd->beamwidth));
564 strncpy(pCd->cable,(pCd-j)->cable,sizeof(pCd->cable));
565 strncpy(pCd->heigth,(pCd-j)->heigth,sizeof(pCd->heigth));
566 }
567 }
568 }
569 }
570 else /*if (bCardBezig)*/
571 {
572 if (!memicmp(pos,pCd->sprintfname,strlen(pCd->sprintfname)))
573 {
574 VulIpAdressen();
575 CardTeller++;
576 bCardBezig=FALSE;
577 }
578 else if (!memicmp(pos,"TYPE=",5)) strncpy(pCd->type,pos+5,sizeof(pCd->type));
579 else if (!memicmp(pos,"IP=",3))
580 {
581 if (!memicmp(pos+3,"$master_ip",10))
582 {
583 strcpy(pCd->ip,pCN->master_ip);
584 strcat(pCd->ip,pos+13);
585 }
586 else strncpy(pCd->ip,pos+3,sizeof(pCd->ip));
587 }
588 else if (!memcmp(pos,"DESC=",5)) strncpy(pCd->desc,pos+5,sizeof(pCd->desc));
589 else if (!memicmp(pos,"SDESC=",6)) strncpy(pCd->sdesc,pos+6,sizeof(pCd->sdesc));
590 else if (!memicmp(pos,"SPEED=",6)) strncpy(pCd->speed,pos+6,sizeof(pCd->speed));
591 else if (!memicmp(pos,"POINT_TO_POINT=",15)) strncpy(pCd->pointtopoint,pos+15,sizeof(pCd->pointtopoint));
592 else if (!memicmp(pos,"OSPF_BROADCAST=",15)) strncpy(pCd->ospfbroadcast,pos+15,sizeof(pCd->ospfbroadcast));
593 else if (!memicmp(pos,"OSPF_NEIGHBORS=",15)) strncpy(pCd->ospfneighbors,pos+15,sizeof(pCd->ospfneighbors));
594 else if (!memicmp(pos,"DHCP=",5)) strncpy(pCd->dhcp,pos+5,sizeof(pCd->dhcp));
595 else if (!memicmp(pos,"MODE=",5)) strncpy(pCd->mode,pos+5,sizeof(pCd->mode));
596 else if (!memicmp(pos,"ESSID=",6)) strncpy(pCd->essid,pos+6,sizeof(pCd->essid));
597 else if (!memicmp(pos,"CHANNEL=",8)) strncpy(pCd->channel,pos+8,sizeof(pCd->channel));
598 else if (!memicmp(pos,"POLAR=",6)) strncpy(pCd->polar,pos+6,sizeof(pCd->polar));
599 else if (!memicmp(pos,"ANTENNA=",8)) strncpy(pCd->antenna,pos+8,sizeof(pCd->antenna));
600 else if (!memicmp(pos,"GAIN=",5)) strncpy(pCd->gain,pos+5,sizeof(pCd->gain));
601 else if (!memicmp(pos,"DIRECTION=",10)) strncpy(pCd->direction,pos+10,sizeof(pCd->direction));
602 else if (!memicmp(pos,"BEAMWIDTH=",10)) strncpy(pCd->beamwidth,pos+10,sizeof(pCd->beamwidth));
603 else if (!memicmp(pos,"CABLE=",6)) strncpy(pCd->cable,pos+6,sizeof(pCd->cable));
604 else if (!memicmp(pos,"HEIGTH=",7)) strncpy(pCd->heigth,pos+7,sizeof(pCd->heigth));
605 }
606}
607
608void VulIpAdressen(void)
609{
610 CARD *pCd=&Card[CardTeller];
611 char buf[36];
612 char *t;
613 strcpy(buf,pCd->ip);//111.111.111.111/30
614 t=strtok(buf,".");
615 if (t)
616 {
617 pCd->ipr.ip.ip0=(unsigned char)atoi(t);
618 t=strtok(NULL,".");
619 if (t)
620 {
621 pCd->ipr.ip.ip1=(unsigned char)atoi(t);
622 t=strtok(NULL,".");
623 if (t)
624 {
625 pCd->ipr.ip.ip2=(unsigned char)atoi(t);
626 t=strtok(NULL,"/");// let op /
627 if (t)
628 {
629 pCd->ipr.ip.ip3=(unsigned char)atoi(t);
630 t=strtok(NULL,".");
631 if (t) pCd->ipr.mask=(unsigned char)atoi(t);
632 }
633 }
634 }
635 }
636 strcpy(buf,pCd->pointtopoint);//111.111.111.111;111.111.111.111
637 t=strtok(buf,".");
638 if (t)
639 {
640 pCd->ptp1.ip0=(unsigned char)atoi(t);
641 t=strtok(NULL,".");
642 if (t)
643 {
644 pCd->ptp1.ip1=(unsigned char)atoi(t);
645 t=strtok(NULL,".");
646 if (t)
647 {
648 pCd->ptp1.ip2=(unsigned char)atoi(t);
649 t=strtok(NULL,";");// let op ;
650 if (t)
651 {
652 pCd->ptp1.ip3=(unsigned char)atoi(t);
653 t=strtok(NULL,".");
654 if (t)
655 {
656 pCd->ptp2.ip0=(unsigned char)atoi(t);
657 t=strtok(NULL,".");
658 if (t)
659 {
660 pCd->ptp2.ip1=(unsigned char)atoi(t);
661 t=strtok(NULL,".");
662 if (t)
663 {
664 pCd->ptp2.ip2=(unsigned char)atoi(t);
665 t=strtok(NULL,";");
666 if (t) pCd->ptp2.ip3=(unsigned char)atoi(t);
667 }
668 }
669 }
670 }
671 }
672 }
673 }
674 strcpy(buf,pCd->ospfneighbors);//111.111.111.111;111.111.111.111
675 t=strtok(buf,".");
676 if (t)
677 {
678 pCd->on1.ip0=(unsigned char)atoi(t);
679 t=strtok(NULL,".");
680 if (t)
681 {
682 pCd->on1.ip1=(unsigned char)atoi(t);
683 t=strtok(NULL,".");
684 if (t)
685 {
686 pCd->on1.ip2=(unsigned char)atoi(t);
687 t=strtok(NULL,";");// let op ;
688 if (t)
689 {
690 pCd->on1.ip3=(unsigned char)atoi(t);
691 t=strtok(NULL,".");
692 if (t)
693 {
694 pCd->on2.ip0=(unsigned char)atoi(t);
695 t=strtok(NULL,".");
696 if (t)
697 {
698 pCd->on2.ip1=(unsigned char)atoi(t);
699 t=strtok(NULL,".");
700 if (t)
701 {
702 pCd->on2.ip2=(unsigned char)atoi(t);
703 t=strtok(NULL,";");
704 if (t) pCd->on2.ip3=(unsigned char)atoi(t);
705 }
706 }
707 }
708 }
709 }
710 }
711 }
712 {
713 IPADDRESS ips=pCd->ipr.ip;
714 int mask3=pCd->ipr.mask;
715 if (mask3<24)//komt nu niet voor, maar vang af met 0,0,0,0
716 {
717 ips.ip0=ips.ip1=ips.ip2=ips.ip3=0;
718 pCd->ipstart=pCd->ipend=ips;
719 }
720 else
721 {
722 int mask3p,mask3pxor;
723 mask3-=24;
724 mask3p=255;
725 mask3p>>=mask3; //shift right
726 mask3pxor=255^mask3p;
727 ips.ip3=ips.ip3&mask3pxor;
728 pCd->ipstart=ips;
729 ips.ip3=ips.ip3|mask3p;
730 pCd->ipend=ips;
731 }
732 }
733}
734
735void MaakIpOverzicht(void)
736{
737 //bubble sort card records op oplopend ip
738 CARD *pCd1,*pCd2;
739 IPADDRESS *pAd1, *pAd2;
740 int i,j;
741 BOOL swapped;
742 do
743 {
744 swapped=FALSE;
745 for (i=0,j=1;i<CardTeller-1;i++,j++)
746 {
747 BOOL swappen=FALSE;
748 pCd1=&Card[i];pCd2=&Card[j];
749 pAd1=&(pCd1->ipr.ip);pAd2=&(pCd2->ipr.ip);
750 if (pAd1->ip0>pAd2->ip0) swappen=TRUE;
751 else if (pAd1->ip0<pAd2->ip0) continue;
752 else if (pAd1->ip1>pAd2->ip1) swappen=TRUE;
753 else if (pAd1->ip1<pAd2->ip1) continue;
754 else if (pAd1->ip2>pAd2->ip2) swappen=TRUE;
755 else if (pAd1->ip2<pAd2->ip2) continue;
756 else if (pAd1->ip3>pAd2->ip3) swappen=TRUE;
757 else if (pAd1->ip3<pAd2->ip3) continue;
758 else if (pCd1->ipr.mask<pCd2->ipr.mask) swappen=TRUE;
759 if (swappen)
760 {
761 SwapCards(i);
762 swapped=TRUE;
763 }
764 }
765 }
766 while (swapped);
767 MaakCSV(2);
768 MaakCSV2(1);
769}
770
771void SwapCards(int i)
772{
773 CARD tempCd=Card[i+1];
774 Card[i+1]=Card[i];
775 Card[i]=tempCd;
776}
777
778void MaakCSV2(int code)
779{
780 int i;
781 CNODE *pCN;
782 CARD *pCd;
783 if (code==1) hConf=fopen("configip1.csv","w");
784 if (code==2) hConf=fopen("configip2.csv","w");
785 if (hConf)
786 {
787 strcpy(buf,"status");AddTekst();AddKomma();
788 strcpy(buf,"nodename");AddTekst();AddKomma();
789 strcpy(buf,"configname");AddTekst();AddKomma();
790 strcpy(buf,"essid");AddTekst();AddKomma();
791 strcpy(buf,"sdesc");AddTekst();AddKomma();
792 strcpy(buf,"master_ip");AddTekst();AddKomma();
793 strcpy(buf,"IP-range");AddTekst();AddKomma();
794 strcpy(buf,"IP-start");AddTekst();AddKomma();
795 strcpy(buf,"IP-end");AddTekst();AddKomma();
796 strcpy(buf,"point_to_point");AddTekst();AddKomma();
797 strcpy(buf,"ospf_neighbors");AddTekst();AddKomma();
798 strcpy(buf,"mode");AddTekst();AddKomma();
799 strcpy(buf,"channel");AddTekst();AddKomma();
800 strcpy(buf,"Current data from nodes");AddTekst();AddKomma();
801 fwrite( "\n", sizeof( char ), 1, hConf );
802
803 for (i=0;i<CardTeller;i++)
804 {
805 pCd=&Card[i];
806 pCN=&CNode[atoi(pCd->nodenr)];
807 if (i>0)
808 { //extra lege regel
809 if (CompareIp(&(pCd->ipstart),&((pCd-1)->ipstart))||CompareIp(&(pCd->ipend),&((pCd-1)->ipend)))
810 fwrite( "\n", sizeof( char ), 1, hConf );
811 }
812 fwrite( pCN->status, sizeof( char ), strlen(pCN->status), hConf );AddKomma();
813 fwrite( pCN->nodename, sizeof( char ), strlen(pCN->nodename), hConf );AddKomma();
814 fwrite( pCd->configname, sizeof( char ), strlen(pCd->configname), hConf );AddKomma();
815 fwrite( pCd->essid, sizeof( char ), strlen(pCd->essid), hConf );AddKomma();
816 fwrite( pCd->sdesc, sizeof( char ), strlen(pCd->sdesc), hConf );AddKomma();
817 fwrite( pCN->master_ip, sizeof( char ), strlen(pCN->master_ip), hConf );AddKomma();
818 fwrite( pCd->ip, sizeof( char ), strlen(pCd->ip), hConf );AddKomma();
819 {
820 char buf[20];
821 sprintf(buf,"%i.%i.%i.%i",pCd->ipstart.ip0,pCd->ipstart.ip1,pCd->ipstart.ip2,pCd->ipstart.ip3);
822 fwrite( buf, sizeof( char ),strlen(buf), hConf );AddKomma();
823 sprintf(buf,"%i.%i.%i.%i",pCd->ipend.ip0,pCd->ipend.ip1,pCd->ipend.ip2,pCd->ipend.ip3);
824 fwrite( buf, sizeof( char ),strlen(buf), hConf );AddKomma();
825 }
826 fwrite( pCd->pointtopoint, sizeof( char ), strlen(pCd->pointtopoint), hConf );AddKomma();
827 fwrite( pCd->ospfneighbors, sizeof( char ), strlen(pCd->ospfneighbors), hConf );AddKomma();
828 fwrite( pCd->mode, sizeof( char ), strlen(pCd->mode), hConf );AddKomma();
829 fwrite( pCd->channel, sizeof( char ), strlen(pCd->channel), hConf );AddKomma();
830 {
831 int j;
832 IFOUTPUT *pIO;
833 char tbuf[30];
834 strcpy(tbuf,pCd->ip);
835 for (j=0;j<strlen(pCd->ip);j++)
836 {
837 if (tbuf[j]=='/') tbuf[j]='\0';
838 }
839 for (j=0;j<IfOutputTeller;j++)
840 {
841 pIO=&IfOutput[j];//lengtes moeten ook gelijk zijn anders: 172.1.1.227==172.1.1.22
842 if ((strlen(pIO->ip)==strlen(tbuf))&&(!memcmp(pIO->ip,tbuf,strlen(pIO->ip)))) break;
843 }
844 if (j<IfOutputTeller)
845 {
846 CARDOUTPUT *pCDO=&CardOutput[atoi(pIO->cardnr)];
847 fwrite( pIO->ip, sizeof( char ), strlen(pIO->ip), hConf );AddKomma();
848 fwrite( pCDO->configname, sizeof( char ), strlen(pCDO->configname), hConf );AddKomma();
849 fwrite( pCDO->ether, sizeof( char ), strlen(pCDO->ether), hConf );AddKomma();
850 fwrite( pCDO->status, sizeof( char ), strlen(pCDO->status), hConf );AddKomma();
851 fwrite( pCDO->ssid, sizeof( char ), strlen(pCDO->ssid), hConf );AddKomma();
852 fwrite( pCDO->stationname, sizeof( char ), strlen(pCDO->stationname), hConf );AddKomma();
853 fwrite( pCDO->channel, sizeof( char ), strlen(pCDO->channel), hConf );AddKomma();
854 }
855 }
856
857#ifdef xyz //even er uit
858 {
859 BOOL even;
860 int test=pCd->ipr.ip.ip3;
861 even=(test==((int)(test/2))*2);
862 if (!memicmp(pCd->mode,"managed",7)&&!even)
863 {
864 fwrite("oneven ip-adres en managed mode",sizeof( char ),31,hConf);
865 AddKomma();
866 }
867 if (!memicmp(pCd->mode,"master",6)&&even)
868 {
869 fwrite("even ip-adres en master mode",sizeof( char ),28,hConf);
870 AddKomma();
871 }
872 }
873
874 if (CompareIp(&pCd->ptp1,&pCd->ipstart)<0||CompareIp(&pCd->ptp1,&pCd->ipend)>0)
875 {
876 fwrite("point-to-point adres buiten range",sizeof( char ),33,hConf);
877 AddKomma();
878 }
879 if (CompareIp(&pCd->on1,&pCd->ipstart)<0||CompareIp(&pCd->on1,&pCd->ipend)>0)
880 {
881 fwrite("ospf-neighbors adres buiten range",sizeof( char ),33,hConf);
882 AddKomma();
883 }
884#endif
885 fwrite( "\n", sizeof( char ), 1, hConf );
886 }
887 fclose(hConf);
888 }
889}
890
891void MaakCSV(int code)
892{
893 int i;
894 CNODE *pCN;
895 CARD *pCd;
896 if (code==1) hConf=fopen("configs1.csv","w");
897 if (code==2) hConf=fopen("configs2.csv","w");
898 if (hConf)
899 {
900 strcpy(buf,"location");AddTekst();AddKomma();
901 strcpy(buf,"master_ip");AddTekst();AddKomma();
902 strcpy(buf,"gw_open");AddTekst();AddKomma();
903 strcpy(buf,"nodetype");AddTekst();AddKomma();
904 strcpy(buf,"nodename");AddTekst();AddKomma();
905 strcpy(buf,"status");AddTekst();AddKomma();
906 strcpy(buf,"OS");AddTekst();AddKomma();
907 strcpy(buf,"labelpos");AddTekst();AddKomma();
908 strcpy(buf,"X");AddTekst();AddKomma();
909 strcpy(buf,"Y");AddTekst();AddKomma();
910 strcpy(buf,"N");AddTekst();AddKomma();
911 strcpy(buf,"E");AddTekst();AddKomma();
912 strcpy(buf,"ESSID");AddTekst();AddKomma();
913 strcpy(buf,"configname");AddTekst();AddKomma();
914 strcpy(buf,"sprintfname");AddTekst();AddKomma();
915 strcpy(buf,"type");AddTekst();AddKomma();
916 strcpy(buf,"ip");AddTekst();AddKomma();
917 strcpy(buf,"desc");AddTekst();AddKomma();
918 strcpy(buf,"sdesc");AddTekst();AddKomma();
919 strcpy(buf,"speed");AddTekst();AddKomma();
920 strcpy(buf,"point_to_point");AddTekst();AddKomma();
921 strcpy(buf,"ospf_broadcast");AddTekst();AddKomma();
922 strcpy(buf,"ospf_neighbors");AddTekst();AddKomma();
923 strcpy(buf,"dhcp");AddTekst();AddKomma();
924 strcpy(buf,"mode");AddTekst();AddKomma();
925 strcpy(buf,"essid");AddTekst();AddKomma();
926 strcpy(buf,"channel");AddTekst();AddKomma();
927 strcpy(buf,"polar");AddTekst();AddKomma();
928 strcpy(buf,"antenna");AddTekst();AddKomma();
929 strcpy(buf,"gain");AddTekst();AddKomma();
930 strcpy(buf,"direction");AddTekst();AddKomma();
931 strcpy(buf,"beamwidth");AddTekst();AddKomma();
932 strcpy(buf,"cable");AddTekst();AddKomma();
933 strcpy(buf,"heigth");AddTekst();AddKomma();
934
935 fwrite( "\n", sizeof( char ), 1, hConf );
936
937 for (i=0;i<CardTeller;i++)
938 {
939 pCd=&Card[i];
940 pCN=&CNode[atoi(pCd->nodenr)];
941 fwrite( pCN->location, sizeof( char ), strlen(pCN->location), hConf );AddKomma();
942 fwrite( pCN->master_ip, sizeof( char ), strlen(pCN->master_ip), hConf );AddKomma();
943 fwrite( pCN->gw_open, sizeof( char ), strlen(pCN->gw_open), hConf );AddKomma();
944 fwrite( pCN->nodetype, sizeof( char ), strlen(pCN->nodetype), hConf );AddKomma();
945 fwrite( pCN->nodename, sizeof( char ), strlen(pCN->nodename), hConf );AddKomma();
946 fwrite( pCN->status, sizeof( char ), strlen(pCN->status), hConf );AddKomma();
947 fwrite( pCN->OS, sizeof( char ), strlen(pCN->OS), hConf );AddKomma();
948 fwrite( pCN->labelpos, sizeof( char ), strlen(pCN->labelpos), hConf );AddKomma();
949 fwrite( pCN->X, sizeof( char ), strlen(pCN->X), hConf );AddKomma();
950 fwrite( pCN->Y, sizeof( char ), strlen(pCN->Y), hConf );AddKomma();
951 fwrite( pCN->N, sizeof( char ), strlen(pCN->N), hConf );AddKomma();
952 fwrite( pCN->E, sizeof( char ), strlen(pCN->E), hConf );AddKomma();
953 fwrite( pCN->ESSID, sizeof( char ), strlen(pCN->ESSID), hConf );AddKomma();
954 fwrite( pCd->configname, sizeof( char ), strlen(pCd->configname), hConf );AddKomma();
955 fwrite( pCd->sprintfname, sizeof( char ), strlen(pCd->sprintfname), hConf );AddKomma();
956 fwrite( pCd->type, sizeof( char ), strlen(pCd->type), hConf );AddKomma();
957 fwrite( pCd->ip, sizeof( char ), strlen(pCd->ip), hConf );AddKomma();
958 fwrite( pCd->desc, sizeof( char ), strlen(pCd->desc), hConf );AddKomma();
959 fwrite( pCd->sdesc, sizeof( char ), strlen(pCd->sdesc), hConf );AddKomma();
960 fwrite( pCd->speed, sizeof( char ), strlen(pCd->speed), hConf );AddKomma();
961 fwrite( pCd->pointtopoint, sizeof( char ), strlen(pCd->pointtopoint), hConf );AddKomma();
962 fwrite( pCd->ospfbroadcast, sizeof( char ), strlen(pCd->ospfbroadcast), hConf );AddKomma();
963 fwrite( pCd->ospfneighbors, sizeof( char ), strlen(pCd->ospfneighbors), hConf );AddKomma();
964 fwrite( pCd->dhcp, sizeof( char ), strlen(pCd->dhcp), hConf );AddKomma();
965 fwrite( pCd->mode, sizeof( char ), strlen(pCd->mode), hConf );AddKomma();
966 fwrite( pCd->essid, sizeof( char ), strlen(pCd->essid), hConf );AddKomma();
967 fwrite( pCd->channel, sizeof( char ), strlen(pCd->channel), hConf );AddKomma();
968 fwrite( pCd->polar, sizeof( char ), strlen(pCd->polar), hConf );AddKomma();
969 fwrite( pCd->antenna, sizeof( char ), strlen(pCd->antenna), hConf );AddKomma();
970 fwrite( pCd->gain, sizeof( char ), strlen(pCd->gain), hConf );AddKomma();
971 fwrite( pCd->direction, sizeof( char ), strlen(pCd->direction), hConf );AddKomma();
972 fwrite( pCd->beamwidth, sizeof( char ), strlen(pCd->beamwidth), hConf );AddKomma();
973 fwrite( pCd->cable, sizeof( char ), strlen(pCd->cable), hConf );AddKomma();
974 fwrite( pCd->heigth, sizeof( char ), strlen(pCd->heigth), hConf );AddKomma();
975 {
976 int j;
977 IFOUTPUT *pIO;
978 char tbuf[30];
979 strcpy(tbuf,pCd->ip);
980 for (j=0;j<strlen(pCd->ip);j++)
981 {
982 if (tbuf[j]=='/') tbuf[j]='\0';
983 }
984 for (j=0;j<IfOutputTeller;j++)
985 {
986 pIO=&IfOutput[j];//lengtes moeten ook gelijk zijn anders: 172.1.1.227==172.1.1.22
987 if ((strlen(pIO->ip)==strlen(tbuf))&&(!memcmp(pIO->ip,tbuf,strlen(pIO->ip)))) break;
988 }
989 if (j<IfOutputTeller)
990 {
991 CARDOUTPUT *pCDO=&CardOutput[atoi(pIO->cardnr)];
992 fwrite( pIO->ip, sizeof( char ), strlen(pIO->ip), hConf );AddKomma();
993 fwrite( pCDO->configname, sizeof( char ), strlen(pCDO->configname), hConf );AddKomma();
994 fwrite( pCDO->ether, sizeof( char ), strlen(pCDO->ether), hConf );AddKomma();
995 fwrite( pCDO->status, sizeof( char ), strlen(pCDO->status), hConf );AddKomma();
996 fwrite( pCDO->ssid, sizeof( char ), strlen(pCDO->ssid), hConf );AddKomma();
997 fwrite( pCDO->stationname, sizeof( char ), strlen(pCDO->stationname), hConf );AddKomma();
998 fwrite( pCDO->channel, sizeof( char ), strlen(pCDO->channel), hConf );AddKomma();
999 }
1000 }
1001 fwrite( "\n", sizeof( char ), 1, hConf );
1002 }
1003 fclose(hConf);
1004 }
1005}
1006
1007void MaakCSV3(int code)
1008{
1009 int i;
1010 CNODE *pCN;
1011 CARD *pCd;
1012 IFOUTPUT *pIO;
1013 CARDOUTPUT *pCDO;
1014 CNODEOUTPUT *pCNO;
1015 if (code==1) hConf=fopen("outputs1.csv","w");
1016 if (code==2) hConf=fopen("outputs2.csv","w");
1017 if (hConf)
1018 {
1019 strcpy(buf,"name");AddTekst();AddKomma();
1020 strcpy(buf,"stationname");AddTekst();AddKomma();
1021 strcpy(buf,"ssid");AddTekst();AddKomma();
1022 strcpy(buf,"configname");AddTekst();AddKomma();
1023 strcpy(buf,"status");AddTekst();AddKomma();
1024 strcpy(buf,"ether");AddTekst();AddKomma();
1025 strcpy(buf,"channel");AddTekst();AddKomma();
1026 strcpy(buf,"ip");AddTekst();AddKomma();
1027 strcpy(buf,"netmask");AddTekst();AddKomma();
1028 strcpy(buf,"broadcast");AddTekst();AddKomma();
1029 strcpy(buf,"wleiden.conf");AddTekst();AddKomma();
1030 fwrite( "\n", sizeof( char ), 1, hConf );
1031
1032 for (i=0;i<IfOutputTeller;i++)
1033 {
1034 pIO=&IfOutput[i];
1035 pCDO=&CardOutput[atoi(pIO->cardnr)];
1036 pCNO=&CNodeOutput[atoi(pCDO->nodenr)];
1037 fwrite( pCNO->name, sizeof( char ), strlen(pCNO->name), hConf );AddKomma();
1038 fwrite( pCDO->stationname, sizeof( char ), strlen(pCDO->stationname), hConf );AddKomma();
1039 fwrite( pCDO->ssid, sizeof( char ), strlen(pCDO->ssid), hConf );AddKomma();
1040 fwrite( pCDO->configname, sizeof( char ), strlen(pCDO->configname), hConf );AddKomma();
1041 fwrite( pCDO->status, sizeof( char ), strlen(pCDO->status), hConf );AddKomma();
1042 fwrite( pCDO->ether, sizeof( char ), strlen(pCDO->ether), hConf );AddKomma();
1043 fwrite( pCDO->channel, sizeof( char ), strlen(pCDO->channel), hConf );AddKomma();
1044 fwrite( pIO->ip, sizeof( char ), strlen(pIO->ip), hConf );AddKomma();
1045 fwrite( pIO->netmask, sizeof( char ), strlen(pIO->netmask), hConf );AddKomma();
1046 fwrite( pIO->broadcast, sizeof( char ), strlen(pIO->broadcast), hConf );AddKomma();
1047 {
1048 int j;
1049 char tbuf[30];
1050 for (j=0;j<CardTeller;j++)
1051 {
1052 int k;
1053 pCd=&Card[j];
1054 strcpy(tbuf,pCd->ip);
1055 for (k=0;k<strlen(pCd->ip);k++)
1056 {
1057 if (tbuf[k]=='/') tbuf[k]='\0';
1058 }
1059 if ((strlen(pIO->ip)==strlen(tbuf))&&(!memcmp(pIO->ip,tbuf,strlen(pIO->ip)))) break;
1060 }
1061 if (j<CardTeller)
1062 {
1063 pCN=&CNode[atoi(pCd->nodenr)];
1064 fwrite( pCN->master_ip, sizeof( char ), strlen(pCN->master_ip), hConf );AddKomma();
1065 fwrite( pCN->nodename, sizeof( char ), strlen(pCN->nodename), hConf );AddKomma();
1066 fwrite( pCN->status, sizeof( char ), strlen(pCN->status), hConf );AddKomma();
1067 fwrite( pCN->ESSID, sizeof( char ), strlen(pCN->ESSID), hConf );AddKomma();
1068 fwrite( pCd->configname, sizeof( char ), strlen(pCd->configname), hConf );AddKomma();
1069 fwrite( pCd->sprintfname, sizeof( char ), strlen(pCd->sprintfname), hConf );AddKomma();
1070 fwrite( pCd->type, sizeof( char ), strlen(pCd->type), hConf );AddKomma();
1071 fwrite( pCd->ip, sizeof( char ), strlen(pCd->ip), hConf );AddKomma();
1072 fwrite( pCd->desc, sizeof( char ), strlen(pCd->desc), hConf );AddKomma();
1073 fwrite( pCd->sdesc, sizeof( char ), strlen(pCd->sdesc), hConf );AddKomma();
1074 fwrite( pCd->pointtopoint, sizeof( char ), strlen(pCd->pointtopoint), hConf );AddKomma();
1075 fwrite( pCd->ospfbroadcast, sizeof( char ), strlen(pCd->ospfbroadcast), hConf );AddKomma();
1076 fwrite( pCd->ospfneighbors, sizeof( char ), strlen(pCd->ospfneighbors), hConf );AddKomma();
1077 fwrite( pCd->dhcp, sizeof( char ), strlen(pCd->dhcp), hConf );AddKomma();
1078 fwrite( pCd->mode, sizeof( char ), strlen(pCd->mode), hConf );AddKomma();
1079 fwrite( pCd->essid, sizeof( char ), strlen(pCd->essid), hConf );AddKomma();
1080 fwrite( pCd->channel, sizeof( char ), strlen(pCd->channel), hConf );AddKomma();
1081 }
1082 }
1083 fwrite( "\n", sizeof( char ), 1, hConf );
1084 }
1085 fclose(hConf);
1086 }
1087}
1088
1089void AddKomma(void)
1090{
1091 fwrite( ",", sizeof( char ), 1, hConf );
1092}
1093
1094void AddTekst(void)
1095{
1096 fwrite( buf, sizeof( char ), strlen(buf), hConf );
1097}
1098
1099int CompareIp(IPADDRESS *ad1,IPADDRESS *ad2)
1100{//ad1>ad2->1;ad1==ad2->0;ad1<ad2->-1
1101 if(ad1->ip0>ad2->ip0) return 1;
1102 if(ad1->ip0<ad2->ip0) return -1;
1103 if(ad1->ip1>ad2->ip1) return 1;
1104 if(ad1->ip1<ad2->ip1) return -1;
1105 if(ad1->ip2>ad2->ip2) return 1;
1106 if(ad1->ip2<ad2->ip2) return -1;
1107 if(ad1->ip3>ad2->ip3) return 1;
1108 if(ad1->ip3<ad2->ip3) return -1;
1109 return 0;
1110}
1111
Note: See TracBrowser for help on using the repository browser.