]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
tmp
authorVojtech Vilimek <vojtech.vilimek@nic.cz>
Tue, 6 Dec 2022 15:32:26 +0000 (16:32 +0100)
committerVojtech Vilimek <vojtech.vilimek@nic.cz>
Tue, 6 Dec 2022 15:32:26 +0000 (16:32 +0100)
proto/snmp/bgp_mib.c
proto/snmp/snmp.c
proto/snmp/snmp.h
proto/snmp/snmp_test.c
proto/snmp/snmp_utils.h
proto/snmp/subagent.c

index cb386950bf227af85a13318665dc1df17029a21c..5be28da84f34618de69b386f9ec4b121d5deb179 100644 (file)
@@ -106,6 +106,67 @@ ip4_from_oid(const struct oid *o)
 o->ids[8]) : IP4_NONE;
 }
 
+static void
+print_bgp_record(struct bgp_config *config)
+{
+  struct proto_config *cf = (struct proto_config *) config;
+  struct proto *P = cf->proto;
+  struct bgp_proto *bgp_proto = (struct bgp_proto *) cf->proto;
+  struct bgp_conn *conn = bgp_proto->conn;
+
+  log(L_INFO "    name: %s", cf->name);
+  log(L_INFO "");
+  log(L_INFO "    rem. identifier: %u", bgp_proto->remote_id);
+  log(L_INFO "    local ip: %I", config->local_ip);
+  log(L_INFO "    remote ip: %I", config->remote_ip);
+  log(L_INFO "    local port: %u", config->local_port);
+  log(L_INFO "    remote port: %u", config->remote_port);
+
+  // crashes ?
+  if (conn) {
+    log(L_INFO "    state: %u", conn->state);
+    log(L_INFO "    remote as: %u", conn->remote_caps->as4_number);
+  }
+
+
+  log(L_INFO "    in updates: %u", bgp_proto->stats.rx_updates);
+  log(L_INFO "    out updates: %u", bgp_proto->stats.tx_updates);
+  log(L_INFO "    in total: %u", bgp_proto->stats.rx_messages);
+  log(L_INFO "    out total: %u", bgp_proto->stats.tx_messages);
+  log(L_INFO "    fsm transitions: %u",
+bgp_proto->stats.fsm_established_transitions);
+
+  // not supported yet
+  log(L_INFO "    fsm total time: --");
+  log(L_INFO "    retry interval: %u", config->connect_retry_time);
+
+  log(L_INFO "    hold configurated: %u", config->hold_time );
+  log(L_INFO "    keep alive config: %u", config->keepalive_time );
+
+  // unknown
+  log(L_INFO "    min AS origin. int.: --");
+  log(L_INFO "    min route advertisement: %u", 0 );
+  log(L_INFO "    in update elapsed time: %u", 0 );
+
+  if (!conn)
+    log(L_INFO "  no connection established");
+
+  log(L_INFO "  outgoinin_conn state %u", bgp_proto->outgoing_conn.state + 1);
+  log(L_INFO "  incoming_conn state: %u", bgp_proto->incoming_conn.state + 1);
+
+}
+
+static void
+print_bgp_record_all(struct snmp_proto *p)
+{
+  log(L_INFO "dumping watched bgp status");
+  HASH_WALK(p->bgp_hash, next, peer)
+  {
+    print_bgp_record(peer->config);
+  }
+  HASH_WALK_END;
+}
+
 /**
  * snmp_bgp_state - linearize oid from BGP4-MIB
  * @oid: prefixed object identifier from BGP4-MIB::bgp subtree
@@ -471,6 +532,11 @@ search_bgp_mib(struct snmp_proto *p, struct oid *o_start, struct oid *o_end, uin
   //u8 state_curr = snmp_bgp_state(o_start);
   //u8 state_end = (o_end) ? snmp_bgp_state(o_end) : 0;
 
+
+
+  // print debugging information
+  print_bgp_record_all(p);
+
   if (o_start->include && snmp_bgp_has_value(start_state) &&
       !is_dynamic(start_state) && o_start->n_subid == 3)
   {
index eb517243af007d4ae705318bcd670a6285ca9902..72a82c44329fb64c5ad1b6cb522cdf0999a8a85f 100644 (file)
@@ -66,7 +66,10 @@ snmp_startup_timeout(timer *t)
 static void
 snmp_startup(struct snmp_proto *p)
 {
+  p->state = SNMP_INIT;
+
   /* starting agentX communicaiton channel */
+
   log(L_INFO "preparing lock");
   struct object_lock *lock;
   log(L_INFO "snmp_startup() object lock state %p", p->lock);
@@ -258,8 +261,8 @@ static void snmp_show_proto_info(struct proto *P)
     cli_msg(-1006, "");
     cli_msg(-1006, "    rem. identifier: %u", bp->remote_id);
     // learn more !!
-    cli_msg(-1006, "    admin status: %s", (p->disabled) ? "start" :
-             "stop");
+    cli_msg(-1006, "    admin status: %s", (p->disabled) ? "stop" :
+             "start");
     // version ?
     cli_msg(-1006, "    version: 4");
     cli_msg(-1006, "    local ip: %u", bcf->local_ip);
index ac2f01d6e7d11ea7a35462a89c00da26b39e2506..4b797888705da517a48b299c3ce449c9a9af9b14 100644 (file)
@@ -106,4 +106,6 @@ struct snmp_proto {
   uint errs;
 };
 
+#define snmp_log(x) log(L_INFO "snmp" x);
+
 #endif
index d6acda34c78c8f42cd145a8ce6d1b64019479302..2a54d6cf06795def99505e2ca00bd269fa169de5 100644 (file)
@@ -13,7 +13,6 @@
 #include "subagent.h"
 #include "snmp.h"
 #include "snmp_utils.h"
-#include "snmp_internal.h"
 
 #define SNMP_EXPECTED(actual, expected) \
   bt_debug("%s  expected: %3u   actual: %3u\n", \
index 1d2136f3f5bbfdb8c91b3472422cf7b253af229a..a1bd6df338db86cbdc438f3782ce68b956b053ee 100644 (file)
@@ -31,4 +31,5 @@ void snmp_oid_dump(struct oid *oid);
 
 int snmp_oid_compare(struct oid *left, struct oid *right);
 
+struct oid *snmp_prefixize(struct snmp_proto *p, struct oid *o, int byte_ord);
 #endif
index e4742e1ecbfd7e00d9cef1ede20c7775c8ed357b..ffbb3f96e4315403487d0cce98da45223681b968 100644 (file)
@@ -13,8 +13,6 @@
 #include "snmp_utils.h"
 #include "bgp_mib.h"
 
-#include "snmp_internal.h"
-
 /* =============================================================
  *  Problems
  *  ------------------------------------------------------------