- Introduce struct uip_ip to present IP package
- Add a helper uip_ip_len() to return totoal length of a IP package
- Add a helper uip_ip_hdrlen() to return the IP header length
- Currently, uip does not support IP options
Drop IP package if IP header length is not 20 bytes which means it
contains IP options.
Signed-off-by: Asias He <asias.hejun@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
OBJS += ioeventfd.o
OBJS += irq.o
OBJS += uip/arp.o
+OBJS += uip/ipv4.o
OBJS += uip/buf.o
OBJS += kvm-cmd.o
OBJS += kvm-debug.o
u32 dip;
} __attribute__((packed));
+struct uip_ip {
+ struct uip_eth eth;
+ u8 vhl;
+ u8 tos;
+ /*
+ * len = IP hdr + IP payload
+ */
+ u16 len;
+ u16 id;
+ u16 flgfrag;
+ u8 ttl;
+ u8 proto;
+ u16 csum;
+ u32 sip;
+ u32 dip;
+} __attribute__((packed));
+
struct uip_info {
struct list_head udp_socket_head;
struct list_head tcp_socket_head;
int eth_len;
};
+static inline u16 uip_ip_hdrlen(struct uip_ip *ip)
+{
+ return (ip->vhl & 0x0f) * 4;
+}
+
+static inline u16 uip_ip_len(struct uip_ip *ip)
+{
+ return htons(ip->len);
+}
+
+int uip_tx_do_ipv4(struct uip_tx_arg *arg);
int uip_tx_do_arp(struct uip_tx_arg *arg);
struct uip_buf *uip_buf_set_used(struct uip_info *info, struct uip_buf *buf);
--- /dev/null
+#include "kvm/uip.h"
+
+int uip_tx_do_ipv4(struct uip_tx_arg *arg)
+{
+ struct uip_ip *ip;
+
+ ip = (struct uip_ip *)(arg->eth);
+
+ if (uip_ip_hdrlen(ip) != 20) {
+ pr_warning("IP header length is not 20 bytes");
+ return -1;
+ }
+
+ return 0;
+}