1 /*
2  * Copyright (c) 2013 Corey Tabaka
3  *
4  * Use of this source code is governed by a MIT-style
5  * license that can be found in the LICENSE file or at
6  * https://opensource.org/licenses/MIT
7  */
8 #pragma once
9 
10 #include <lk/list.h>
11 #include <lk/compiler.h>
12 #include <dev/driver.h>
13 
14 struct netstack_state;
15 struct pbuf;
16 
17 /* netif interface */
18 struct netif_ops {
19     struct driver_ops std;
20 
21     status_t (*set_state)(struct device *dev, struct netstack_state *state);
22     ssize_t (*get_hwaddr)(struct device *dev, void *buf, size_t max_len);
23     ssize_t (*get_mtu)(struct device *dev);
24 
25     status_t (*set_status)(struct device *dev, bool up);
26     status_t (*output)(struct device *dev, struct pbuf *p);
27     status_t (*mcast_filter)(struct device *dev, const uint8_t *mac, int action);
28 };
29 
30 __BEGIN_CDECLS
31 
32 /* netif API */
33 status_t class_netif_set_state(struct device *dev, struct netstack_state *state);
34 ssize_t class_netif_get_hwaddr(struct device *dev, void *buf, size_t max_len);
35 ssize_t class_netif_get_mtu(struct device *dev);
36 status_t class_netif_set_status(struct device *dev, bool up);
37 status_t class_netif_output(struct device *dev, struct pbuf *p);
38 status_t class_netif_mcast_filter(struct device *dev, const uint8_t *mac, int action);
39 
40 status_t class_netif_add(struct device *dev);
41 
42 /* network stack API - called by drivers */
43 status_t class_netstack_input(struct device *dev, struct netstack_state *state, struct pbuf *p);
44 
45 status_t class_netstack_wait_for_network(lk_time_t timeout);
46 
47 __END_CDECLS
48 
49