[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 1.5 Install and the Networks table
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday 20 March 2002 18:23 pm, B Bowers wrote:
> Hi all,
>
>
> Hitesh, I want to second Rob Mitzel's comment from a prior post. I've been
> watching the software progression for a little while as well. And I must
> say that I'm very impressed!
Thanks!
> I'm new to PostgreSQL so this is probably a
> very simple problem. I have a spreadsheet with several hundred netblocks
> that are allocated to different devices. What I'm trying to do is find a
> way to do a mass import of this data. I've tried doing several manual
> inserts of the data into the 'networks' table but it is refusing it since
> the 'network' field is empty.
>
> I can supply all of the other data for the relevant fields but I am not
> familiar enough with Postgres to understand what hash is being used to
> generate the 'network' column. Any advice or suggestions would be greatly
> appreciated!
>
I have attached a short perl script that will convert a network number
(x.x.x.x) into the interger format used for the network field. For instance
if you the block 10.0.0.0/16 run:
perl ip2int.pl 10.0.0.0
(notice you leave off the mask length.. that goes in the masklen field)
the output of the script is the number '167772160'. Just put this number in
the network field for that block and your good to go.
Let us know how this works for you.
- --
+---------------------------------+----------------------------+
| Hitesh Patel | Lead Developer |
| hitesh@presys.com | NorthStar |
+---------------------------------+----------------------------+
| NorthStar: http://www.brownkid.net/NorthStar/ |
| PGP Key: http://www.brownkid.net/pgpkey.asc |
+--------------------------------------------------------------+
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE8mZccCws8KqPtd2URAslAAJ9ZjXW8SIMMnRPEOQTrW5/NsRp/nQCfUFi8
LSCFY8RZFOIUiKzzyGEkFLM=
=40pf
-----END PGP SIGNATURE-----
#
# Copyright (C) 2001, Hitesh Patel <hitesh@presys.com>.
# All rights resevered.
#
# This file is part of NorthStar and is covered under
# the terms of the Apache Software License version 1.1
#
# A copy of this license is included in the LICENSE file
#
# $Header: /cvsroot/NorthStar/lib/util.lib,v 1.22 2002/03/18 08:54:12 brownkid Exp $
#
print IP_DQToInt($ARGV[0]) . "\n";
sub IP_DQToBin {
my @dq;
my $q;
my $i;
my $bin;
foreach $q (split /\./,$_[0]) {
push @dq,$q;
}
for ($i = 0; $i < 4 ; $i++) {
if (! defined $dq[$i]) {
push @dq,0;
}
}
$bin = pack("CCCC",@dq); # 4 unsigned chars
return $bin;
}
sub IP_BinToInt {
return unpack("N",$_[0]);
}
sub IP_DQToInt {
return(IP_BinToInt(IP_DQToBin($_[0])));
}