2017-05-09 22:09:55 -04:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Definitions for the network module.
|
|
|
|
|
*
|
2018-03-18 20:48:10 +01:00
|
|
|
* Version: @(#)network.h 1.0.13 2018/03/18
|
2017-05-09 22:09:55 -04:00
|
|
|
*
|
2017-06-04 02:11:19 -04:00
|
|
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
2017-05-09 22:09:55 -04:00
|
|
|
*/
|
2017-06-04 02:11:19 -04:00
|
|
|
#ifndef EMU_NETWORK_H
|
|
|
|
|
# define EMU_NETWORK_H
|
2017-05-06 17:48:33 +02:00
|
|
|
# include <stdint.h>
|
|
|
|
|
|
|
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
/* Network provider types. */
|
|
|
|
|
#define NET_TYPE_NONE 0 /* networking disabled */
|
|
|
|
|
#define NET_TYPE_PCAP 1 /* use the (Win)Pcap API */
|
|
|
|
|
#define NET_TYPE_SLIRP 2 /* use the SLiRP port forwarder */
|
|
|
|
|
|
|
|
|
|
/* Supported network cards. */
|
2018-01-28 03:15:01 +01:00
|
|
|
enum {
|
|
|
|
|
NONE = 0,
|
|
|
|
|
NE1000,
|
|
|
|
|
NE2000,
|
|
|
|
|
RTL8019AS,
|
|
|
|
|
RTL8029AS
|
|
|
|
|
};
|
2017-05-06 17:48:33 +02:00
|
|
|
|
|
|
|
|
|
2017-05-12 05:05:20 -04:00
|
|
|
typedef void (*NETRXCB)(void *, uint8_t *, int);
|
2017-05-08 04:54:17 +02:00
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
|
2017-05-12 05:05:20 -04:00
|
|
|
typedef struct {
|
2018-02-18 10:32:51 +01:00
|
|
|
const char *name;
|
|
|
|
|
const char *internal_name;
|
2017-05-12 05:05:20 -04:00
|
|
|
device_t *device;
|
2017-10-16 04:54:41 -04:00
|
|
|
void *priv;
|
2017-05-12 05:05:20 -04:00
|
|
|
int (*poll)(void *);
|
|
|
|
|
NETRXCB rx;
|
2017-10-29 04:20:20 -05:00
|
|
|
uint8_t *mac;
|
2017-05-12 05:05:20 -04:00
|
|
|
} netcard_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
char device[128];
|
|
|
|
|
char description[128];
|
|
|
|
|
} netdev_t;
|
|
|
|
|
|
|
|
|
|
|
2017-11-02 02:28:00 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-05-12 05:05:20 -04:00
|
|
|
/* Global variables. */
|
2017-10-29 04:20:20 -05:00
|
|
|
extern int nic_do_log; /* config */
|
|
|
|
|
extern int network_card; /* config */
|
|
|
|
|
extern int network_type; /* config */
|
|
|
|
|
extern char network_pcap[512]; /* config */
|
2017-05-18 01:57:16 -04:00
|
|
|
extern int network_ndev;
|
|
|
|
|
extern netdev_t network_devs[32];
|
2017-05-17 21:56:31 +02:00
|
|
|
|
2017-05-12 05:05:20 -04:00
|
|
|
|
|
|
|
|
/* Function prototypes. */
|
2017-10-29 04:20:20 -05:00
|
|
|
extern void network_wait(uint8_t wait);
|
|
|
|
|
extern void network_poll(void);
|
2017-10-17 05:15:53 +02:00
|
|
|
extern void network_busy(uint8_t set);
|
2017-10-19 23:55:51 +02:00
|
|
|
extern void network_end(void);
|
2017-10-16 21:19:51 +02:00
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
extern void network_init(void);
|
2017-10-29 04:20:20 -05:00
|
|
|
extern void network_attach(void *, uint8_t *, NETRXCB);
|
2017-05-12 05:05:20 -04:00
|
|
|
extern void network_close(void);
|
2017-05-06 17:48:33 +02:00
|
|
|
extern void network_reset(void);
|
2017-10-29 04:20:20 -05:00
|
|
|
extern int network_available(void);
|
2017-05-12 05:05:20 -04:00
|
|
|
extern void network_tx(uint8_t *, int);
|
|
|
|
|
|
2017-10-29 04:20:20 -05:00
|
|
|
extern int net_pcap_prepare(netdev_t *);
|
|
|
|
|
extern int net_pcap_init(void);
|
2018-03-18 20:48:10 +01:00
|
|
|
extern int net_pcap_reset(netcard_t *, uint8_t *);
|
2017-10-29 04:20:20 -05:00
|
|
|
extern void net_pcap_close(void);
|
|
|
|
|
extern void net_pcap_in(uint8_t *, int);
|
|
|
|
|
|
|
|
|
|
extern int net_slirp_init(void);
|
2018-03-18 20:48:10 +01:00
|
|
|
extern int net_slirp_reset(netcard_t *, uint8_t *);
|
2017-10-29 04:20:20 -05:00
|
|
|
extern void net_slirp_close(void);
|
|
|
|
|
extern void net_slirp_in(uint8_t *, int);
|
2017-05-06 17:48:33 +02:00
|
|
|
|
2017-05-18 01:57:16 -04:00
|
|
|
extern int network_dev_to_id(char *);
|
2017-05-12 05:05:20 -04:00
|
|
|
extern int network_card_available(int);
|
|
|
|
|
extern char *network_card_getname(int);
|
|
|
|
|
extern int network_card_has_config(int);
|
|
|
|
|
extern char *network_card_get_internal_name(int);
|
|
|
|
|
extern int network_card_get_from_internal_name(char *);
|
2017-05-18 01:57:16 -04:00
|
|
|
extern device_t *network_card_getdevice(int);
|
2017-05-06 17:48:33 +02:00
|
|
|
|
2017-11-02 02:28:00 -05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-05-06 17:48:33 +02:00
|
|
|
|
2017-06-04 02:11:19 -04:00
|
|
|
#endif /*EMU_NETWORK_H*/
|