miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Toggle main menu visibility
Loading...
Searching...
No Matches
netdev.h
Go to the documentation of this file.
1
// MIT License
2
//
3
// Copyright (c) 2026 Christian Spoo
4
//
5
// Permission is hereby granted, free of charge, to any person obtaining a copy
6
// of this software and associated documentation files (the "Software"), to deal
7
// in the Software without restriction, including without limitation the rights
8
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
// copies of the Software, and to permit persons to whom the Software is
10
// furnished to do so, subject to the following conditions:
11
//
12
// The above copyright notice and this permission notice shall be included in all
13
// copies or substantial portions of the Software.
14
//
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
// SOFTWARE.
22
23
#ifndef _MINIOS_NET_NETDEV_H_
24
#define _MINIOS_NET_NETDEV_H_
25
26
#include <
miniOS/types.h
>
27
28
#define NET_MAX_DEVICES 4
29
#define NET_MAX_FRAME_SIZE 1518
30
31
struct
net_device
;
32
33
typedef
void (*
net_rx_handler_t
)(
struct
net_device
*dev,
34
const
void
*frame,
35
size_t
frame_len,
36
void
*ctx);
37
38
typedef
struct
{
39
int (*
open
)(
struct
net_device
*dev);
40
int (*
poll
)(
struct
net_device
*dev);
41
int (*
xmit
)(
struct
net_device
*dev,
const
void
*frame,
size_t
frame_len);
42
int (*
get_mac
)(
struct
net_device
*dev,
uint8_t
mac_out[6]);
43
bool (*
get_link
)(
struct
net_device
*dev);
44
}
netdev_ops_t
;
45
46
typedef
struct
net_device
{
47
char
name
[8];
48
uint8_t
mac
[6];
49
uint16_t
mtu
;
50
bool
link_up
;
51
void
*
driver_data
;
52
net_rx_handler_t
rx_handler
;
53
void
*
rx_handler_ctx
;
54
const
netdev_ops_t
*
ops
;
55
struct
56
{
57
uint64_t
rx_packets
;
58
uint64_t
rx_dropped
;
59
uint64_t
tx_packets
;
60
uint64_t
tx_dropped
;
61
uint64_t
rx_bytes
;
62
uint64_t
tx_bytes
;
63
}
stats
;
64
}
netdev_t
;
65
66
typedef
netdev_t
net_device_t
;
67
68
void
net_init
(
void
);
69
int
netdev_register
(
netdev_t
*dev);
70
netdev_t
*
netdev_first
(
void
);
71
void
netdev_poll_all
(
void
);
72
73
#endif
/* _MINIOS_NET_NETDEV_H_ */
net_init
void net_init(void)
Definition
netdev.c:52
net_device_t
netdev_t net_device_t
Definition
netdev.h:66
netdev_first
netdev_t * netdev_first(void)
Definition
netdev.c:100
netdev_t
struct net_device netdev_t
netdev_poll_all
void netdev_poll_all(void)
Definition
netdev.c:107
netdev_register
int netdev_register(netdev_t *dev)
Definition
netdev.c:75
net_rx_handler_t
void(*) net_rx_handler_t(struct net_device *dev, const void *frame, size_t frame_len, void *ctx)
Definition
netdev.h:33
net_device::[struct].stats::rx_bytes
uint64_t rx_bytes
net_device::[struct].stats::tx_dropped
uint64_t tx_dropped
net_device::[struct].stats::rx_packets
uint64_t rx_packets
net_device::[struct].stats::tx_packets
uint64_t tx_packets
net_device::[struct].stats::rx_dropped
uint64_t rx_dropped
net_device::[struct].stats::tx_bytes
uint64_t tx_bytes
net_device
Definition
netdev.h:46
net_device::link_up
bool link_up
Definition
netdev.h:50
net_device::rx_handler_ctx
void * rx_handler_ctx
Definition
netdev.h:53
net_device::stats
struct net_device::@013264340106352364216143336071100070110304173332 stats
net_device::name
char name[8]
Definition
netdev.h:47
net_device::rx_handler
net_rx_handler_t rx_handler
Definition
netdev.h:52
net_device::ops
const netdev_ops_t * ops
Definition
netdev.h:54
net_device::mtu
uint16_t mtu
Definition
netdev.h:49
net_device::driver_data
void * driver_data
Definition
netdev.h:51
net_device::mac
uint8_t mac[6]
Definition
netdev.h:48
netdev_ops_t
Definition
netdev.h:38
netdev_ops_t::xmit
int(*) xmit(struct net_device *dev, const void *frame, size_t frame_len)
Definition
netdev.h:41
netdev_ops_t::poll
int(*) poll(struct net_device *dev)
Definition
netdev.h:40
netdev_ops_t::open
int(*) open(struct net_device *dev)
Definition
netdev.h:39
netdev_ops_t::get_mac
int(*) get_mac(struct net_device *dev, uint8_t mac_out[6])
Definition
netdev.h:42
netdev_ops_t::get_link
bool(*) get_link(struct net_device *dev)
Definition
netdev.h:43
types.h
uint16_t
unsigned short uint16_t
Definition
types.h:31
uint64_t
unsigned long int uint64_t
Definition
types.h:37
uint8_t
unsigned char uint8_t
Definition
types.h:28
include
miniOS
net
netdev.h
Generated by
1.18.0