Ejemplo n.º 1
0
int_32 Shell_arpdisp(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   _rtcs_if_handle   ihandle = ipcfg_get_ihandle (BSP_DEFAULT_ENET_DEVICE);
  
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

    if (!print_usage)  {
      if (argc > 2)  {
         return_code = SHELL_EXIT_ERROR;
         print_usage = TRUE;
      } else  { 
        ARP_display_if_table(ihandle);
      }
    }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s [<ihandle>]\n", argv[0]);
      } else  {
         printf("Usage: %s [<ihandle>] \n", argv[0]);
         printf("   <ihandle>  = Interface handle\n");
      }
   }

   return return_code;
} /* Endbody */
Ejemplo n.º 2
0
int_32 Shell_arpdel(int_32 argc, char_ptr argv[] )
{ /* Body */
   boolean           print_usage, shorthelp = FALSE;
   int_32            return_code = SHELL_EXIT_SUCCESS;
   _ip_address       ipaddr;
   _rtcs_if_handle   ihandle = ipcfg_get_ihandle (BSP_DEFAULT_ENET_DEVICE);
  
   print_usage = Shell_check_help_request(argc, argv, &shorthelp );

   if (!print_usage)  {
      if (argc != 2)  {
         return_code = SHELL_EXIT_ERROR;
         print_usage = TRUE;
      } else  if (! Shell_parse_ip_address( argv[1], &ipaddr))  {
          printf("Error, invalid ip address\n");
          return_code = SHELL_EXIT_ERROR;
      }
      if (return_code == SHELL_EXIT_SUCCESS) {
          RTCS_arp_delete(ihandle,ipaddr);
      }
   }
   
   if (print_usage)  {
      if (shorthelp)  {
         printf("%s <ip_address>\n", argv[0]);
      } else  {
         printf("Usage: %s <ip_address> \n", argv[0]);
         printf("   <ip_address>  = IP Address\n");
      }
   }

   return return_code;
} /* Endbody */
Ejemplo n.º 3
0
uint32_t iwcfg_set_sec_type 
    (
        uint32_t dev_num,
        char  *sec_type
    )
{
    _rtcs_if_handle ihandle;
    uint32_t error,inout_param;
    bool dev_status;

   if (strcmp(sec_type,"none") == 0)
   {
      inout_param = ENET_MEDIACTL_SECURITY_TYPE_NONE;
   }
   else if (strcmp(sec_type,"wep") == 0)
   {
     inout_param = ENET_MEDIACTL_SECURITY_TYPE_WEP;
   }
   else if (strcmp(sec_type,"wpa") == 0)
   {
     inout_param = ENET_MEDIACTL_SECURITY_TYPE_WPA;
   }
   else if (strcmp(sec_type,"wpa2") == 0)
   {
     inout_param = ENET_MEDIACTL_SECURITY_TYPE_WPA2;
   }
   else
   {
     printf("%s sectype passed is incorrect. refer help\n",sec_type);
     return ENET_ERROR;
   }
   
   if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_SET_MEDIACTL_SEC_TYPE,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        return ENET_OK;
    }   
    return ENETERR_INVALID_DEVICE;  
}
Ejemplo n.º 4
0
uint32_t iwcfg_get_sectype
    (
        uint32_t dev_num,
        char *sectype /*[OUT]*/
    )
{
    _rtcs_if_handle ihandle;
    uint32_t  inout_param;
    uint32_t error;
    bool dev_status;
    
    if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }

        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }

        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_GET_MEDIACTL_SEC_TYPE,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        
        if (inout_param == ENET_MEDIACTL_SECURITY_TYPE_NONE)  
           strcpy(sectype,"none");
        else if (inout_param == ENET_MEDIACTL_SECURITY_TYPE_WEP)
           strcpy(sectype,"wep");
        else if (inout_param == ENET_MEDIACTL_SECURITY_TYPE_WPA)
           strcpy(sectype,"wpa");
        else if (inout_param == ENET_MEDIACTL_SECURITY_TYPE_WPA2)
           strcpy(sectype,"wpa2");
        else
        {
           sectype = NULL;
           return ENET_ERROR;   
        }
        
        return ENET_OK;
    }
    printf("IWCONFIG_ERROR: Invalid Device number\n");
    return ENETERR_INVALID_DEVICE;
}
Ejemplo n.º 5
0
uint32_t iwcfg_set_mode
    (
        uint32_t dev_num,
        char *mode
    )
{
    _rtcs_if_handle ihandle;
    uint32_t error;
    uint32_t inout_param;
    bool dev_status;
 
    if (!strcmp(mode,"managed")) 
    {
        inout_param = ENET_MEDIACTL_MODE_INFRA;
    }
    else if (!strcmp(mode,"adhoc")) 
    {
        inout_param = ENET_MEDIACTL_MODE_ADHOC;
    }
    else
    {
        printf("Invalid Mode parameter %s. Refer help\n",mode);
        return ENET_ERROR;
    }
        
    if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }
        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_SET_MEDIACTL_MODE,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        return ENET_OK;
    }
    
    return ENETERR_INVALID_DEVICE;
}
Ejemplo n.º 6
0
uint32_t iwcfg_set_wep_key 
    (
        uint32_t dev_num,
        char *wep_key,
        uint32_t key_len,
        uint32_t key_index
        
    )
{
    _rtcs_if_handle ihandle;
    uint32_t error;
    bool dev_status;
    uint32_t flags = 0;
    ENET_MEDIACTL_PARAM  inout_param;

   if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }
        
        if (wep_key == NULL)
         flags |= ENET_MEDIACTL_ENCODE_DISABLED|ENET_MEDIACTL_ENCODE_MODE;
        else
         flags |= ENET_MEDIACTL_ENCODE_ENABLED;
        
        flags |= (key_index & 0xFF); 
        inout_param.data = wep_key;
        inout_param.length = key_len;
        inout_param.flags = flags;
        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_SET_MEDIACTL_ENCODE,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        return ENET_OK;
    }   
    return ENETERR_INVALID_DEVICE;  
}
Ejemplo n.º 7
0
uint32_t iwcfg_get_mode
    (
        uint32_t dev_num,
        char *mode /*[OUT]*/
    )
{
    _rtcs_if_handle ihandle;
    uint32_t  inout_param;
    uint32_t error;
    bool dev_status;
    
    if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }

        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }

        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_GET_MEDIACTL_MODE,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        
        if (inout_param == ENET_MEDIACTL_MODE_INFRA)  
           strcpy(mode,"managed");
        else if (inout_param == ENET_MEDIACTL_MODE_ADHOC)
           strcpy(mode,"adhoc");
        else
        {
           mode = NULL;
           return ENET_ERROR;   
        }
        
        return ENET_OK;
    }
    printf("IWCONFIG_ERROR: Invalid Device number\n");
    return ENETERR_INVALID_DEVICE;
}
Ejemplo n.º 8
0
uint32_t iwcfg_get_essid
    (
        uint32_t dev_num,
        char *essid /*[OUT]*/
    )
{
    _rtcs_if_handle ihandle;
    ENET_MEDIACTL_PARAM  inout_param;
    uint32_t error;
    bool dev_status;
    
    
    if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }

        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }

        inout_param.data = (void *)essid;
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_GET_MEDIACTL_ESSID,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        
        if (!inout_param.flags)
            return ENET_ERROR;
        
        essid[inout_param.length] = '\0';
        return ENET_OK;
    }
    printf("IWCONFIG_ERROR: Invalid Device number\n");
    return ENETERR_INVALID_DEVICE;
}
Ejemplo n.º 9
0
uint32_t iwcfg_set_essid
    (
        uint32_t dev_num,
        char *essid
    )
{
    _rtcs_if_handle ihandle;
    ENET_ESSID  inout_param;
    uint32_t error;
    bool dev_status;
    
    if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }
        if (!essid)
          inout_param.flags = 0;
        else
         inout_param.flags = 1;
        
        inout_param.essid = essid;
        inout_param.length = strlen(essid);
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }

        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_SET_MEDIACTL_ESSID,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        return ENET_OK;
    }
    printf("IWCONFIG_ERROR: Invalid Device number\n");
    return ENETERR_INVALID_DEVICE;
}
Ejemplo n.º 10
0
uint32_t iwcfg_get_wep_key 
    (
        uint32_t dev_num,
        char *wep_key,
        uint32_t *key_index
  
    )
{
    _rtcs_if_handle ihandle;
    uint32_t error;
    bool dev_status;
    uint32_t flags = 0;
    ENET_MEDIACTL_PARAM  inout_param;

   if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }
        
        inout_param.data = (void *)wep_key;
                
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_GET_MEDIACTL_ENCODE,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        wep_key[inout_param.length] = '\0';
        if (key_index)
           *key_index = inout_param.flags & 0xFF;
        return ENET_OK;
    }   
    return ENETERR_INVALID_DEVICE;  
}
Ejemplo n.º 11
0
uint32_t iwcfg_set_power 
    (
        uint32_t dev_num,
        uint32_t pow_val,
        uint32_t flags
        
    )
{
    _rtcs_if_handle ihandle;
    uint32_t error;
    bool dev_status;
    ENET_MEDIACTL_PARAM  inout_param;

   if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }
        
        inout_param.value = pow_val;
        inout_param.disabled = flags;
        inout_param.flags = ENET_MEDIACTL_POWER_PERIOD;
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_SET_MEDIACTL_POWER,&inout_param);
        if (ENET_OK != error)
        {
            return error;
        }
        return ENET_OK;
    }   
    return ENETERR_INVALID_DEVICE;  
}
Ejemplo n.º 12
0
uint32_t iwcfg_set_passphrase
    (
        uint32_t dev_num,
        char *passphrase
    )
{
    _rtcs_if_handle ihandle;
    uint32_t error;
    bool dev_status;
    ENET_MEDIACTL_PARAM param;
    
    if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }        
        param.data = passphrase;
        param.length = strlen(passphrase);
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }
        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_SET_MEDIACTL_PASSPHRASE,&param);
        if (ENET_OK != error)
        {
            return error;
        }
        return ENET_OK;
    }
    printf("IWCONFIG_ERROR: Invalid Device number\n");
    return ENETERR_INVALID_DEVICE;
}
Ejemplo n.º 13
0
uint32_t iwcfg_commit
    (
        uint32_t dev_num
    )
{
    _rtcs_if_handle ihandle;
    uint32_t error;
    bool dev_status;
    
    if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }

        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_SET_MEDIACTL_COMMIT,NULL);
        if (ENET_OK != error)
        {
            return error;
        }
        return ENET_OK;
    }
    
    return ENETERR_INVALID_DEVICE;
}
Ejemplo n.º 14
0
static int32_t Shell_ipconfig_dns (uint32_t enet_device, uint32_t index, int32_t argc, char *argv[])
{
    uint32_t        i;
    bool            res;
#if RTCSCFG_ENABLE_IP4
    _ip_address     dns_addr;
#endif
#if RTCSCFG_ENABLE_IP6
    in6_addr        dns6_addr;
#endif

    if (argc > ++index)
    {
        if (strcmp (argv[index], "add") == 0)
        {
            if (argc > ++index)
            {
#if RTCSCFG_ENABLE_IP4
                if(inet_pton(AF_INET, argv[index], &dns_addr, sizeof(dns_addr)) == RTCS_OK)
                {
                    res = ipcfg_add_dns_ip(enet_device, dns_addr);
                }
                else
#endif
#if RTCSCFG_ENABLE_IP6
                    if(inet_pton(AF_INET6, argv[index], &dns6_addr, sizeof(dns6_addr)) == RTCS_OK)
                    {
                        res = ipcfg6_add_dns_ip(enet_device, &dns6_addr);
                    }
                    else
#endif
                    {
                        printf ("Error in dns command, invalid ip address!\n");
                        return SHELL_EXIT_ERROR;
                    }

                if(res == TRUE)
                {
                    printf ("Add dns ip successful.\n");
                }
                else
                {
                    printf ("Add dns ip failed!\n");
                    return SHELL_EXIT_ERROR;
                }
            }
            else
            {
                printf ("Error in dns command, missing ip parameter!\n");
                return SHELL_EXIT_ERROR;
            }
        }
        else if (strcmp (argv[index], "del") == 0)
        {
            if (argc > ++index)
            {
#if RTCSCFG_ENABLE_IP4
                if(inet_pton(AF_INET, argv[index], &dns_addr, sizeof(dns_addr)) == RTCS_OK)
                {
                    res = ipcfg_del_dns_ip(enet_device, dns_addr);
                }
                else
#endif
#if RTCSCFG_ENABLE_IP6
                    if(inet_pton(AF_INET6, argv[index], &dns6_addr, sizeof(dns6_addr)) == RTCS_OK)
                    {
                        res = ipcfg6_del_dns_ip(enet_device, &dns6_addr);
                    }
                    else
#endif
                    {
                        printf ("Error in dns command, invalid ip address!\n");
                        return SHELL_EXIT_ERROR;
                    }

                if(res == TRUE)
                {
                    printf ("Del dns ip successful.\n");
                }
                else
                {
                    printf ("Del dns ip failed!\n");
                    return SHELL_EXIT_ERROR;
                }
            }
            else
            {
                printf ("Error in dns command, missing ip parameter!\n");
                return SHELL_EXIT_ERROR;
            }
        }
        else
        {
            printf ("Error in dns command, unknown parameter!\n");
            return SHELL_EXIT_ERROR;
        }

    }
    else
    {
        char        addr_str[RTCS_IP_ADDR_STR_SIZE];
        int         i;
        sockaddr    dns_server;

        /* Print server address list.*/
        for(i=0;; i++)
        {
            if(DNSCLN_get_dns_addr(ipcfg_get_ihandle(enet_device), i, &dns_server) == TRUE)
            {
                printf ("[%d] %s\n", i + 1, inet_ntop(dns_server.sa_family, &RTCS_SOCKADDR_ADDR(&dns_server), addr_str, sizeof(addr_str)));
            }
            else
            {
                break;
            }
        }
    }

    return SHELL_EXIT_SUCCESS;
}
Ejemplo n.º 15
0
void Main_task(uint32_t temp)
{
   #include <ipcfg.h>
   
   IPCFG_IP_ADDRESS_DATA    ip_data;
   
   _rtcs_if_handle   ihandle;
   uint32_t           error;
   _ip_address       new_target; 
   _enet_address     enet_address;                                   

    /* runtime RTCS configuration */
    _RTCSPCB_init = 4;
    _RTCSPCB_grow = 2;
    _RTCSPCB_max = 6;
    _RTCS_socket_part_init = 4;
    _RTCS_socket_part_grow = 2;
    _RTCS_socket_part_max  = 6;
    
   
    error = RTCS_create();
    if (error) {
        printf("\nFailed to initialize RTCS, error = %X", error);
        _task_block();
    } /* Endif */

    ip_data.ip = ENET_IPADDR;
    ip_data.mask = ENET_IPMASK;
    ip_data.gateway = ENET_IPGATEWAY;
    
    ENET_get_mac_address (BSP_DEFAULT_ENET_DEVICE, ENET_IPADDR, enet_address);
    error = ipcfg_init_device (BSP_DEFAULT_ENET_DEVICE, enet_address);
    error = ipcfg_bind_staticip (BSP_DEFAULT_ENET_DEVICE, &ip_data);
    
    ihandle = ipcfg_get_ihandle( BSP_DEFAULT_ENET_DEVICE );

   /* 
   ** Install some MIBs for the SNMP agent
   ** MIB1213_init must be called before SNMP_init functions 
   ** It should not be removed.
   ** If application wishes to use MQX RTOS, MIBMQX_init must be called
   ** before SNMP_init functions.
   */  
   MIB1213_init();
   /* init MQX MIB */
#if 0
   /* It conflicts with the sample MIB and should only be reinstated when 
    * "your_company" is changed to a more appropriate identifier. 
    * You can find it in the snmp_demo.def file. */
   MIBMQX_init();
#endif
   /* demo MIB table init */
   MIBdemo_init();
    
   /* 
   ** Initialize the agent. 
   ** There are two functions for initializing SNMP agent.
   ** If application wants to send ColdStart/WarmStart traps at 
   ** the initialization time, it must call: 
   ** SNMP_init_with_traps(agent task name, agent task priority, 
   **                      agent task stack size, list of trap receivers);
   **
   ** Calling this function will initialize SNMP agent and send 
   ** ColdStart/WarmStart (depending on system up time) traps to the 
   ** station(s).
   **
   ** If application does not want to send ColdStart/WarmStart traps at 
   ** the initialization time, it must call:
   ** SNMP_init(agent task name, agent task priority, 
   **           agent task stack size);
   **
   ** Note1: If application wishes to use SNMP_init() to initialize the 
   **        SNMP agent, there is no IP address for trap to be sent.
   **        Application must add trap receivers to the list by calling
   **        RTCS_trap_target_add(_ip_address). To remove receiver from
   **        trap receivers list call RTCS_trap_target_remove(_ip_address).
   **
   ** This function initializes SNMP agent without sending any traps. 
   **
   ** This example will use SNMP_init_with_traps. 
   */
   
   //error = SNMP_init("SNMP", 7, 3000);
   
   error = SNMP_init_with_traps("SNMP", 7, 2500, my_trap_list);
   if (error) {
      printf("\nFailed to initialize SNMP agent, error = %X", error);
      _task_block();
   } /* Endif */

    printf("Demo started, wait... \n\r");   
   /* 
   ** RTCS/SNMP agent now supports private and public communities. 
   ** User can add community to the community list, that is defined 
   ** in snmpcfg.h by adding community string to the SNMPCFG_COMMUNITY_LIST
   ** and changing the SNMPCFG_NUM_COMMUNITY respectively.
   **
   ** Note1: Communities cannot be added dynamically.
   ** Note2: RTCS/SNMP agent will respond to get, set and getnext messages 
   **        to communities defined in SNMPCFG_COMMUNITY_LIST.
   **
   ** Application can select communities for send and receive traps by calling
   ** SNMP_trap_select_community(community name); Where community name should 
   ** match one of the strings in the SNMPCFG_COMMUNITY_LIST. By default
   ** current community is set to first string in SNMPCFG_COMMUNITY_LIST[].
   ** This function returns TRUE if the community was changed successfully,
   ** FALSE on failure.
   ** 
   ** Note3: SNMP_trap_select_community(char *community_name); should be
   **        called after SNMP_init (or with trap) has been called. 
   ** 
   ** Note4: mylinkdown trap is enterprise specific, therefore application 
   ** need to implement this trap. SNMP_trap_myLinkDown is just an example 
   ** for use as reference.
   */
   
   /* Send some traps to private and public communities */
   
   /* trap will be sent to four IPs in my_trap_list */
   if(SNMP_trap_select_community("private")) 
   {
      SNMP_trap_linkDown(ihandle);
      SNMP_trap_linkUp(ihandle);
      SNMP_trap_myLinkDown(ihandle);
      SNMP_trap_coldStart(); 
      SNMP_trap_warmStart(); 
   }

   new_target = ENET_TRAP_ADDR5;
   
   /* Add a new IP address to the trap list */
   error = RTCS_trap_target_add(new_target);
   if (error) {
      printf("\nFailed to add target trap, error = %X", error);
   } /* Endif */
   
   /* trap will be sent to five IPs */
   if(SNMP_trap_select_community("public")) 
   {
      SNMP_trap_linkDown(ihandle);
      SNMP_trap_linkUp(ihandle);
      SNMP_trap_myLinkDown(ihandle);
      SNMP_trap_coldStart(); 
      SNMP_trap_warmStart(); 
   }

   /* Remove the new IP address from trap list */
   error = RTCS_trap_target_remove(new_target);
   if (error) {
      printf("\nFailed to remove target trap, error = %X", error);
   } /* Endif */
   
   
#ifdef SNMPCFG_SEND_V2_TRAPS   
   if (SNMP_trap_select_community("public"))
   {
      SNMPv2_trap_linkDown(ihandle);
      SNMPv2_trap_linkUp(ihandle);
      SNMPv2_trap_coldStart();
      SNMPv2_trap_warmStart();
   }
#endif
    
    /* Call the counter demo function */
    Snmp_task(0);
   _task_block();

}
Ejemplo n.º 16
0
uint32_t iwcfg_set_scan
    (
        uint32_t dev_num,
        char *ssid
    )
{
    _rtcs_if_handle ihandle;
    uint32_t error;
    bool dev_status;
    uint32_t i=0;
    ENET_SCAN_LIST  param;
    
    if (dev_num < IPCFG_DEVICE_COUNT)
    {
        ihandle = ipcfg_get_ihandle(dev_num);
        if (ihandle == NULL)
        {
            printf("Initialize Wifi Device Using ipconfig\n");
            return ENET_ERROR;
        }        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_MEDIACTL_IS_INITIALIZED,&dev_status);
        if (ENET_OK != error)
        {
            return error;
        }
        if (dev_status == FALSE)
        {
            return ENET_ERROR;
        }
        
        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_SET_MEDIACTL_SCAN,NULL);
        if (ENET_OK != error)
        {
            return error;
        }

        error = ENET_mediactl (((IP_IF_PTR)ihandle)->HANDLE,ENET_GET_MEDIACTL_SCAN,&param);
        if (ENET_OK != error)
        {
            return error;
        }
   
        for (i = 0;i<param.num_scan_entries;i++)
        {
            uint8_t j = MAX_RSSI_TABLE_SZ-1;
            
            printf("\n\r");
            if (param.scan_info_list[i].ssid_len == 1)
               printf("ssid = SSID Not available\n");
            else
               printf ("ssid = %s\n",param.scan_info_list[i].ssid);
            printf ("bssid = %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",param.scan_info_list[i].bssid[0],param.scan_info_list[i].bssid[1],param.scan_info_list[i].bssid[2],param.scan_info_list[i].bssid[3],param.scan_info_list[i].bssid[4],param.scan_info_list[i].bssid[5]);
            printf ("channel = %d\n",param.scan_info_list[i].channel);
            printf("strength = ");
             do {    
      
                if ( RSSI_TBL_ENTRY_MIN(j) < param.scan_info_list[i].rssi )
                  printf("#");
                else
                  printf(".");
                  
            } while ( j-- > 0 );
            printf("\nindicator = %d",param.scan_info_list[i].rssi);
            printf("\n\r");
        }
        return ENET_OK;
    }
    printf("IWCONFIG_ERROR: Invalid Device number\n");
    return ENETERR_INVALID_DEVICE;
}