zoukankan      html  css  js  c++  java
  • lldp中与snmp相关内容agentx

    struct lldpd {

     int    g_snmp;  

     struct event  *g_snmp_timeout;

     void   *g_snmp_fds;

     char   *g_snmp_agentx;

    }

    lldpd_main()

    {

        struct lldpd *cfg;  

        // 初始化snmp相关参数  

       int snmp = 0;  

       char *agentx = NULL; /* AgentX socket */

        // lldpd进程支持的参数  

       char *popt, opts[] =   "H:vhkrdD:xX:m:u:4:6:I:C:p:M:P:S:iL:@                    ";  

         // 对参数进行解析  

       while ((ch = getopt(argc, argv, opts)) != -1) {  

          switch (ch) {            

               // 是否启用agentX      

               case 'x':     

          snmp = 1;     

          break;    

        case 'X':     

          snmp = 1;     

          agentx = optarg;     

          break;          

        // 是否启用lldpcli       

        case 'L':    

           if (strlen(optarg))     

             lldpcli = optarg;     

          else      

            lldpcli = NULL;    

        }  

       cfg->g_snmp = snmp;

      cfg->g_snmp_agentx = agentx;

    }

    static void levent_init(struct lldpd *cfg)

    {  

      if (cfg->g_snmp) {     

        // 注册agentx   

        agent_init(cfg, cfg->g_snmp_agentx);  

         // 设置定时器  

           cfg->g_snmp_timeout = evtimer_new(cfg->g_base,       levent_snmp_timeout,       cfg);   

        if (!cfg->g_snmp_timeout)   

           fatalx("unable to setup timeout function for SNMP");   

        if ((cfg->g_snmp_fds =    malloc(sizeof(struct ev_l))) == NULL)    

          fatalx("unable to allocate memory for SNMP events");  

         TAILQ_INIT(levent_snmp_fds(cfg));

       }

    }

    void levent_loop(struct lldpd *cfg) {    

       // 更新snmp socket通信相关

        if (cfg->g_snmp)  

         levent_snmp_update(cfg);  

       // 关闭agetnx

       if (cfg->g_snmp)   

        agent_shutdown();

    }

    static void usage(void)

    {  

      fprintf(stderr, "-x       Enable SNMP subagent. ");

    }

    static void notify_clients_deletion(struct lldpd_hardware *hardware,struct lldpd_port *rport)

    {

        agent_notify(hardware, NEIGHBOR_CHANGE_DELETED, rport);

    }     

    static void lldpd_decode(struct lldpd *cfg, char *frame, int s,struct lldpd_hardware *hardware)

    {

        if (oport) {     

         agent_notify(hardware, NEIGHBOR_CHANGE_UPDATED, port);

       }  else  {   

        agent_notify(hardware, NEIGHBOR_CHANGE_ADDED, port);

       }   

  • 相关阅读:
    【Java】XML编码
    【GIS】ArcGIS瓦片组织规则
    论写代码的合理性
    快速解决github网页图片显示不了的问题
    pyqt5-tools安装后 desinner.exe 报错 PyQt5 the application failed to start because no Qt platform could be initialized 最强大快速的解决
    Prometheus基本概述
    sql在group by 中使用case when
    【sql server自动化】sql server自动化备份
    (4.45)数据库编程中的三种性能模式比较
    【redis故障处理】redis哨兵节点之间无法互相识别通信
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/4989434.html
Copyright © 2011-2022 走看看