grub/net/protocol.c
Manoel R. Abranches 60cdb895da Adaptation for the new protocols and interface structs.
implementation of receive in the protocols.
Also all unwanted packets are discarded.
2010-06-21 19:15:45 -03:00

37 lines
1.1 KiB
C

#include <grub/net/protocol.h>
#include <grub/misc.h>
#include <grub/mm.h>
#define PROTOCOL_REGISTER_FUNCTIONS(layername) \
struct grub_net_##layername##_layer_protocol *grub_net_##layername##_layer_protocols;\
\
void grub_net_##layername##_layer_protocol_register (struct grub_net_##layername##_layer_protocol *prot)\
{\
grub_list_push (GRUB_AS_LIST_P (&grub_net_##layername##_layer_protocols),\
GRUB_AS_LIST (prot));\
}\
\
void grub_net_##layername##_layer_protocol_unregister (struct grub_net_##layername##_layer_protocol *prot)\
{\
grub_list_remove (GRUB_AS_LIST_P (&grub_net_##layername##_layer_protocols),\
GRUB_AS_LIST (prot));\
}\
\
struct grub_net_##layername##_layer_protocol \
*grub_net_##layername##_layer_protocol_get (grub_net_protocol_id_t id)\
{\
struct grub_net_##layername##_layer_protocol *p;\
\
for (p = grub_net_##layername##_layer_protocols; p; p = p->next)\
{\
if (p->id == id)\
return p;\
}\
\
return NULL; \
}
PROTOCOL_REGISTER_FUNCTIONS(application);
PROTOCOL_REGISTER_FUNCTIONS(transport);
PROTOCOL_REGISTER_FUNCTIONS(network);
PROTOCOL_REGISTER_FUNCTIONS(link);