dhcp-network.c revision 68328ed63ce3a938679caf41db64e068234a0ca8
/***
This file is part of systemd.
Copyright (C) 2013 Intel Corporation. All rights reserved.
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <string.h>
#include <linux/if_packet.h>
#include <net/ethernet.h>
#include <stdio.h>
#include <unistd.h>
#include "socket-util.h"
#include "dhcp-internal.h"
struct sock_filter filter[] = {
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, offsetof(DHCPPacket, ip.frag_off)), /* A <- Flags + Fragment offset */
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, DHCP_PORT_CLIENT, 1, 0), /* UDP destination port == DHCP client port ? */
/* TODO: match chaddr */
};
struct sock_fprog fprog = {
};
_cleanup_close_ int s = -1;
int r, on = 1;
if (s < 0)
return -errno;
if (r < 0)
return -errno;
if (r < 0)
return -errno;
if (r < 0)
return -errno;
r = s;
s = -1;
return r;
}
union sockaddr_union src = {
};
_cleanup_close_ int s = -1;
int r, tos = IPTOS_CLASS_CS6;
if (s < 0)
return -errno;
if (r < 0)
return -errno;
if (address == INADDR_ANY) {
int on = 1;
if (r < 0)
return -errno;
if (r < 0)
return -errno;
if (r < 0)
return -errno;
}
if (r < 0)
return -errno;
r = s;
s = -1;
return r;
}
int r;
if (r < 0)
return -errno;
return 0;
}
union sockaddr_union dest = {
};
int r;
assert(s >= 0);
if (r < 0)
return -errno;
return 0;
}