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.

netcfg.h 5.2 KiB

17 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. #ifndef _NETCFG_H_
  2. #define _NETCFG_H_
  3. #define INTERFACES_FILE "/etc/network/interfaces"
  4. #define HOSTS_FILE "/etc/hosts"
  5. #define HOSTNAME_FILE "/etc/hostname"
  6. #define NETWORKS_FILE "/etc/networks"
  7. #define RESOLV_FILE "/etc/resolv.conf"
  8. #define DHCLIENT_CONF "/etc/dhclient.conf"
  9. #define DOMAIN_FILE "/tmp/domain_name"
  10. #define NTP_SERVER_FILE "/tmp/dhcp-ntp-servers"
  11. #define WPASUPP_CTRL "/var/run/wpa_supplicant"
  12. #define WPAPID "/var/run/wpa_supplicant.pid"
  13. #define DEVNAMES "/etc/network/devnames"
  14. #define DEVHOTPLUG "/etc/network/devhotplug"
  15. #ifdef __linux__
  16. #define STAB "/var/run/stab"
  17. #endif
  18. #define WPA_MIN 8 /* minimum passphrase length */
  19. #define WPA_MAX 64 /* maximum passphrase length */
  20. #define _GNU_SOURCE
  21. #include <sys/types.h>
  22. #include <arpa/inet.h>
  23. #include <stdio.h>
  24. #include <cdebconf/debconfclient.h>
  25. #ifndef ARRAY_SIZE
  26. # define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
  27. #endif
  28. #define empty_str(s) (s != NULL && *s == '\0')
  29. #define HELPFUL_COMMENT \
  30. "# This file describes the network interfaces available on your system\n" \
  31. "# and how to activate them. For more information, see interfaces(5).\n"
  32. #define IPV6_HOSTS \
  33. "# The following lines are desirable for IPv6 capable hosts\n" \
  34. "::1 ip6-localhost ip6-loopback\n" \
  35. "fe00::0 ip6-localnet\n" \
  36. "ff00::0 ip6-mcastprefix\n" \
  37. "ff02::1 ip6-allnodes\n" \
  38. "ff02::2 ip6-allrouters\n"
  39. /* The time, in seconds, that we will wait for a link to be established
  40. * via link autonegotiation. Sometime in the future this may become a
  41. * preseed option.
  42. */
  43. #define NETCFG_LINK_WAIT_TIME 3
  44. #ifndef MAXHOSTNAMELEN
  45. #define MAXHOSTNAMELEN 63
  46. #endif
  47. typedef enum { NOT_ASKED = 30, GO_BACK, REPLY_WEP, REPLY_WPA } response_t;
  48. typedef enum { DHCP, STATIC, DUNNO } method_t;
  49. typedef enum { ADHOC = 1, MANAGED = 2 } wifimode_t;
  50. extern enum wpa_t { WPA_OK, WPA_QUEUED, WPA_UNAVAIL } wpa_supplicant_status;
  51. extern int netcfg_progress_displayed;
  52. extern int wfd, skfd;
  53. extern int input_result;
  54. extern int have_domain;
  55. /* network config */
  56. extern char *interface;
  57. extern char *hostname;
  58. extern char *dhcp_hostname;
  59. extern char *domain;
  60. extern struct in_addr ipaddress;
  61. extern struct in_addr nameserver_array[4];
  62. extern struct in_addr network;
  63. extern struct in_addr broadcast;
  64. extern struct in_addr netmask;
  65. extern struct in_addr gateway;
  66. extern struct in_addr pointopoint;
  67. /* wireless */
  68. extern char *essid, *wepkey, *passphrase;
  69. extern wifimode_t mode;
  70. /* common functions */
  71. extern int check_kill_switch (const char *iface);
  72. extern int is_interface_up (char *inter);
  73. extern void get_name (char *name, char *p);
  74. extern int get_all_ifs (int all, char ***ptr);
  75. extern char *get_ifdsc (struct debconfclient *client, const char *ifp);
  76. extern FILE *file_open (char *path, const char *opentype);
  77. extern void netcfg_die (struct debconfclient *client);
  78. extern int netcfg_get_interface(struct debconfclient *client, char **interface, int *num_interfaces, char* defif);
  79. extern short valid_hostname (const char *hname);
  80. extern short valid_domain (const char *dname);
  81. extern int netcfg_get_hostname(struct debconfclient *client, char *template, char **hostname, short hdset);
  82. extern int netcfg_get_nameservers (struct debconfclient *client, char **nameservers);
  83. extern int netcfg_get_domain(struct debconfclient *client, char **domain);
  84. extern int netcfg_get_static(struct debconfclient *client);
  85. extern int netcfg_activate_dhcp(struct debconfclient *client);
  86. extern int resolv_conf_entries (void);
  87. extern int read_resolv_conf_nameservers (struct in_addr array[]);
  88. extern int ask_dhcp_options (struct debconfclient *client);
  89. extern int netcfg_activate_static(struct debconfclient *client);
  90. extern void netcfg_write_loopback (void);
  91. extern void netcfg_write_common (struct in_addr ipaddress, char *hostname,
  92. char *domain);
  93. void netcfg_nameservers_to_array(char *nameservers, struct in_addr array[]);
  94. extern int is_wireless_iface (const char* iface);
  95. extern int netcfg_wireless_set_essid (struct debconfclient *client, char* iface, char* priority);
  96. extern int netcfg_wireless_set_wep (struct debconfclient *client, char* iface);
  97. extern int wireless_security_type (struct debconfclient *client, char* iface);
  98. extern int netcfg_set_passphrase (struct debconfclient *client, char* iface);
  99. extern int init_wpa_supplicant_support (void);
  100. extern int kill_wpa_supplicant (void);
  101. extern int wpa_supplicant_start (struct debconfclient *client, char *iface, char *ssid, char *passphrase);
  102. extern int iface_is_hotpluggable(const char *iface);
  103. extern short find_in_stab (const char *iface);
  104. extern void deconfigure_network(void);
  105. extern void interface_up (char*);
  106. extern void interface_down (char*);
  107. extern void loop_setup(void);
  108. extern void seed_hostname_from_dns(struct debconfclient *client, struct in_addr * ipaddress);
  109. extern int inet_ptom (const char *src, int *dst, struct in_addr * addrp);
  110. extern const char *inet_mtop (int src, char *dst, socklen_t cnt);
  111. extern void parse_args (int argc, char** argv);
  112. extern void open_sockets (void);
  113. extern void reap_old_files (void);
  114. extern void netcfg_update_entropy (void);
  115. extern int netcfg_write_resolv (char*, struct in_addr *);
  116. extern int ethtool_lite (const char *if_name);
  117. extern int netcfg_detect_link(struct debconfclient *client, const char *if_name);
  118. #endif /* _NETCFG_H_ */