2022-08-01 11:01:49 +00:00
|
|
|
/*
|
|
|
|
* BIRD -- Simple Network Management Protocol (SNMP)
|
|
|
|
*
|
|
|
|
* (c) 2022 Vojtech Vilimek <vojtech.vilimek@nic.cz>
|
|
|
|
* (c) 2022 CZ.NIC z.s.p.o
|
|
|
|
*
|
|
|
|
* Can be freely distributed and used under the terms of the GNU GPL.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _BIRD_SNMP_H_
|
2022-08-10 15:31:32 +00:00
|
|
|
#define _BIRD_SNMP_H_
|
2022-08-01 11:01:49 +00:00
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
#include "lib/ip.h"
|
|
|
|
#include "lib/socket.h"
|
|
|
|
#include "lib/timer.h"
|
|
|
|
#include "nest/bird.h"
|
|
|
|
#include "nest/protocol.h"
|
2022-08-01 11:01:49 +00:00
|
|
|
#include "proto/bgp/bgp.h"
|
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
|
2022-08-02 14:04:25 +00:00
|
|
|
#define SNMP_UNDEFINED 0
|
|
|
|
#define SNMP_BGP 1
|
|
|
|
#define SNMP_OSPF 2
|
|
|
|
#define SNMP_INVALID 255
|
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
#define SNMP_PORT 705
|
|
|
|
|
|
|
|
#define SNMP_RX_BUFFER_SIZE 2048
|
|
|
|
#define SNMP_TX_BUFFER_SIZE 2048
|
|
|
|
|
2022-09-06 16:04:29 +00:00
|
|
|
#define SNMP_INIT 1
|
|
|
|
#define SNMP_REGISTR 2
|
|
|
|
#define SNMP_CONN 3
|
|
|
|
#define SNMP_ERR 4
|
|
|
|
|
|
|
|
#define SNMP_OFF 0
|
|
|
|
|
|
|
|
|
|
|
|
/* hash table macros */
|
2022-09-20 12:28:57 +00:00
|
|
|
#define SNMP_HASH_KEY(n) n->peer_ip
|
|
|
|
#define SNMP_HASH_NEXT(n) n->next
|
2022-09-06 16:04:29 +00:00
|
|
|
#define SNMP_HASH_EQ(ip1, ip2) ipa_equal(ip1, ip2)
|
|
|
|
#define SNMP_HASH_FN(ip) ipa_hash(ip)
|
|
|
|
|
2022-08-02 14:04:25 +00:00
|
|
|
struct snmp_bond {
|
|
|
|
node n;
|
|
|
|
struct proto_config *proto;
|
|
|
|
u8 type;
|
|
|
|
};
|
|
|
|
|
2022-08-01 11:01:49 +00:00
|
|
|
struct snmp_config {
|
2022-08-10 15:31:32 +00:00
|
|
|
struct proto_config cf;
|
|
|
|
ip_addr local_ip;
|
|
|
|
ip_addr remote_ip;
|
|
|
|
u16 local_port;
|
|
|
|
u16 remote_port;
|
2022-09-20 12:28:57 +00:00
|
|
|
u32 local_as;
|
2022-08-10 15:31:32 +00:00
|
|
|
u8 timeout;
|
|
|
|
//struct iface *iface;
|
2022-08-02 14:04:25 +00:00
|
|
|
list bgp_entries;
|
2022-08-01 11:01:49 +00:00
|
|
|
};
|
|
|
|
|
2022-09-20 12:28:57 +00:00
|
|
|
struct snmp_bgp_peer {
|
2022-09-06 16:04:29 +00:00
|
|
|
struct snmp_bond *bond;
|
|
|
|
ip_addr peer_ip;
|
2022-09-20 12:28:57 +00:00
|
|
|
struct snmp_bgp_peer *next;
|
|
|
|
};
|
2022-09-06 16:04:29 +00:00
|
|
|
|
2022-08-01 11:01:49 +00:00
|
|
|
struct snmp_proto {
|
2022-08-10 15:31:32 +00:00
|
|
|
struct proto p;
|
|
|
|
struct object_lock *lock;
|
2022-09-06 16:04:29 +00:00
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
ip_addr local_ip;
|
|
|
|
ip_addr remote_ip;
|
|
|
|
u16 local_port;
|
|
|
|
u16 remote_port;
|
2022-09-20 12:28:57 +00:00
|
|
|
u32 local_as;
|
2022-09-06 16:04:29 +00:00
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
sock *sock;
|
|
|
|
u8 timeout;
|
2022-09-06 16:04:29 +00:00
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
u32 session_id;
|
|
|
|
u32 transaction_id;
|
|
|
|
u32 packet_id;
|
2022-09-06 16:04:29 +00:00
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
//struct iface *iface;
|
|
|
|
// map goes here
|
2022-09-20 12:28:57 +00:00
|
|
|
HASH(struct snmp_bgp_peer) bgp_hash;
|
2022-08-01 11:01:49 +00:00
|
|
|
struct tbf rl_gen;
|
2022-09-06 16:04:29 +00:00
|
|
|
|
2022-08-10 15:31:32 +00:00
|
|
|
timer *ping_timer;
|
2022-09-20 12:28:57 +00:00
|
|
|
timer *retry_timer;
|
2022-09-06 16:04:29 +00:00
|
|
|
u8 state;
|
|
|
|
|
|
|
|
list bgp_entries;
|
2022-08-01 11:01:49 +00:00
|
|
|
};
|
|
|
|
|
2022-09-06 16:04:29 +00:00
|
|
|
/*
|
2022-08-01 11:01:49 +00:00
|
|
|
struct snmp_channel_config {
|
|
|
|
struct channel_config c;
|
|
|
|
struct bgp_config *bgp;
|
2022-08-02 14:04:25 +00:00
|
|
|
u8 type;
|
2022-08-01 11:01:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct snmp_channel {
|
|
|
|
struct channel c;
|
|
|
|
};
|
2022-09-06 16:04:29 +00:00
|
|
|
*/
|
2022-08-10 15:31:32 +00:00
|
|
|
|
|
|
|
|
2022-08-01 11:01:49 +00:00
|
|
|
#endif
|