sysctl_net_ax25.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * Copyright (C) 1996 Mike Shaver (shaver@zeroknowledge.com)
  8. */
  9. #include <linux/mm.h>
  10. #include <linux/slab.h>
  11. #include <linux/sysctl.h>
  12. #include <linux/spinlock.h>
  13. #include <net/ax25.h>
  14. static int min_ipdefmode[1], max_ipdefmode[] = {1};
  15. static int min_axdefmode[1], max_axdefmode[] = {1};
  16. static int min_backoff[1], max_backoff[] = {2};
  17. static int min_conmode[1], max_conmode[] = {2};
  18. static int min_window[] = {1}, max_window[] = {7};
  19. static int min_ewindow[] = {1}, max_ewindow[] = {63};
  20. static int min_t1[] = {1}, max_t1[] = {30000};
  21. static int min_t2[] = {1}, max_t2[] = {20000};
  22. static int min_t3[1], max_t3[] = {3600000};
  23. static int min_idle[1], max_idle[] = {65535000};
  24. static int min_n2[] = {1}, max_n2[] = {31};
  25. static int min_paclen[] = {1}, max_paclen[] = {512};
  26. static int min_proto[1], max_proto[] = { AX25_PROTO_MAX };
  27. #ifdef CONFIG_AX25_DAMA_SLAVE
  28. static int min_ds_timeout[1], max_ds_timeout[] = {65535000};
  29. #endif
  30. static const struct ctl_table ax25_param_table[] = {
  31. {
  32. .procname = "ip_default_mode",
  33. .maxlen = sizeof(int),
  34. .mode = 0644,
  35. .proc_handler = proc_dointvec_minmax,
  36. .extra1 = &min_ipdefmode,
  37. .extra2 = &max_ipdefmode
  38. },
  39. {
  40. .procname = "ax25_default_mode",
  41. .maxlen = sizeof(int),
  42. .mode = 0644,
  43. .proc_handler = proc_dointvec_minmax,
  44. .extra1 = &min_axdefmode,
  45. .extra2 = &max_axdefmode
  46. },
  47. {
  48. .procname = "backoff_type",
  49. .maxlen = sizeof(int),
  50. .mode = 0644,
  51. .proc_handler = proc_dointvec_minmax,
  52. .extra1 = &min_backoff,
  53. .extra2 = &max_backoff
  54. },
  55. {
  56. .procname = "connect_mode",
  57. .maxlen = sizeof(int),
  58. .mode = 0644,
  59. .proc_handler = proc_dointvec_minmax,
  60. .extra1 = &min_conmode,
  61. .extra2 = &max_conmode
  62. },
  63. {
  64. .procname = "standard_window_size",
  65. .maxlen = sizeof(int),
  66. .mode = 0644,
  67. .proc_handler = proc_dointvec_minmax,
  68. .extra1 = &min_window,
  69. .extra2 = &max_window
  70. },
  71. {
  72. .procname = "extended_window_size",
  73. .maxlen = sizeof(int),
  74. .mode = 0644,
  75. .proc_handler = proc_dointvec_minmax,
  76. .extra1 = &min_ewindow,
  77. .extra2 = &max_ewindow
  78. },
  79. {
  80. .procname = "t1_timeout",
  81. .maxlen = sizeof(int),
  82. .mode = 0644,
  83. .proc_handler = proc_dointvec_minmax,
  84. .extra1 = &min_t1,
  85. .extra2 = &max_t1
  86. },
  87. {
  88. .procname = "t2_timeout",
  89. .maxlen = sizeof(int),
  90. .mode = 0644,
  91. .proc_handler = proc_dointvec_minmax,
  92. .extra1 = &min_t2,
  93. .extra2 = &max_t2
  94. },
  95. {
  96. .procname = "t3_timeout",
  97. .maxlen = sizeof(int),
  98. .mode = 0644,
  99. .proc_handler = proc_dointvec_minmax,
  100. .extra1 = &min_t3,
  101. .extra2 = &max_t3
  102. },
  103. {
  104. .procname = "idle_timeout",
  105. .maxlen = sizeof(int),
  106. .mode = 0644,
  107. .proc_handler = proc_dointvec_minmax,
  108. .extra1 = &min_idle,
  109. .extra2 = &max_idle
  110. },
  111. {
  112. .procname = "maximum_retry_count",
  113. .maxlen = sizeof(int),
  114. .mode = 0644,
  115. .proc_handler = proc_dointvec_minmax,
  116. .extra1 = &min_n2,
  117. .extra2 = &max_n2
  118. },
  119. {
  120. .procname = "maximum_packet_length",
  121. .maxlen = sizeof(int),
  122. .mode = 0644,
  123. .proc_handler = proc_dointvec_minmax,
  124. .extra1 = &min_paclen,
  125. .extra2 = &max_paclen
  126. },
  127. {
  128. .procname = "protocol",
  129. .maxlen = sizeof(int),
  130. .mode = 0644,
  131. .proc_handler = proc_dointvec_minmax,
  132. .extra1 = &min_proto,
  133. .extra2 = &max_proto
  134. },
  135. #ifdef CONFIG_AX25_DAMA_SLAVE
  136. {
  137. .procname = "dama_slave_timeout",
  138. .maxlen = sizeof(int),
  139. .mode = 0644,
  140. .proc_handler = proc_dointvec_minmax,
  141. .extra1 = &min_ds_timeout,
  142. .extra2 = &max_ds_timeout
  143. },
  144. #endif
  145. { } /* that's all, folks! */
  146. };
  147. int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
  148. {
  149. char path[sizeof("net/ax25/") + IFNAMSIZ];
  150. int k;
  151. struct ctl_table *table;
  152. table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
  153. if (!table)
  154. return -ENOMEM;
  155. for (k = 0; k < AX25_MAX_VALUES; k++)
  156. table[k].data = &ax25_dev->values[k];
  157. snprintf(path, sizeof(path), "net/ax25/%s", ax25_dev->dev->name);
  158. ax25_dev->sysheader = register_net_sysctl(&init_net, path, table);
  159. if (!ax25_dev->sysheader) {
  160. kfree(table);
  161. return -ENOMEM;
  162. }
  163. return 0;
  164. }
  165. void ax25_unregister_dev_sysctl(ax25_dev *ax25_dev)
  166. {
  167. struct ctl_table_header *header = ax25_dev->sysheader;
  168. struct ctl_table *table;
  169. if (header) {
  170. ax25_dev->sysheader = NULL;
  171. table = header->ctl_table_arg;
  172. unregister_net_sysctl_table(header);
  173. kfree(table);
  174. }
  175. }