From: Asias He <asias.hejun@gmail.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: Cyrill Gorcunov <gorcunov@gmail.com>, Ingo Molnar <mingo@elte.hu>,
Sasha Levin <levinsasha928@gmail.com>,
Prasad Joshi <prasadjoshi124@gmail.com>,
kvm@vger.kernel.org, Asias He <asias.hejun@gmail.com>
Subject: [PATCH 04/16] kvm tools: Add helpers to tell the type of a DHCP message
Date: Sun, 17 Jul 2011 16:56:52 +0800 [thread overview]
Message-ID: <1310893024-21615-5-git-send-email-asias.hejun@gmail.com> (raw)
In-Reply-To: <1310893024-21615-1-git-send-email-asias.hejun@gmail.com>
If DHCP DISCOVER or DHCP REQUEST is found, reply with DHCP OFFER or DHCP
ACK respectively.
Signed-off-by: Asias He <asias.hejun@gmail.com>
---
tools/kvm/include/kvm/uip.h | 6 ++++++
tools/kvm/net/uip/dhcp.c | 14 ++++++++++++++
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/tools/kvm/include/kvm/uip.h b/tools/kvm/include/kvm/uip.h
index 7c84dea..6534c7f 100644
--- a/tools/kvm/include/kvm/uip.h
+++ b/tools/kvm/include/kvm/uip.h
@@ -38,6 +38,12 @@
#define UIP_DHCP_MAGIC_COOKIE 0x63825363
#define UIP_DHCP_MAGIC_COOKIE_LEN 4
#define UIP_DHCP_OPTION_LEN (UIP_DHCP_VENDOR_SPECIFIC_LEN - UIP_DHCP_MAGIC_COOKIE_LEN)
+#define UIP_DHCP_DISCOVER 1
+#define UIP_DHCP_OFFER 2
+#define UIP_DHCP_REQUEST 3
+#define UIP_DHCP_ACK 5
+#define UIP_DHCP_TAG_MSG_TYPE 53
+#define UIP_DHCP_TAG_MSG_TYPE_LEN 1
/*
* IP package maxium len == 64 KBytes
* IP header == 20 Bytes
diff --git a/tools/kvm/net/uip/dhcp.c b/tools/kvm/net/uip/dhcp.c
index af0407f..0a6293a 100644
--- a/tools/kvm/net/uip/dhcp.c
+++ b/tools/kvm/net/uip/dhcp.c
@@ -1,5 +1,19 @@
#include "kvm/uip.h"
+static inline bool uip_dhcp_is_discovery(struct uip_dhcp *dhcp)
+{
+ return (dhcp->option[2] == UIP_DHCP_DISCOVER &&
+ dhcp->option[1] == UIP_DHCP_TAG_MSG_TYPE_LEN &&
+ dhcp->option[0] == UIP_DHCP_TAG_MSG_TYPE);
+}
+
+static inline bool uip_dhcp_is_request(struct uip_dhcp *dhcp)
+{
+ return (dhcp->option[2] == UIP_DHCP_REQUEST &&
+ dhcp->option[1] == UIP_DHCP_TAG_MSG_TYPE_LEN &&
+ dhcp->option[0] == UIP_DHCP_TAG_MSG_TYPE);
+}
+
bool uip_udp_is_dhcp(struct uip_udp *udp)
{
struct uip_dhcp *dhcp;
--
1.7.5.4
next prev parent reply other threads:[~2011-07-17 8:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-17 8:56 [PATCH 00/16] Implement DHCP support for user mode network Asias He
2011-07-17 8:56 ` [PATCH 01/16] kvm tools: Introduce uip_udp_make_pkg() Asias He
2011-07-17 8:56 ` [PATCH 02/16] kvm tools: Introduce struct uip_dhcp Asias He
2011-07-17 8:56 ` [PATCH 03/16] kvm tools: Add helper to tell if a UDP package is a DHCP package Asias He
2011-07-17 8:56 ` Asias He [this message]
2011-07-17 8:56 ` [PATCH 05/16] kvm tools: Get domain name and nameserver from host Asias He
2011-07-17 9:36 ` Sasha Levin
2011-07-18 4:48 ` Asias He
2011-07-18 8:27 ` Pekka Enberg
2011-07-17 8:56 ` [PATCH 06/16] kvm tools: Fill DHCP options with domain name and DNS server IP Asias He
2011-07-17 8:56 ` [PATCH 07/16] kvm tools: Fill all DHCP options Asias He
2011-07-17 8:56 ` [PATCH 08/16] kvm tools: Introduce uip_dhcp_make_pkg() Asias He
2011-07-17 8:56 ` [PATCH 09/16] kvm tools: Introduce uip_tx_do_ipv4_udp_dhcp() Asias He
2011-07-17 8:56 ` [PATCH 10/16] kvm tools: Get DNS information from host in uip_init() Asias He
2011-07-17 8:56 ` [PATCH 11/16] kvm tools: Handle DHCP package in gernal UDP processing path Asias He
2011-07-17 8:57 ` [PATCH 12/16] kvm tools: Introduce --guest-ip option Asias He
2011-07-17 8:57 ` [PATCH 13/16] kvm tools: Introduce --host-mac option Asias He
2011-07-17 8:57 ` [PATCH 14/16] kvm tools: Rename --host-ip-addr to --host-ip Asias He
2011-07-17 8:57 ` [PATCH 15/16] kvm tools: Initialize MAC address for virtio net properly Asias He
2011-07-17 8:57 ` [PATCH 16/16] kvm tools: Initialize MAC and IP address for uip properly Asias He
2011-07-18 10:20 ` [PATCH 00/16] Implement DHCP support for user mode network Pekka Enberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1310893024-21615-5-git-send-email-asias.hejun@gmail.com \
--to=asias.hejun@gmail.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=mingo@elte.hu \
--cc=penberg@kernel.org \
--cc=prasadjoshi124@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox