1 /* SmoothWall libsmooth.
3 * This program is distributed under the terms of the GNU General Public
4 * Licence. See the file COPYING for details.
6 * (c) Lawrence Manning, 2001
7 * Contains network library functions.
11 #include "libsmooth.h"
19 extern struct nic nics
[];
20 extern struct knic knics
[];
22 char *ucolourcard
[] = { "GREEN", "RED", "ORANGE", "BLUE", NULL
};
23 char *lcolourcard
[] = { "green", "red", "orange", "blue", NULL
};
25 int scanned_nics_read_done
= 0;
27 newtComponent networkform
;
28 newtComponent addressentry
;
29 newtComponent netmaskentry
;
30 newtComponent statictyperadio
;
31 newtComponent dhcptyperadio
;
32 newtComponent pppoetyperadio
;
33 newtComponent pptptyperadio
;
34 newtComponent dhcphostnameentry
;
36 /* acceptable character filter for IP and netmaks entry boxes */
37 static int ip_input_filter(newtComponent entry
, void * data
, int ch
, int cursor
)
39 if ((ch
>= '0' && ch
<= '9') || ch
== '.' || ch
== '\r' || ch
>= NEWT_KEY_EXTRA_BASE
)
44 /* This is a groovie dialog for showing network info. Takes a keyvalue list,
45 * a colour and a dhcp flag. Shows the current settings, and rewrites them
46 * if necessary. DHCP flag sets wether to show the dhcp checkbox. */
47 int changeaddress(struct keyvalue
*kv
, char *colour
, int typeflag
,
48 char *defaultdhcphostname
)
52 char *dhcphostnameresult
;
53 struct newtExitStruct es
;
55 newtComponent addresslabel
;
56 newtComponent netmasklabel
;
57 newtComponent dhcphostnamelabel
;
58 newtComponent ok
, cancel
;
60 char temp
[STRING_SIZE
];
61 char addressfield
[STRING_SIZE
];
62 char netmaskfield
[STRING_SIZE
];
63 char typefield
[STRING_SIZE
];
64 char dhcphostnamefield
[STRING_SIZE
];
67 char type
[STRING_SIZE
];
68 int startstatictype
= 0;
69 int startdhcptype
= 0;
70 int startpppoetype
= 0;
71 int startpptptype
= 0;
73 /* Build some key strings. */
74 sprintf(addressfield
, "%s_ADDRESS", colour
);
75 sprintf(netmaskfield
, "%s_NETMASK", colour
);
76 sprintf(typefield
, "%s_TYPE", colour
);
77 sprintf(dhcphostnamefield
, "%s_DHCP_HOSTNAME", colour
);
79 sprintf(message
, ctr
[TR_INTERFACE
], colour
);
80 newtCenteredWindow(44, (typeflag
? 18 : 12), message
);
82 networkform
= newtForm(NULL
, NULL
, 0);
84 sprintf(message
, ctr
[TR_ENTER_THE_IP_ADDRESS_INFORMATION
], colour
);
85 header
= newtTextboxReflowed(1, 1, message
, 42, 0, 0, 0);
86 newtFormAddComponent(networkform
, header
);
88 /* See if we need a dhcp checkbox. If we do, then we shift the contents
89 * of the window down two rows to make room. */
92 strcpy(temp
, "STATIC"); findkey(kv
, typefield
, temp
);
93 if (strcmp(temp
, "STATIC") == 0) startstatictype
= 1;
94 if (strcmp(temp
, "DHCP") == 0) startdhcptype
= 1;
95 if (strcmp(temp
, "PPPOE") == 0) startpppoetype
= 1;
96 if (strcmp(temp
, "PPTP") == 0) startpptptype
= 1;
97 statictyperadio
= newtRadiobutton(2, 4, ctr
[TR_STATIC
], startstatictype
, NULL
);
98 dhcptyperadio
= newtRadiobutton(2, 5, "DHCP", startdhcptype
, statictyperadio
);
99 pppoetyperadio
= newtRadiobutton(2, 6, "PPPOE", startpppoetype
, dhcptyperadio
);
100 pptptyperadio
= newtRadiobutton(2, 7, "PPTP", startpptptype
, pppoetyperadio
);
101 newtFormAddComponents(networkform
, statictyperadio
, dhcptyperadio
,
102 pppoetyperadio
, pptptyperadio
, NULL
);
103 newtComponentAddCallback(statictyperadio
, networkdialogcallbacktype
, NULL
);
104 newtComponentAddCallback(dhcptyperadio
, networkdialogcallbacktype
, NULL
);
105 newtComponentAddCallback(pppoetyperadio
, networkdialogcallbacktype
, NULL
);
106 newtComponentAddCallback(pptptyperadio
, networkdialogcallbacktype
, NULL
);
107 dhcphostnamelabel
= newtTextbox(2, 9, 18, 1, 0);
108 newtTextboxSetText(dhcphostnamelabel
, ctr
[TR_DHCP_HOSTNAME
]);
109 strcpy(temp
, defaultdhcphostname
);
110 findkey(kv
, dhcphostnamefield
, temp
);
111 dhcphostnameentry
= newtEntry(20, 9, temp
, 20, &dhcphostnameresult
, 0);
112 newtFormAddComponent(networkform
, dhcphostnamelabel
);
113 newtFormAddComponent(networkform
, dhcphostnameentry
);
114 if (startdhcptype
== 0)
115 newtEntrySetFlags(dhcphostnameentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_SET
);
118 addresslabel
= newtTextbox(2, (typeflag
? 11 : 4) + 0, 18, 1, 0);
119 newtTextboxSetText(addresslabel
, ctr
[TR_IP_ADDRESS_PROMPT
]);
121 findkey(kv
, addressfield
, temp
);
122 addressentry
= newtEntry(20, (typeflag
? 11 : 4) + 0, temp
, 20, &addressresult
, 0);
123 newtEntrySetFilter(addressentry
, ip_input_filter
, NULL
);
124 if (typeflag
== 1 && startstatictype
== 0 && startpptptype
== 0 )
125 newtEntrySetFlags(addressentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_SET
);
126 newtFormAddComponent(networkform
, addresslabel
);
127 newtFormAddComponent(networkform
, addressentry
);
130 netmasklabel
= newtTextbox(2, (typeflag
? 11 : 4) + 1, 18, 1, 0);
131 newtTextboxSetText(netmasklabel
, ctr
[TR_NETMASK_PROMPT
]);
132 strcpy(temp
, "255.255.255.0"); findkey(kv
, netmaskfield
, temp
);
133 netmaskentry
= newtEntry(20, (typeflag
? 11 : 4) + 1, temp
, 20, &netmaskresult
, 0);
134 newtEntrySetFilter(netmaskentry
, ip_input_filter
, NULL
);
135 if (typeflag
== 1 && startstatictype
== 0 && startpptptype
== 0 )
136 newtEntrySetFlags(netmaskentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_SET
);
138 newtFormAddComponent(networkform
, netmasklabel
);
139 newtFormAddComponent(networkform
, netmaskentry
);
142 ok
= newtButton(8, (typeflag
? 14 : 7), ctr
[TR_OK
]);
143 cancel
= newtButton(26, (typeflag
? 14 : 7), ctr
[TR_CANCEL
]);
145 newtFormAddComponents(networkform
, ok
, cancel
, NULL
);
148 newtDrawForm(networkform
);
153 newtFormRun(networkform
, &es
);
157 /* OK was pressed; verify the contents of each entry. */
158 strcpy(message
, ctr
[TR_INVALID_FIELDS
]);
160 strcpy(type
, "STATIC");
163 if (strcmp(type
, "STATIC") == 0 || strcmp(type
, "PPTP") == 0 )
165 if (inet_addr(addressresult
) == INADDR_NONE
)
167 strcat(message
, ctr
[TR_IP_ADDRESS_CR
]);
170 if (inet_addr(netmaskresult
) == INADDR_NONE
)
172 strcat(message
, ctr
[TR_NETWORK_MASK_CR
]);
176 if (strcmp(type
, "DHCP") == 0)
178 if (!strlen(dhcphostnameresult
))
180 strcat(message
, ctr
[TR_DHCP_HOSTNAME_CR
]);
188 /* No errors! Set new values, depending on dhcp flag etc. */
191 replacekeyvalue(kv
, dhcphostnamefield
, dhcphostnameresult
);
192 if (strcmp(type
, "STATIC") != 0 && strcmp(type
, "PPTP") != 0)
194 replacekeyvalue(kv
, addressfield
, "0.0.0.0");
195 replacekeyvalue(kv
, netmaskfield
, "0.0.0.0");
199 replacekeyvalue(kv
, addressfield
, addressresult
);
200 replacekeyvalue(kv
, netmaskfield
, netmaskresult
);
202 replacekeyvalue(kv
, typefield
, type
);
206 replacekeyvalue(kv
, addressfield
, addressresult
);
207 replacekeyvalue(kv
, netmaskfield
, netmaskresult
);
210 setnetaddress(kv
, colour
);
217 newtFormDestroy(networkform
);
223 /* for pppoe: return string thats type STATIC, DHCP or PPPOE */
224 int gettype(char *type
)
226 newtComponent selected
= newtRadioGetCurrent(statictyperadio
);
228 if (selected
== statictyperadio
)
229 strcpy(type
, "STATIC");
230 else if (selected
== dhcptyperadio
)
231 strcpy(type
, "DHCP");
232 else if (selected
== pppoetyperadio
)
233 strcpy(type
, "PPPOE");
234 else if (selected
== pptptyperadio
)
235 strcpy(type
, "PPTP");
237 strcpy(type
, "ERROR");
242 /* 0.9.9: calculates broadcast too. */
243 int setnetaddress(struct keyvalue
*kv
, char *colour
)
245 char addressfield
[STRING_SIZE
];
246 char netaddressfield
[STRING_SIZE
];
247 char netmaskfield
[STRING_SIZE
];
248 char broadcastfield
[STRING_SIZE
];
249 char address
[STRING_SIZE
];
250 char netmask
[STRING_SIZE
];
251 unsigned long int intaddress
;
252 unsigned long int intnetaddress
;
253 unsigned long int intnetmask
;
254 unsigned long int intbroadcast
;
259 /* Build some key strings. */
260 sprintf(addressfield
, "%s_ADDRESS", colour
);
261 sprintf(netaddressfield
, "%s_NETADDRESS", colour
);
262 sprintf(netmaskfield
, "%s_NETMASK", colour
);
263 sprintf(broadcastfield
, "%s_BROADCAST", colour
);
265 strcpy(address
, ""); findkey(kv
, addressfield
, address
);
266 strcpy(netmask
, ""); findkey(kv
, netmaskfield
, netmask
);
268 /* Calculate netaddress. Messy.. */
269 intaddress
= inet_addr(address
);
270 intnetmask
= inet_addr(netmask
);
272 intnetaddress
= intaddress
& intnetmask
;
273 temp
.s_addr
= intnetaddress
;
274 netaddress
= inet_ntoa(temp
);
276 replacekeyvalue(kv
, netaddressfield
, netaddress
);
278 intbroadcast
= intnetaddress
| ~intnetmask
;
279 temp
.s_addr
= intbroadcast
;
280 broadcast
= inet_ntoa(temp
);
282 replacekeyvalue(kv
, broadcastfield
, broadcast
);
287 /* Called when dhcp flag is toggled. Toggle disabled state of other 3
289 void networkdialogcallbacktype(newtComponent cm
, void *data
)
291 char type
[STRING_SIZE
];
295 if (strcmp(type
, "STATIC") != 0 && strcmp(type
, "PPTP") != 0 )
297 newtEntrySetFlags(addressentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_SET
);
298 newtEntrySetFlags(netmaskentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_SET
);
302 newtEntrySetFlags(addressentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_RESET
);
303 newtEntrySetFlags(netmaskentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_RESET
);
305 if (strcmp(type
, "DHCP") == 0)
306 newtEntrySetFlags(dhcphostnameentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_RESET
);
308 newtEntrySetFlags(dhcphostnameentry
, NEWT_FLAG_DISABLED
, NEWT_FLAGS_SET
);
311 newtDrawForm(networkform
);
314 int interfacecheck(struct keyvalue
*kv
, char *colour
)
316 char temp
[STRING_SIZE
];
317 char colourfields
[NETCHANGE_TOTAL
][STRING_SIZE
];
320 sprintf(colourfields
[ADDRESS
], "%s_ADDRESS", colour
);
321 sprintf(colourfields
[NETADDRESS
], "%s_NETADDRESS", colour
);
322 sprintf(colourfields
[NETMASK
], "%s_NETMASK", colour
);
324 for (c
= 0; c
< 3; c
++)
326 strcpy(temp
, ""); findkey(kv
, colourfields
[c
], temp
);
327 if (!(strlen(temp
))) return 0;
332 /* Funky routine for loading all drivers (cept those are already loaded.). */
333 int probecards(char *driver
, char *driveroptions
)
338 /* ### alter strupper ###
339 char *strupper(char *s)
342 for (n=0;s[n];n++) s[n]=toupper(s[n]);
347 /* neuer StringUpper, wird zur Zeit nicht benutzt da UTF-8 nicht geht.
348 void strupper(unsigned char *string)
351 for (str = string; *str != '\0'; str++)
352 if (!(*str & 0x80) && islower(*str))
353 *str = toupper(*str);
357 /* int ismacaddr(char *ismac)
360 fprintf(flog,"Check is MAC true\n"); // #### Debug ####
361 for (a = ismac; *a; a++) {
362 sprintf(flog,"%c\n", *a); // #### Debug ####
363 if (*a != ':' && !isxdigit(*a)) return 0; // is int != ':' or not hexdigit then exit
369 int get_knic(int card
) //returns "0" for zero cards or error and "1" card is found.
371 struct keyvalue
*kv
= initkeyvalues();
372 char temp
[STRING_SIZE
], searchstr
[STRING_SIZE
];
375 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
378 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
382 sprintf(searchstr
, "%s_MACADDR", ucolourcard
[card
]);
383 strcpy(temp
, ""); findkey(kv
, searchstr
, temp
);
385 strcpy(knics
[ card
].macaddr
, temp
);
386 strcpy(knics
[ card
].colour
, "GREEN");
388 sprintf(searchstr
, "%s_DESCRIPTION", ucolourcard
[card
]);
389 findkey(kv
, searchstr
, temp
);
390 strcpy(knics
[ card
].description
, temp
);
392 sprintf(searchstr
, "%s_DRIVER", ucolourcard
[card
]);
393 findkey(kv
, searchstr
, temp
);
394 strcpy(knics
[ card
].driver
, temp
);
397 strcpy(knics
[ card
].description
, ctr
[TR_UNSET
]);
407 found
+= get_knic(_GREEN_CARD_
);
408 found
+= get_knic(_RED_CARD_
);
409 found
+= get_knic(_ORANGE_CARD_
);
410 found
+= get_knic(_BLUE_CARD_
);
415 int create_udev(void)
417 #define UDEV_NET_CONF "/etc/udev/rules.d/30-persistent-network.rules"
421 fprintf(flog
,"Enter create_udev: "UDEV_NET_CONF
"\n"); // #### Debug ####
422 if ( (fp
= fopen(UDEV_NET_CONF
, "w")) == NULL
) {
423 fprintf(stderr
,"Couldn't open" UDEV_NET_CONF
);
427 for (i
= 0 ; i
< 4 ; i
++)
429 if (strcmp(knics
[i
].macaddr
, "")) {
430 fprintf(fp
,"ACTION==\"add\", SUBSYSTEM==\"net\", SYSFS{address}==\"%s\", NAME=\"%s0\" # %s\n", knics
[i
].macaddr
, lcolourcard
[i
], knics
[i
].description
);
431 fprintf(flog
,"Write %s\n",lcolourcard
[i
]); // #### Debug ####
438 int write_configs_netudev(int card
, int colour
)
440 char commandstring
[STRING_SIZE
];
441 struct keyvalue
*kv
= initkeyvalues();
442 char temp1
[STRING_SIZE
], temp2
[STRING_SIZE
], temp3
[STRING_SIZE
];
443 char ucolour
[STRING_SIZE
];
445 sprintf(ucolour
, ucolourcard
[colour
]);
446 strcpy(knics
[colour
].driver
, nics
[card
].driver
);
447 strcpy(knics
[colour
].description
, nics
[card
].description
);
448 strcpy(knics
[colour
].macaddr
, nics
[card
].macaddr
);
450 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
453 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
457 sprintf(temp1
, "%s_DEV", ucolour
);
458 sprintf(temp2
, "%s_MACADDR", ucolour
);
459 sprintf(temp3
, "%s0", lcolourcard
[colour
]);
460 replacekeyvalue(kv
, temp1
, temp3
);
461 replacekeyvalue(kv
, temp2
, nics
[card
].macaddr
);
462 sprintf(temp1
, "%s_DESCRIPTION", ucolour
);
463 replacekeyvalue(kv
, temp1
, nics
[card
].description
);
464 sprintf(temp1
, "%s_DRIVER", ucolour
);
465 replacekeyvalue(kv
, temp1
, nics
[card
].driver
);
467 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
473 char g_temp
[STRING_SIZE
]="";
474 char* readmac(char *card
) {
475 fprintf(flog
,"Enter readmac... NIC: %s\n", card
); // #### Debug ####
477 char temp
[STRING_SIZE
], mac
[20];
479 sprintf(temp
,"/sys/class/net/%s/address",card
);
480 if( (fp
= fopen(temp
, "r")) == NULL
) {
481 fprintf(flog
,"Couldn't open: %s\n",temp
);
491 char* find_nic4mac(char *findmac
) {
492 fprintf(flog
,"Enter find_name4nic... Search for %s\n", findmac
); // #### Debug ####
493 #define SYSDIR "/sys/class/net"
496 struct dirent
*dirzeiger
;
497 char temp
[STRING_SIZE
], temp2
[STRING_SIZE
];
499 if((dir
=opendir(SYSDIR
)) == NULL
) {
500 fprintf(flog
,"Fehler bei opendir (find_name4nic) ...\n");
505 while((dirzeiger
=readdir(dir
)) != NULL
) {
506 if(*((*dirzeiger
).d_name
) != '.' & strcmp(((*dirzeiger
).d_name
), "lo") != 0) {
507 sprintf(temp2
, "%s", readmac((*dirzeiger
).d_name
) );
508 if (strcmp(findmac
, temp2
) == 0) {
509 sprintf(temp
,"%s", (*dirzeiger
).d_name
);
510 fprintf(flog
,"MAC: %s is NIC: %s\n", findmac
, temp
); // #### Debug ####
516 if(closedir(dir
) == -1) fprintf(flog
,"Fehler beim schliessen von %s\n", SYSDIR
);
517 strcpy(g_temp
, temp
);
521 int scan_network_cards(void)
524 char driver
[STRING_SIZE
], description
[STRING_SIZE
], macaddr
[STRING_SIZE
], temp_line
[STRING_SIZE
];
526 const char _driver
[]="driver: ";
527 const char _desc
[]="desc: ";
528 const char _network_hwaddr
[]="network.hwaddr: ";
530 if (!(scanned_nics_read_done
))
532 fprintf(flog
,"Enter scan_network_cards\n"); // #### Debug ####
533 mysystem("/bin/probenic.sh");
534 // Read our scanned nics
535 if( (fp
= fopen(SCANNED_NICS
, "r")) == NULL
)
537 fprintf(stderr
,"Couldn't open "SCANNED_NICS
);
540 while (fgets(temp_line
, STRING_SIZE
, fp
) != NULL
)
542 temp_line
[strlen(temp_line
) -1] = 0;
543 if ( strncmp(temp_line
, _driver
, strlen(_driver
)) == 0 ) sprintf(nics
[count
].driver
, "%s", temp_line
+strlen(_driver
));
544 if ( strncmp(temp_line
, _desc
, strlen(_desc
)) == 0 ) sprintf(nics
[count
].description
, "%s", temp_line
+strlen(_desc
));
545 if ( strncmp(temp_line
, _network_hwaddr
, strlen(_network_hwaddr
)) == 0 ) sprintf(nics
[count
].macaddr
, "%s", temp_line
+strlen(_network_hwaddr
));
546 if (strlen(nics
[count
].macaddr
) > 15 ) {
547 sprintf(nics
[count
].nic
, "%s", find_nic4mac(nics
[count
].macaddr
));
552 scanned_nics_read_done
= count
;
553 } else fprintf(flog
,"Scan Networkcards does read.\n");
554 return scanned_nics_read_done
;
559 int nicmenu(int colour
)
561 int rc
, choise
= 0, count
= 0, kcount
= 0, mcount
= 0, i
, j
, nic_in_use
;
562 int found_NIC_as_Card
[4];
563 char message
[STRING_SIZE
];
565 char cMenuInhalt
[STRING_SIZE
];
566 char MenuInhalt
[20][180];
567 char *pMenuInhalt
[20];
569 // strcpy( message , pnics[count].macaddr);
570 // while (strcmp(message, "")) {
572 // strcpy( message , pnics[count].macaddr);
575 while (strcmp(nics
[count
].macaddr
, "")) count
++; // 2 find how many nics in system
576 for ( i
=0 ; i
<4;i
++) if (strcmp(knics
[i
].macaddr
, "")) kcount
++; // loop to find all knowing nics
577 fprintf(flog
, "Enter NicMenu\n"); // #### Debug ####
578 fprintf(flog
, "count nics %i\ncount knics %i\n", count
, kcount
); // #### Debug ####
580 // If new nics are found...
581 if (count
> kcount
) {
582 for (i
=0 ; i
< count
; i
++)
585 for (j
=0 ; j
<= kcount
; j
++) {
586 if (strcmp(nics
[ i
].macaddr
, knics
[ j
].macaddr
) == 0 ) {
588 fprintf(flog
,"NIC \"%s\" is in use.\n", nics
[ i
].macaddr
); // #### Debug ####
593 fprintf(flog
,"NIC \"%s\" is free.\n", nics
[ i
].macaddr
); // #### Debug ####
594 if ( strlen(nics
[i
].description
) < 55 )
595 sprintf(MenuInhalt
[mcount
], "%.*s", strlen(nics
[i
].description
)-2, nics
[i
].description
+1);
597 sprintf(cMenuInhalt
, "%.50s", nics
[i
].description
+ 1);
598 sprintf(MenuInhalt
[mcount
], cMenuInhalt
);
599 strcat (MenuInhalt
[mcount
], "...");
602 while ( strlen(MenuInhalt
[mcount
]) < 53) strcat(MenuInhalt
[mcount
], " "); // Fill with space.
604 strcat(MenuInhalt
[mcount
], " (");
605 strcat(MenuInhalt
[mcount
], nics
[i
].macaddr
);
606 strcat(MenuInhalt
[mcount
], ")");
607 pMenuInhalt
[mcount
] = MenuInhalt
[mcount
];
608 found_NIC_as_Card
[mcount
]=i
;
613 pMenuInhalt
[mcount
] = NULL
;
615 // sprintf(message, "Es wurde(n) %d freie Netzwerkkarte(n) in Ihrem System gefunden.\nBitte waehlen Sie im naechsten Dialog eine davon aus.\n", count);
616 // newtWinMessage("NetcardMenu", ctr[TR_OK], message);
618 sprintf(message
, "(TR) Bitte wählen Sie eine der untenstehenden Netzwerkkarten fuer die Schnittstelle \"%s\" aus.\n", ucolourcard
[colour
]);
619 rc
= newtWinMenu("(TR) NetcardMenu2", message
, 50, 5, 5, 6, pMenuInhalt
, &choise
, ctr
[TR_OK
], ctr
[TR_SELECT
], ctr
[TR_CANCEL
], NULL
);
621 if ( rc
== 0 || rc
== 1) {
622 write_configs_netudev(found_NIC_as_Card
[choise
], colour
);
623 } else if (rc
== 2) {
624 // manualdriver("pcnet32","");
628 // We have to add here that you can manually add a device
629 errorbox("(TR) Es wurden leider keine freien Netzwerkkarten fuer die Schnittstelle in ihrem System gefunden.");
634 int clear_card_entry(int card
)
636 struct keyvalue
*kv
= initkeyvalues();
637 char temp
[STRING_SIZE
];
639 if (!(readkeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings")))
642 errorbox(ctr
[TR_UNABLE_TO_OPEN_SETTINGS_FILE
]);
646 strcpy(knics
[card
].driver
, "");
647 strcpy(knics
[card
].description
, ctr
[TR_UNSET
]);
648 strcpy(knics
[card
].macaddr
, "");
649 strcpy(knics
[card
].colour
, "");
650 sprintf(temp
, "%s_DRIVER", ucolourcard
[card
]);
651 replacekeyvalue(kv
, temp
, "");
652 sprintf(temp
, "%s_DEV", ucolourcard
[card
]);
653 replacekeyvalue(kv
, temp
, "");
654 sprintf(temp
, "%s_MACADDR", ucolourcard
[card
]);
655 replacekeyvalue(kv
, temp
, "");
656 sprintf(temp
, "%s_DESCRIPTION", ucolourcard
[card
]);
657 replacekeyvalue(kv
, temp
, "");
659 writekeyvalues(kv
, CONFIG_ROOT
"/ethernet/settings");
662 fprintf(flog
,"Card \"%s\" cleared\n",ucolourcard
[card
]); // #### Debug ####
666 int ask_clear_card_entry(int card
)
668 char message
[STRING_SIZE
];
671 sprintf(message
, "(TR) Soll die Zuordnung der Netzwerkkarte \"%s\" entfernt werden ?\n", ucolourcard
[card
]);
672 rc
= newtWinChoice(ctr
[TR_WARNING
], ctr
[TR_OK
], ctr
[TR_CANCEL
], message
);
674 if ( rc
= 0 || rc
== 1) {
675 clear_card_entry(card
);
676 // sprintf(temp1, "%s_DEV", ucolour);
677 // sprintf(temp2, "%s_MACADDR", ucolour);
678 // replacekeyvalue(kv, temp1, "");
679 // replacekeyvalue(kv, temp2, "");
680 // sprintf(temp1, "%s_DESCRIPTION", ucolour);
681 // replacekeyvalue(kv, temp1, "");
683 // writekeyvalues(kv, CONFIG_ROOT "/ethernet/settings");
689 /* Manual entry for gurus. */
690 int manualdriver(char *driver
, char *driveroptions
)
692 char *values
[] = { NULL
, NULL
}; /* pointers for the values. */
693 struct newtWinEntry entries
[] =
694 { { "", &values
[0], 0,}, { NULL
, NULL
, 0 } };
696 char commandstring
[STRING_SIZE
];
700 strcpy(driveroptions
, "");
702 rc
= newtWinEntries(ctr
[TR_SELECT_NETWORK_DRIVER
],
703 ctr
[TR_MODULE_PARAMETERS
], 50, 5, 5, 40, entries
,
704 ctr
[TR_OK
], ctr
[TR_CANCEL
], NULL
);
705 if (rc
== 0 || rc
== 1)
707 if (strlen(values
[0]))
709 sprintf(commandstring
, "/sbin/modprobe %s", values
[0]);
710 if (runcommandwithstatus(commandstring
, ctr
[TR_LOADING_MODULE
]) == 0)
712 if ((driverend
= strchr(values
[0], ' ')))
715 strcpy(driver
, values
[0]);
716 strcpy(driveroptions
, driverend
+ 1);
720 strcpy(driver
, values
[0]);
721 strcpy(driveroptions
, "");
725 errorbox(ctr
[TR_UNABLE_TO_LOAD_DRIVER_MODULE
]);
728 errorbox(ctr
[TR_MODULE_NAME_CANNOT_BE_BLANK
]);