• 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);

       }   

  • 相关阅读:
    集合(5)—Map之HashMap()
    《转》python 10 集合
    《转》python8元组
    《转》python(7)列表
    《转》python数据类型
    《转》python对象
    《转》python
    《转》python基础下
    《转》python学习基础
    《转》python 9 字典,numpy
  • 原文地址:https://www.cnblogs.com/rohens-hbg/p/4989434.html
Copyright © 2020-2023  润新知