Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 03 Feb 2003 12:45:19 -0800
From:      Maksim Yevmenkin <myevmenk@exodus.net>
To:        hackers@FreeBSD.ORG, questions@FreeBSD.ORG, brian@freebsd.org
Cc:        doconnor@gsoft.com.au, imp@bsdimp.com
Subject:   [PATCH] PPP in -direct mode does not execute any chat scripts
Message-ID:  <3E3ED4DF.7090904@exodus.net>
References:  <45258A4365C6B24A9832BFE224837D552B1283@sjdcex01.int.exodus.net>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------040507020505080405040700
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Dear Hackers,

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


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

did i miss anything? objections? comments? reviews?

thanks,
max


> 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.
> 
> thanks,
> max

--------------040507020505080405040700
Content-Type: text/plain;
 name="ppp.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="ppp.diff"

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 MAX_ENDDISC_CLASS 5
 
 #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 */
 #else
-#define OPT_MAX 11
+#define OPT_MAX 12
 #endif
 
   {"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 @@
   free(dl);
 
   return result;
 }
 
 void
 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) {
     case DATALINK_CLOSED:
       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
 command.
 No proxy arp entries are made for the interface address itself
 (as created by the
 .Dq set ifaddr
 command).
+.It run-scripts-in-direct-mode
+Default: Disabled. This allows to run chat scripts in
+.Dv direct 
+mode.
 .It sroutes
 Default: Enabled.
 When the
 .Dq add
 command is used with the
 .Dv HISADDR ,
 .Dv MYADDR ,
 .Dv HISADDR6

--------------040507020505080405040700--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E3ED4DF.7090904>