00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 #ifndef PORTABLE_H
00092 #define PORTABLE_H
00093
00094
00095 #define DIBBLER_VERSION "0.4.1"
00096
00097 #define DIBBLER_COPYRIGHT1 "| Dibbler - a portable DHCPv6, version " DIBBLER_VERSION
00098 #define DIBBLER_COPYRIGHT2 "| Authors : Tomasz Mrugalski<thomson(at)klub.com.pl>,Marek Senderski<msend(at)o2.pl>"
00099 #define DIBBLER_COPYRIGHT3 "| Licence : GNU GPL v2 or later. Developed at Gdansk University of Technology."
00100 #define DIBBLER_COPYRIGHT4 "| Homepage: http://klub.com.pl/dhcpv6/"
00101
00102 #ifdef LINUX
00103 #include <netinet/in.h>
00104 #include <stdio.h>
00105 #include <stdlib.h>
00106 #include <unistd.h>
00107 #include <resolv.h>
00108 #include <sys/socket.h>
00109 #include <sys/select.h>
00110 #include <sys/time.h>
00111 #include <arpa/inet.h>
00112 #include <ctype.h>
00113 #include <stdarg.h>
00114 #include <string.h>
00115 #endif
00116
00117
00118
00119
00120
00121 #define CLNTCFGMGR_FILE "client-CfgMgr.xml"
00122 #define CLNTIFACEMGR_FILE "client-IfaceMgr.xml"
00123 #define CLNTDUID_FILE "client-duid"
00124 #define CLNTADDRMGR_FILE "client-AddrMgr.xml"
00125 #define CLNTTRANSMGR_FILE "client-TransMgr.xml"
00126
00127 #define SRVCFGMGR_FILE "server-CfgMgr.xml"
00128 #define SRVIFACEMGR_FILE "server-IfaceMgr.xml"
00129 #define SRVDUID_FILE "server-duid"
00130 #define SRVADDRMGR_FILE "server-AddrMgr.xml"
00131 #define SRVTRANSMGR_FILE "server-TransMgr.xml"
00132
00133 #define RELCFGMGR_FILE "relay-CfgMgr.xml"
00134 #define RELIFACEMGR_FILE "relay-IfaceMgr.xml"
00135 #define RELTRANSMGR_FILE "relay-TransMgr.xml"
00136
00137
00138
00139
00140 #define CLIENT_BIND_REUSE true
00141
00142 #ifdef WIN32
00143 #define WORKDIR ".\\"
00144 #define CLNTCONF_FILE "client.conf"
00145 #define SRVCONF_FILE "server.conf"
00146 #define RELCONF_FILE "relay.conf"
00147 #define CLNTLOG_FILE "client.log"
00148 #define SRVLOG_FILE "server.log"
00149 #define RELLOG_FILE "relay.log"
00150 #define NULLFILE "nul"
00151 #endif
00152
00153 #ifdef LINUX
00154 #define WORKDIR "/var/lib/dibbler"
00155 #define CLNTCONF_FILE "/etc/dibbler/client.conf"
00156 #define SRVCONF_FILE "/etc/dibbler/server.conf"
00157 #define RELCONF_FILE "/etc/dibbler/relay.conf"
00158 #define RESOLVCONF_FILE "/etc/resolv.conf"
00159 #define CLNTPID_FILE "/var/lib/dibbler/client.pid"
00160 #define SRVPID_FILE "/var/lib/dibbler/server.pid"
00161 #define RELPID_FILE "/var/lib/dibbler/relay.pid"
00162 #define CLNTLOG_FILE "/var/lib/dibbler/dibbler-client.log"
00163 #define SRVLOG_FILE "/var/lib/dibbler/dibbler-server.log"
00164 #define RELLOG_FILE "/var/lib/dibbler/dibbler-relay.log"
00165 #define NULLFILE "/dev/null"
00166 #endif
00167
00168
00169 #define OPTION_DNS_SERVERS_FILENAME "option-dns-servers"
00170 #define OPTION_DOMAINS_FILENAME "option-domains"
00171 #define OPTION_NTP_SERVERS_FILENAME "option-ntp-servers"
00172 #define OPTION_TIMEZONE_FILENAME "option-timezone"
00173 #define OPTION_SIP_SERVERS_FILENAME "option-sip-servers"
00174 #define OPTION_SIP_DOMAINS_FILENAME "option-sip-domains"
00175 #define OPTION_NIS_SERVERS_FILENAME "option-nis-servers"
00176 #define OPTION_NIS_DOMAIN_FILENAME "option-nis-domain"
00177 #define OPTION_NISP_SERVERS_FILENAME "option-nisplus-servers"
00178 #define OPTION_NISP_DOMAIN_FILENAME "option-nisplus-domain"
00179
00180
00181
00182
00183
00184 #ifdef WIN32
00185 #define MAX_IFNAME_LENGTH 255
00186 #define LOGLEVEL 0
00187 #define IF_RUNNING 0x1
00188 #define IF_UP 0x1
00189 #define IF_MULTICAST 0x4
00190 #define IF_LOOPBACK 0x8
00191 #endif
00192
00193 #ifdef LINUX
00194 #define MAX_IFNAME_LENGTH 64
00195 #define LOGLEVEL 0
00196 #define IF_UP 0x1
00197 #define IF_LOOPBACK 0x8
00198 #define IF_RUNNING 0x40
00199 #define IF_MULTICAST 0x1000
00200 #endif
00201
00202
00203
00204
00205
00206 #ifdef WIN32
00207 #define strncasecmp _strnicmp
00208 #include <windows.h>
00209 #include <time.h>
00210 #endif
00211
00212 #define now() (unsigned) time(NULL)
00213
00214
00215
00216
00217
00218 #ifdef __cplusplus
00219 extern "C" {
00220 #endif
00221
00222 extern struct iface * if_list_get();
00223 extern void if_list_release(struct iface * list);
00224
00225
00226 extern int ipaddr_add(const char* ifacename, int ifindex, const char* addr,
00227 unsigned long pref, unsigned long valid);
00228 extern int ipaddr_del(const char* ifacename, int ifindex, const char* addr);
00229
00230
00231 extern int sock_add(char* ifacename,int ifaceid, char* addr, int port, int thisifaceonly, int reuse);
00232 extern int sock_del(int fd);
00233 extern int sock_send(int fd, char* addr, char* buf, int buflen, int port, int iface);
00234 extern int sock_recv(int fd, char* myPlainAddr, char* peerPlainAddr, char* buf, int buflen);
00235
00236
00237 extern void print_packed(char addr[]);
00238 extern int inet_pton4(const char* src, char* dst);
00239 extern int inet_pton6(const char* src, char* dst);
00240 extern char * inet_ntop4(const char* src, char* dst);
00241 extern char * inet_ntop6(const char* src, char* dst);
00242 extern void print_packed(char * addr);
00243 extern int is_addr_tentative(char* ifacename, int iface, char* plainAddr);
00244
00245 extern void microsleep(int microsecs);
00246
00247
00248 extern int dns_add(const char* ifname, int ifindex, const char* addrPlain);
00249 extern int dns_del(const char* ifname, int ifindex, const char* addrPlain);
00250 extern int domain_add(const char* ifname, int ifindex, const char* domain);
00251 extern int domain_del(const char* ifname, int ifindex, const char* domain);
00252 extern int ntp_add(const char* ifname, int ifindex, const char* addrPlain);
00253 extern int ntp_del(const char* ifname, int ifindex, const char* addrPlain);
00254 extern int timezone_set(const char* ifname, int ifindex, const char* timezone);
00255 extern int timezone_del(const char* ifname, int ifindex, const char* timezone);
00256 extern int sipserver_add(const char* ifname, int ifindex, const char* addrPlain);
00257 extern int sipserver_del(const char* ifname, int ifindex, const char* addrPlain);
00258 extern int sipdomain_add(const char* ifname, int ifindex, const char* domain);
00259 extern int sipdomain_del(const char* ifname, int ifindex, const char* domain);
00260 extern int nisserver_add(const char* ifname, int ifindex, const char* addrPlain);
00261 extern int nisserver_del(const char* ifname, int ifindex, const char* addrPlain);
00262 extern int nisdomain_set(const char* ifname, int ifindex, const char* domain);
00263 extern int nisdomain_del(const char* ifname, int ifindex, const char* domain);
00264
00265 extern int nisplusserver_add(const char* ifname, int ifindex, const char* addrPlain);
00266 extern int nisplusserver_del(const char* ifname, int ifindex, const char* addrPlain);
00267 extern int nisplusdomain_set(const char* ifname, int ifindex, const char* domain);
00268 extern int nisplusdomain_del(const char* ifname, int ifindex, const char* domain);
00269
00270 #ifdef __cplusplus
00271 }
00272 #endif
00273
00274 #ifndef MAX_IFNAME_LENGTH
00275 #define MAX_IFNAME_LENGTH 255
00276 #endif
00277
00278 struct iface {
00279 char name[MAX_IFNAME_LENGTH];
00280 int id;
00281 int hardwareType;
00282 char mac[255];
00283 int maclen;
00284 char *linkaddr;
00285 int linkaddrcount;
00286 char *globaladdr;
00287 int globaladdrcount;
00288 unsigned int flags;
00289 struct iface* next;
00290 };
00291
00292 #endif
00293