miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
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
31struct net_device;
32
33typedef void (*net_rx_handler_t)(struct net_device *dev,
34 const void *frame,
35 size_t frame_len,
36 void *ctx);
37
38typedef 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);
45
65
67
68void net_init(void);
71void netdev_poll_all(void);
72
73#endif /* _MINIOS_NET_NETDEV_H_ */
void(* net_rx_handler_t)(struct net_device *dev, const void *frame, size_t frame_len, void *ctx)
Definition netdev.h:33
void net_init(void)
Definition netdev.c:52
netdev_t net_device_t
Definition netdev.h:66
netdev_t * netdev_first(void)
Definition netdev.c:100
struct net_device netdev_t
void netdev_poll_all(void)
Definition netdev.c:107
int netdev_register(netdev_t *dev)
Definition netdev.c:75
Definition netdev.h:46
bool link_up
Definition netdev.h:50
uint64_t tx_bytes
Definition netdev.h:62
void * rx_handler_ctx
Definition netdev.h:53
uint64_t rx_dropped
Definition netdev.h:58
uint64_t tx_packets
Definition netdev.h:59
struct net_device::@013264340106352364216143336071100070110304173332 stats
char name[8]
Definition netdev.h:47
net_rx_handler_t rx_handler
Definition netdev.h:52
const netdev_ops_t * ops
Definition netdev.h:54
uint64_t rx_bytes
Definition netdev.h:61
uint16_t mtu
Definition netdev.h:49
uint64_t tx_dropped
Definition netdev.h:60
uint64_t rx_packets
Definition netdev.h:57
void * driver_data
Definition netdev.h:51
uint8_t mac[6]
Definition netdev.h:48
Definition netdev.h:38
int(* get_mac)(struct net_device *dev, uint8_t mac_out[6])
Definition netdev.h:42
int(* poll)(struct net_device *dev)
Definition netdev.h:40
bool(* get_link)(struct net_device *dev)
Definition netdev.h:43
int(* open)(struct net_device *dev)
Definition netdev.h:39
int(* xmit)(struct net_device *dev, const void *frame, size_t frame_len)
Definition netdev.h:41
unsigned short uint16_t
Definition types.h:31
unsigned long int uint64_t
Definition types.h:37
unsigned char uint8_t
Definition types.h:28