2 ===================================================================
3 RCS file: /cvsroot/pptpclient/pptp-linux/routing.c,v
4 retrieving revision 1.1
5 diff -u -r1.1 routing.c
6 --- a/routing.c 2 Aug 2006 07:07:37 -0000 1.1
7 +++ b/routing.c 25 Mar 2009 13:58:28 -0000
14 +#if defined (__SVR4) && defined (__sun) /* Solaris */
15 +#include <sys/types.h>
16 +#include <sys/socket.h>
18 +#include <arpa/inet.h>
23 +/* Destination and gateway addresses */
24 +struct sockaddr_in rdst, rgw;
25 +/* Request sequence */
29 /* route to the server */
38 void routing_init(char *ip) {
39 +#if defined (__SVR4) && defined (__sun) /* Solaris */
40 + rdst.sin_family = AF_INET;
41 + if ( ! inet_pton(AF_INET, ip, &rdst.sin_addr) ) {
42 + log("Cannot convert address: %s", strerror(errno));
46 + if ( (rts = socket(PF_ROUTE, SOCK_RAW, AF_INET )) < 0 ) {
47 + log("Cannot open routing socket: %s", strerror(errno));
51 + struct rt_msg rtm = {
52 + .hdr.rtm_msglen = sizeof(struct rt_msg),
53 + .hdr.rtm_version = RTM_VERSION,
54 + .hdr.rtm_type = RTM_GET,
55 + .hdr.rtm_addrs = RTA_DST,
56 + .hdr.rtm_pid = getpid(),
57 + .hdr.rtm_seq = ++rseq,
58 + .addrs[RTAX_DST] = rdst
61 + if ( write(rts, &rtm, rtm.hdr.rtm_msglen) != rtm.hdr.rtm_msglen ) {
62 + log("Error writing to routing socket: %s", strerror(errno));
67 + while ( read(rts, &rtm, sizeof(struct rt_msg)) > 0 )
68 + if ( rtm.hdr.rtm_pid == getpid() && rtm.hdr.rtm_seq == rseq) {
69 + /* Check if host route already present */
70 + if ( ( rtm.hdr.rtm_flags & RTF_HOST ) != RTF_HOST ) {
71 + rgw = rtm.addrs[RTAX_GATEWAY];
78 - snprintf(buf, 255, "/bin/ip route get %s", ip);
79 - FILE *p = popen(buf, "r");
82 + snprintf(buf, 255, "%s route get %s", IP_BINARY, ip);
83 + p = popen(buf, "r");
85 /* TODO: check for failure of fgets */
88 /* TODO: check for failure of command */
92 void routing_start() {
93 +#if defined (__SVR4) && defined (__sun) /* Solaris */
97 + struct rt_msg rtm = {
98 + .hdr.rtm_msglen = sizeof(struct rt_msg),
99 + .hdr.rtm_version = RTM_VERSION,
100 + .hdr.rtm_type = RTM_ADD,
101 + .hdr.rtm_flags = RTF_HOST | RTF_GATEWAY | RTF_STATIC,
102 + .hdr.rtm_addrs = RTA_DST | RTA_GATEWAY,
103 + .hdr.rtm_pid = getpid(),
104 + .hdr.rtm_seq = ++rseq,
105 + .addrs[RTAX_DST] = rdst,
106 + .addrs[RTAX_GATEWAY] = rgw
109 + if ( write(rts, &rtm, rtm.hdr.rtm_msglen) != rtm.hdr.rtm_msglen ) {
110 + log("Error adding route: %s", strerror(errno));
114 - snprintf(buf, 255, "/bin/ip route replace %s", route);
115 - FILE *p = popen(buf, "r");
118 + snprintf(buf, 255, "%s route replace %s", IP_BINARY, route);
119 + p = popen(buf, "r");
121 +#endif /* Solaris */
125 +#if defined (__SVR4) && defined (__sun) /* Solaris */
129 + struct rt_msg rtm = {
130 + .hdr.rtm_msglen = sizeof(struct rt_msg),
131 + .hdr.rtm_version = RTM_VERSION,
132 + .hdr.rtm_type = RTM_DELETE,
133 + .hdr.rtm_flags = RTF_HOST | RTF_GATEWAY | RTF_STATIC,
134 + .hdr.rtm_addrs = RTA_DST | RTA_GATEWAY,
135 + .hdr.rtm_pid = getpid(),
136 + .hdr.rtm_seq = ++rseq,
137 + .addrs[RTAX_DST] = rdst,
138 + .addrs[RTAX_GATEWAY] = rgw
141 + if ( write(rts, &rtm, rtm.hdr.rtm_msglen) != rtm.hdr.rtm_msglen ) {
142 + log("Error deleting route: %s", strerror(errno));
146 - snprintf(buf, 255, "/bin/ip route delete %s", route);
147 - FILE *p = popen(buf, "r");
150 + snprintf(buf, 255, "%s route delete %s", IP_BINARY, route);
151 + p = popen(buf, "r");
153 +#endif /* Solaris */
156 ===================================================================
157 RCS file: /cvsroot/pptpclient/pptp-linux/Makefile,v
158 retrieving revision 1.47
159 retrieving revision 1.49
160 diff -u -r1.47 -r1.49
161 --- a/Makefile 14 May 2008 06:32:52 -0000 1.47
162 +++ b/Makefile 24 Jul 2008 05:37:47 -0000 1.49
164 -# $Id: Makefile,v 1.47 2008/05/14 06:32:52 quozl Exp $
165 +# $Id: Makefile,v 1.49 2008/07/24 05:37:47 quozl Exp $
169 #################################################################
170 -# CHANGE THIS LINE to point to the location of your pppd binary.
171 +# CHANGE THIS LINE to point to the location of binaries
172 PPPD = /usr/sbin/pppd
174 +# PPPD = /usr/bin/pppd
176 #################################################################
178 BINDIR=$(DESTDIR)/usr/sbin
180 echo "/* text added by Makefile target config.h */" > config.h
181 echo "#define PPTP_LINUX_VERSION \"$(VERSION)$(RELEASE)\"" >> config.h
182 echo "#define PPPD_BINARY \"$(PPPD)\"" >> config.h
183 + echo "#define IP_BINARY \"$(IP)\"" >> config.h
185 vector_test: vector_test.o vector.o
186 $(CC) -o vector_test vector_test.o vector.o