+$max = 0;
+
+sub count
+{
+ my $n = scalar (keys %list);
+ $max = $n if $n > $max;
+ return $n;
+}
+
+sub max
+{
+ count();
+ return $max;
+}
+
+#
+# this routine handles the possible adding of an entry in the routing
+# table. It will only add an entry if it is new. It may have all sorts of
+# other side effects which may include fixing up other links.
+#
+# It will return a node object if (and only if) it is a completely new
+# object with that callsign. The upper layers are expected to do something
+# sensible with this!
+#
+# called as $dxchan->add(call, dxchan, version, flags)
+#
+
+sub add
+{
+ my $dxchan = shift;
+ my $call = uc shift;
+ confess "Route::add trying to add $call to myself" if $call eq $dxchan->{call};
+ my $self = get($call);
+ if ($self) {
+ $self->_adddxchan($dxchan);
+ $dxchan->_addnode($self);
+ return undef;
+ }
+ $self = $dxchan->new($call, @_);
+ $dxchan->_addnode($self);
+ return $self;
+}
+
+#
+# this routine is the opposite of 'add' above.
+#
+# It will return an object if (and only if) this 'del' will remove
+# this object completely
+#
+
+sub del
+{
+ my $self = shift;
+ my $pref = shift;
+
+ # delete dxchan from this call's dxchan list
+ $pref->_delnode($self);
+ $self->_deldxchan($pref);
+ my @nodes;
+ my $ncall = $self->{call};
+
+ # is this the last connection, I have no dxchan anymore?
+ unless (@{$self->{dxchan}}) {
+ foreach my $rcall (@{$self->{nodes}}) {
+ next if grep $rcall eq $_, @_;
+ my $r = Route::Node::get($rcall);
+ push @nodes, $r->del($self, $ncall, @_) if $r;
+ }
+ $self->_del_users;
+ delete $list{$self->{call}};
+ push @nodes, $self;
+ }
+ return @nodes;
+}