From owner-svn-src-all@freebsd.org Sun May 28 21:30:02 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6AA1CD85E3A; Sun, 28 May 2017 21:30:02 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2DE4F1F53; Sun, 28 May 2017 21:30:02 +0000 (UTC) (envelope-from tsoome@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v4SLU1nU006717; Sun, 28 May 2017 21:30:01 GMT (envelope-from tsoome@FreeBSD.org) Received: (from tsoome@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v4SLU1FX006716; Sun, 28 May 2017 21:30:01 GMT (envelope-from tsoome@FreeBSD.org) Message-Id: <201705282130.v4SLU1FX006716@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: tsoome set sender to tsoome@FreeBSD.org using -f From: Toomas Soome Date: Sun, 28 May 2017 21:30:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319085 - head/lib/libstand X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 May 2017 21:30:02 -0000 Author: tsoome Date: Sun May 28 21:30:01 2017 New Revision: 319085 URL: https://svnweb.freebsd.org/changeset/base/319085 Log: use the same option list for dhcp discovery and request The DHCP client is supposed to use the same option request list for both DHCP discovery and request. This will also allow us to fill the list in single function. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10981 Modified: head/lib/libstand/bootp.c Modified: head/lib/libstand/bootp.c ============================================================================== --- head/lib/libstand/bootp.c Sun May 28 21:20:55 2017 (r319084) +++ head/lib/libstand/bootp.c Sun May 28 21:30:01 2017 (r319085) @@ -93,6 +93,35 @@ struct in_addr dhcp_serverip; struct bootp *bootp_response; size_t bootp_response_size; +static void +bootp_fill_request(unsigned char *bp_vend) +{ + /* + * We are booting from PXE, we want to send the string + * 'PXEClient' to the DHCP server so you have the option of + * only responding to PXE aware dhcp requests. + */ + bp_vend[0] = TAG_CLASSID; + bp_vend[1] = 9; + bcopy("PXEClient", &bp_vend[2], 9); + bp_vend[11] = TAG_USER_CLASS; + /* len of each user class + number of user class */ + bp_vend[12] = 8; + /* len of the first user class */ + bp_vend[13] = 7; + bcopy("FreeBSD", &bp_vend[14], 7); + bp_vend[21] = TAG_PARAM_REQ; + bp_vend[22] = 7; + bp_vend[23] = TAG_ROOTPATH; + bp_vend[24] = TAG_HOSTNAME; + bp_vend[25] = TAG_SWAPSERVER; + bp_vend[26] = TAG_GATEWAY; + bp_vend[27] = TAG_SUBNET_MASK; + bp_vend[28] = TAG_INTF_MTU; + bp_vend[29] = TAG_SERVERID; + bp_vend[30] = TAG_END; +} + /* Fetch required bootp infomation */ void bootp(int sock) @@ -136,31 +165,8 @@ bootp(int sock) bp->bp_vend[4] = TAG_DHCP_MSGTYPE; bp->bp_vend[5] = 1; bp->bp_vend[6] = DHCPDISCOVER; + bootp_fill_request(&bp->bp_vend[7]); - /* - * We are booting from PXE, we want to send the string - * 'PXEClient' to the DHCP server so you have the option of - * only responding to PXE aware dhcp requests. - */ - bp->bp_vend[7] = TAG_CLASSID; - bp->bp_vend[8] = 9; - bcopy("PXEClient", &bp->bp_vend[9], 9); - bp->bp_vend[18] = TAG_USER_CLASS; - /* len of each user class + number of user class */ - bp->bp_vend[19] = 8; - /* len of the first user class */ - bp->bp_vend[20] = 7; - bcopy("FreeBSD", &bp->bp_vend[21], 7); - bp->bp_vend[28] = TAG_PARAM_REQ; - bp->bp_vend[29] = 7; - bp->bp_vend[30] = TAG_ROOTPATH; - bp->bp_vend[31] = TAG_HOSTNAME; - bp->bp_vend[32] = TAG_SWAPSERVER; - bp->bp_vend[33] = TAG_GATEWAY; - bp->bp_vend[34] = TAG_SUBNET_MASK; - bp->bp_vend[35] = TAG_INTF_MTU; - bp->bp_vend[36] = TAG_SERVERID; - bp->bp_vend[37] = TAG_END; #else bp->bp_vend[4] = TAG_END; #endif @@ -196,10 +202,7 @@ bootp(int sock) bp->bp_vend[20] = 4; leasetime = htonl(300); bcopy(&leasetime, &bp->bp_vend[21], 4); - bp->bp_vend[25] = TAG_CLASSID; - bp->bp_vend[26] = 9; - bcopy("PXEClient", &bp->bp_vend[27], 9); - bp->bp_vend[36] = TAG_END; + bootp_fill_request(&bp->bp_vend[25]); expected_dhcpmsgtype = DHCPACK;