Skip to content

Commit

Permalink
feat(common): Added fully operational ifconfig and ping command
Browse files Browse the repository at this point in the history
  • Loading branch information
espressif-abhikroy committed Sep 6, 2023
1 parent d5fec78 commit 4d96574
Show file tree
Hide file tree
Showing 14 changed files with 451 additions and 217 deletions.
4 changes: 2 additions & 2 deletions components/console_cmd_ifconfig/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
idf_component_register(SRCS "console_connect.c" "console_ifconfig.c"
INCLUDE_DIRS "include"
idf_component_register(SRCS "console_ifconfig.c"
INCLUDE_DIRS "."
REQUIRES "ethernet_init"
PRIV_REQUIRES esp_netif console nvs_flash esp_eth)
18 changes: 0 additions & 18 deletions components/console_cmd_ifconfig/Kconfig.projbuild

This file was deleted.

53 changes: 21 additions & 32 deletions components/console_cmd_ifconfig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ The component offers a console that enables runtime network interface configurat
## API

### Steps to enable console in an example code:
1. Add this component to your project using the command:
```bash
idf.py add-dependency
```
1. Add this component to your project using ```idf.py add-dependency``` command.
2. In the main file of the example, add the following line:
```c
#include "console_connect.h"
#include "console_ifconfig.h"
```
3. Ensure esp-netif is initialized and default event loop is created in your app_main():
```c
Expand All @@ -19,39 +16,31 @@ The component offers a console that enables runtime network interface configurat
```
4. In your app_main() function, add the following line as the last line:
```c
example_start_networking_console(NULL, NULL);
```
5. Optionally, you can add a user-defined command:
```c
example_start_networking_console("user_cmd", usr_cmd_hndl);
```
In the above line, "user_cmd" is a string representing the user-defined command name, and usr_cmd_hndl is the command callback function with the prototype.
```c
int usr_cmd_hndl(int argc, char **argv)
console_cmd_init(); // Initialize console
console_cmd_ifconfig_register();
console_cmd_start(); // Start console
```


## Suported commands:

### Ifconfig:
* **ifconfig help:** Prints the help text for all ifconfig commands
* **ifconfig netif create/destroy \<ethernet handle id\>/\<iface\>:** Create or destroy a network interface with the specified ethernet handle or interface name
* **ifconfig eth show:** Display a list of available ethernet handle
* **ifconfig:** Display a list of all esp_netif interfaces along with their information.
* **ifconfig \<iface>:** Provide the details of the named interface.
* **ifconfig \<iface> default:** Set the specified interface as the default interface.
* **ifconfig \<iface> ip6:** Enable IPv6 on the specified interface.
* **ifconfig <iface> up:** Enable the specified interface.
* **ifconfig <iface> down:** Disable the specified interface.
* **ifconfig \<iface> link \<up/down>:** Enable or disable the link of the specified interface.
* **ifconfig \<iface> ip \<ipv4 address>:** Set the IPv4 address of the specified interface.
* **ifconfig \<iface> mask \<ipv4 address>:** Set the subnet mask of the specified interface.
* **ifconfig \<iface> gw \<ipv4 address>:** Set the default gateway of the specified interface.
* **ifconfig \<iface> napt \<enable/disable>:** Enable or disable Network Address and Port Translation (NAPT) on the specified interface.
* **ifconfig \<iface> dhcp server \<enable/disable>:** Enable or disable the DHCP server on the specified interface. (Note: DHCP server is not supported yet)
* **ifconfig \<iface> dhcp client \<enable/disable>:** Enable or disable the DHCP client on the specified interface.
* **ifconfig netif create/destroy \<ethernet handle id>/\<iface>:** Create or destroy a network interface with the specified ethernet handle or interface name
* **ifconfig eth init/deinit/show:** Initialize, deinitialize and display a list of available ethernet handle
* **ifconfig:** Display a list of all esp_netif interfaces along with their information
* **ifconfig \<iface>:** Provide the details of the named interface
* **ifconfig \<iface> default:** Set the specified interface as the default interface
* **ifconfig \<iface> ip6:** Enable IPv6 on the specified interface
* **ifconfig \<iface> up:** Enable the specified interface
* **ifconfig \<iface> down:** Disable the specified interface
* **ifconfig \<iface> link <up/down>:** Enable or disable the link of the specified interface
* **ifconfig \<iface> napt <enable/disable>:** Enable or disable NAPT on the specified interface.
* **ifconfig \<iface> ip <ipv4 addr>:** Set the IPv4 address of the specified interface
* **ifconfig \<iface> mask <ipv4 addr>:** Set the subnet mask of the specified interface
* **ifconfig \<iface> gw <ipv4 addr>:** Set the default gateway of the specified interface
* **ifconfig \<iface> staticip:** Enables static ip
* **ifconfig \<iface> dhcp server <enable/disable>:** Enable or disable the DHCP server.(Note: DHCP server is not supported yet)
* **ifconfig \<iface> dhcp client <enable/disable>:** Enable or disable the DHCP client.

Note: Disabling the DHCP server and client enables the use of static IP configuration.

### Quit:
**quit:** Quits the Console application.
96 changes: 0 additions & 96 deletions components/console_cmd_ifconfig/console_connect.c

This file was deleted.

Loading

0 comments on commit 4d96574

Please sign in to comment.