Network cleanup, updated pcap_if to have a sniffer, PCAP now works properly. Removed all Slirp warnings.
This commit is contained in:
@@ -1,16 +1,27 @@
|
||||
/* Copyright holders: Sarah Walker, Tenshi
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||
* running old operating systems and software designed for IBM
|
||||
* PC systems and compatibles from 1981 through fairly recent
|
||||
* system designs based on the PCI bus.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
*
|
||||
* Implementation of the network module.
|
||||
*
|
||||
* Version: @(#)network.c 1.0.1 2017/05/09
|
||||
*
|
||||
* Authors: Kotori, <oubattler@gmail.com>
|
||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "ibm.h"
|
||||
#include "device.h"
|
||||
#include "network.h"
|
||||
#include "timer.h"
|
||||
#include "thread.h"
|
||||
|
||||
#include "network.h"
|
||||
#include "net_ne2000.h"
|
||||
|
||||
|
||||
@@ -21,14 +32,13 @@ typedef struct {
|
||||
} NETCARD;
|
||||
|
||||
typedef struct {
|
||||
void (*poller)(void *p);
|
||||
void (*poller)(void *);
|
||||
void *priv;
|
||||
} NETPOLL;
|
||||
|
||||
|
||||
static int net_handlers_num;
|
||||
static int net_card_last = 0;
|
||||
static uint32_t net_poll_time = 0;
|
||||
static uint32_t net_poll_time = 100;
|
||||
static NETPOLL net_handlers[8];
|
||||
static NETCARD net_cards[] = {
|
||||
{ "None", "none", NULL },
|
||||
@@ -37,8 +47,8 @@ static NETCARD net_cards[] = {
|
||||
{ "", "", NULL }
|
||||
};
|
||||
|
||||
int network_card_current = 0;
|
||||
|
||||
int network_card_current = 0;
|
||||
uint8_t ethif;
|
||||
int inum;
|
||||
|
||||
@@ -65,24 +75,12 @@ net_poll(void *priv)
|
||||
void
|
||||
network_init(void)
|
||||
{
|
||||
if (net_cards[network_card_current].device)
|
||||
device_add(net_cards[network_card_current].device);
|
||||
/* No network interface right now. */
|
||||
network_card_current = 0;
|
||||
net_handlers_num = 0;
|
||||
|
||||
net_card_last = network_card_current;
|
||||
|
||||
if (network_card_current != 0) {
|
||||
network_reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Add a handler for a network card. */
|
||||
void
|
||||
network_add_handler(void (*poller)(void *p), void *p)
|
||||
{
|
||||
net_handlers[net_handlers_num].poller = poller;
|
||||
net_handlers[net_handlers_num].priv = p;
|
||||
net_handlers_num++;
|
||||
/* This should be a config value, really. --FvK */
|
||||
net_poll_time = 100;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,15 +88,28 @@ network_add_handler(void (*poller)(void *p), void *p)
|
||||
void
|
||||
network_reset(void)
|
||||
{
|
||||
pclog("network_reset()\n");
|
||||
pclog("NETWORK: reset (card=%d)\n", network_card_current);
|
||||
|
||||
net_handlers_num = 0;
|
||||
if (! network_card_current) return;
|
||||
|
||||
if (network_card_current) {
|
||||
pclog("NETWORK: adding timer...\n");
|
||||
|
||||
timer_add(net_poll, &net_poll_time, TIMER_ALWAYS_ENABLED, NULL);
|
||||
if (net_cards[network_card_current].device) {
|
||||
pclog("NETWORK: adding device '%s'\n",
|
||||
net_cards[network_card_current].name);
|
||||
device_add(net_cards[network_card_current].device);
|
||||
}
|
||||
|
||||
pclog("NETWORK: adding timer...\n");
|
||||
timer_add(net_poll, &net_poll_time, TIMER_ALWAYS_ENABLED, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* Add a handler for a network card. */
|
||||
void
|
||||
network_add_handler(void (*poller)(void *), void *p)
|
||||
{
|
||||
net_handlers[net_handlers_num].poller = poller;
|
||||
net_handlers[net_handlers_num].priv = p;
|
||||
net_handlers_num++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user