#ifndef GRUB_INTERFACE_HEADER
#define GRUB_INTERFACE_HEADER
-#include <grub/net.h>
-#include <grub/net/protocol.h>
+//#include <grub/net.h>
+#include <grub/net/type_net.h>
+#include <grub/list.h>
+#include <grub/misc.h>
-struct grub_net_protstack
+struct grub_net_protocol_stack
{
- struct grub_net_protstack *next;
- struct grub_net_protocol* prot;
+ struct grub_net_protocol_stack *next;
+ char *name;
+ grub_net_protocol_id_t id;
+ void *interface;
};
-struct grub_net_interface
+struct grub_net_application_transport_interface
{
- struct grub_net_card *card;
- struct grub_net_protstack* protstack;
- char *path;
- char *username;
- char *password;
- /*transport layer addres*/
- struct grub_net_addr *tla;
- /*internet layer addres*/
- struct grub_net_addr *ila;
- /*link layer addres*/
- struct grub_net_addr *lla;
+ struct grub_net_transport_network_interface *inner_layer;
+ void *data;
+ struct grub_net_application_layer_protocol *app_prot;
+ struct grub_net_transport_layer_protocol *trans_prot;
};
+struct grub_net_transport_network_interface
+{
+ struct grub_net_network_link_interface *inner_layer;
+ void *data;
+ struct grub_net_transport_layer_protocol *trans_prot;
+ struct grub_net_network_layer_protocol *net_prot;
+};
+
+struct grub_net_network_link_interface
+{
+ void *data;
+ struct grub_net_network_layer_protocol *net_prot;
+ struct grub_net_link_layer_protocol *link_prot;
+};
+
+
+extern struct grub_net_protocol_stack *grub_net_protocol_stacks;
+static inline void
+grub_net_stack_register (struct grub_net_protocol_stack *stack)
+{
+
+ grub_list_push (GRUB_AS_LIST_P (&grub_net_protocol_stacks),
+ GRUB_AS_LIST (stack));
+}
+/*
+void grub_net_stack_unregister (struct grub_net_protocol_stack *stack)
+{
+ grub_list_remove (GRUB_AS_LIST_P (&grub_net_protocol_stacks),
+ GRUB_AS_LIST (stack));
+}*/
+
+struct grub_net_protocol_stack *grub_net_protocol_stack_get (char *name);
+
+/*
+static inline void
+grub_net_interface_application_transport_register (struct grub_net_application_transport_interface);
+static inline void
+grub_net_interface_application_transport_unregister (struct grub_net_application_transport_interface);
+static inline void
+grub_net_interface_transport_network_register (struct grub_net_transport_network_interface);
+static inline void
+grub_net_interface_transport_network_unregister (struct grub_net_transport_network_interface);
+static inline void
+grub_net_interface_network_link_register (struct grub_net_network_link_interface);
+static inline void
+grub_net_interface_network_link_unregister (struct grub_net_network_link_interface);*/
#endif
#ifndef GRUB_PROTOCOL_HEADER
#define GRUB_PROTOCOL_HEADER
#include <grub/err.h>
-#include <grub/net/protocol.h>
+#include <grub/net/interface.h>
#include <grub/net/netbuff.h>
-#include <grub/net.h>
+#include <grub/net/type_net.h>
struct grub_net_protocol;
-struct grub_net_interface;
-struct grub_net_protstack;
+struct grub_net_protocol_stack;
+struct grub_net_network_layer_interface;
-struct grub_net_protocol
+
+typedef enum grub_network_layer_protocol_id
+{
+ GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4
+} grub_network_layer_protocol_id_t;
+
+struct grub_net_application_layer_protocol
+{
+ struct grub_net_application_layer_protocol *next;
+ char *name;
+ grub_net_protocol_id_t id;
+ int (*get_file_size) (struct grub_net_network_layer_interface* inf,
+ struct grub_net_protocol_stack *protocol_stack, struct grub_net_buff *nb,char *filename);
+ grub_err_t (*open) (struct grub_net_network_layer_interface* inf,
+ struct grub_net_protocol_stack *protocol_stack, struct grub_net_buff *nb,char *filename);
+ grub_err_t (*send_ack) (struct grub_net_network_layer_interface* inf,
+ struct grub_net_protocol_stack *protocol_stack, struct grub_net_buff *nb);
+ grub_err_t (*send) (struct grub_net_network_layer_interface *inf,
+ struct grub_net_protocol_stack *protocol_stack, struct grub_net_buff *nb);
+ grub_err_t (*recv) (struct grub_net_network_layer_interface *inf,
+ struct grub_net_protocol_stack *protocol_stack, struct grub_net_buff *nb);
+ grub_err_t (*close) (struct grub_net_network_layer_interface *inf,
+ struct grub_net_protocol_stack *protocol_stack, struct grub_net_buff *nb);
+};
+
+struct grub_net_transport_layer_protocol
+{
+ struct grub_net_transport_layer_protocol *next;
+ char *name;
+ grub_net_protocol_id_t id;
+ //grub_transport_layer_protocol_id_t id;
+ grub_err_t (*open) (struct grub_net_network_layer_interface* inf,
+ struct grub_net_application_transport_interface *app_trans_inf, struct grub_net_buff *nb);
+ grub_err_t (*send_ack) (struct grub_net_network_layer_interface* inf,
+ struct grub_net_protocol_stack *protocol_stack, struct grub_net_buff *nb);
+ grub_err_t (*send) (struct grub_net_network_layer_interface *inf,
+ struct grub_net_application_transport_interface *app_trans_inf, struct grub_net_buff *nb);
+ grub_err_t (*recv) (struct grub_net_network_layer_interface *inf,
+ struct grub_net_application_transport_interface *app_trans_inf, struct grub_net_buff *nb);
+ grub_err_t (*close) (struct grub_net_network_layer_interface *inf,
+ struct grub_net_protocol_stack *protocol_stack, struct grub_net_buff *nb);
+};
+
+struct grub_net_network_layer_protocol
+{
+ struct grub_net_network_layer_protocol *next;
+ char *name;
+ grub_net_protocol_id_t id;
+ //grub_network_layer_protocol_id_t id;
+ grub_err_t (*ntoa) (char *name, grub_net_network_layer_address_t *addr);
+ char * (*aton) (union grub_net_network_layer_address addr);
+ grub_err_t (*net_ntoa) (char *name,
+ grub_net_network_layer_netaddress_t *addr);
+ char * (*net_aton) (grub_net_network_layer_netaddress_t addr);
+ int (* match_net) (grub_net_network_layer_netaddress_t net,
+ grub_net_network_layer_address_t addr);
+ grub_err_t (*send) (struct grub_net_network_layer_interface *inf ,
+ struct grub_net_transport_network_interface *trans_net_inf, struct grub_net_buff *nb);
+ grub_err_t (*recv) (struct grub_net_network_layer_interface *inf ,
+ struct grub_net_transport_network_interface *trans_net_inf, struct grub_net_buff *nb);
+};
+
+struct grub_net_link_layer_protocol
{
- struct grub_net_protocol *next;
+
+ struct grub_net_link_layer_protocol *next;
char *name;
- grub_err_t (*open) (struct grub_net_interface* inf,
- struct grub_net_protstack *protstack, struct grub_net_buff *nb);
- grub_err_t (*open_confirm) (struct grub_net_interface *inf,
- struct grub_net_protstack *protstack, struct grub_net_buff *nb);
- grub_err_t (*get_payload) (struct grub_net_interface *inf,
- struct grub_net_protstack *protstack, struct grub_net_buff *nb);
- grub_err_t (*get_payload_confirm) (struct grub_net_interface* inf,
- struct grub_net_protstack *protstack, struct grub_net_buff *nb);
- grub_err_t (*close) (struct grub_net_interface *inf,
- struct grub_net_protstack *protstack, struct grub_net_buff *nb);
- grub_err_t (*send) (struct grub_net_interface *inf ,
- struct grub_net_protstack *protstack, struct grub_net_buff *nb);
- grub_err_t (*recv) (struct grub_net_interface *inf ,
- struct grub_net_protstack *protstack, struct grub_net_buff *nb);
+ grub_net_protocol_id_t id;
+ grub_err_t (*send) (struct grub_net_network_layer_interface *inf ,
+ struct grub_net_network_link_interface *net_link_inf, struct grub_net_buff *nb);
+ grub_err_t (*recv) (struct grub_net_network_layer_interface *inf ,
+ struct grub_net_network_link_interface *net_link_inf, struct grub_net_buff *nb);
};
+extern struct grub_net_network_layer_protocol *grub_net_network_layer_protocols;
+
typedef struct grub_net_protocol *grub_net_protocol_t;
-void grub_protocol_register (grub_net_protocol_t prot);
-void grub_protocol_unregister (grub_net_protocol_t prot);
+void grub_net_application_layer_protocol_register (struct grub_net_application_layer_protocol *prot);
+void grub_net_application_layer_protocol_unregister (struct grub_net_application_layer_protocol *prot);
+struct grub_net_application_layer_protocol *grub_net_application_layer_protocol_get (grub_net_protocol_id_t id);
+void grub_net_transport_layer_protocol_register (struct grub_net_transport_layer_protocol *prot);
+void grub_net_transport_layer_protocol_unregister (struct grub_net_transport_layer_protocol *prot);
+struct grub_net_transport_layer_protocol *grub_net_transport_layer_protocol_get (grub_net_protocol_id_t id);
+void grub_net_network_layer_protocol_register (struct grub_net_network_layer_protocol *prot);
+void grub_net_network_layer_protocol_unregister (struct grub_net_network_layer_protocol *prot);
+struct grub_net_network_layer_protocol *grub_net_network_layer_protocol_get (grub_net_protocol_id_t id);
+void grub_net_link_layer_protocol_register (struct grub_net_link_layer_protocol *prot);
+void grub_net_link_layer_protocol_unregister (struct grub_net_link_layer_protocol *prot);
+struct grub_net_link_layer_protocol *grub_net_link_layer_protocol_get (grub_net_protocol_id_t id);
#endif