Index: trunk/cgi-bin/IPDB.pm
===================================================================
--- trunk/cgi-bin/IPDB.pm	(revision 673)
+++ trunk/cgi-bin/IPDB.pm	(revision 674)
@@ -99,4 +99,8 @@
 our $revgroup = 1;	# should probably be configurable somewhere
 our $rpccount = 0;
+
+# Largest inverse CIDR mask length to show per-IP rDNS list
+# (eg, NetAddr::IP->bits - NetAddr::IP->masklen)
+our $maxrevlist = 5;  # /27
 
 ##
Index: trunk/cgi-bin/MyIPDB.pm
===================================================================
--- trunk/cgi-bin/MyIPDB.pm	(revision 673)
+++ trunk/cgi-bin/MyIPDB.pm	(revision 674)
@@ -72,4 +72,9 @@
 #$IPDB::rpc_url = 'http://dnsadmin.example.com/dns-rpc.cgi';
 
+# Largest inverse CIDR mask length to show per-IP rDNS list
+# (eg, NetAddr::IP->bits - NetAddr::IP->masklen)
+# allowing longer than a /27 is probably going to slow things down;  longer than /29 will scroll.
+#$IPDB::maxrevlist = 8;  # v4 /24
+
 ## connectDB_My()
 # Wrapper for IPDB::connectDB
Index: trunk/cgi-bin/main.cgi
===================================================================
--- trunk/cgi-bin/main.cgi	(revision 673)
+++ trunk/cgi-bin/main.cgi	(revision 674)
@@ -462,4 +462,26 @@
     } # check for freeblocks assignment or IPDB-controlled assignment
 
+    # Generate the IP list for the new allocation in case someone wants to set per-IP rDNS right away.
+    # We don't do this on the previous page because we don't know how big a block or even what IP range
+    # it's for (if following the "normal" allocation process)
+    if ($IPDBacl{$authuser} =~ /c/
+	&& $cidr->masklen != $cidr->bits
+	&& ($cidr->bits - $cidr->masklen) <= $IPDB::maxrevlist
+	&& $webvar{alloctype} !~ /^.[dpi]/
+	# do we want to allow v6 at all?
+	#&& ! $cidr->{isv6}
+	) {
+      my @list;
+      foreach my $ip (@{$cidr->splitref()}) {
+        my %row;
+        $row{r_ip} = $ip->addr;
+        $row{iphost} = '';
+        push @list, \%row;
+      }
+      $page->param(r_iplist => \@list);
+      # We don't use this here, because these IPs should already be bare.
+      # ... or should we be paranoid?  Make it a config option?
+      #getRDNSbyIP($ip_dbh, type => $webvar{alloctype}, range => "$cidr", user => $authuser) );
+    }
   } # if ($webvar{alloctype} =~ /^.i$/)
 
Index: trunk/ipdb.css
===================================================================
--- trunk/ipdb.css	(revision 673)
+++ trunk/ipdb.css	(revision 674)
@@ -122,4 +122,57 @@
 }
 
+/* Reverse DNS odds and ends */
+div.rdns {
+	max-height: 20em;
+//	overflow-y: scroll;
+	overflow-x: hidden;
+//	display:inline-block;
+	width: 600px;
+//	width: 16em;
+	border: solid 1px #000000;
+}
+
+/* Abuse collapsible list tree for hideable page segment */
+
+/* hide the content <li> */
+.collapsible li > input + * {
+	display: none;
+}
+/* when the input is checked, show the content <li> */
+.collapsible li > input:checked + * {
+	display: block;
+}
+/* hide the checkbox */
+.collapsible li > input {
+	display: none;
+	margin: 0em;
+	padding: 0px;
+}
+/* mostly just making the input label clickable */
+.collapsible label {
+	cursor: pointer;
+	display: inline;
+	margin: 0em;
+	padding: 0px;
+	padding-left: 10px;
+}
+/* be nice if we could make this work without the HTML list structure... */
+.notalist {
+	list-style: none;
+	margin: 0;
+	padding: 3px;
+}
+
+/* done hideable page segment */
+
+/* Per-IP rDNS listings on edit allocation page */
+.revdata {
+	background-color: #C8D3DE;
+}
+.host {
+	width: 450px;
+//	width: 35em;
+}
+
 /* legacy defs */
 tr.hack {
Index: trunk/templates/confirm.tmpl
===================================================================
--- trunk/templates/confirm.tmpl	(revision 673)
+++ trunk/templates/confirm.tmpl	(revision 674)
@@ -32,7 +32,30 @@
 
 <tr class="row0">
-<td>Reverse DNS pattern:</td>
-<td><TMPL_IF rdns><TMPL_VAR NAME=rdns><TMPL_ELSE>[ Keep default ]</TMPL_IF>
+<td>Reverse DNS:</td>
+<td>
+<TMPL_IF rdns><TMPL_VAR NAME=rdns><TMPL_ELSE>[ Keep default ]</TMPL_IF>
 <input type="button" value=" ? " onclick="helpRDNS()" class="regular">
+<TMPL_IF r_iplist>
+<div class="rdns revdata">
+<ul class="collapsible notalist">
+<li><label for="per-iplist">Per-IP reverse entries (click to show) <img src="<TMPL_VAR NAME=webpath>/images/tree_open.png"></label>
+<input type="checkbox" id="per-iplist" />
+<ul class="notalist">
+<li>
+<table>
+<TMPL_LOOP name="r_iplist">
+<tr>
+<td><TMPL_VAR NAME=r_ip></td>
+<td><input class="host" name="host_<TMPL_VAR NAME=r_ip>" value="<TMPL_VAR NAME=iphost>"></td>
+</tr>
+</TMPL_LOOP>
+</table>
+</li>
+</ul>
+</li>
+</ul>
+</div>
+</TMPL_IF>
+
 </td>
 </tr>
