ppp.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/sh
  2. NETIFD_MAIN_DIR=../../scripts
  3. . $NETIFD_MAIN_DIR/netifd-proto.sh
  4. init_proto "$@"
  5. ppp_generic_init_config() {
  6. proto_config_add_string "username"
  7. proto_config_add_string "password"
  8. proto_config_add_int "keepalive"
  9. }
  10. proto_ppp_init_config() {
  11. no_device=1
  12. available=1
  13. ppp_generic_init_config
  14. }
  15. proto_ppp_setup() {
  16. echo "ppp_setup($1): $2"
  17. }
  18. proto_ppp_teardown() {
  19. return
  20. }
  21. add_protocol ppp
  22. proto_pppoe_init_config() {
  23. ppp_generic_init_config
  24. }
  25. proto_pppoe_setup() {
  26. local interface="$1"
  27. local device="$2"
  28. json_get_var username username
  29. json_get_var password password
  30. echo "pppoe_setup($interface, $device), username=$username, password=$password"
  31. proto_init_update pppoe-$interface 1
  32. proto_set_keep 1
  33. proto_add_ipv4_address "192.168.2.1" 32
  34. proto_add_dns_server "192.168.2.2"
  35. proto_add_ipv4_route "0.0.0.0" 0 192.168.2.2
  36. proto_add_data
  37. json_add_string "ppp-type" "pppoe"
  38. proto_close_data
  39. proto_send_update "$interface"
  40. proto_init_update pppoe-$interface 1
  41. proto_set_keep 1
  42. proto_add_ipv6_address "fe80::2" 64
  43. proto_add_ipv6_route "::0" 0 "fe80::1"
  44. proto_add_data
  45. json_add_string "ppp-type" "pppoe"
  46. proto_close_data
  47. proto_send_update "$interface"
  48. proto_run_command "$interface" sleep 30
  49. }
  50. proto_pppoe_teardown() {
  51. [ "$ERROR" = 9 ] && {
  52. proto_notify_error "$interface" PROCESS_KILLED
  53. proto_block_restart "$interface"
  54. }
  55. proto_kill_command "$interface"
  56. return
  57. }
  58. add_protocol pppoe