13
#include <mem/objalloc.h>
15
#include <pnet/core/types.h>
16
#include <pnet/core/core.h>
18
#include <framework/mod/options.h>
20
#define CONFIG_PNET_NODES_QUANTITY OPTION_GET(NUMBER,pnet_nodes_quantity)
22
OBJALLOC_DEF(net_nodes, struct net_node, CONFIG_PNET_NODES_QUANTITY);
24
net_node_t pnet_node_init(net_node_t node, pnet_proto_t proto) {
28
INIT_LIST_HEAD(&node->gr_link);
30
node->rx_dfault = node->tx_dfault = NULL;
36
net_node_t pnet_node_alloc(net_addr_t addr, pnet_proto_t proto) {
38
if (NULL == proto || NULL == proto->actions.alloc) {
39
node = (net_node_t) objalloc(&net_nodes);
41
node = proto->actions.alloc();
44
pnet_node_init(node, proto);
50
int pnet_node_free(net_node_t node) {
52
if ((NULL != node->proto) && (NULL != node->proto->actions.free)) {
53
if (node->proto->actions.free(node) == 0) {
57
objfree(&net_nodes, node);
61
int pnet_node_attach(net_node_t node, net_id_t id, net_node_t other) {
68
node->rx_dfault = other;
71
node->tx_dfault = other;
78
net_node_t pnet_node_get(net_node_t node, net_id_t id) {
81
return node->rx_dfault;
83
return node->tx_dfault;