1 |
gbeauche |
1.1 |
/*
|
2 |
|
|
* interfaces.cpp - ip router
|
3 |
|
|
*
|
4 |
gbeauche |
1.2 |
* Basilisk II (C) 1997-2008 Christian Bauer
|
5 |
gbeauche |
1.1 |
*
|
6 |
|
|
* Windows platform specific code copyright (C) Lauri Pesonen
|
7 |
|
|
*
|
8 |
|
|
* This program is free software; you can redistribute it and/or modify
|
9 |
|
|
* it under the terms of the GNU General Public License as published by
|
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
11 |
|
|
* (at your option) any later version.
|
12 |
|
|
*
|
13 |
|
|
* This program is distributed in the hope that it will be useful,
|
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
16 |
|
|
* GNU General Public License for more details.
|
17 |
|
|
*
|
18 |
|
|
* You should have received a copy of the GNU General Public License
|
19 |
|
|
* along with this program; if not, write to the Free Software
|
20 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
21 |
|
|
*/
|
22 |
|
|
|
23 |
|
|
#include "sysdeps.h"
|
24 |
|
|
#include "interfaces.h"
|
25 |
|
|
#include "../dump.h"
|
26 |
|
|
#include "mibaccess.h"
|
27 |
|
|
|
28 |
|
|
#if DEBUG
|
29 |
|
|
#pragma optimize("",off)
|
30 |
|
|
#endif
|
31 |
|
|
|
32 |
|
|
#include "debug.h"
|
33 |
|
|
|
34 |
|
|
static UINT ip_array[100];
|
35 |
|
|
static UINT ip_array_sz = 0;
|
36 |
|
|
|
37 |
|
|
void init_interfaces()
|
38 |
|
|
{
|
39 |
|
|
MibII _mibs(false);
|
40 |
|
|
|
41 |
|
|
ip_array_sz = sizeof(ip_array) / sizeof(ip_array[0]);
|
42 |
|
|
|
43 |
|
|
if(_mibs.Init()) {
|
44 |
|
|
_mibs.GetIPAddress( ip_array, ip_array_sz );
|
45 |
|
|
}
|
46 |
|
|
|
47 |
|
|
if(ip_array_sz == 0) {
|
48 |
|
|
ip_array_sz = 1;
|
49 |
|
|
ip_array[0] = 0; // localhost
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
D(bug("init_interfaces() found %d interfaces.\r\n", ip_array_sz));
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
void final_interfaces()
|
56 |
|
|
{
|
57 |
|
|
// Currently nothing to do.
|
58 |
|
|
}
|
59 |
|
|
|
60 |
|
|
int get_ip_count()
|
61 |
|
|
{
|
62 |
|
|
return ip_array_sz;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
uint32 get_ip_by_index( int index )
|
66 |
|
|
{
|
67 |
|
|
return index >= 0 && index < (int)ip_array_sz ? ip_array[index] : 0;
|
68 |
|
|
}
|