Dear Hackers,

Please find attached patch that adds new option to the PPP.

	Default: Disabled. This allows to run chat scripts in
	direct mode.

did i miss anything? objections? comments? reviews?


I'm working on the Bluetooth stack for FreeBSD and currently
doing testing for new in-kernel RFCOMM code. RFCOMM is a way
to emulate serial link over Bluetooth.

In particular Bluetooth spec defines two RFCOMM based profiles
LAN (Network Access profile) and DUN (DialUp Networking profile).
Both profiles use PPP.

My current in-kernel RFCOMM code provides SOCK_STREAM sockets
interface, i.e. when application wants to talk RFCOMM it just
opens a socket. The next step is to run PPP, so the launcher
program opens RFCOMM connection then dup() socket to stdin and
stdout and exec() PPP in direct mode.

Everything works great for the LAN profile, where null-modem
connection is assumed and both client and server start talking
PPP right after RFCOMM connection is established.

However the DUN profile is more tricky. In this scenario client
just connected to the virtual serial port on the server. Now to
start PPP session client must "dial a number". i.e. there is
still need for a little chat script.

Here is an example:

1) I'd like to use my GPRS and Bluetooth enabled cell phone to
access the Internet
2) I open a RFCOMM connection to the cell phone and get connected
to the virtual serial port on the cell phone.
3) Now i must dial a "special" GRPS number, i.e. something like
ATD*98***1# and wait for CONNECT string from the phone
4) Now i can talk PPP.

So the questions is: would it be possible to enable PPP chat in "direct" mode? Is there any reason to not allow this? It
seems 'login' script would do just fine. Is there any other/
better way to do this? One possible option right now is to
execute /bin/chat from the launcher program before executing
PPP, but i'd rather keep all chat scripts in PPP.

diff -ru8 ppp.orig/bundle.h ppp/bundle.h
--- ppp.orig/bundle.h   Mon Feb  3 10:34:44 2003
+++ ppp/bundle.h        Mon Feb  3 10:36:56 2003
@@ -44,16 +44,17 @@
 #define OPT_LOOPBACK   0x0040
 #define OPT_PASSWDAUTH 0x0080
 #define OPT_PROXY      0x0100
 #define OPT_PROXYALL   0x0200
 #define OPT_SROUTES    0x0400
 #define OPT_TCPMSSFIXUP        0x0800
 #define OPT_THROUGHPUT 0x1000
 #define OPT_UTMP       0x2000
+#define OPT_RSIDM      0x4000 /* run-scripts-in-direct-mode */
 #define Enabled(b, o) ((b)->cfg.opt & (o))
 /* AutoAdjust() values */
 #define AUTO_UP                1
 #define AUTO_DOWN      2
diff -ru8 ppp.orig/command.c ppp/command.c
--- ppp.orig/command.c  Mon Feb  3 10:34:45 2003
+++ ppp/command.c       Mon Feb  3 10:57:05 2003
@@ -2851,29 +2851,32 @@
   {"loopback", NULL, OptSet, LOCAL_AUTH, "Loop packets for local iface",
   "disable|enable", (const void *)OPT_LOOPBACK},
   {"passwdauth", NULL, OptSet, LOCAL_AUTH, "Use passwd file",
   "disable|enable", (const void *)OPT_PASSWDAUTH},
   {"proxy", NULL, OptSet, LOCAL_AUTH, "Create a proxy ARP entry",
   "disable|enable", (const void *)OPT_PROXY},
   {"proxyall", NULL, OptSet, LOCAL_AUTH, "Proxy ARP for all remote hosts",
   "disable|enable", (const void *)OPT_PROXYALL},
+  {"run-scripts-in-direct-mode", NULL, OptSet, LOCAL_AUTH,
+   "Run char scripts in direct mode", "disable|enable",
+   (const void *)OPT_RSIDM},
   {"sroutes", NULL, OptSet, LOCAL_AUTH, "Use sticky routes",
   "disable|enable", (const void *)OPT_SROUTES},
   {"tcpmssfixup", "mssfixup", OptSet, LOCAL_AUTH, "Modify MSS options",
   "disable|enable", (const void *)OPT_TCPMSSFIXUP},
   {"throughput", NULL, OptSet, LOCAL_AUTH, "Rolling throughput",
   "disable|enable", (const void *)OPT_THROUGHPUT},
   {"utmp", NULL, OptSet, LOCAL_AUTH, "Log connections in utmp",
   "disable|enable", (const void *)OPT_UTMP},
 #ifndef NOINET6
-#define OPT_MAX 13     /* accept/deny allowed below and not above */
+#define OPT_MAX 14     /* accept/deny allowed below and not above */
-#define OPT_MAX 11
+#define OPT_MAX 12
   {"acfcomp", NULL, NegotiateSet, LOCAL_AUTH | LOCAL_CX,
   "Address & Control field compression", "accept|deny|disable|enable",
   (const void *)NEG_ACFCOMP},
   {"chap", "chap05", NegotiateSet, LOCAL_AUTH | LOCAL_CX,
   "Challenge Handshake Authentication Protocol", "accept|deny|disable|enable",
   (const void *)NEG_CHAP05},
diff -ru8 ppp.orig/datalink.c ppp/datalink.c
--- ppp.orig/datalink.c Mon Feb  3 10:34:45 2003
+++ ppp/datalink.c      Mon Feb  3 11:03:48 2003
@@ -956,17 +956,18 @@
   return result;
 datalink_Up(struct datalink *dl, int runscripts, int packetmode)
-  if (dl->physical->type & (PHYS_DIRECT|PHYS_DEDICATED))
+  if ((dl->physical->type & PHYS_DEDICATED) ||
+      ((dl->physical->type & PHYS_DIRECT) && !Enabled(dl->bundle, OPT_RSIDM)))
     /* Ignore scripts */
     runscripts = 0;
   switch (dl->state) {
       if (bundle_Phase(dl->bundle) == PHASE_DEAD ||
           bundle_Phase(dl->bundle) == PHASE_TERMINATE)
         bundle_NewPhase(dl->bundle, PHASE_ESTABLISH);
diff -ru8 ppp.orig/ppp.8.m4 ppp/ppp.8.m4
--- ppp.orig/ppp.8.m4   Mon Feb  3 10:34:46 2003
+++ ppp/ppp.8.m4        Mon Feb  3 12:23:52 2003
@@ -3089,16 +3089,20 @@
 Proxy arp entries are only made for sticky routes that are added
 using the
 .Dq add
 No proxy arp entries are made for the interface address itself
 (as created by the
 .Dq set ifaddr
+.It run-scripts-in-direct-mode
+Default: Disabled. This allows to run chat scripts in
+.Dv direct 
 .It sroutes
 Default: Enabled.
 When the
 .Dq add
 command is used with the

Reply via email to