1*79c60261Smiod /* $OpenBSD: pxe_udp.c,v 1.1 2014/11/19 20:09:58 miod Exp $ */
2*79c60261Smiod /* $NetBSD: net.c,v 1.14 1996/10/13 02:29:02 christos Exp $ */
3*79c60261Smiod
4*79c60261Smiod /*
5*79c60261Smiod * Copyright (c) 1992 Regents of the University of California.
6*79c60261Smiod * All rights reserved.
7*79c60261Smiod *
8*79c60261Smiod * This software was developed by the Computer Systems Engineering group
9*79c60261Smiod * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
10*79c60261Smiod * contributed to Berkeley.
11*79c60261Smiod *
12*79c60261Smiod * Redistribution and use in source and binary forms, with or without
13*79c60261Smiod * modification, are permitted provided that the following conditions
14*79c60261Smiod * are met:
15*79c60261Smiod * 1. Redistributions of source code must retain the above copyright
16*79c60261Smiod * notice, this list of conditions and the following disclaimer.
17*79c60261Smiod * 2. Redistributions in binary form must reproduce the above copyright
18*79c60261Smiod * notice, this list of conditions and the following disclaimer in the
19*79c60261Smiod * documentation and/or other materials provided with the distribution.
20*79c60261Smiod * 3. All advertising materials mentioning features or use of this software
21*79c60261Smiod * must display the following acknowledgement:
22*79c60261Smiod * This product includes software developed by the University of
23*79c60261Smiod * California, Lawrence Berkeley Laboratory and its contributors.
24*79c60261Smiod * 4. Neither the name of the University nor the names of its contributors
25*79c60261Smiod * may be used to endorse or promote products derived from this software
26*79c60261Smiod * without specific prior written permission.
27*79c60261Smiod *
28*79c60261Smiod * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29*79c60261Smiod * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30*79c60261Smiod * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31*79c60261Smiod * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32*79c60261Smiod * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33*79c60261Smiod * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34*79c60261Smiod * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35*79c60261Smiod * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36*79c60261Smiod * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37*79c60261Smiod * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38*79c60261Smiod * SUCH DAMAGE.
39*79c60261Smiod *
40*79c60261Smiod * @(#) Header: net.c,v 1.9 93/08/06 19:32:15 leres Exp (LBL)
41*79c60261Smiod */
42*79c60261Smiod
43*79c60261Smiod #include <sys/param.h>
44*79c60261Smiod #include <sys/socket.h>
45*79c60261Smiod
46*79c60261Smiod #include <net/if.h>
47*79c60261Smiod
48*79c60261Smiod #include <netinet/in.h>
49*79c60261Smiod #include <netinet/if_ether.h>
50*79c60261Smiod #include <netinet/ip.h>
51*79c60261Smiod #include <netinet/ip_var.h>
52*79c60261Smiod #include <netinet/udp.h>
53*79c60261Smiod #include <netinet/udp_var.h>
54*79c60261Smiod
55*79c60261Smiod #include <lib/libsa/stand.h>
56*79c60261Smiod #include <lib/libsa/net.h>
57*79c60261Smiod
58*79c60261Smiod #include <pxeboot.h>
59*79c60261Smiod
60*79c60261Smiod /* Caller must leave room for ethernet, ip and udp headers in front!! */
61*79c60261Smiod ssize_t
sendudp(struct iodesc * d,void * pkt,size_t len)62*79c60261Smiod sendudp(struct iodesc *d, void *pkt, size_t len)
63*79c60261Smiod {
64*79c60261Smiod return pxesendudp(d, pkt, len);
65*79c60261Smiod }
66*79c60261Smiod
67*79c60261Smiod /*
68*79c60261Smiod * Receive a UDP packet and validate it is for us.
69*79c60261Smiod * Caller leaves room for the headers (Ether, IP, UDP)
70*79c60261Smiod */
71*79c60261Smiod ssize_t
readudp(struct iodesc * d,void * pkt,size_t len,time_t tleft)72*79c60261Smiod readudp(struct iodesc *d, void *pkt, size_t len, time_t tleft)
73*79c60261Smiod {
74*79c60261Smiod return pxereadudp(d, pkt, len, tleft);
75*79c60261Smiod }
76