aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoachim Tingvold <joachim@tingvold.com>2017-04-07 21:21:43 +0200
committerJoachim Tingvold <joachim@tingvold.com>2017-04-07 21:21:43 +0200
commit80e7346876c24dc68ff10fd3ec77b62165ed501a (patch)
tree66a8b6eeb3a1aafc3949cef35662d8737dcc76cc
parent6bea366658a912a777be2a3748fe49475f7ce73f (diff)
Fix FAP-config in DHCP.
-rwxr-xr-xbootstrap/make-dhcpd.pl66
-rwxr-xr-xbootstrap/make-dhcpd6.pl10
-rwxr-xr-xinclude/config.pm.dist10
3 files changed, 74 insertions, 12 deletions
diff --git a/bootstrap/make-dhcpd.pl b/bootstrap/make-dhcpd.pl
index 3dbefbd..7bd1a5c 100755
--- a/bootstrap/make-dhcpd.pl
+++ b/bootstrap/make-dhcpd.pl
@@ -19,6 +19,7 @@ my $dhcpd_conf = $dhcpd_base . "dhcpd.conf";
my $dhcpd_pxeconf = $dhcpd_base . "v4-pxe-boot.conf";
my $dhcpd_wlc_conf = $dhcpd_base . "v4-wlc.conf";
my $dhcpd_voip_conf = $dhcpd_base . "v4-voip.conf";
+my $dhcpd_fap_conf = $dhcpd_base . "v4-fap.conf";
# primary
my $pri_range = Net::IP->new($nms::config::pri_net_v4) or die ("pri_range fail");
@@ -101,6 +102,7 @@ include "/etc/dhcp/v4-generated-include.conf";
include "$dhcpd_pxeconf";
include "$dhcpd_wlc_conf";
include "$dhcpd_voip_conf";
+include "$dhcpd_fap_conf";
EOF
close DHCPDFILE;
@@ -144,7 +146,7 @@ class "access-points" {
# I.e if "Access Point", you have to use (0, 12)
match if substring (option vendor-class-identifier, 0, 12) = "Access Point";
vendor-option-space WLC;
- option WLC.controller-address "$nms::config::wlc1";
+ option WLC.controller-address "$nms::config::wlc1_v4";
}
EOF
close WLCFILE;
@@ -164,18 +166,72 @@ class "cisco-voip-lan" {
match if substring (option vendor-class-identifier, 0, 28) = "Cisco Systems, Inc. IP Phone";
vendor-option-space CiscoVOIP;
log( info, concat( "LOLOPHONE: " , option vendor-class-identifier ));
- option CiscoVOIP.cm-tftp-server $nms::config::voip1;
- next-server $nms::config::voip1;
+ option CiscoVOIP.cm-tftp-server $nms::config::voip1_v4;
+ next-server $nms::config::voip1_v4;
}
class "cisco-voip-wlan" {
match if substring (option vendor-class-identifier, 0, 33) = "Cisco Systems Inc. Wireless Phone";
vendor-option-space CiscoVOIP;
log( info, concat( "BANANAPHONE: " , option vendor-class-identifier ));
- option CiscoVOIP.cm-tftp-server $nms::config::voip1;
- next-server $nms::config::voip1;
+ option CiscoVOIP.cm-tftp-server $nms::config::voip1_v4;
+ next-server $nms::config::voip1_v4;
}
EOF
close VOIPFILE;
}
+# Create FAP/Gondul config
+if ( not -f $dhcpd_fap_conf )
+{
+ print STDERR "Creating file " . $dhcpd_fap_conf . "\n";
+ open FAPFILE, ">" . $dhcpd_fap_conf or die ( $! . " " . $dhcpd_fap_conf);
+
+ print FAPFILE <<"EOF";
+# Define structure of option 43 ( Zero Touch Protocol options)
+option space ztp;
+#option ztp.image-file-name code 0 = text;
+option ztp.config-file-name code 1 = text;
+option ztp.image-file-type code 2 = text;
+option ztp.transfer-mode code 3 = text;
+option ztp.alt-image-file-name code 4 = text;
+option ztp-encapsulation code 43 = encapsulate ztp;
+
+# define option 150 - TFTP server (used for defining HTTP server for option 43)
+option option-150 code 150 = { ip-address };
+
+# define option 60 - used for classifying ZTP clients ("vendor class identifier")
+option vendor-class-identifier code 60 = text;
+
+# set short leasetime, so that it times out at reboot
+default-lease-time 120;
+max-lease-time 120;
+
+# define ranges
+group {
+ # No DDNS
+ ddns-updates off;
+ ddns-hostname = none;
+ ddns-domainname = none;
+
+ # supershort leasetime
+ default-lease-time 120;
+ max-lease-time 120;
+
+ # ZTP Settings
+ option option-150 $nms::config::fap_server_v4;
+ option tftp-server-name "$nms::config::fap_server_v4";
+ option ztp.transfer-mode "http";
+ option ztp.config-file-name = concat("api/config/", (option agent.circuit-id));
+
+ #option ztp.image-file-name "files/jinstall-ex-2200-14.1X53-D15.2-domestic-signed.tgz";
+
+
+}
+
+EOF
+ close FAPFILE;
+}
+
+
+
diff --git a/bootstrap/make-dhcpd6.pl b/bootstrap/make-dhcpd6.pl
index f678c14..dc3f8b9 100755
--- a/bootstrap/make-dhcpd6.pl
+++ b/bootstrap/make-dhcpd6.pl
@@ -134,7 +134,7 @@ set vendor-string = option vendor-class-identifier;
class "access-points" {
match if substring (option vendor-class-identifier, 0, 8) = "Access Point";
vendor-option-space AP;
- option AP.server-address $nms
function popup_search(searchform) {
	searchform = document.getElementById(searchform);
	searchform.target = 'popup_' + window.name;
	searchform.navtarget.value = window.name;
	window.open('about:blank', 'popup_' + window.name,
		'resizable,width=400,height=600,menubar=yes,status=yes,scrollbars=yes');
	return true;
}

function popup_anchor() {
	var anchor = this;
	window.open('about:blank', 'popup_' + window.name,
		'resizable,width=400,height=600,location=no,menubar=yes,scrollbars=yes'); 

	anchor.target = 'popup_' + window.name;

	if (anchor.href.indexOf("navtarget=") >= 0)
		return true;

	if (anchor.href.indexOf("?") >= 0) {
		anchor.href = anchor.href + ';navtarget=' + window.name;
	}
	else {
		anchor.href = anchor.href + '?navtarget=' + window.name;
	}
	return true;
}

function navigate_here(searchform) {
	searchform = document.getElementById(searchform);
	searchform.target = window.name;
	return true;
}

function window_unique(serial) {
	if (!window.name)
		window.name = 'lxr_source_' + serial;
}

function do_search(form) {
	if (use_ajax_navigation) {
		var res = document.getElementById('search_results');
		res.style.display = 'block';
		res.innerHTML = '<div class="progress">Searching...</div>';
	
		pjx_search(['type__search',
			    'search', 'v', 'tree__' + loaded_tree, 'NO_CACHE'],
			   ['search_results']);
		return false;
	}
	else if (use_popup_navigation) {
		form.target = 'popup_' + window.name;
		form.navtarget.value = window.name;
		reswin = window.open('about:blank', 'popup_' + window.name,
			'resizable,width=400,height=600,location=no,menubar=yes,scrollbars=yes');
	}
	return true;
}

function hide_search() {
	var res = document.getElementById('search_results');
	res.style.display = 'none';
	return false;
}

var loaded_hash;
var loaded_tree;
var loaded_file;
var loaded_ver;
var loaded_line;

var pending_tree;
var pending_file;
var pending_ver;
var pending_line;

function ajax_nav() {
	var file = this.href.replace(/^(http:.*?\/.*?[+][*]\/|)/, '');
	load_file(loaded_tree, file, loaded_ver, '');
	return false;
}

function ajax_jumpto_line() {
	location.hash = location.hash.replace(/\#L\d+$/, '') + 
		this.href.replace(/.*(\#L\d+)$/, '$1');
	check_hash_navigation();	
	return false;
}

function ajax_prefs() {
	if (use_ajax_navigation) {
		var full_path = location.href.split(/#/)[0];
		full_path = full_path + '/' + loaded_tree;
		if (loaded_ver) {
			full_path = full_path + '+' + loaded_ver;
		}
		full_path = full_path + '/+prefs?return=' + loaded_file.replace(/^\/?$/, '.');
		location = full_path;
		return false;
	}
	else {
		return true;
	}
}

var hash_check;
function check_hash_navigation() {
	if (location.hash != loaded_hash) {
		if (location.hash.replace(/\#L\d+$/, '') == 
		    loaded_hash.replace(/\#L\d+$/, ''))
		{
			var l = location.hash.replace(/.*#(L\d+)$/, '$1');
			var a = document.getElementById(l);
			if (l && a) {
				a.name = location.hash.replace(/^\#/, '');
				location.hash = a.name;
				loaded_hash = location.hash;
			}
			hash_check = setTimeout('check_hash_navigation()', 50);
		}
		else {
			load_content();		
		}
	}
	else {
		hash_check = setTimeout('check_hash_navigation()', 50);
	}
}

function load_file(tree, file, ver, line) {
	if (!use_ajax_navigation) {
		return true;
	}

	if (hash_check) {
		clearTimeout(hash_check);
	}

	if ((pending_tree == tree) &&
	    (pending_file == file) &&
	    (pending_ver == ver))
	{
	        if (line > 0)
			line = '#L' + line;
		location.hash = location.hash.replace(/\#L\d+$/, '') + line;
		check_hash_navigation();
		return false;
	}


	var res = document.getElementById('content');

	res.innerHTML = '<div class="progress">Loading...</div>';
	pending_line = line;
	pending_tree = tree;
	pending_file = file;
	if (ver) {
		pending_ver = ver;
	}
	else {
		pending_ver = '';
	}
	
	if (!file)
		file = '/';
	if (line < 1)
		line = 1;
	pjx_load_file(['tree__' + tree, 'file__' + file, 'v__' + ver,
		       'line__' + line, 'NO_CACHE'],
		      [load_file_finalize]);
	return false;
}

function load_file_finalize(content) {
	var res = document.getElementById('content');
	res.innerHTML = 'Done';
	res.innerHTML = content;
	var head = document.getElementById('current_path');
	head.innerHTML = '<a class=\"fref\" href=\".\">' + pending_tree + '</a>';
	var path_walked = '';
	var elems = pending_file.split(/\//);
	for (var i=0; i<elems.length; i++) {
		if (elems[i] != '') {
			head.innerHTML = head.innerHTML + '/' +
				'<a class=\"fref\" href=\"' + path_walked + elems[i] +
				'\">' + elems[i] + '</a>';
			path_walked = path_walked + elems[i] + '/';
		}
	}
	document.title = 'LXR ' + pending_tree + '/' + pending_file;

	var full_tree = pending_tree;
	if (pending_ver) {
		full_tree = full_tree + '+' + pending_ver;
	}
	var full_path = full_tree + '/' + pending_file.replace(/^\/?/, '');

	var pre = document.getElementById('file_contents');
	if (pre && pre.className == 'partial') {
		pjx_load_file(['tree__' + pending_tree, 'file__' + pending_file,
			       'v__' + pending_ver, 'full__1', 'NO_CACHE'],
			      [load_file_finalize]);
	}

	var print = document.getElementById('lxr_print');
	var dirlist = document.getElementById('content_dir');
	if (dirlist) {
		print.style.display = 'none';
	}
	else {
		var pform = document.getElementById('print_form');
		pform.action = '../' + full_tree + '/+print=' + 
			pending_file.replace(/^\/?/, '');
		print.style.display = 'inline';
	}

	if (hash_check) {
		clearTimeout(hash_check);
	}
	if (pending_line) {
		var anchor = document.getElementById('L' + pending_line);
		if (anchor) {
			anchor.name = full_path + '#L' + pending_line;
			location.hash = full_path + '#L' + pending_line;
		}
		else {
			location.hash = full_path;
		}
		loaded_line = pending_line;
	}
	else {
		location.hash = full_path;
		loaded_line = 0;
	}
	loaded_hash = location.hash;
	loaded_tree = pending_tree;
	loaded_file = pending_file;
	loaded_ver = pending_ver;
	hash_check = setTimeout('check_hash_navigation()', 50);

//	TODO: This really takes oodles of time.  Consider coding into html.
	var i;
	for (i = 0; i < document.links.length; i++) {
		if (document.links[i].className == 'fref') {
			document.links[i].onclick = ajax_nav;
		}
		else if (document.links[i].className == 'line') {
			document.links[i].onclick = ajax_jumpto_line;
		}
		else if (document.links[i].className == 'sref' || 
		    document.links[i].className == 'falt')
		{
			document.links[i].onclick = ajax_lookup_anchor; 
		}

	}
}

function load_content() {
	if (!use_ajax_navigation) {
		return false;
	}
	var tree = location.hash.split('/', 1);
	tree = tree[0].split(/[+]/);
	var ver = tree[1] || '';
	tree = tree[0].replace(/^#/, '');
	var file = location.hash.replace(/^[^\/]*\/?/, '');
	var line = file.replace(/.*\#L(\d+)/, '$1');
	file = file.replace(/\#L\d+$/, '');
	load_file(tree, file, ver, line);

	pjx_releases(['tree__' + tree, 'NO_CACHE'],
		     [load_content_finalize]);
}

function load_content_finalize(content) {
	var res = document.getElementById('ver_select');
	res.innerHTML = content;
	var verlist = document.getElementById('v');
	verlist.value = pending_ver;
}

function update_version(verlist, base_url, tree, defversion, path) {
	if (use_ajax_navigation) {
		var file = location.hash.replace(/^[^\/]*\//, '');
		var line = file.replace(/.*\#L(\d+)/, '$1');
		file = file.replace(/\#L\d*$/, '');
	
		load_file(loaded_tree, file, verlist.value, line);
		return false;
	}
	else {
		var newurl = base_url.replace(/[^\/]*\/?$/, '');
		if (verlist.value == defversion) {
			newurl = newurl + tree;
		}
		else {
			newurl = newurl + tree + '+' + verlist.value;
		}
		newurl = newurl + '/' + path.replace(/^\//, '');
		document.location = newurl;
	}
}

function next_version() {
	var verlist = document.getElementById('v');
	if (verlist.selectedIndex > 0) {
		verlist.selectedIndex = verlist.selectedIndex - 1;
		update_version(verlist, '', '', '', '');
	}
	return false;
}

function previous_version() {
	var verlist = document.getElementById('v');
	if (verlist.selectedIndex < verlist.length - 1) {
		verlist.selectedIndex = verlist.selectedIndex + 1;
		update_version(verlist, '', '', '', '');
	}
	return false;
}

function popup_prepare(serial) {
	window_unique(serial);
	var i;
	for (i = 0; i < document.links.length; i++) {
		if (document.links[i].className == 'sref' || 
		    document.links[i].className == 'falt')
		{
			document.links[i].onclick = popup_anchor;
		}
	}
}

function ajax_lookup_anchor(event, anchor) {
	if (!use_ajax_navigation)
		return true;

	if (!anchor)
		anchor = this;
	
	lookup = anchor.href.replace(/^(http:.*?\/.*?[+][*]\/|)/, '');

	var lvar = document.getElementById('ajax_lookup');
	lvar.value = lookup;

	var res = document.getElementById('search_results');
	res.style.display = 'block';
	res.innerHTML = '<div class="progress">Searching...</div>';

	pjx_search(['ajax_lookup', 'v', 'tree__' + loaded_tree, 'NO_CACHE'],
		   ['search_results']);
	return false;
}