Suggestions for addresspool changes

- unused functions are now #ifdef NEVER.
  They can be checked by the compiler if NEVER is defined.

- new comments (need to be checked).  Comments with ??? indicate
  things not understood.

- removed __LINE__ uses from logging.  Each message is unique so this
  added nothing.  Furthermore it would create uninteresting differences
  in output logs making testing more difficult.

- changed calls to pfreeany to pfree where this was obviously correct.

- deleted unused struct ip_pool_old

- moved struct lease_addr and struct ip_pool from addresspool.h to addresspool.h
  These should be opaque types outside addresspool.c.

- moved pluto_pools from addresspool.h to addresspool.h
  This made a slight change to install_addresspool necessary.

- tried to clarify use of struct lease_addr's "ends" field.
  Renamed it "ended".  Reworked assignments of boolean constants
  to this field.  Added a passert to enforce an unstated assumption
  that the current time_t could not be 0.

- renamed struct ip_pools "lease" field to "leases" since it is the
  head of a list of leases.

- several while-loops changed to for-loops to clarify their structure.
  To make the code more understandable, tried to use the same idiom
  whenever reasonable.  Simplified loops that were meant to remove
  an item from a list.

- where easy, reduced the scope of local variables.

- rel_lease_entry, free_lease: changed the name of the lease index
  parameter from "lease" to i: a lease index is not a lease!

- rel_lease_entry??

- free_lease renamed to free_lease_for_index because that's what it
  does.  "free_lease" suggests a function that takes a lease argument.

- made rel_lease_addr return bool, not int (reflects actual code)

- changed unreference_addresspool to properly remove the addresspool
  from the list of pools.

- The code in connections.c that called free_addresspool_entry ignored
  the return value and so would have broken the addresspool list.
  Besides, it really should have called unreference_addresspool since
  there might be other references to this pool.  Changed to use
  unreference_addresspool.

- free_addresspool didn't unlink the pool from the pluto_pools list.
  Fixed.

- free_addresspool_entry had a number of problems.  Deleted.  Use
  other functions in its place (free_addresspool,
  unreference_addresspool).

  + free_addresspool_entry was misnamed.  If the pool had a
    refcount greater than one, it didn't actually delete the pool.
    A better name would have been unreference_addresspool, but we
    already have one of them.

  + free_addresspool_entry's return result was hard for some callers
    honour.  It was supposed to overwrite the list's pointer to the
    old pool (Either in preceding pool's next pointer, or the list
    head).  Caller's like the one in connection.c had no easy way of
    doing that.

  + free_addresspool_entry, even when it didn't delete the entry, did
    unlink it from the pools list (assuming that the caller properly
    used the return value (see above)).  This is not correct.

  + free_addresspool_entry had a serious bug.  If the pool had a
    refcount greater than one, it didn't actually delete the pool
    (contrary to what the name suggests).  Furthermore, even if it
    didn't delete the entry, it did unlink it from the pools list
    (assuming that the caller properly used the return value (see
    above)).

- reference_addresspool's result was never used.  Change it to return
  void.

- partial rewrite of rel_lease_addr:

  + rename abuf* to make their contents manifest

  + use properties of unsigned arithmetic to make range
    comparison simpler.

- changes to get_addr_lease trying to make it more understandable.

- changes to find_addresspool trying to make it more understandable.
  Now detect inexact range overlaps, which should be banned.

- changes to install_addresspool trying to make it more
  understandable.

- Added more checking to install_addresspool
Suggestions for addresspool changes

- unused functions are now #ifdef NEVER.
  They can be checked by the compiler if NEVER is defined.

- new comments (need to be checked).  Comments with ??? indicate
  things not understood.

- removed __LINE__ uses from logging.  Each message is unique so this
  added nothing.  Furthermore it would create uninteresting differences
  in output logs making testing more difficult.

- changed calls to pfreeany to pfree where this was obviously correct.

- deleted unused struct ip_pool_old

- moved struct lease_addr and struct ip_pool from addresspool.h to addresspool.h
  These should be opaque types outside addresspool.c.

- moved pluto_pools from addresspool.h to addresspool.h
  This made a slight change to install_addresspool necessary.

- tried to clarify use of struct lease_addr's "ends" field.
  Renamed it "ended".  Reworked assignments of boolean constants
  to this field.  Added a passert to enforce an unstated assumption
  that the current time_t could not be 0.

- renamed struct ip_pools "lease" field to "leases" since it is the
  head of a list of leases.

- several while-loops changed to for-loops to clarify their structure.
  To make the code more understandable, tried to use the same idiom
  whenever reasonable.  Simplified loops that were meant to remove
  an item from a list.

- where easy, reduced the scope of local variables.

- rel_lease_entry, free_lease: changed the name of the lease index
  parameter from "lease" to i: a lease index is not a lease!

- rel_lease_entry??

- free_lease renamed to free_lease_for_index because that's what it
  does.  "free_lease" suggests a function that takes a lease argument.

- made rel_lease_addr return bool, not int (reflects actual code)

- changed unreference_addresspool to properly remove the addresspool
  from the list of pools.

- The code in connections.c that called free_addresspool_entry ignored
  the return value and so would have broken the addresspool list.
  Besides, it really should have called unreference_addresspool since
  there might be other references to this pool.  Changed to use
  unreference_addresspool.

- free_addresspool didn't unlink the pool from the pluto_pools list.
  Fixed.

- free_addresspool_entry had a number of problems.  Deleted.  Use
  other functions in its place (free_addresspool,
  unreference_addresspool).

  + free_addresspool_entry was misnamed.  If the pool had a
    refcount greater than one, it didn't actually delete the pool.
    A better name would have been unreference_addresspool, but we
    already have one of them.

  + free_addresspool_entry's return result was hard for some callers
    honour.  It was supposed to overwrite the list's pointer to the
    old pool (Either in preceding pool's next pointer, or the list
    head).  Caller's like the one in connection.c had no easy way of
    doing that.

  + free_addresspool_entry, even when it didn't delete the entry, did
    unlink it from the pools list (assuming that the caller properly
    used the return value (see above)).  This is not correct.

  + free_addresspool_entry had a serious bug.  If the pool had a
    refcount greater than one, it didn't actually delete the pool
    (contrary to what the name suggests).  Furthermore, even if it
    didn't delete the entry, it did unlink it from the pools list
    (assuming that the caller properly used the return value (see
    above)).

- reference_addresspool's result was never used.  Change it to return
  void.

- partial rewrite of rel_lease_addr:

  + rename abuf* to make their contents manifest

  + use properties of unsigned arithmetic to make range
    comparison simpler.

- changes to get_addr_lease trying to make it more understandable.

- changes to find_addresspool trying to make it more understandable.
  Now detect inexact range overlaps, which should be banned.

- changes to install_addresspool trying to make it more
  understandable.

- Added more checking to install_addresspool
address pool validations on the end
Merge branch 'addresspool-play' of vault.libreswan.org:/srv/src/libreswan into addresspool-play
fix addresspool range check
address commit 480ccb2e1
resolve the qustions dhr raised.
Suggestions for addresspool changes

- unused functions are now #ifdef NEVER.
  They can be checked by the compiler if NEVER is defined.

- new comments (need to be checked).  Comments with ??? indicate
  things not understood.

- removed __LINE__ uses from logging.  Each message is unique so this
  added nothing.  Furthermore it would create uninteresting differences
  in output logs making testing more difficult.

- changed calls to pfreeany to pfree where this was obviously correct.

- deleted unused struct ip_pool_old

- moved struct lease_addr and struct ip_pool from addresspool.h to addresspool.h
  These should be opaque types outside addresspool.c.

- moved pluto_pools from addresspool.h to addresspool.h
  This made a slight change to install_addresspool necessary.

- tried to clarify use of struct lease_addr's "ends" field.
  Renamed it "ended".  Reworked assignments of boolean constants
  to this field.  Added a passert to enforce an unstated assumption
  that the current time_t could not be 0.

- renamed struct ip_pools "lease" field to "leases" since it is the
  head of a list of leases.

- several while-loops changed to for-loops to clarify their structure.
  To make the code more understandable, tried to use the same idiom
  whenever reasonable.  Simplified loops that were meant to remove
  an item from a list.

- where easy, reduced the scope of local variables.

- rel_lease_entry, free_lease: changed the name of the lease index
  parameter from "lease" to i: a lease index is not a lease!

- rel_lease_entry??

- free_lease renamed to free_lease_for_index because that's what it
  does.  "free_lease" suggests a function that takes a lease argument.

- made rel_lease_addr return bool, not int (reflects actual code)

- changed unreference_addresspool to properly remove the addresspool
  from the list of pools.

- The code in connections.c that called free_addresspool_entry ignored
  the return value and so would have broken the addresspool list.
  Besides, it really should have called unreference_addresspool since
  there might be other references to this pool.  Changed to use
  unreference_addresspool.

- free_addresspool didn't unlink the pool from the pluto_pools list.
  Fixed.

- free_addresspool_entry had a number of problems.  Deleted.  Use
  other functions in its place (free_addresspool,
  unreference_addresspool).

  + free_addresspool_entry was misnamed.  If the pool had a
    refcount greater than one, it didn't actually delete the pool.
    A better name would have been unreference_addresspool, but we
    already have one of them.

  + free_addresspool_entry's return result was hard for some callers
    honour.  It was supposed to overwrite the list's pointer to the
    old pool (Either in preceding pool's next pointer, or the list
    head).  Caller's like the one in connection.c had no easy way of
    doing that.

  + free_addresspool_entry, even when it didn't delete the entry, did
    unlink it from the pools list (assuming that the caller properly
    used the return value (see above)).  This is not correct.

  + free_addresspool_entry had a serious bug.  If the pool had a
    refcount greater than one, it didn't actually delete the pool
    (contrary to what the name suggests).  Furthermore, even if it
    didn't delete the entry, it did unlink it from the pools list
    (assuming that the caller properly used the return value (see
    above)).

- reference_addresspool's result was never used.  Change it to return
  void.

- partial rewrite of rel_lease_addr:

  + rename abuf* to make their contents manifest

  + use properties of unsigned arithmetic to make range
    comparison simpler.

- changes to get_addr_lease trying to make it more understandable.

- changes to find_addresspool trying to make it more understandable.
  Now detect inexact range overlaps, which should be banned.

- changes to install_addresspool trying to make it more
  understandable.

- Added more checking to install_addresspool
address pool validations on the end
fix addresspool range check
use the unused code.
Merge branch 'addresspool-play' of vault.libreswan.org:/srv/src/libreswan into addresspool-play

Conflicts:
	lib/libipsecconf/confread.c
	programs/pluto/addresspool.c
	programs/pluto/addresspool.h
	programs/pluto/connections.c
real fix the previous one was a git accident
Merge branch 'master' into addresspool-play
fix  unreference_addresspool
testing: removed cruft from TESTING
initialize peer to zero in ikev1_decode_peer_id
improve validation of addresspool in confread and whack
addresspool:

- move definition of struct ip_pool from .h to .c:
  the type should be opaque to other modules

- since connection.c can no longer log anything from within struct ip_pool,
  change unreference_addresspool to take over this logging
  (so it needs to be given the struct connection *)

- unreference_addresspool now sets the connection's pool
  pointer to NULL: the connection no longer has a pool.

- unreference_addresspool passerts that the reference count
  is sane.  Continuing with insanity makes no sense.

- renamed "NEVER" to "COMPILE_UNUSED_THING" -- more accurate.
Merge branch 'addresspool-play' of vault.libreswan.org:/srv/src/libreswan into addresspool-play