2022-06-27 19:36:56 +02:00
|
|
|
/*
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
UMKa - User-Mode KolibriOS developer tools
|
|
|
|
vnet - virtual network card
|
|
|
|
|
2023-02-01 19:30:44 +01:00
|
|
|
Copyright (C) 2020-2023 Ivan Baravy <dunkaist@gmail.com>
|
2022-06-27 19:36:56 +02:00
|
|
|
*/
|
|
|
|
|
2020-05-06 23:33:32 +02:00
|
|
|
#ifndef VNET_H_INCLUDED
|
|
|
|
#define VNET_H_INCLUDED
|
|
|
|
|
2023-02-06 17:01:37 +01:00
|
|
|
#include <stdatomic.h>
|
2020-05-07 03:57:01 +02:00
|
|
|
#include "umka.h"
|
2020-05-06 23:33:32 +02:00
|
|
|
|
2023-02-03 03:35:26 +01:00
|
|
|
#define VNET_BUFIN_CAP (NET_BUFFER_SIZE - offsetof(net_buff_t, data))
|
2023-02-01 19:30:44 +01:00
|
|
|
|
|
|
|
enum vnet_type {
|
2023-02-06 17:01:37 +01:00
|
|
|
VNET_DEVTYPE_NULL,
|
|
|
|
VNET_DEVTYPE_FILE,
|
|
|
|
VNET_DEVTYPE_TAP,
|
2023-02-01 19:30:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct vnet {
|
2023-02-02 01:37:11 +01:00
|
|
|
struct eth_device eth;
|
2023-02-03 03:35:26 +01:00
|
|
|
uint8_t bufin[VNET_BUFIN_CAP];
|
|
|
|
size_t bufin_len;
|
2023-02-01 19:30:44 +01:00
|
|
|
int fdin;
|
|
|
|
int fdout;
|
|
|
|
int input_processed;
|
2023-02-06 17:01:37 +01:00
|
|
|
const atomic_int *running;
|
2023-02-01 19:30:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct vnet *
|
2023-02-06 17:01:37 +01:00
|
|
|
vnet_init(enum vnet_type type, const atomic_int *running);
|
2020-10-14 19:56:28 +02:00
|
|
|
|
2020-05-06 23:33:32 +02:00
|
|
|
#endif // VNET_H_INCLUDED
|