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.
 
 
 
 

105 lines
3.5 KiB

  1. #ifndef _NM_CONF_H
  2. #define _NM_CONF_H
  3. #include "netcfg.h"
  4. /* Constants for maximum size for Network Manager config fields. */
  5. #define NM_MAX_LEN_BUF 1024 /* Max len for most buffers */
  6. #define NM_MAX_LEN_ID 128
  7. #define NM_MAX_LEN_SSID 128
  8. #define NM_MAX_LEN_MAC_ADDR 20 /* AA:BB:CC:DD:EE:FF format */
  9. #define NM_MAX_LEN_IPV4 20 /* x.x.x.x format */
  10. #define NM_MAX_LEN_WPA_PSK 65 /* 64 standard + NULL char */
  11. #define NM_MAX_LEN_WEP_KEY 30 /* Rough estimation (should be 26) */
  12. #define NM_MAX_LEN_PATH 128 /* Assume a path won't be longer */
  13. #define NM_MAX_LEN_UUID 37
  14. #define NM_NO_BITS_IPV4 32
  15. /* Some Network Manager default values for connection types. */
  16. #define NM_DEFAULT_WIRED "802-3-ethernet"
  17. #define NM_DEFAULT_WIRED_NAME "Wired connection 1"
  18. #define NM_DEFAULT_WIRELESS "802-11-wireless"
  19. #define NM_DEFAULT_WIRELESS_SECURITY "802-11-wireless-security"
  20. #define NM_DEFAULT_PATH_FOR_MAC "/sys/class/net/%s/address"
  21. #define NM_CONFIG_FILE_PATH "/etc/NetworkManager/system-connections"
  22. #define NM_CONNECTION_FILE "/tmp/connection_type"
  23. #define NM_SETTINGS_CONNECTION "[connection]"
  24. #define NM_SETTINGS_WIRELESS "["NM_DEFAULT_WIRELESS"]"
  25. #define NM_SETTINGS_WIRED "["NM_DEFAULT_WIRED"]"
  26. #define NM_SETTINGS_WIRELESS_SECURITY "["NM_DEFAULT_WIRELESS_SECURITY"]"
  27. #define NM_SETTINGS_IPV4 "[ipv4]"
  28. #define NM_SETTINGS_IPV6 "[ipv6]"
  29. /* Minimalist structures for storing basic elements in order to write a Network
  30. * Manager format config file.
  31. *
  32. * See full specifications at:
  33. *
  34. * http://projects.gnome.org/NetworkManager/developers/settings-spec-08.html
  35. *
  36. */
  37. typedef struct nm_connection
  38. {
  39. char id[NM_MAX_LEN_ID];
  40. char uuid[NM_MAX_LEN_UUID];
  41. enum {WIRED, WIFI} type;
  42. int manual; /* 1 = true, 0 = false */
  43. } nm_connection;
  44. typedef struct nm_wired
  45. {
  46. char mac_addr[NM_MAX_LEN_MAC_ADDR];
  47. } nm_wired;
  48. typedef struct nm_wireless
  49. {
  50. char ssid[NM_MAX_LEN_SSID];
  51. char mac_addr[NM_MAX_LEN_MAC_ADDR];
  52. enum {AD_HOC, INFRASTRUCTURE} mode;
  53. enum {FALSE = 0, TRUE = 1} is_secured; /* 1 = secure, 0 = unsecure */
  54. } nm_wireless;
  55. typedef struct nm_wireless_security
  56. {
  57. enum {WEP_KEY, WPA_PSK} key_mgmt;
  58. union
  59. {
  60. char psk[NM_MAX_LEN_WPA_PSK];
  61. struct
  62. {
  63. enum {HEX_ASCII = 1, PASSPHRASE = 2} wep_key_type;
  64. enum {OPEN, SHARED} auth_alg;
  65. unsigned char wep_key0[NM_MAX_LEN_WEP_KEY];
  66. };
  67. };
  68. } nm_wireless_security;
  69. typedef struct nm_ipvX
  70. {
  71. int used; /* 1 = true, 0 = false */
  72. enum {AUTO, MANUAL, IGNORE} method;
  73. char * ip_address;
  74. char * gateway;
  75. char * nameservers[NETCFG_NAMESERVERS_MAX];
  76. unsigned int masklen;
  77. } nm_ipvX;
  78. typedef struct nm_config_info
  79. {
  80. nm_connection connection;
  81. nm_wired wired;
  82. nm_wireless wireless;
  83. nm_wireless_security wireless_security;
  84. nm_ipvX ipv4;
  85. nm_ipvX ipv6;
  86. } nm_config_info;
  87. /* Public functions */
  88. void nm_get_configuration(struct netcfg_interface *niface, struct nm_config_info *nmconf);
  89. void nm_write_configuration(struct nm_config_info nmconf);
  90. #endif