]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blame - pptp/patches/pptp-1.7.2-ip-path.patch
Move all packages to root.
[people/ms/ipfire-3.x.git] / pptp / patches / pptp-1.7.2-ip-path.patch
CommitLineData
7d288e76
MT
1Index: routing.c
2===================================================================
3RCS file: /cvsroot/pptpclient/pptp-linux/routing.c,v
4retrieving revision 1.1
5diff -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
8@@ -23,9 +23,26 @@
9 #include <stdio.h>
10 #include <string.h>
11 #include "routing.h"
12+#include "config.h"
13
14+#if defined (__SVR4) && defined (__sun) /* Solaris */
15+#include <sys/types.h>
16+#include <sys/socket.h>
17+#include <net/if.h>
18+#include <arpa/inet.h>
19+#include <errno.h>
20+#include "util.h"
21+/* PF_ROUTE socket*/
22+int rts;
23+/* Destination and gateway addresses */
24+struct sockaddr_in rdst, rgw;
25+/* Request sequence */
26+int rseq;
27+int dorouting;
28+#else /* Solaris */
29 /* route to the server */
30 char *route;
31+#endif /* Solaris */
32
33 /*
34
35@@ -54,26 +71,113 @@
36 */
37
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));
43+ return;
44+ }
45+
46+ if ( (rts = socket(PF_ROUTE, SOCK_RAW, AF_INET )) < 0 ) {
47+ log("Cannot open routing socket: %s", strerror(errno));
48+ return;
49+ }
50+
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
59+ };
60+
61+ if ( write(rts, &rtm, rtm.hdr.rtm_msglen) != rtm.hdr.rtm_msglen ) {
62+ log("Error writing to routing socket: %s", strerror(errno));
63+ close(rts);
64+ return;
65+ }
66+
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];
72+ dorouting = 1;
73+ }
74+ break;
75+ }
76+#else /* Solaris */
77 char buf[256];
78- snprintf(buf, 255, "/bin/ip route get %s", ip);
79- FILE *p = popen(buf, "r");
80+ FILE *p;
81+
82+ snprintf(buf, 255, "%s route get %s", IP_BINARY, ip);
83+ p = popen(buf, "r");
84 fgets(buf, 255, p);
85 /* TODO: check for failure of fgets */
86 route = strdup(buf);
87 pclose(p);
88 /* TODO: check for failure of command */
89+#endif /* Solaris */
90 }
91
92 void routing_start() {
93+#if defined (__SVR4) && defined (__sun) /* Solaris */
94+ if ( ! dorouting )
95+ return;
96+
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
107+ };
108+
109+ if ( write(rts, &rtm, rtm.hdr.rtm_msglen) != rtm.hdr.rtm_msglen ) {
110+ log("Error adding route: %s", strerror(errno));
111+ }
112+#else /* Solaris */
113 char buf[256];
114- snprintf(buf, 255, "/bin/ip route replace %s", route);
115- FILE *p = popen(buf, "r");
116+ FILE *p;
117+
118+ snprintf(buf, 255, "%s route replace %s", IP_BINARY, route);
119+ p = popen(buf, "r");
120 pclose(p);
121+#endif /* Solaris */
122 }
123
124 void routing_end() {
125+#if defined (__SVR4) && defined (__sun) /* Solaris */
126+ if ( ! dorouting)
127+ return;
128+
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
139+ };
140+
141+ if ( write(rts, &rtm, rtm.hdr.rtm_msglen) != rtm.hdr.rtm_msglen ) {
142+ log("Error deleting route: %s", strerror(errno));
143+ }
144+#else /* Solaris */
145 char buf[256];
146- snprintf(buf, 255, "/bin/ip route delete %s", route);
147- FILE *p = popen(buf, "r");
148+ FILE *p;
149+
150+ snprintf(buf, 255, "%s route delete %s", IP_BINARY, route);
151+ p = popen(buf, "r");
152 pclose(p);
153+#endif /* Solaris */
154 }
155Index: Makefile
156===================================================================
157RCS file: /cvsroot/pptpclient/pptp-linux/Makefile,v
158retrieving revision 1.47
159retrieving revision 1.49
160diff -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
163@@ -1,10 +1,13 @@
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 $
166 VERSION=1.7.2
167 RELEASE=
168
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
173+# Solaris
174+# PPPD = /usr/bin/pppd
175+IP = /bin/ip
176 #################################################################
177
178 BINDIR=$(DESTDIR)/usr/sbin
179@@ -47,6 +52,7 @@
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
184
185 vector_test: vector_test.o vector.o
186 $(CC) -o vector_test vector_test.o vector.o