anchor.diff:  -include_lib("diameter/include/diameter.hrl").
   -include("diameter_internal.hrl").
   
  +%% The "old" states maintained in this module historically.
   -define(STATE_UP,   up).
   -define(STATE_DOWN, down).
  +
  +-type op_state() :: ?STATE_UP
  +                  | ?STATE_DOWN.
  +
  +%% The RFC 3539 watchdog states that are now maintained, albeit
  +%% along with the old up/down. okay = up, else down.
  +-define(WD_INITIAL, initial).
  +-define(WD_OKAY,    okay).
  +-define(WD_SUSPECT, suspect).
  +-define(WD_DOWN,    down).
  +-define(WD_REOPEN,  reopen).
  +
  +-type wd_state() :: ?WD_INITIAL
  +                  | ?WD_OKAY
  +                  | ?WD_SUSPECT
  +                  | ?WD_DOWN
  +                  | ?WD_REOPEN.
   
   -define(DEFAULT_TC,     30000).  %% RFC 3588 ch 2.1
   -define(DEFAULT_TIMEOUT, 5000).  %% for outgoing requests
  
positive.code: 
  %% Send an event at connection establishment failure.
  closed({shutdown, {close, _TPid, Reason}},
         #peer{op_state = ?STATE_DOWN,
               ref = Ref,
               type = Type,
               options = Opts},
  
negative.code:     reconnect(Pid, S),
      ok;
  
  %% Watchdog is sending notification of a state transition. Note that
  %% the connection_up/down messages are pre-date this message and are
  %% still used. A 'watchdog' message will follow these and communicate
  %% the same state as was set in handling connection_up/down.
  transition({watchdog, Pid, {TPid, From, To}}, #state{service_name = SvcName,
                                                       peerT = PeerT}) ->
      #peer{ref = Ref, type = T, options = Opts, op_state = {OS,_}}
          = P
          = fetch(PeerT, Pid),
      insert(PeerT, P#peer{op_state = {OS, To}}),
      send_event(SvcName, {watchdog, Ref, TPid, {From, To}, {T, Opts}}),
      ok;
  %% Death of a peer process results in the removal of it's peer and any
  %% associated conn record when 'DOWN' is received (after this) but the
  %% states will be {?STATE_UP, ?WD_DOWN} for a short time. (No real
  %% problem since ?WD_* is only used in service_info.) We set ?WD_OKAY
  %% as a consequence of connection_up since we know a watchdog is
  %% coming. We can't set anything at connection_down since we don't
  %% know if the subsequent watchdog message will be ?WD_DOWN or
  %% ?WD_SUSPECT. We don't (yet) set ?STATE_* as a consequence of a
  %% watchdog message since this requires changing some of the matching
  %% on ?STATE_*.
  %%
  %% Death of a conn process results in connection_down followed by
  %% watchdog ?WD_DOWN. The latter doesn't result in the conn record
  %% being deleted since 'DOWN' from death of its peer doesn't (yet)
  %% deal with the record having been removed.
  
  %% Monitor process has died. Just die with a reason that tells
  %% diameter_config about the happening. If a cleaner shutdown is
  