|
|
1.1 root 1: /*
2: Previous - dlgEthernet.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
6: */
7: const char DlgEthernet_fileid[] = "Previous dlgEthernet.c : " __DATE__ " " __TIME__;
8:
9: #include "main.h"
10: #include "configuration.h"
11: #include "dialog.h"
12: #include "sdlgui.h"
13: #include "file.h"
14: #include "paths.h"
15:
1.1.1.3 ! root 16: #if HAVE_PCAP
! 17: #define DLGENET_ENABLE 4
! 18: #define DLGENET_THIN 5
! 19: #define DLGENET_TWISTED 6
1.1 root 20:
1.1.1.3 ! root 21: #define DLGENET_SLIRP 9
! 22: #define DLGENET_PCAP 10
! 23:
! 24: #define DLGENET_EXIT 12
! 25:
! 26: #define PCAP_INTERFACE_LEN 19
! 27:
! 28: char pcap_interface[PCAP_INTERFACE_LEN] = "PCAP";
! 29:
! 30: /* The Boot options dialog: */
! 31: static SGOBJ enetdlg[] =
! 32: {
! 33: { SGBOX, 0, 0, 0,0, 51,19, NULL },
! 34: { SGTEXT, 0, 0, 17,1, 16,1, "Ethernet options" },
! 35:
! 36: { SGBOX, 0, 0, 1,3, 24,9, NULL },
! 37: { SGTEXT, 0, 0, 3,4, 15,1, "Guest interface" },
! 38: { SGCHECKBOX, 0, 0, 3,6, 20,1, "Ethernet connected" },
! 39: { SGRADIOBUT, 0, 0, 5,8, 11,1, "Thin wire" },
! 40: { SGRADIOBUT, 0, 0, 5,10, 14,1, "Twisted pair" },
! 41:
! 42: { SGBOX, 0, 0, 26,3, 24,9, NULL },
! 43: { SGTEXT, 0, 0, 28,4, 14,1, "Host interface" },
! 44: { SGRADIOBUT, 0, 0, 29,6, 7,1, "SLiRP" },
! 45: { SGRADIOBUT, 0, 0, 29,8, PCAP_INTERFACE_LEN,1, pcap_interface },
! 46:
! 47: { SGTEXT, 0, 0, 4,13, 15,1, "Note: PCAP requires super user privileges." },
! 48:
! 49: { SGBUTTON, SG_DEFAULT, 0, 15,16, 21,1, "Back to main menu" },
! 50: { -1, 0, 0, 0,0, 0,0, NULL }
! 51: };
! 52: #else // !HAVE_PCAP
1.1 root 53: #define DLGENET_ENABLE 3
1.1.1.2 root 54: #define DLGENET_THIN 4
55: #define DLGENET_TWISTED 5
1.1 root 56:
1.1.1.2 root 57: #define DLGENET_EXIT 6
1.1 root 58:
59:
60:
61: /* The Boot options dialog: */
62: static SGOBJ enetdlg[] =
63: {
1.1.1.3 ! root 64: { SGBOX, 0, 0, 0,0, 40,17, NULL },
! 65: { SGTEXT, 0, 0, 12,1, 16,1, "Ethernet options" },
! 66:
! 67: { SGBOX, 0, 0, 1,3, 38,9, NULL },
! 68: { SGCHECKBOX, 0, 0, 4,5, 20,1, "Ethernet connected" },
! 69: { SGRADIOBUT, 0, 0, 6,7, 11,1, "Thin wire" },
! 70: { SGRADIOBUT, 0, 0, 6,9, 14,1, "Twisted pair" },
1.1 root 71:
1.1.1.3 ! root 72: { SGBUTTON, SG_DEFAULT, 0, 10,14, 21,1, "Back to main menu" },
! 73: { -1, 0, 0, 0,0, 0,0, NULL }
1.1 root 74: };
1.1.1.3 ! root 75: #endif
1.1 root 76:
77:
78: /*-----------------------------------------------------------------------*/
79: /**
80: * Show and process the Boot options dialog.
81: */
82: void DlgEthernet_Main(void)
83: {
84: int but;
85:
86: SDLGui_CenterDlg(enetdlg);
87:
88: /* Set up the dialog from actual values */
1.1.1.2 root 89:
90: enetdlg[DLGENET_ENABLE].state &= ~SG_SELECTED;
91: enetdlg[DLGENET_THIN].state &= ~SG_SELECTED;
92: enetdlg[DLGENET_TWISTED].state &= ~SG_SELECTED;
93:
94: if (ConfigureParams.Ethernet.bEthernetConnected) {
1.1 root 95: enetdlg[DLGENET_ENABLE].state |= SG_SELECTED;
1.1.1.2 root 96: if (ConfigureParams.Ethernet.bTwistedPair) {
97: enetdlg[DLGENET_TWISTED].state |= SG_SELECTED;
98: } else {
99: enetdlg[DLGENET_THIN].state |= SG_SELECTED;
100: }
101: }
1.1.1.3 ! root 102: #if HAVE_PCAP
! 103: enetdlg[DLGENET_SLIRP].state &= ~SG_SELECTED;
! 104: enetdlg[DLGENET_PCAP].state &= ~SG_SELECTED;
! 105:
! 106: if (ConfigureParams.Ethernet.nHostInterface == ENET_PCAP) {
! 107: enetdlg[DLGENET_PCAP].state |= SG_SELECTED;
! 108: snprintf(pcap_interface, PCAP_INTERFACE_LEN, "PCAP: %s", ConfigureParams.Ethernet.szInterfaceName);
! 109: } else {
! 110: enetdlg[DLGENET_SLIRP].state |= SG_SELECTED;
! 111: sprintf(pcap_interface, "PCAP");
! 112: }
! 113: #endif
1.1 root 114:
115: /* Draw and process the dialog */
116:
117: do
118: {
119: but = SDLGui_DoDialog(enetdlg, NULL);
1.1.1.2 root 120:
121: switch (but) {
122: case DLGENET_ENABLE:
123: if (enetdlg[DLGENET_ENABLE].state & SG_SELECTED) {
124: if (ConfigureParams.Ethernet.bTwistedPair) {
125: enetdlg[DLGENET_TWISTED].state |= SG_SELECTED;
126: } else {
127: enetdlg[DLGENET_THIN].state |= SG_SELECTED;
128: }
129: } else {
130: enetdlg[DLGENET_THIN].state &= ~SG_SELECTED;
131: enetdlg[DLGENET_TWISTED].state &= ~SG_SELECTED;
132: }
133: break;
134: case DLGENET_THIN:
135: case DLGENET_TWISTED:
136: if (!(enetdlg[DLGENET_ENABLE].state & SG_SELECTED)) {
137: enetdlg[DLGENET_ENABLE].state |= SG_SELECTED;
138: }
139: break;
1.1.1.3 ! root 140: #if HAVE_PCAP
! 141: case DLGENET_PCAP:
! 142: if (DlgEthernetAdvanced()) {
! 143: snprintf(pcap_interface, PCAP_INTERFACE_LEN, "PCAP: %s", ConfigureParams.Ethernet.szInterfaceName);
! 144: } else {
! 145: sprintf(pcap_interface, "PCAP");
! 146: enetdlg[DLGENET_PCAP].state &= ~SG_SELECTED;
! 147: enetdlg[DLGENET_SLIRP].state |= SG_SELECTED;
! 148: }
! 149: break;
! 150: case DLGENET_SLIRP:
! 151: sprintf(pcap_interface, "PCAP");
! 152: break;
! 153: #endif
1.1.1.2 root 154: default:
155: break;
156: }
157: }
1.1 root 158: while (but != DLGENET_EXIT && but != SDLGUI_QUIT
159: && but != SDLGUI_ERROR && !bQuitProgram);
160:
161:
162: /* Read values from dialog */
163: ConfigureParams.Ethernet.bEthernetConnected = enetdlg[DLGENET_ENABLE].state & SG_SELECTED;
1.1.1.2 root 164: ConfigureParams.Ethernet.bTwistedPair = enetdlg[DLGENET_TWISTED].state & SG_SELECTED;
1.1.1.3 ! root 165: #if HAVE_PCAP
! 166: if (enetdlg[DLGENET_PCAP].state & SG_SELECTED) {
! 167: ConfigureParams.Ethernet.nHostInterface = ENET_PCAP;
! 168: } else {
! 169: ConfigureParams.Ethernet.nHostInterface = ENET_SLIRP;
! 170: }
! 171: #endif
1.1 root 172: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.