Split DHCP code off into a separate source code file
[project/relayd.git] / relayd.h
index fd23833..3ae4edc 100644 (file)
--- a/relayd.h
+++ b/relayd.h
@@ -68,6 +68,7 @@ struct relayd_interface {
        struct list_head hosts;
        uint8_t src_ip[4];
        bool managed;
+       int rt_table;
 };
 
 struct relayd_host {
@@ -84,21 +85,6 @@ struct arp_packet {
        struct ether_arp arp;
 } __packed;
 
-struct ip_packet {
-       struct ether_header eth;
-       struct iphdr iph;
-} __packed;
-
-struct dhcp_header {
-       uint8_t op, htype, hlen, hops;
-       uint32_t xit;
-       uint16_t secs, flags;
-       struct in_addr ciaddr, yiaddr, siaddr, giaddr;
-       unsigned char chaddr[16];
-       unsigned char sname[64];
-       unsigned char file[128];
-} __packed;
-
 struct rtnl_req {
        struct nlmsghdr nl;
        struct rtmsg rt;
@@ -106,13 +92,31 @@ struct rtnl_req {
 
 extern struct list_head interfaces;
 extern int debug;
+extern int route_table;
 
-void relayd_add_route(struct relayd_host *host);
-void relayd_del_route(struct relayd_host *host);
+void rtnl_route_set(struct relayd_host *host, bool add);
+
+static inline void relayd_add_route(struct relayd_host *host)
+{
+       rtnl_route_set(host, true);
+}
+
+static inline void relayd_del_route(struct relayd_host *host)
+{
+       rtnl_route_set(host, false);
+}
+
+void relayd_add_interface_routes(struct relayd_interface *rif);
+void relayd_del_interface_routes(struct relayd_interface *rif);
 
 int relayd_rtnl_init(void);
 void relayd_rtnl_done(void);
 
-struct relayd_host *relayd_refresh_host(struct relayd_interface *rif, const uint8_t *lladdr, const uint8_t *ipaddr);
+struct relayd_host *relayd_refresh_host(struct relayd_interface *rif,
+                                       const uint8_t *lladdr,
+                                       const uint8_t *ipaddr);
+
+void relayd_forward_bcast_packet(struct relayd_interface *from_rif, void *packet, int len);
+bool relayd_handle_dhcp_packet(struct relayd_interface *rif, void *data, int len, bool forward);
 
 #endif