From patchwork Sun Jul 17 08:56:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 982962 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6H8xW24023627 for ; Sun, 17 Jul 2011 08:59:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753859Ab1GQI72 (ORCPT ); Sun, 17 Jul 2011 04:59:28 -0400 Received: from mail-iy0-f174.google.com ([209.85.210.174]:39735 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754024Ab1GQI70 (ORCPT ); Sun, 17 Jul 2011 04:59:26 -0400 Received: by mail-iy0-f174.google.com with SMTP id 12so2303241iyb.19 for ; Sun, 17 Jul 2011 01:59:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=TWPktIG09vB7Z14dV+aDKWpoO47wKIJr7JYgpJtNWKs=; b=nlPszbOzIU2yStNA77eervuPEC+43W8pUYNF7e3YgWTMEnoDmHp3QQZBTK2wL19t5y SKHUyvDw/69oVL6bfJ/RMFOMqH8h7y+0z9+bTil+rrK4t+1m1GJe40TiQYRonYKAnprI CzNEmBqxussaImfBiWxzXk0zhI7X//mzBvNLs= Received: by 10.42.151.138 with SMTP id e10mr5850327icw.251.1310893166478; Sun, 17 Jul 2011 01:59:26 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id us2sm3593680icb.19.2011.07.17.01.59.23 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 17 Jul 2011 01:59:26 -0700 (PDT) From: Asias He To: Pekka Enberg Cc: Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi , kvm@vger.kernel.org, Asias He Subject: [PATCH 08/16] kvm tools: Introduce uip_dhcp_make_pkg() Date: Sun, 17 Jul 2011 16:56:56 +0800 Message-Id: <1310893024-21615-9-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1310893024-21615-1-git-send-email-asias.hejun@gmail.com> References: <1310893024-21615-1-git-send-email-asias.hejun@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 17 Jul 2011 08:59:33 +0000 (UTC) This patch cooks a DHCP package. Signed-off-by: Asias He --- tools/kvm/net/uip/dhcp.c | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/tools/kvm/net/uip/dhcp.c b/tools/kvm/net/uip/dhcp.c index 42e354c..612e024 100644 --- a/tools/kvm/net/uip/dhcp.c +++ b/tools/kvm/net/uip/dhcp.c @@ -132,3 +132,25 @@ static int uip_dhcp_fill_option(struct uip_info *info, struct uip_dhcp *dhcp, in return 0; } + +static int uip_dhcp_make_pkg(struct uip_info *info, struct uip_udp_socket *sk, struct uip_buf *buf, u8 reply_msg_type) +{ + struct uip_dhcp *dhcp; + + dhcp = (struct uip_dhcp *)buf->eth; + + dhcp->msg_type = 2; + dhcp->client_ip = 0; + dhcp->your_ip = htonl(info->guest_ip); + dhcp->server_ip = htonl(info->host_ip); + dhcp->agent_ip = 0; + + uip_dhcp_fill_option(info, dhcp, reply_msg_type); + + sk->sip = htonl(info->guest_ip); + sk->dip = htonl(info->host_ip); + sk->sport = htons(UIP_DHCP_PORT_CLIENT); + sk->dport = htons(UIP_DHCP_PORT_SERVER); + + return 0; +}