1/*
2 * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25#ifndef _S_DHCPLIB_H
26#define _S_DHCPLIB_H
27
28#include <mach/boolean.h>
29#include <sys/time.h>
30#import <netinet/bootp.h>
31#include "dhcp_options.h"
32#include "gen_dhcp_tags.h"
33
34void	dhcp_packet_print_cfstr(CFMutableStringRef str,
35				struct dhcp * dp, int pkt_len);
36void	dhcp_packet_fprint(FILE * f, struct dhcp * dp, int pkt_len);
37void	dhcp_packet_print(struct dhcp * dp, int pkt_len);
38
39/*
40 * Function: is_dhcp_packet
41 *
42 * Purpose:
43 *   Return whether packet is a DHCP packet.
44 *   If the packet contains DHCP message ids, then its a DHCP packet.
45 */
46static __inline__ boolean_t
47is_dhcp_packet(dhcpol_t * options, dhcp_msgtype_t * msgtype)
48{
49    if (options) {
50	u_char * opt;
51	int opt_len;
52
53	opt = dhcpol_find(options, dhcptag_dhcp_message_type_e,
54			  &opt_len, NULL);
55	if (opt != NULL) {
56	    if (msgtype)
57		*msgtype = *opt;
58	    return (TRUE);
59	}
60    }
61    return (FALSE);
62}
63
64boolean_t
65dhcp_packet_match(struct bootp * packet, u_int32_t xid,
66		  u_char hwtype, void * hwaddr, int hwlen);
67
68#endif /* _S_DHCPLIB_H */
69