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