I got lazy after having to create a load of DHCP scopes for Cisco Lightweight Access Points, each requiring Option 43 in TLV format. And now you can be lazy too.

Save the following as a HTML file and open in your favorite browser. In the text area enter your WLC IP addresses one per line and hit submit. This will generate the hex string to use in DHCP Option 43. Alternatively I’ve also put the code in to jsfiddle here.

<html>
<head>
<title>Cisco LWAP Option 43 TLV generator</title>
</head>
<body>

<script>
function ip2hex(ip) {
	var octets = ip.split(".");
	var hex = "";
	
	for(var i = 0; i < octets.length; i++) {
		hex += dec2hex(parseInt(octets[i]));
	}

	return hex;
}

function dec2hex(dec) {
	return (dec + 0x10000).toString(16).substr(-2);
}

function option43() {
	var ips = document.getElementById("ips").value.split("\n");
	var hex = "";
	
	document.getElementById("option43").innerText = "f1";
	
	document.getElementById("option43").innerText = document.getElementById("option43").innerText + dec2hex(ips.length * 4);
	
	for (var i = 0; i < ips.length; i++) {
		hex += ip2hex(ips[i]);
	}

	document.getElementById("option43").innerText = document.getElementById("option43").innerText + hex;
	
	return false;
}
</script>

<form action="" onsubmit="return option43();">
<textarea rows="4" cols="15" id="ips"></textarea><br />
<input type="submit" />
</form>

<div id="option43"></div>

</body>
</html>

 

 

Leave a Reply

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.