- # we check IP addresses for PC61
- if (@$pc > 8 && is_ipaddr($pc->[8])) {
- my $ip = $pc->[8];
- $ip =~ s/,/:/g;
- $ip =~ s/^::ffff://;
- if (DXCIDR::find($ip)) {
- dbg($line) if isdbg('nologchan');
- dbg("PCPROT: $ip in badip list, dropped");
- return;
+ # Populate the routing table
+ my $rn = Route::Node::get($pc->[7]);
+ unless ($rn) {
+ $rn = Route::Node->new($pc->[7]);
+ dbg("ROUTE $self->{call}: ADD NEW node: $pc->[7]") if isdbg('pc11');
+ }
+ my $r = Route::User::get($pc->[6]);
+ unless ($r) {
+ $rn->add_user($pc->[6], 0, undef);
+ dbg("ROUTE $self->{call}: ADD NEW user: $pc->[6] -> $pc->[7]") if isdbg('pc11');
+ $r = Route::User::get($pc->[6]);
+ }
+
+ # Add/Change any IP address info
+ if ($pcno == 61) {
+
+ # as we have a route to a user, if it (or the node) does not exist then create them
+ # link the user to the node if not already done.
+ # then add or alter the IP address
+ if ($pc->[8]) {
+ my $new = $pc->[8];
+ if ($r) {
+ if ($r->ip ne $new) {
+ if ($r->ip) {
+ my $old = $r->ip;
+ $r->ip($new);
+ dbg("ROUTE $self->{call}: ALTER IP node: $pc->[7] user: $pc->[6] old IP: '$old'-> new IP: '$new'") if isdbg('pc11');
+ } else{
+ $r->ip($new);
+ dbg("ROUTE $self->{call}: NEW IP node: $pc->[7] user: $pc->[6] IP: '$new'") if isdbg('pc11');
+ }
+ }
+ } else {
+ dbg("ROUTE $self->{call}: ADD Failed for node $pc->[7] user $pc->[6]") if isdbg('pc11');
+ }
+ } else {
+ dbg("PCPROT: ROUTE $self->{call} NO IP ADDRESS in '$line'!");