-/* $OpenBSD: clparse.c,v 1.96 2016/07/31 18:55:16 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.97 2016/08/16 21:57:51 krw Exp $ */
/* Parser for dhclient config and lease files. */
/*
* The new lease will supersede a lease of the same type and for
- * the same address.
+ * the same address or the same SSID.
*/
TAILQ_FOREACH_SAFE(lp, &client->leases, next, pl) {
- if (lp->address.s_addr == lease->address.s_addr &&
- lp->is_static == is_static) {
+ if (lp->is_static != is_static)
+ continue;
+ if ((strcmp(lp->ssid, ifi->ssid) == 0) ||
+ (lp->address.s_addr == lease->address.s_addr)) {
TAILQ_REMOVE(&client->leases, lp, next);
lp->is_static = 0; /* Else it won't be freed. */
free_client_lease(lp);
case TOK_SERVER_NAME:
lease->server_name = parse_string(cfile);
return;
+ case TOK_SSID:
+ val = parse_string(cfile);
+ if (val)
+ strlcpy(lease->ssid, val, sizeof(lease->ssid));
+ free(val);
+ return;
case TOK_RENEW:
lease->renewal = parse_date(cfile);
return;
-/* $OpenBSD: dhclient.c,v 1.379 2016/07/23 15:53:19 stsp Exp $ */
+/* $OpenBSD: dhclient.c,v 1.380 2016/08/16 21:57:51 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
#include <netinet/in.h>
#include <netinet/if_ether.h>
+#include <net80211/ieee80211.h>
+#include <net80211/ieee80211_ioctl.h>
+
#include <arpa/inet.h>
#include <ctype.h>
int
main(int argc, char *argv[])
{
+ struct ifreq ifr;
+ struct ieee80211_nwid nwid;
struct stat sb;
int ch, fd, socket_fd[2];
extern char *__progname;
struct passwd *pw;
char *ignore_list = NULL;
ssize_t tailn;
- int rtfilter, tailfd;
+ int rtfilter, sock, tailfd;
saved_argv = argv;
tzset();
+ /* Get the ssid if present. */
+ if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
+ error("Can't create socket to get ssid");
+ memset(&ifr, 0, sizeof(ifr));
+ memset(&nwid, 0, sizeof(nwid));
+ ifr.ifr_data = (caddr_t)&nwid;
+ strlcpy(ifr.ifr_name, ifi->name, sizeof(ifr.ifr_name));
+ if (ioctl(sock, SIOCG80211NWID, (caddr_t)&ifr) == 0) {
+ memset(ifi->ssid, 0, sizeof(ifi->ssid));
+ memcpy(ifi->ssid, nwid.i_nwid, nwid.i_len);
+ }
+ close(sock);
+
/* Put us into the correct rdomain */
ifi->rdomain = get_rdomain(ifi->name);
if (setrtable(ifi->rdomain) == -1)
/* Run through the list of leases and see if one can be used. */
TAILQ_FOREACH(lp, &client->leases, next) {
+ if (strcmp(lp->ssid, ifi->ssid) != 0)
+ continue;
if (addressinuse(lp->address, ifname) &&
strncmp(ifname, ifi->name, IF_NAMESIZE) != 0)
continue;
}
client->new = lease;
+ memcpy(client->new->ssid, ifi->ssid, sizeof(client->new->ssid));
/* Stop resending DHCPREQUEST. */
cancel_timeout();
TAILQ_FOREACH_SAFE(lease, &client->leases, next, pl) {
if (lease->is_static)
break;
+ if (client->active && strcmp(client->active->ssid,
+ lease->ssid) != 0)
+ continue;
if (client->active == lease)
seen = 1;
else if (lease->expiry <= cur_time || lease->address.s_addr ==
/* Run through the list of leases and see if one can be used. */
time(&cur_time);
TAILQ_FOREACH(lp, &client->leases, next) {
+ if (strcmp(lp->ssid, ifi->ssid) != 0)
+ continue;
if (addressinuse(lp->address, ifname) &&
strncmp(ifname, ifi->name, IF_NAMESIZE) != 0)
continue;
p += rslt;
sz -= rslt;
}
+ if (strlen(lease->ssid)) {
+ rslt = snprintf(p, sz, " ssid ");
+ if (rslt == -1 || rslt >= sz)
+ return (NULL);
+ p += rslt;
+ sz -= rslt;
+ rslt = pretty_print_string(p, sz, lease->ssid,
+ strlen(lease->ssid), 1);
+ if (rslt == -1 || rslt >= sz)
+ return (NULL);
+ p += rslt;
+ sz -= rslt;
+ rslt = snprintf(p, sz, ";\n");
+ if (rslt == -1 || rslt >= sz)
+ return (NULL);
+ p += rslt;
+ sz -= rslt;
+ }
for (i = 0; i < 256; i++) {
if (i == DHO_DHCP_CLIENT_IDENTIFIER) {
newlease->is_bootp = oldlease->is_bootp;
newlease->address = oldlease->address;
newlease->next_server = oldlease->next_server;
+ memcpy(newlease->ssid, oldlease->ssid, sizeof(newlease->ssid));
if (oldlease->server_name) {
newlease->server_name = strdup(oldlease->server_name);