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

Last change on this file since 4776 was 3281, checked in by lodewijk, 20 years ago
  • svn:eol-style op native, dan wordt gelijk nodechk_unix.c overbodig
  • memicmp() is strncasecmp() onder posix.1
  • binaries, en gegenereerde dingen in het algemeen, zijn meestal geen goed idee in svn.
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 37.2 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
193#define memicmp strncasecmp
194#endif
195
196main()
197{
198 FILE *hFile;
199 NodeTeller=0;
200 CardTeller=0;
201
202 if (hFile=fopen("location","r"))
203 {
204 fread(location,sizeof(char),64,hFile);
205 fclose(hFile);
206 {
207 char *pos=&location[strlen(location)-1];
208 while (*pos=='\n'||*pos=='\r'||*pos=='\t'||*pos==' ')
209 {
210 *pos='\0';
211 pos--;
212 }
213 }
214 if (hFile=fopen("nnames","r"))
215 {
216 char *pos;
217 numread=fread(nnamesbuf,sizeof(char),2000,hFile);
218 fclose(hFile);
219 pos=strtok(nnamesbuf,"\n\r");
220 while(pos)
221 {
222 memset((char*)&(CNode[NodeTeller]),'\0',sizeof(CNode[NodeTeller]));
223 strcpy(CNode[NodeTeller++].name,pos);
224 pos=strtok(NULL,"\n\r");
225 }
226 NodeTeller=0;
227 while (*(CNode[NodeTeller].name))
228 {
229#ifdef WIN32
230 sprintf(fn,"%s%s\\wleiden.conf",location,CNode[NodeTeller].name);
231#else
232 sprintf(fn,"%s%s/wleiden.conf",location,CNode[NodeTeller].name);
233#endif
234 printf(fn);
235 printf("\n");
236
237 if (hConf=fopen(fn,"r"))
238 {
239 LeesNode();
240 fclose(hConf);
241 }
242 NodeTeller++;
243 }
244 }
245 }
246 sprintf(buf,"\naantal nodes: %i\n\r",NodeTeller);
247 printf(buf);
248
249 if (hConf=fopen("confs","r"))
250 {
251 LeesNodeOutput();
252 fclose(hConf);
253 }
254 MaakCSV(1);
255 MaakIpOverzicht();
256 MaakCSV3(1);
257
258 return 0;
259}
260
261void LeesNodeOutput(void)
262{
263 char *pos;
264 int regels=0;
265 int rest;
266 memset((char*)&(CNodeOutput),'\0',sizeof(CNodeOutput));
267 NodeOutputTeller=-1;
268 CardOutputTeller=-1;
269 IfOutputTeller=-1;
270
271 toread=BUFLEN;
272 numread=fread(Tekstbuf,sizeof(char),toread,hConf);
273
274 pos=strtok(Tekstbuf,"\n\r" );
275 while (pos)
276 {
277 unsigned j;
278 strcpy(Regelbuf,Tekstbuf);
279 rest=strlen(Regelbuf);
280 for (j=0;j<numread-rest-1;j++)
281 {
282 Tekstbuf[j]=Tekstbuf[j+rest+1]; //tekst naar links schuiven
283 }
284 if (numread==BUFLEN)
285 {
286 numread-=(rest+1);
287 numread+=fread(Tekstbuf+numread,sizeof(char),rest+1,hConf);
288 if (numread<BUFLEN) Tekstbuf[numread]='\0';
289 }
290 else
291 {
292 numread-=(rest+1);
293 Tekstbuf[numread]='\0';
294 }
295
296 BehandelOutputRegel();
297 strcat(Regelbuf,"\n");
298 printf("%s",Regelbuf);
299 regels++;
300 pos=strtok(Tekstbuf,"\n\r" );
301 }
302 sprintf(buf,"\naantal regels: %i\n\r",regels);
303 printf(buf);
304}
305
306void BehandelOutputRegel(void)
307{
308 char *pos=Regelbuf;
309 CNODEOUTPUT *pCNO;
310 CARDOUTPUT *pCDO;
311 IFOUTPUT *pIO;
312 while (*pos=='\n'||*pos=='\r') pos++;
313 if (!memicmp(pos,"CONFIG FOR ",11))
314 {
315 pCNO=&CNodeOutput[++NodeOutputTeller];
316 strncpy(pCNO->name,pos+11,sizeof(pCNO->name));
317 sprintf(pCNO->volgnr,"%3d",NodeOutputTeller);
318 strcpy(pCNO->present,"0");
319 }
320 else if (*pos!=' '&&*pos!='\t')
321 {
322 //interface naam
323 unsigned int len;
324 char *pos1=pos;
325 pCDO=&CardOutput[++CardOutputTeller];
326 pCNO=&CNodeOutput[NodeOutputTeller];
327 strcpy(pCNO->present,"1");
328 while(*pos1++!=':');
329 len=pos1-pos-1;
330 if (len>9) len=9;
331 memcpy(pCDO->configname,pos,len);
332 pCDO->configname[len]='\0';
333 sprintf(pCDO->volgnr,"%3d",CardOutputTeller);
334 sprintf(pCDO->nodenr,"%3d",NodeOutputTeller);
335 }
336 else
337 {
338 pCDO=&CardOutput[CardOutputTeller];
339 while (*pos==' '||*pos=='\t'||*pos=='\n'||*pos=='\r') pos++;//skip leading spaces
340 if (!memicmp(pos,"inet ",5))
341 {
342 unsigned int len;
343 char *pos1=pos+5;
344 pIO=&IfOutput[++IfOutputTeller];
345 while(*pos1++!=' ');
346 len=pos1-pos-6;
347 if (len>17) len=17;
348 memcpy(pIO->ip,pos+5,len);
349 pIO->ip[len]='\0';
350 memcpy(pIO->netmask,pos1+8,10);
351 pIO->netmask[10]='\0';
352 if (*(pos1+19)=='b') //broadcast
353 {
354 strcpy(pIO->broadcast,pos1+29);
355 }
356 sprintf(pIO->cardnr,"%3d",CardOutputTeller);
357 }
358 else if (!memicmp(pos,"ether ",6)) strcpy(pCDO->ether,pos+6);
359 else if (!memicmp(pos,"status: ",8)) strcpy(pCDO->status,pos+8);
360 else if (!memicmp(pos,"ssid ",5))
361 {
362 unsigned int len;
363 char *pos1=pos+5;
364 while(*pos1++!=' ');
365 len=pos1-pos-6;
366 if (len>38) len=38;
367 memcpy(pCDO->ssid,pos+5,len);
368 pCDO->ssid[len]='\0';
369 }
370 else if (!memicmp(pos,"channel ",8))
371 {
372 unsigned int len;
373 char *pos1=pos+8;
374 while(*pos1++!=' ');
375 len=pos1-pos-9;
376 if (len>3) len=3;
377 memcpy(pCDO->channel,pos+8,len);
378 pCDO->channel[len]='\0';
379 }
380 else if (!memicmp(pos,"stationname ",12)) strcpy(pCDO->stationname,pos+12);
381 }
382}
383
384void LeesNode(void)
385{
386 char *pos;
387 int regels=0;
388 int rest;
389 bCardBezig=FALSE;
390
391 toread=BUFLEN;
392 numread=fread(Tekstbuf,sizeof(char),toread,hConf);
393
394 pos=strtok(Tekstbuf,"\n\r" );
395 while (pos)
396 {
397 unsigned j;
398 strcpy(Regelbuf,Tekstbuf);
399 rest=strlen(Regelbuf);
400 for (j=0;j<numread-rest-1;j++)
401 {
402 Tekstbuf[j]=Tekstbuf[j+rest+1]; //tekst naar links schuiven
403 }
404 if (numread==BUFLEN)
405 {
406 numread-=(rest+1);
407 numread+=fread(Tekstbuf+numread,sizeof(char),rest+1,hConf);
408 if (numread<BUFLEN) Tekstbuf[numread]='\0';
409 }
410 else
411 {
412 numread-=(rest+1);
413 Tekstbuf[numread]='\0';
414 }
415
416 BehandelRegel();
417 strcat(Formatbuf,"\n");
418 printf(Formatbuf);
419 regels++;
420 pos=strtok(Tekstbuf,"\n\r" );
421 }
422 sprintf(buf,"\naantal regels: %i\n\r",regels);
423 printf(buf);
424}
425
426void FormatRegel(void)
427{
428 char *pos=Regelbuf;
429 char *pose=Formatbuf;
430 BOOL bDescFlag;
431 BOOL bDubbelIpFlag;
432 {
433 //vervang # door \0
434 char *posd=pos;
435 while (*posd!='#'&&*posd!='\0') posd++;
436 *posd='\0';
437 }
438 {
439 //vervang /" door /'
440 char *posd=pos;
441 while (*posd!='\0')
442 {
443 if (*posd=='\"') *posd='\'';
444 posd++;
445 }
446 }
447 while (pos[strlen(pos)-1]==' ') //skip trailing spaces
448 {
449 pos[strlen(pos)-1]='\0';
450 }
451 if (pos[strlen(pos)-1]==';') //skip trailing ;
452 {
453 pos[strlen(pos)-1]='\0';
454 }
455 if (pos[strlen(pos)-1]=='\'') //skip trailing '
456 {
457 pos[strlen(pos)-1]='\0';
458 }
459 while (pos[strlen(pos)-1]==' ') //skip trailing spaces
460 {
461 pos[strlen(pos)-1]='\0';
462 }
463 while (*pos==' '||*pos=='\t'||*pos=='\n'||*pos=='\r') pos++;//skip leading spaces
464
465 bDescFlag=(!memicmp(pos,"DESC",4)); //bij DESC spaties laten
466 bDubbelIpFlag=(!memicmp(pos,"POINT_TO_POINT=",15)||!memicmp(pos,"OSPF_NEIGHBORS=",15)); //spaties vervangen door ;
467 for (;*pos!='\0';pos++)
468 {
469 if (bDubbelIpFlag&&(*pos==' '||*pos=='\t'))
470 {
471 while (*pos==' '||*pos=='\t') pos++;//skip overige spaces
472 *(--pos)=';';
473 }
474 while (!bDescFlag&&(*pos==' '||*pos=='\t')) pos++;//skip spaces
475 if (*pos=='\'') //neem tekst tussen quotes letterlijk over
476 { //tot volgende quote of eind
477 *pose++=*pos++;
478 while (*pos!='\''&&*pos!='\0')
479 {
480 if (*pos==',') *pos=';'; //geen komma's ivm csv-list
481 *pose++=*pos++;
482 }
483 }
484 if (*pos==',') *pos=';'; //geen komma's ivm csv-list
485 *pose++=*pos;
486 }
487 *pose='\0';
488 strcpy(Regelbuf,Formatbuf);
489}
490
491void BehandelRegel(void)
492{
493 char *pos=Regelbuf;
494 CNODE *pCN=&CNode[NodeTeller];
495 CARD *pCd=&Card[CardTeller];
496 FormatRegel();
497
498 if (!bCardBezig)
499 {
500 if (!memicmp(pos,"$location='",11)) strncpy(pCN->location,pos+11,sizeof(pCN->location));
501 else if (!memicmp(pos,"$master_ip='",12))
502 {
503 sprintf(pCN->volgnr,"%3d",NodeTeller); //hier want t hoeft maar 1 keer
504 strncpy(pCN->master_ip,pos+12,sizeof(pCN->master_ip));
505 }
506 else if (!memicmp(pos,"$gw_open='",10)) strncpy(pCN->gw_open,pos+10,sizeof(pCN->gw_open));
507 else if (!memicmp(pos,"$nodetype='",11)) strncpy(pCN->nodetype,pos+11,sizeof(pCN->nodetype));
508 else if (!memicmp(pos,"$nodename='",11)) strncpy(pCN->nodename,pos+11,sizeof(pCN->nodename));
509 else if (!memicmp(pos,"$status='",9)) strncpy(pCN->status,pos+9,sizeof(pCN->status));
510 else if (!memicmp(pos,"$OS='",5)) strncpy(pCN->OS,pos+5,sizeof(pCN->OS));
511 else if (!memicmp(pos,"$labelpos='",11)) strncpy(pCN->labelpos,pos+11,sizeof(pCN->labelpos));
512 else if (!memicmp(pos,"$X='",4)) strncpy(pCN->X,pos+4,sizeof(pCN->X));
513 else if (!memicmp(pos,"$Y='",4)) strncpy(pCN->Y,pos+4,sizeof(pCN->Y));
514 else if (!memicmp(pos,"$N='",4)) strncpy(pCN->N,pos+4,sizeof(pCN->N));
515 else if (!memicmp(pos,"$E='",4)) strncpy(pCN->E,pos+4,sizeof(pCN->E));
516 else if (!memicmp(pos,"$ESSID='",8)) strncpy(pCN->ESSID,pos+8,sizeof(pCN->ESSID));
517
518 else if (!memicmp(pos,"$config{'",9))
519 {
520 unsigned int len;
521 char *pos1=pos+9;
522 while(*pos1++!='\'');
523 len=pos1-pos-10;
524 if (len>9) len=9;
525 memcpy(pCd->configname,pos+9,len);
526 pCd->configname[len]='\0';
527 sprintf(pCd->volgnr,"%3d",CardTeller); //hier want t hoeft maar 1 keer
528 sprintf(pCd->nodenr,"%3d",NodeTeller); //hier want t hoeft maar 1 keer
529 //opvang voor ontbreken van 'sprintf' bij sommige configs
530 if (*(pos+12+len)=='<')
531 {
532 strncpy(pCd->sprintfname,pos+len+14,sizeof(pCd->sprintfname));
533 }
534 else strncpy(pCd->sprintfname,pos+len+21,sizeof(pCd->sprintfname));
535 bCardBezig=TRUE;
536 if (*(pCd->configname+strlen(pCd->configname)-2)==':')
537 { //alias, dan hoofdgegevens overnemen, ga ervan uit dat hoofd-interface altijd direct aan aliassen voorafgaat
538 int j=0;
539 while (*((pCd-j)->configname+strlen((pCd-j)->configname)-2)==':'&&(j<=CardTeller)) j++;
540 if (j<=CardTeller)
541 {
542 strncpy(pCd->mode,(pCd-j)->mode,sizeof(pCd->mode));
543 strncpy(pCd->essid,(pCd-j)->essid,sizeof(pCd->essid));
544 strncpy(pCd->channel,(pCd-j)->channel,sizeof(pCd->channel));
545 strncpy(pCd->polar,(pCd-j)->polar,sizeof(pCd->polar));
546 strncpy(pCd->antenna,(pCd-j)->antenna,sizeof(pCd->antenna));
547 strncpy(pCd->gain,(pCd-j)->gain,sizeof(pCd->gain));
548 strncpy(pCd->direction,(pCd-j)->direction,sizeof(pCd->direction));
549 strncpy(pCd->beamwidth,(pCd-j)->beamwidth,sizeof(pCd->beamwidth));
550 strncpy(pCd->cable,(pCd-j)->cable,sizeof(pCd->cable));
551 strncpy(pCd->heigth,(pCd-j)->heigth,sizeof(pCd->heigth));
552 }
553 }
554 }
555 }
556 else /*if (bCardBezig)*/
557 {
558 if (!memicmp(pos,pCd->sprintfname,strlen(pCd->sprintfname)))
559 {
560 VulIpAdressen();
561 CardTeller++;
562 bCardBezig=FALSE;
563 }
564 else if (!memicmp(pos,"TYPE=",5)) strncpy(pCd->type,pos+5,sizeof(pCd->type));
565 else if (!memicmp(pos,"IP=",3))
566 {
567 if (!memicmp(pos+3,"$master_ip",10))
568 {
569 strcpy(pCd->ip,pCN->master_ip);
570 strcat(pCd->ip,pos+13);
571 }
572 else strncpy(pCd->ip,pos+3,sizeof(pCd->ip));
573 }
574 else if (!memcmp(pos,"DESC=",5)) strncpy(pCd->desc,pos+5,sizeof(pCd->desc));
575 else if (!memicmp(pos,"SDESC=",6)) strncpy(pCd->sdesc,pos+6,sizeof(pCd->sdesc));
576 else if (!memicmp(pos,"SPEED=",6)) strncpy(pCd->speed,pos+6,sizeof(pCd->speed));
577 else if (!memicmp(pos,"POINT_TO_POINT=",15)) strncpy(pCd->pointtopoint,pos+15,sizeof(pCd->pointtopoint));
578 else if (!memicmp(pos,"OSPF_BROADCAST=",15)) strncpy(pCd->ospfbroadcast,pos+15,sizeof(pCd->ospfbroadcast));
579 else if (!memicmp(pos,"OSPF_NEIGHBORS=",15)) strncpy(pCd->ospfneighbors,pos+15,sizeof(pCd->ospfneighbors));
580 else if (!memicmp(pos,"DHCP=",5)) strncpy(pCd->dhcp,pos+5,sizeof(pCd->dhcp));
581 else if (!memicmp(pos,"MODE=",5)) strncpy(pCd->mode,pos+5,sizeof(pCd->mode));
582 else if (!memicmp(pos,"ESSID=",6)) strncpy(pCd->essid,pos+6,sizeof(pCd->essid));
583 else if (!memicmp(pos,"CHANNEL=",8)) strncpy(pCd->channel,pos+8,sizeof(pCd->channel));
584 else if (!memicmp(pos,"POLAR=",6)) strncpy(pCd->polar,pos+6,sizeof(pCd->polar));
585 else if (!memicmp(pos,"ANTENNA=",8)) strncpy(pCd->antenna,pos+8,sizeof(pCd->antenna));
586 else if (!memicmp(pos,"GAIN=",5)) strncpy(pCd->gain,pos+5,sizeof(pCd->gain));
587 else if (!memicmp(pos,"DIRECTION=",10)) strncpy(pCd->direction,pos+10,sizeof(pCd->direction));
588 else if (!memicmp(pos,"BEAMWIDTH=",10)) strncpy(pCd->beamwidth,pos+10,sizeof(pCd->beamwidth));
589 else if (!memicmp(pos,"CABLE=",6)) strncpy(pCd->cable,pos+6,sizeof(pCd->cable));
590 else if (!memicmp(pos,"HEIGTH=",7)) strncpy(pCd->heigth,pos+7,sizeof(pCd->heigth));
591 }
592}
593
594void VulIpAdressen(void)
595{
596 CARD *pCd=&Card[CardTeller];
597 char buf[36];
598 char *t;
599 strcpy(buf,pCd->ip);//111.111.111.111/30
600 t=strtok(buf,".");
601 if (t)
602 {
603 pCd->ipr.ip.ip0=(unsigned char)atoi(t);
604 t=strtok(NULL,".");
605 if (t)
606 {
607 pCd->ipr.ip.ip1=(unsigned char)atoi(t);
608 t=strtok(NULL,".");
609 if (t)
610 {
611 pCd->ipr.ip.ip2=(unsigned char)atoi(t);
612 t=strtok(NULL,"/");// let op /
613 if (t)
614 {
615 pCd->ipr.ip.ip3=(unsigned char)atoi(t);
616 t=strtok(NULL,".");
617 if (t) pCd->ipr.mask=(unsigned char)atoi(t);
618 }
619 }
620 }
621 }
622 strcpy(buf,pCd->pointtopoint);//111.111.111.111;111.111.111.111
623 t=strtok(buf,".");
624 if (t)
625 {
626 pCd->ptp1.ip0=(unsigned char)atoi(t);
627 t=strtok(NULL,".");
628 if (t)
629 {
630 pCd->ptp1.ip1=(unsigned char)atoi(t);
631 t=strtok(NULL,".");
632 if (t)
633 {
634 pCd->ptp1.ip2=(unsigned char)atoi(t);
635 t=strtok(NULL,";");// let op ;
636 if (t)
637 {
638 pCd->ptp1.ip3=(unsigned char)atoi(t);
639 t=strtok(NULL,".");
640 if (t)
641 {
642 pCd->ptp2.ip0=(unsigned char)atoi(t);
643 t=strtok(NULL,".");
644 if (t)
645 {
646 pCd->ptp2.ip1=(unsigned char)atoi(t);
647 t=strtok(NULL,".");
648 if (t)
649 {
650 pCd->ptp2.ip2=(unsigned char)atoi(t);
651 t=strtok(NULL,";");
652 if (t) pCd->ptp2.ip3=(unsigned char)atoi(t);
653 }
654 }
655 }
656 }
657 }
658 }
659 }
660 strcpy(buf,pCd->ospfneighbors);//111.111.111.111;111.111.111.111
661 t=strtok(buf,".");
662 if (t)
663 {
664 pCd->on1.ip0=(unsigned char)atoi(t);
665 t=strtok(NULL,".");
666 if (t)
667 {
668 pCd->on1.ip1=(unsigned char)atoi(t);
669 t=strtok(NULL,".");
670 if (t)
671 {
672 pCd->on1.ip2=(unsigned char)atoi(t);
673 t=strtok(NULL,";");// let op ;
674 if (t)
675 {
676 pCd->on1.ip3=(unsigned char)atoi(t);
677 t=strtok(NULL,".");
678 if (t)
679 {
680 pCd->on2.ip0=(unsigned char)atoi(t);
681 t=strtok(NULL,".");
682 if (t)
683 {
684 pCd->on2.ip1=(unsigned char)atoi(t);
685 t=strtok(NULL,".");
686 if (t)
687 {
688 pCd->on2.ip2=(unsigned char)atoi(t);
689 t=strtok(NULL,";");
690 if (t) pCd->on2.ip3=(unsigned char)atoi(t);
691 }
692 }
693 }
694 }
695 }
696 }
697 }
698 {
699 IPADDRESS ips=pCd->ipr.ip;
700 int mask3=pCd->ipr.mask;
701 if (mask3<24)//komt nu niet voor, maar vang af met 0,0,0,0
702 {
703 ips.ip0=ips.ip1=ips.ip2=ips.ip3=0;
704 pCd->ipstart=pCd->ipend=ips;
705 }
706 else
707 {
708 int mask3p,mask3pxor;
709 mask3-=24;
710 mask3p=255;
711 mask3p>>=mask3; //shift right
712 mask3pxor=255^mask3p;
713 ips.ip3=ips.ip3&mask3pxor;
714 pCd->ipstart=ips;
715 ips.ip3=ips.ip3|mask3p;
716 pCd->ipend=ips;
717 }
718 }
719}
720
721void MaakIpOverzicht(void)
722{
723 //bubble sort card records op oplopend ip
724 CARD *pCd1,*pCd2;
725 IPADDRESS *pAd1, *pAd2;
726 int i,j;
727 BOOL swapped;
728 do
729 {
730 swapped=FALSE;
731 for (i=0,j=1;i<CardTeller-1;i++,j++)
732 {
733 BOOL swappen=FALSE;
734 pCd1=&Card[i];pCd2=&Card[j];
735 pAd1=&(pCd1->ipr.ip);pAd2=&(pCd2->ipr.ip);
736 if (pAd1->ip0>pAd2->ip0) swappen=TRUE;
737 else if (pAd1->ip0<pAd2->ip0) continue;
738 else if (pAd1->ip1>pAd2->ip1) swappen=TRUE;
739 else if (pAd1->ip1<pAd2->ip1) continue;
740 else if (pAd1->ip2>pAd2->ip2) swappen=TRUE;
741 else if (pAd1->ip2<pAd2->ip2) continue;
742 else if (pAd1->ip3>pAd2->ip3) swappen=TRUE;
743 else if (pAd1->ip3<pAd2->ip3) continue;
744 else if (pCd1->ipr.mask<pCd2->ipr.mask) swappen=TRUE;
745 if (swappen)
746 {
747 SwapCards(i);
748 swapped=TRUE;
749 }
750 }
751 }
752 while (swapped);
753 MaakCSV(2);
754 MaakCSV2(1);
755}
756
757void SwapCards(int i)
758{
759 CARD tempCd=Card[i+1];
760 Card[i+1]=Card[i];
761 Card[i]=tempCd;
762}
763
764void MaakCSV2(int code)
765{
766 int i;
767 CNODE *pCN;
768 CARD *pCd;
769 if (code==1) hConf=fopen("configip1.csv","w");
770 if (code==2) hConf=fopen("configip2.csv","w");
771 if (hConf)
772 {
773 strcpy(buf,"status");AddTekst();AddKomma();
774 strcpy(buf,"nodename");AddTekst();AddKomma();
775 strcpy(buf,"configname");AddTekst();AddKomma();
776 strcpy(buf,"essid");AddTekst();AddKomma();
777 strcpy(buf,"sdesc");AddTekst();AddKomma();
778 strcpy(buf,"master_ip");AddTekst();AddKomma();
779 strcpy(buf,"IP-range");AddTekst();AddKomma();
780 strcpy(buf,"IP-start");AddTekst();AddKomma();
781 strcpy(buf,"IP-end");AddTekst();AddKomma();
782 strcpy(buf,"point_to_point");AddTekst();AddKomma();
783 strcpy(buf,"ospf_neighbors");AddTekst();AddKomma();
784 strcpy(buf,"mode");AddTekst();AddKomma();
785 strcpy(buf,"channel");AddTekst();AddKomma();
786 strcpy(buf,"Current data from nodes");AddTekst();AddKomma();
787 fwrite( "\n", sizeof( char ), 1, hConf );
788
789 for (i=0;i<CardTeller;i++)
790 {
791 pCd=&Card[i];
792 pCN=&CNode[atoi(pCd->nodenr)];
793 if (i>0)
794 { //extra lege regel
795 if (CompareIp(&(pCd->ipstart),&((pCd-1)->ipstart))||CompareIp(&(pCd->ipend),&((pCd-1)->ipend)))
796 fwrite( "\n", sizeof( char ), 1, hConf );
797 }
798 fwrite( pCN->status, sizeof( char ), strlen(pCN->status), hConf );AddKomma();
799 fwrite( pCN->nodename, sizeof( char ), strlen(pCN->nodename), hConf );AddKomma();
800 fwrite( pCd->configname, sizeof( char ), strlen(pCd->configname), hConf );AddKomma();
801 fwrite( pCd->essid, sizeof( char ), strlen(pCd->essid), hConf );AddKomma();
802 fwrite( pCd->sdesc, sizeof( char ), strlen(pCd->sdesc), hConf );AddKomma();
803 fwrite( pCN->master_ip, sizeof( char ), strlen(pCN->master_ip), hConf );AddKomma();
804 fwrite( pCd->ip, sizeof( char ), strlen(pCd->ip), hConf );AddKomma();
805 {
806 char buf[20];
807 sprintf(buf,"%i.%i.%i.%i",pCd->ipstart.ip0,pCd->ipstart.ip1,pCd->ipstart.ip2,pCd->ipstart.ip3);
808 fwrite( buf, sizeof( char ),strlen(buf), hConf );AddKomma();
809 sprintf(buf,"%i.%i.%i.%i",pCd->ipend.ip0,pCd->ipend.ip1,pCd->ipend.ip2,pCd->ipend.ip3);
810 fwrite( buf, sizeof( char ),strlen(buf), hConf );AddKomma();
811 }
812 fwrite( pCd->pointtopoint, sizeof( char ), strlen(pCd->pointtopoint), hConf );AddKomma();
813 fwrite( pCd->ospfneighbors, sizeof( char ), strlen(pCd->ospfneighbors), hConf );AddKomma();
814 fwrite( pCd->mode, sizeof( char ), strlen(pCd->mode), hConf );AddKomma();
815 fwrite( pCd->channel, sizeof( char ), strlen(pCd->channel), hConf );AddKomma();
816 {
817 int j;
818 IFOUTPUT *pIO;
819 char tbuf[30];
820 strcpy(tbuf,pCd->ip);
821 for (j=0;j<strlen(pCd->ip);j++)
822 {
823 if (tbuf[j]=='/') tbuf[j]='\0';
824 }
825 for (j=0;j<IfOutputTeller;j++)
826 {
827 pIO=&IfOutput[j];//lengtes moeten ook gelijk zijn anders: 172.1.1.227==172.1.1.22
828 if ((strlen(pIO->ip)==strlen(tbuf))&&(!memcmp(pIO->ip,tbuf,strlen(pIO->ip)))) break;
829 }
830 if (j<IfOutputTeller)
831 {
832 CARDOUTPUT *pCDO=&CardOutput[atoi(pIO->cardnr)];
833 fwrite( pIO->ip, sizeof( char ), strlen(pIO->ip), hConf );AddKomma();
834 fwrite( pCDO->configname, sizeof( char ), strlen(pCDO->configname), hConf );AddKomma();
835 fwrite( pCDO->ether, sizeof( char ), strlen(pCDO->ether), hConf );AddKomma();
836 fwrite( pCDO->status, sizeof( char ), strlen(pCDO->status), hConf );AddKomma();
837 fwrite( pCDO->ssid, sizeof( char ), strlen(pCDO->ssid), hConf );AddKomma();
838 fwrite( pCDO->stationname, sizeof( char ), strlen(pCDO->stationname), hConf );AddKomma();
839 fwrite( pCDO->channel, sizeof( char ), strlen(pCDO->channel), hConf );AddKomma();
840 }
841 }
842
843#ifdef xyz //even er uit
844 {
845 BOOL even;
846 int test=pCd->ipr.ip.ip3;
847 even=(test==((int)(test/2))*2);
848 if (!memicmp(pCd->mode,"managed",7)&&!even)
849 {
850 fwrite("oneven ip-adres en managed mode",sizeof( char ),31,hConf);
851 AddKomma();
852 }
853 if (!memicmp(pCd->mode,"master",6)&&even)
854 {
855 fwrite("even ip-adres en master mode",sizeof( char ),28,hConf);
856 AddKomma();
857 }
858 }
859
860 if (CompareIp(&pCd->ptp1,&pCd->ipstart)<0||CompareIp(&pCd->ptp1,&pCd->ipend)>0)
861 {
862 fwrite("point-to-point adres buiten range",sizeof( char ),33,hConf);
863 AddKomma();
864 }
865 if (CompareIp(&pCd->on1,&pCd->ipstart)<0||CompareIp(&pCd->on1,&pCd->ipend)>0)
866 {
867 fwrite("ospf-neighbors adres buiten range",sizeof( char ),33,hConf);
868 AddKomma();
869 }
870#endif
871 fwrite( "\n", sizeof( char ), 1, hConf );
872 }
873 fclose(hConf);
874 }
875}
876
877void MaakCSV(int code)
878{
879 int i;
880 CNODE *pCN;
881 CARD *pCd;
882 if (code==1) hConf=fopen("configs1.csv","w");
883 if (code==2) hConf=fopen("configs2.csv","w");
884 if (hConf)
885 {
886 strcpy(buf,"location");AddTekst();AddKomma();
887 strcpy(buf,"master_ip");AddTekst();AddKomma();
888 strcpy(buf,"gw_open");AddTekst();AddKomma();
889 strcpy(buf,"nodetype");AddTekst();AddKomma();
890 strcpy(buf,"nodename");AddTekst();AddKomma();
891 strcpy(buf,"status");AddTekst();AddKomma();
892 strcpy(buf,"OS");AddTekst();AddKomma();
893 strcpy(buf,"labelpos");AddTekst();AddKomma();
894 strcpy(buf,"X");AddTekst();AddKomma();
895 strcpy(buf,"Y");AddTekst();AddKomma();
896 strcpy(buf,"N");AddTekst();AddKomma();
897 strcpy(buf,"E");AddTekst();AddKomma();
898 strcpy(buf,"ESSID");AddTekst();AddKomma();
899 strcpy(buf,"configname");AddTekst();AddKomma();
900 strcpy(buf,"sprintfname");AddTekst();AddKomma();
901 strcpy(buf,"type");AddTekst();AddKomma();
902 strcpy(buf,"ip");AddTekst();AddKomma();
903 strcpy(buf,"desc");AddTekst();AddKomma();
904 strcpy(buf,"sdesc");AddTekst();AddKomma();
905 strcpy(buf,"speed");AddTekst();AddKomma();
906 strcpy(buf,"point_to_point");AddTekst();AddKomma();
907 strcpy(buf,"ospf_broadcast");AddTekst();AddKomma();
908 strcpy(buf,"ospf_neighbors");AddTekst();AddKomma();
909 strcpy(buf,"dhcp");AddTekst();AddKomma();
910 strcpy(buf,"mode");AddTekst();AddKomma();
911 strcpy(buf,"essid");AddTekst();AddKomma();
912 strcpy(buf,"channel");AddTekst();AddKomma();
913 strcpy(buf,"polar");AddTekst();AddKomma();
914 strcpy(buf,"antenna");AddTekst();AddKomma();
915 strcpy(buf,"gain");AddTekst();AddKomma();
916 strcpy(buf,"direction");AddTekst();AddKomma();
917 strcpy(buf,"beamwidth");AddTekst();AddKomma();
918 strcpy(buf,"cable");AddTekst();AddKomma();
919 strcpy(buf,"heigth");AddTekst();AddKomma();
920
921 fwrite( "\n", sizeof( char ), 1, hConf );
922
923 for (i=0;i<CardTeller;i++)
924 {
925 pCd=&Card[i];
926 pCN=&CNode[atoi(pCd->nodenr)];
927 fwrite( pCN->location, sizeof( char ), strlen(pCN->location), hConf );AddKomma();
928 fwrite( pCN->master_ip, sizeof( char ), strlen(pCN->master_ip), hConf );AddKomma();
929 fwrite( pCN->gw_open, sizeof( char ), strlen(pCN->gw_open), hConf );AddKomma();
930 fwrite( pCN->nodetype, sizeof( char ), strlen(pCN->nodetype), hConf );AddKomma();
931 fwrite( pCN->nodename, sizeof( char ), strlen(pCN->nodename), hConf );AddKomma();
932 fwrite( pCN->status, sizeof( char ), strlen(pCN->status), hConf );AddKomma();
933 fwrite( pCN->OS, sizeof( char ), strlen(pCN->OS), hConf );AddKomma();
934 fwrite( pCN->labelpos, sizeof( char ), strlen(pCN->labelpos), hConf );AddKomma();
935 fwrite( pCN->X, sizeof( char ), strlen(pCN->X), hConf );AddKomma();
936 fwrite( pCN->Y, sizeof( char ), strlen(pCN->Y), hConf );AddKomma();
937 fwrite( pCN->N, sizeof( char ), strlen(pCN->N), hConf );AddKomma();
938 fwrite( pCN->E, sizeof( char ), strlen(pCN->E), hConf );AddKomma();
939 fwrite( pCN->ESSID, sizeof( char ), strlen(pCN->ESSID), hConf );AddKomma();
940 fwrite( pCd->configname, sizeof( char ), strlen(pCd->configname), hConf );AddKomma();
941 fwrite( pCd->sprintfname, sizeof( char ), strlen(pCd->sprintfname), hConf );AddKomma();
942 fwrite( pCd->type, sizeof( char ), strlen(pCd->type), hConf );AddKomma();
943 fwrite( pCd->ip, sizeof( char ), strlen(pCd->ip), hConf );AddKomma();
944 fwrite( pCd->desc, sizeof( char ), strlen(pCd->desc), hConf );AddKomma();
945 fwrite( pCd->sdesc, sizeof( char ), strlen(pCd->sdesc), hConf );AddKomma();
946 fwrite( pCd->speed, sizeof( char ), strlen(pCd->speed), hConf );AddKomma();
947 fwrite( pCd->pointtopoint, sizeof( char ), strlen(pCd->pointtopoint), hConf );AddKomma();
948 fwrite( pCd->ospfbroadcast, sizeof( char ), strlen(pCd->ospfbroadcast), hConf );AddKomma();
949 fwrite( pCd->ospfneighbors, sizeof( char ), strlen(pCd->ospfneighbors), hConf );AddKomma();
950 fwrite( pCd->dhcp, sizeof( char ), strlen(pCd->dhcp), hConf );AddKomma();
951 fwrite( pCd->mode, sizeof( char ), strlen(pCd->mode), hConf );AddKomma();
952 fwrite( pCd->essid, sizeof( char ), strlen(pCd->essid), hConf );AddKomma();
953 fwrite( pCd->channel, sizeof( char ), strlen(pCd->channel), hConf );AddKomma();
954 fwrite( pCd->polar, sizeof( char ), strlen(pCd->polar), hConf );AddKomma();
955 fwrite( pCd->antenna, sizeof( char ), strlen(pCd->antenna), hConf );AddKomma();
956 fwrite( pCd->gain, sizeof( char ), strlen(pCd->gain), hConf );AddKomma();
957 fwrite( pCd->direction, sizeof( char ), strlen(pCd->direction), hConf );AddKomma();
958 fwrite( pCd->beamwidth, sizeof( char ), strlen(pCd->beamwidth), hConf );AddKomma();
959 fwrite( pCd->cable, sizeof( char ), strlen(pCd->cable), hConf );AddKomma();
960 fwrite( pCd->heigth, sizeof( char ), strlen(pCd->heigth), hConf );AddKomma();
961 {
962 int j;
963 IFOUTPUT *pIO;
964 char tbuf[30];
965 strcpy(tbuf,pCd->ip);
966 for (j=0;j<strlen(pCd->ip);j++)
967 {
968 if (tbuf[j]=='/') tbuf[j]='\0';
969 }
970 for (j=0;j<IfOutputTeller;j++)
971 {
972 pIO=&IfOutput[j];//lengtes moeten ook gelijk zijn anders: 172.1.1.227==172.1.1.22
973 if ((strlen(pIO->ip)==strlen(tbuf))&&(!memcmp(pIO->ip,tbuf,strlen(pIO->ip)))) break;
974 }
975 if (j<IfOutputTeller)
976 {
977 CARDOUTPUT *pCDO=&CardOutput[atoi(pIO->cardnr)];
978 fwrite( pIO->ip, sizeof( char ), strlen(pIO->ip), hConf );AddKomma();
979 fwrite( pCDO->configname, sizeof( char ), strlen(pCDO->configname), hConf );AddKomma();
980 fwrite( pCDO->ether, sizeof( char ), strlen(pCDO->ether), hConf );AddKomma();
981 fwrite( pCDO->status, sizeof( char ), strlen(pCDO->status), hConf );AddKomma();
982 fwrite( pCDO->ssid, sizeof( char ), strlen(pCDO->ssid), hConf );AddKomma();
983 fwrite( pCDO->stationname, sizeof( char ), strlen(pCDO->stationname), hConf );AddKomma();
984 fwrite( pCDO->channel, sizeof( char ), strlen(pCDO->channel), hConf );AddKomma();
985 }
986 }
987 fwrite( "\n", sizeof( char ), 1, hConf );
988 }
989 fclose(hConf);
990 }
991}
992
993void MaakCSV3(int code)
994{
995 int i;
996 CNODE *pCN;
997 CARD *pCd;
998 IFOUTPUT *pIO;
999 CARDOUTPUT *pCDO;
1000 CNODEOUTPUT *pCNO;
1001 if (code==1) hConf=fopen("outputs1.csv","w");
1002 if (code==2) hConf=fopen("outputs2.csv","w");
1003 if (hConf)
1004 {
1005 strcpy(buf,"name");AddTekst();AddKomma();
1006 strcpy(buf,"stationname");AddTekst();AddKomma();
1007 strcpy(buf,"ssid");AddTekst();AddKomma();
1008 strcpy(buf,"configname");AddTekst();AddKomma();
1009 strcpy(buf,"status");AddTekst();AddKomma();
1010 strcpy(buf,"ether");AddTekst();AddKomma();
1011 strcpy(buf,"channel");AddTekst();AddKomma();
1012 strcpy(buf,"ip");AddTekst();AddKomma();
1013 strcpy(buf,"netmask");AddTekst();AddKomma();
1014 strcpy(buf,"broadcast");AddTekst();AddKomma();
1015 strcpy(buf,"wleiden.conf");AddTekst();AddKomma();
1016 fwrite( "\n", sizeof( char ), 1, hConf );
1017
1018 for (i=0;i<IfOutputTeller;i++)
1019 {
1020 pIO=&IfOutput[i];
1021 pCDO=&CardOutput[atoi(pIO->cardnr)];
1022 pCNO=&CNodeOutput[atoi(pCDO->nodenr)];
1023 fwrite( pCNO->name, sizeof( char ), strlen(pCNO->name), hConf );AddKomma();
1024 fwrite( pCDO->stationname, sizeof( char ), strlen(pCDO->stationname), hConf );AddKomma();
1025 fwrite( pCDO->ssid, sizeof( char ), strlen(pCDO->ssid), hConf );AddKomma();
1026 fwrite( pCDO->configname, sizeof( char ), strlen(pCDO->configname), hConf );AddKomma();
1027 fwrite( pCDO->status, sizeof( char ), strlen(pCDO->status), hConf );AddKomma();
1028 fwrite( pCDO->ether, sizeof( char ), strlen(pCDO->ether), hConf );AddKomma();
1029 fwrite( pCDO->channel, sizeof( char ), strlen(pCDO->channel), hConf );AddKomma();
1030 fwrite( pIO->ip, sizeof( char ), strlen(pIO->ip), hConf );AddKomma();
1031 fwrite( pIO->netmask, sizeof( char ), strlen(pIO->netmask), hConf );AddKomma();
1032 fwrite( pIO->broadcast, sizeof( char ), strlen(pIO->broadcast), hConf );AddKomma();
1033 {
1034 int j;
1035 char tbuf[30];
1036 for (j=0;j<CardTeller;j++)
1037 {
1038 int k;
1039 pCd=&Card[j];
1040 strcpy(tbuf,pCd->ip);
1041 for (k=0;k<strlen(pCd->ip);k++)
1042 {
1043 if (tbuf[k]=='/') tbuf[k]='\0';
1044 }
1045 if ((strlen(pIO->ip)==strlen(tbuf))&&(!memcmp(pIO->ip,tbuf,strlen(pIO->ip)))) break;
1046 }
1047 if (j<CardTeller)
1048 {
1049 pCN=&CNode[atoi(pCd->nodenr)];
1050 fwrite( pCN->master_ip, sizeof( char ), strlen(pCN->master_ip), hConf );AddKomma();
1051 fwrite( pCN->nodename, sizeof( char ), strlen(pCN->nodename), hConf );AddKomma();
1052 fwrite( pCN->status, sizeof( char ), strlen(pCN->status), hConf );AddKomma();
1053 fwrite( pCN->ESSID, sizeof( char ), strlen(pCN->ESSID), hConf );AddKomma();
1054 fwrite( pCd->configname, sizeof( char ), strlen(pCd->configname), hConf );AddKomma();
1055 fwrite( pCd->sprintfname, sizeof( char ), strlen(pCd->sprintfname), hConf );AddKomma();
1056 fwrite( pCd->type, sizeof( char ), strlen(pCd->type), hConf );AddKomma();
1057 fwrite( pCd->ip, sizeof( char ), strlen(pCd->ip), hConf );AddKomma();
1058 fwrite( pCd->desc, sizeof( char ), strlen(pCd->desc), hConf );AddKomma();
1059 fwrite( pCd->sdesc, sizeof( char ), strlen(pCd->sdesc), hConf );AddKomma();
1060 fwrite( pCd->pointtopoint, sizeof( char ), strlen(pCd->pointtopoint), hConf );AddKomma();
1061 fwrite( pCd->ospfbroadcast, sizeof( char ), strlen(pCd->ospfbroadcast), hConf );AddKomma();
1062 fwrite( pCd->ospfneighbors, sizeof( char ), strlen(pCd->ospfneighbors), hConf );AddKomma();
1063 fwrite( pCd->dhcp, sizeof( char ), strlen(pCd->dhcp), hConf );AddKomma();
1064 fwrite( pCd->mode, sizeof( char ), strlen(pCd->mode), hConf );AddKomma();
1065 fwrite( pCd->essid, sizeof( char ), strlen(pCd->essid), hConf );AddKomma();
1066 fwrite( pCd->channel, sizeof( char ), strlen(pCd->channel), hConf );AddKomma();
1067 }
1068 }
1069 fwrite( "\n", sizeof( char ), 1, hConf );
1070 }
1071 fclose(hConf);
1072 }
1073}
1074
1075void AddKomma(void)
1076{
1077 fwrite( ",", sizeof( char ), 1, hConf );
1078}
1079
1080void AddTekst(void)
1081{
1082 fwrite( buf, sizeof( char ), strlen(buf), hConf );
1083}
1084
1085int CompareIp(IPADDRESS *ad1,IPADDRESS *ad2)
1086{//ad1>ad2->1;ad1==ad2->0;ad1<ad2->-1
1087 if(ad1->ip0>ad2->ip0) return 1;
1088 if(ad1->ip0<ad2->ip0) return -1;
1089 if(ad1->ip1>ad2->ip1) return 1;
1090 if(ad1->ip1<ad2->ip1) return -1;
1091 if(ad1->ip2>ad2->ip2) return 1;
1092 if(ad1->ip2<ad2->ip2) return -1;
1093 if(ad1->ip3>ad2->ip3) return 1;
1094 if(ad1->ip3<ad2->ip3) return -1;
1095 return 0;
1096}
1097
Note: See TracBrowser for help on using the repository browser.