bgpd: simplify ebgp-multihop and ttl-security handling

Change to track configured value in ->ttl and ->gtsm_hops;
not the value set to sockopt. Instead, setting of socket's ttl
and minttl options are now merged to one function which calculates
it on demand. This greatly simplifies the code.
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 45d502a..ba87ad1 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -172,11 +172,10 @@
 
 	for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer))
 	  {
-	    if ((peer->ttl != 1) && (peer->gtsm_hops != 1))
-	      continue;
-
-	    if (ifp == peer->nexthop.ifp)
-	      BGP_EVENT_ADD (peer, BGP_Stop);
+            if (peer->gtsm_hops != 1 && peer_ttl (peer) != 1)
+              continue;
+            if (ifp == peer->nexthop.ifp)
+              BGP_EVENT_ADD (peer, BGP_Stop);
 	  }
       }
   }
@@ -716,7 +715,7 @@
       SET_FLAG (flags, ZEBRA_FLAG_INTERNAL);
     }
 
-  if ((peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
+  if ((peer->sort == BGP_PEER_EBGP && peer_ttl (peer) != 1)
       || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
     SET_FLAG (flags, ZEBRA_FLAG_INTERNAL);
 
@@ -991,7 +990,7 @@
       SET_FLAG (flags, ZEBRA_FLAG_IBGP);
     }
 
-  if ((peer->sort == BGP_PEER_EBGP && peer->ttl != 1)
+  if ((peer->sort == BGP_PEER_EBGP && peer_ttl (peer) != 1)
       || CHECK_FLAG (peer->flags, PEER_FLAG_DISABLE_CONNECTED_CHECK))
     SET_FLAG (flags, ZEBRA_FLAG_INTERNAL);