net.h 974 B

1234567891011121314151617181920212223242526272829303132
  1. #ifndef KERNEL_MOD_NET_H
  2. #define KERNEL_MOD_NET_H
  3. typedef uint8_t* (*get_mac_func)(void);
  4. typedef struct ethernet_packet* (*get_packet_func)(void);
  5. typedef void (*send_packet_func)(uint8_t*, size_t);
  6. struct netif {
  7. void *extra;
  8. get_mac_func get_mac;
  9. get_packet_func get_packet;
  10. send_packet_func send_packet;
  11. uint8_t hwaddr[6];
  12. uint32_t source;
  13. char * driver;
  14. uint32_t gateway;
  15. };
  16. extern void init_netif_funcs(get_mac_func mac_func, get_packet_func get_func, send_packet_func send_func, char * device);
  17. extern void net_handler(void * data, char * name);
  18. extern size_t write_dhcp_packet(uint8_t * buffer);
  19. extern struct socket* net_open(uint32_t type);
  20. extern int net_send(struct socket* socket, uint8_t* payload, size_t payload_size, int flags);
  21. extern size_t net_recv(struct socket* socket, uint8_t* buffer, size_t len);
  22. extern int net_connect(struct socket* socket, uint32_t dest_ip, uint16_t dest_port);
  23. extern int net_close(struct socket* socket);
  24. #endif