OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
3.6 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../wireless-tools/rocknet_wireless.sh
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; version 2 of the License. A copy of the
  12. # GNU General Public License can be found in the file COPYING.
  13. # --- T2-COPYRIGHT-NOTE-END ---
  14. iwdetect_mangle_cells() {
  15. local essid=none mode= encryption= quality=
  16. local line=
  17. mkdir -p $rocknet_tmp_base/$if/
  18. iwlist $if scan | while read line; do
  19. if [[ $line = *ESSID* ]]; then
  20. [ -n "$essid" ] && echo -e "$essid\t$mode\t$encryption\t$quality"
  21. essid="$( echo "$line" | sed -e 's,.*"\(.*\)",\1,g' )"
  22. mode=
  23. encryption=
  24. quality=
  25. elif [[ $line = Mode:* ]]; then
  26. mode=${line#*:}
  27. elif [[ $line = Encryption* ]]; then
  28. encryption=${line#*:}
  29. elif [[ $line = *Quality* ]]; then
  30. quality=$( echo "$line" | sed -e 's,:\([^ ]*\),:\1\n,g' | sed -e 's,^.*:,,g' | head -n 2 | tr '\n' '\t' )
  31. elif [ -z "$line" ]; then
  32. [ "$essid" != "none" ] && echo -e "$essid\t$mode\t$encryption\t$quality"
  33. fi
  34. done > $rocknet_tmp_base/$if/detected_cells
  35. }
  36. iwdetect_select_cell() {
  37. local networkfile=${1:-/etc/conf/network-nettab}
  38. local essid= key= extra=
  39. local line=
  40. if [ -f $networkfile ]; then
  41. while read -r essid key extra; do
  42. line="$( grep -e "^$essid" $rocknet_tmp_base/$if/detected_cells )"
  43. if [ -n "$line" ]; then
  44. echo "'$essid' selected..."
  45. echo "$line" | ( read -r -d '\t' essid mode encryption quality signal;
  46. iwconfig $if essid "$essid"
  47. case "$mode" in
  48. Master) iwconfig $if mode Managed ;;
  49. Ad-Hoc) iwconfig $if mode "Ad-Hoc" ;;
  50. *) echo "WARNING: Unknown mode '$mode'." ;;
  51. esac
  52. )
  53. break
  54. fi
  55. done < $networkfile
  56. else
  57. echo "INFO: to use iwdetect you need to set a $networkfile."
  58. fi
  59. }
  60. public_iwdetect() {
  61. addcode up 4 2 "ip link set $if up"
  62. addcode up 4 3 "iwdetect_mangle_cells"
  63. addcode up 4 4 "iwdetect_select_cell $1"
  64. addcode down 4 5 "iwconfig $if essid any"
  65. }
  66. public_essid() {
  67. addcode up 4 5 "iwconfig $if essid $*"
  68. addcode down 4 5 "iwconfig $if essid any"
  69. }
  70. public_nwid() {
  71. addcode up 4 5 "iwconfig $if nwid $*"
  72. addcode down 4 5 "iwconfig $if nwid off"
  73. }
  74. public_domain() {
  75. addcode up 4 5 "iwconfig $if domain $*"
  76. addcode down 4 5 "iwconfig $if domain off"
  77. }
  78. public_freq() {
  79. addcode up 4 5 "iwconfig $if freq $*"
  80. }
  81. public_channel() {
  82. addcode up 4 5 "iwconfig $if channel $*"
  83. }
  84. public_sens() {
  85. addcode up 4 5 "iwconfig $if sens $*"
  86. }
  87. public_mode() {
  88. addcode up 4 4 "iwconfig $if mode $*"
  89. addcode down 4 4 "iwconfig $if mode Auto"
  90. }
  91. public_ap() {
  92. addcode up 4 5 "iwconfig $if ap $*"
  93. addcode down 4 5 "iwconfig $if ap any"
  94. }
  95. public_nick() {
  96. addcode up 4 5 "iwconfig $if nick $*"
  97. }
  98. public_rate() {
  99. addcode up 4 5 "iwconfig $if rate $*"
  100. addcode down 4 5 "iwconfig $if rate auto"
  101. }
  102. public_rts() {
  103. addcode up 4 5 "iwconfig $if rts $*"
  104. }
  105. public_frag() {
  106. addcode up 4 5 "iwconfig $if frag $*"
  107. }
  108. public_key() {
  109. addcode up 4 5 "iwconfig $if key $*"
  110. addcode down 4 5 "iwconfig $if key off"
  111. }
  112. public_enc() {
  113. addcode up 4 5 "iwconfig $if enc $*"
  114. addcode down 4 5 "iwconfig $if enc off"
  115. }
  116. public_power() {
  117. addcode up 4 5 "iwconfig $if power $*"
  118. }
  119. public_txpower() {
  120. addcode up 4 5 "iwconfig $if txpower $*"
  121. addcode down 4 5 "iwconfig $if txpower auto"
  122. }
  123. public_retry() {
  124. addcode up 4 5 "iwconfig $if retry $*"
  125. }
  126. public_commit() {
  127. addcode up 4 9 "iwconfig $if commit"
  128. }