File: tos-pppd.patch

package info (click to toggle)
tinyos 2.1.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 47,476 kB
  • ctags: 36,607
  • sloc: ansic: 63,646; cpp: 14,974; java: 10,358; python: 5,215; makefile: 1,724; sh: 902; asm: 597; xml: 392; perl: 74; awk: 46
file content (222 lines) | stat: -rw-r--r-- 5,099 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
The TinyOS PPP daemon defines a custom protocol which enables applications
to use printf(3c) with the messages carried over PPP and displayed in the
host computer logs.  This patch adds support for that protocol to the
standard Linux PPP daemon.

The patch has been developed against the latest PPP source head.  Retrieve
the source with:

git clone git://ozlabs.org/~paulus/ppp.git

Apply the patch with:

cd ppp
patch -p1 < ${TOSDIR}/lib/ppp/tos-pppd.patch

Configure and install the updated daemon for local use:

./configure
make DESTDIR=/usr/local/tos-pppd all install

You can then use this version to see messages from the application:

sudo TOS_PPPD=/usr/local/tos-pppd/sbin/pppd ${TOSDIR}/lib/ppp/tospppd

diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux
index 060db6a..db82a9c 100644
--- a/pppd/Makefile.linux
+++ b/pppd/Makefile.linux
@@ -60,9 +60,12 @@ HAVE_MULTILINK=y
 # Linux distributions: Please leave TDB ENABLED in your builds.
 USE_TDB=y
 
+# Uncomment to enable the TinyOS printf protocol
+HAVE_TINYOS=y
+
 HAS_SHADOW=y
-#USE_PAM=y
-#HAVE_INET6=y
+USE_PAM=y
+HAVE_INET6=y
 
 # Enable plugins
 PLUGIN=y
@@ -189,6 +192,13 @@ ifdef CBCP
      HEADERS += cbcp.h
 endif
 
+ifdef HAVE_TINYOS
+     PPPDSRCS += tinyos.c
+     HEADERS  += tinyos.h
+     PPPDOBJS += tinyos.o
+     CFLAGS   += -DTINYOS=1
+endif
+
 ifdef MAXOCTETS
      CFLAGS += -DMAXOCTETS
 endif
diff --git a/pppd/main.c b/pppd/main.c
index 014d614..56887bb 100644
--- a/pppd/main.c
+++ b/pppd/main.c
@@ -105,6 +105,9 @@
 #include "ccp.h"
 #include "ecp.h"
 #include "pathnames.h"
+#ifdef TINYOS
+#include "tinyos.h"
+#endif
 
 #ifdef USE_TDB
 #include "tdb.h"
@@ -295,6 +298,9 @@ struct protent *protocols[] = {
     &atcp_protent,
 #endif
     &eap_protent,
+#ifdef TINYOS
+    &tinyos_protent,
+#endif
     NULL
 };
 
diff --git a/pppd/oshan.sh b/pppd/oshan.sh
new file mode 100755
index 0000000..a99baa7
--- /dev/null
+++ b/pppd/oshan.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+./pppd \
+    debug \
+    passive \
+    noauth \
+    nodetach \
+    noccp \
+    ipv6 ::ff41:4442:e88:2,::ff41:4442:e88:3 \
+    noip \
+    /dev/ttyUSB0
diff --git a/pppd/tinyos.c b/pppd/tinyos.c
new file mode 100644
index 0000000..688c542
--- /dev/null
+++ b/pppd/tinyos.c
@@ -0,0 +1,97 @@
+#include "pppd.h"
+#include "tinyos.h"
+
+/*
+ * Protocol entry points.
+ */
+static void tinyos_init __P((int unit));
+static void tinyos_input __P((int unit, u_char *inp, int inlen));
+static void tinyos_protrej __P((int unit));
+static void tinyos_lowerup __P((int unit));
+static void tinyos_lowerdown __P((int unit));
+static int  tinyos_printpkt __P((u_char *inp, int inlen,
+    void (*)(void *arg, char *fmt, ...), void *arg));
+
+static option_t tinyos_option_list[] = {
+  { NULL }
+};
+
+struct protent tinyos_protent = {
+        PPP_TINYOS,                /* protocol number */
+        tinyos_init,               /* initialization procedure */
+        tinyos_input,              /* process a received packet */
+        tinyos_protrej,            /* process a received protocol-reject */
+        tinyos_lowerup,            /* lower layer has gone up */
+        tinyos_lowerdown,          /* lower layer has gone down */
+        NULL,                   /* open the protocol */
+        NULL,                   /* close the protocol */
+        tinyos_printpkt,           /* print a packet in readable form */
+        NULL,                   /* process a received data packet */
+        1,                      /* protocol enabled */
+        "TOS",                  /* text name of protocol */
+        NULL,                   /* text name of corresponding data protocol */
+        tinyos_option_list,        /* list of command-line options */
+        NULL,                   /* check requested options; assign defaults */
+        NULL,                   /* configure interface for demand-dial */
+        NULL                    /* say whether to bring up link for this pkt */
+};
+
+
+static void
+tinyos_init (unit)
+int unit;
+{ }
+
+static void
+tinyos_input (unit, inp, inlen)
+int unit;
+u_char *inp;
+int inlen;
+{
+#if 0
+  u_char nb;
+  u_char sv;
+  nb = *inp++;
+  sv = inp[nb];
+  inp[nb] = 0;
+  printf("TINYOS: %s", inp);
+  putchar(sv);
+#endif
+}
+
+static void
+tinyos_protrej (unit)
+int unit;
+{
+}
+
+static void
+tinyos_lowerup (unit)
+int unit;
+{
+}
+
+static void
+tinyos_lowerdown (unit)
+int unit;
+{
+}
+
+static int
+tinyos_printpkt (inp, inlen, printer, arg)
+u_char *inp;
+int inlen;
+void (*printer) __P((void *, char *, ...));
+void *arg;
+{
+  u_char nb;
+  u_char sv;
+  nb = *inp++;
+  sv = inp[nb-1];
+  inp[nb-1] = 0;
+  printer(arg, " %s", inp);
+  if ('\n' != sv) {
+    printer(arg, "%c", sv);
+  }
+  return nb + 1;
+}
diff --git a/pppd/tinyos.h b/pppd/tinyos.h
new file mode 100644
index 0000000..9e99050
--- /dev/null
+++ b/pppd/tinyos.h
@@ -0,0 +1,16 @@
+#ifndef PPP_TINYOS_H
+#define PPP_TINYOS_H
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+#define PPP_TINYOS 0x404f
+
+extern struct protent tinyos_protent;
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif /* PPP_TINYOS_H */