                            guessnet

README
======

The guessnet program tries to guess the current network location by
performing tests such as making DHCP and ARP requests.

Please see the guessnet(8) manual page for more information.


SOURCE
======
automake1.8 was used.


TODO
====

 - Create a script to output an ifupdown configuration snippet out of the
   current network configuration:
     $ guessnet-mkconfig eth0 debconf
     iface debconf inet static
       address <current IP address>
       netmask <current netmask>
       broadcast <current broadcast>
       gateway <current gateway>
       test-peer <ip and mac of gateway>
     $ guessnet-mkconfig eth0 debconf peermachine
     <same results except for test-peer>
       test-peer <ip and mac of machine "peermachine">

 - Suggest ifplugd and suggest a high hysteresis

 - Wait for #238344 "unknown physical layer type 0x30f" to be solved

 - Render the libnet work-around optional, wrap it around preprocessor
   directives and set the directives in configure.ac

 - Add an option to just dump configuration to stdout and exit, to be used
   to test configuration file parsers

 - Consider #226031 "support for a --runcommand option"
 
 - It might be that Fabian's patch introduces this bug that guessnet can't kill
   child processes still running when the program should end

 - Make guessnet-scan try to get a dhcp lease, and if it succeeds, output an
   iface line with dhcp and a test-peer to the dhcp server
   (need to wait until the *damn* libnet1 fixes bug#180441 :(( )

 - Use tcpdump's produced packet matching code for having precise and optimized
   packet matching in the sniffer

 - Wish: it would be nice to have a macaddr-only detection mechanism, as
   coming up on the wrong ip on a network can sometimes be disruptive to
   others (i.e.  someone else already using the same ip addr).  I'm not
   sure what mechanism would underlie such a thing, tho.
   (Tony Godshall <togo@of.net>)

 - guessnet: Limit the scope of the program to Ethernet.  Every configuration
   file knows about the kind of an interface, so that's nothing that guessnet
   should do.  Whoever calls guessnet, does it just to find out the correct
   profile for an Ethernet interface.  For detection on other interfaces, other
   programs can be made.

 - Add default tests according to the kind of logical interface defined
   in /e/n/i?

 - If multiple addresses or address/mac pairs are specified in a single
   test-peer line, they should all exist for the test to be true
   (opens the possibility of the same peer being specified in multiple lines,
   requiring to handle this in a smart way).

 - Bringing up and down the interface spawns children which could
   interfere with ProcessRunner (Should not do so, though, since iface_init
   and iface_shutdown are invoked when the ProcessRunner is not active)?

 - I'm open to better ideas on how to implement ProcessRunner.cc (see its
   FIXMEs)

 - Suggest ifupdown people to implement a zcip mode


DONE
====

 * Done in version 0.30

 + Add happy bound checking when accessing packets
 + Add DHCP scan
    - DHCPINFORM, DHCPREQUEST (see dhcping for how to do it)
    - dhcpcd -d -c /dev/null -T ethp_0 -t 4
 + In case timeout happens and there are still multiple candidate profiles,
   return the default profile name


 * Done in version 0.29

 + Allow an extra "src <ip address>" for arp scans, to set the source IP when
   the peer doesn't answer DAD ARP packets
    + Implement in parser
    + Implement in scans
 + Add version info to --debug output
 + Create an example file for the ifupdown (or guessnet) configuration, to be
   shipped in /usr/share/doc/guessnet/examples


 * Done in version 0.28

--- 2004-03-31
 + Fixed debian/copyright file (#240791)
 + Removed ifexpr code (#240759)
 + Did not wait for timeout to get scan results
 + ScanBag: returns the last scan instead of defaultScan if there are no scan
   results (#240781)


 * Done in version 0.27

--- 2004-03-27
 + Really invoke the scan start routine
 + Taken working MII detection from ifplugd
 + Applied Lennart patches (#240387)

--- 2004-03-18
 + Implement tests as binary expression
   NO: it would be hard to evaluate a NOT ping
   Instead, implement the cases in which it makes sense to AND scans: for
   example, allow multiple peer data to be specified in a test-peer, and treat
   them as ANDed together
    + Even, use ambiguity:
       - save each profile with the list of scans
       - as soon as a scan succeeds, remove it
       - the first profile that remains without scans nor other more specific
	 candidates (e.g. dhcp, dhcp+arp) wins
       - on timeout, in case a profile succeeds but there are more specific
	 candidates, forget about them and output the succeeded scan.
 + Debug the strange exception problem in test-netsender (bug#235591)
    - If I don't do a cancel, everything is fine
    - If I don't do delete impl, sometimes aborts
    - If I don't do libnet_destroy, sometimes aborts
    - Replace cancel with a quit request
 + Don't wait for sigchild if ProcessRunner (doesn't work on my system) but
   busy-wait for events with a 10msec pause between iterations (can't come up
   with anything better)

--- 2004-03-16
 + Start test-netsender.cc
 + IFace::initBroadcast: when initializing for 0.0.0.0, IFP_VALID_* are
   probably not accepted.  Search ifconfig sources on how to do that

--- 2004-03-15
 + Start test-iface.cc

--- 2004-01-21
 + Dedicate next release to Alberto Gonzalez Iniesta
 + Don't call ifconfig: directly use interface configuration routines from
   laptop-net (also works around the libnet bug)
 + Include the patch from Chris Hanson to work around libnet's bug

 
 * Done in version 0.26

--- 2004-01-07
 + Use libnet_adv_cull_packet instead of libnet_pblock_coalesce
 + Solve #225221 (FTBFS with patch from Joey)
 + Solve #224894 (segfault on "default:")
   The environments called get() in the constructor, which of course would have
   tried to dereference 0
 + Solve #224910 (Do not enforce UID to be 0, but print a note about uid not
   being 0 when catching fatal exceptions)
 + Solve #224893 by supporting an optional guessnet[0-9]* in front of lines
 + Put an optional 'guessnet[0-9]* ' in front of everything
   Solves #224893 (using 'guessnet' option instead of 'test' in interfaces file)
 + Put an optional arbitary number after test
 + Put the optional dash after test[0-9]*
 + Reintroduce the dash in test-stuff (ifupdown complains about duplicate
   first-words even in unrecognized lines)
 + Document that if no logical interfaces are given on stdin in ifupdown mode,
   all those that are found are tried
 + Document test-missing-cable as test-missing-cable please (and .+ for what
   it matters)
 + Do not mention ethernet in the documentation anymore
    + manpage
    + README
    + README.Debian
    + debian/control
 + Document why numbers and garbage after test-missing-cable
 + Document the optional guessnet name in ifupdown config lines
 + Document the ifupdown wishlist bugs of guessnet interest in README.Debian
 + Apply the changes in #224888
 + Document that multiple test- things are "or-ed" together, not "and-ed"
 + Add a pppoe scan taking the code from one of the ifupdown-roam scripts
 + Add a scripts directory
 + Add experimental support for wireless scans by transparently running
   /usr/share/guessnet/test-wifi-* scripts
 + Print a warning about "guessnet default" being obsolete if it is used in
   ifupdown mode
 + Added some preliminary test scripts for the parser
 

* Done in version 0.25

 + logic_error creating a string with a null when running guessnet -i (or maybe
   also normal guessnet) on an interface who's up but not initialized yet)


* Done in version 0.24

--- 2003-12-21
 + Configuration file: change "test-stuff" in "test stuff".  Allow for both
   syntaxes.
 + Allow for specifying test-peer scans without a macaddress.  If no macaddress
   is provided, when and PARP reply is received it should not be tested for
   MACaddress match, but just make the test succeed.  In this case it's like a
   ping scan.
 + Make sure that we use forward arp instead of reverse arp


* Done in version 0.23 "Who does not die sees himself again"

--- 2003-12-20
 + Implemented two different environments for the two different work modes
   (normal and ifupdown)
 + Port to libnet1
 + Encapsulate configuration parsing, and instantiate the right parser through
   a factory class that checks commandline switches and whatever
 + If there are no profiles given in stdin in ifupdown mode, assume they are
   all enabled
 + Integrate the simple patch from the BTS (thank you Fabian Knittel!)
 + If the interface detects no link beat, output a profile "none".  Add a
   switch to change its name and to turn the feature off for interfaces that do
   not support link beat detection.


 + Open a project on a development server like Savannah, SourceForge or Alioth.
   (Chosen Alioth)


* Done in version 0.21

--- 2003-05-26
 + In ifupdown mode, read from stdin all the commandline parameters, not just
   the --default equivalent
 + Document the new peer and commandline-in-map-lines syntax
 + Guess the local network address and the gateway address through network
   sniffing:
    + build a table with source and target IPs and MACs of IP packets that pass
      thru the network: in the common case, you have packets from and to the
      local net, and packets from/to outside with the gateway MAC address in
      the side of the external IP.  After some sniffing, it should be easy to
      distinguish the gateway from the other machines, and consequently the
      local network address
    + use this scheme in an external application that scans for a gateway and
      prints a guessnet scan definition to be put in the config file


* Done in version 0.20

--- 2003-05-25
 + Removed redundant documentation from the README, and added a line pointing
   to the manpage for further documentation
 + The new peer syntax is not parsed well (it misses all key-value pairs except
   the first)
 + Replace -V with -vv (or with --debug) and let -V work as --version
 + Remove dependancy on libpopt
 + Use the code from netplugd to wait for an interface to come up instead of
   using init-timeout.  Use init-timeout only to avoid waiting indefinitely in
   case of problems.
--- 2003-05-19
 + NetSender, NetWatcher and ProcessRunner didn't increment the Impl reference
   count in their plain constructor


* Done in version 0.19

--- 2003-05-16
 + Change the parser to allow a syntax like:
    + test-peer ip 1.2.3.4 mac a:b:c:d:e:F service www
	     and consider only the parameters that are needed
    + test-command commandline
 + The interface default in ifupdown mode should be listed in a line as:
   default: name
 + The test to see if an interface is up does not work, and if the interface is
   down, pcap_next returns 0 because it's not been brought up
    + the interface keeps existing in /proc/net/dev even if it's down.
    + use the check from netplugd


* Done in version 0.18

--- 2003-05-10
 + Ship guessnet with a guessnet-ifupdown link
 + Do not scan getppid for ifupdown mode, but check argv0.
 + Prefix the ifupdown guessnet lines with "guessnet "
 + manpage: change the program description, since now it doesn't just use ARP probes
 + manpage: document -i behaviour
 + manpage: document script scan behaviour
 + Make a singleton environment class to hold run-time parameters (interface,
   verbosity...)
 + Export NAME=tag and IFACE=interface in the environment of child scripts
 + [Thomas Hood] you need to add an option to set the configuration file.  With
   the [current] syntax, you can't specify a config file unless you also
   specify an ethernet interface
 + ChildProcess: make more versions of fork, especially a simple one that does
   not try to do magic with file descriptors
 + In ifupdown mode, read the list of profiles to try from stdin, so that it
   won't always try every possible stanza found in /etc/network/interfaces
 + guessnet hangs if no candidates are found in input
    + Locks waiting mutex in killall at runner.shutdown()
 + guessnet hangs if only a script /bin/false candidate is found in input


* Done in version 0.17

--- 2003-05-09
 * Introduce other detection ideas:
    + External script
 + Rename --use-interfaces to --use-ifupdown


* Older releases

---
 + Add a manpage
 + Use a different timeout if the interface is not found up but is brought up
   by guessnet, since in that case it might require more time to initialize
   itself
 + Audit the code clearing endianness issues
 + Port to libnet1
 = Check what is the difference between guessnet and the arpfind script found
   in the scripts directory of newer whereami, that do
   arping -f -w1 -D -I $INTERFACE $REMOTEIP | grep -e $REMOTEMAC
   Example:
	marvin:~# arping -f -w1 -D -I eth0 192.168.1.1
	ARPING 192.168.1.1 from 0.0.0.0 eth0
	Unicast reply from 192.168.1.1 [00:01:02:03:04:05] for 192.168.1.1 [00:0A:0B:0C:0D:0E] 0.741ms
	Sent 1 probes (1 broadcast(s))
	Received 1 response(s)

   If they are the same, we could get rid of guessnet and write a shellscript
   around arping to do the same.
    = After the redesign, a script cannot do what guessnet is doing
 + Backport to libnet0 (*&%^%$^!!)
 + See if the broadcast IP address can be used as the local IP address
   No, but 0.0.0.0 can (see arping -D manpage)
 + Implement the new config file syntax
    + <profile-name> <method> <parms...>
    - Example:
      casa peer 192.168.1.1 01:02:03:04:05:06
      uni dhcp <dhcp-data>
      otherplace script /usr/local/bin/detect-otherplace
 + Herv Eychenne
   > So, the pb is that you MUST specify the interface when using -v and -V
   > options, whereas you don't have to when specifying no parameter.

LINKS
=====

 - http://www.networksorcery.com/enp/protocol/
