Hi!

----

Attached is a small diff ("ksh93_sctp_support_prototype.diff.txt", this
diff is against today's OpenSolaris-ksh93-integration branch (see
http://svn.genunix.org/repos/on/branches/ksh93/gisburn/prototype001/m1_ast_ksh_imported/usr/src/
(which is based on OpenSolaris B35 + ksh93r))) with a prototype for SCTP
support (sort-of a small toy to play around with... :-) ).
The code is still incomplete since I do not know (yet) how to
distinguish between SCTP and TCP sockets when only the socket fd is
available (see comment in diff for src/lib/libcmd/common/fds.c) but it
shows how it should be working. The support works along the current
support for /dev/tcp/.

Remaining issues are:
- Fix src/lib/libcmd/common/fds.c to correctly report "tcp" vs. "sctp"
sockets
- Does libast need any adjustments (I am not sure) ?
- Update ksh.1 manual page
- Add #ifdef's for cases when the OS does not support SCTP
- SCTP allows some kind of "substreams" (streams within streams) which
can be reached via |sctp_peeloff()|. This requires further investigation
how this could be made available to the shell (ideas very welcome...)
...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)
-------------- next part --------------
Index: src/lib/libshell/common/sh/io.c
===================================================================
--- src/lib/libshell/common/sh/io.c     (revision 169)
+++ src/lib/libshell/common/sh/io.c     (working copy)
@@ -67,7 +67,7 @@
 static void    *timeout;
 static int     (*fdnotify)(int,int);
 
-#if defined(_lib_socket) && defined(_sys_socket) && defined(_hdr_netinet_in)
+#if 1/*defined(_lib_socket) && defined(_sys_socket) && 
defined(_hdr_netinet_in)*/
 #   include <sys/socket.h>
 #   include <netdb.h>
 #   include <netinet/in.h>
@@ -376,7 +376,9 @@
        mode_t                  mode;
        char                    *e;
 #ifdef SOCKET
-       int                     prot = -1;
+       int                     sock_type = -1;
+       int                     sock_protocol = -1;
+        const char              *sock_address = NULL;
        struct sockaddr_in      addr;
 #endif /* SOCKET */
        va_list                 ap;
@@ -402,6 +404,7 @@
                        break;
                case 's':
                        if (path[6]=='t' && path[7]=='d')
+                       {
                                switch (path[8])
                                {
                                case 'e':
@@ -417,17 +420,36 @@
                                                fd = 1;
                                        break;
                                }
+                               break;
+                       }
+#ifdef SOCKET
+               /* sctp */
+                       else if (path[6]=='c' && path[7]=='t' && path[8]=='p' 
&& path[9]=='/')
+                       {
+                               sock_type = SOCK_STREAM;
+                               sock_protocol = IPPROTO_SCTP;
+                               sock_address = path + 6;
+                       }
                        break;
-#ifdef SOCKET
+               /* tcp */
                case 't':
                        if (path[6]=='c' && path[7]=='p' && path[8]=='/')
-                               prot = SOCK_STREAM;
+                       {
+                               sock_type = SOCK_STREAM;
+                               sock_protocol = 0;
+                               sock_address = path + 5;
+                       }
                        break;
+               /* udp */
                case 'u':
                        if (path[6]=='d' && path[7]=='p' && path[8]=='/')
-                               prot = SOCK_DGRAM;
+                       {
+                               sock_type = SOCK_DGRAM;
+                               sock_protocol = 0;
+                               sock_address = path + 5;
+                       }
                        break;
-#endif
+#endif /* SOCKET */
                }
        if (fd > 0)
        {
@@ -442,9 +464,9 @@
                        return(-1);
        }
 #ifdef SOCKET
-       else if (prot > 0 && str2inet(path + 5, &addr))
+       else if (sock_type > 0 && str2inet(sock_address, &addr))
        {
-               if ((fd = socket(AF_INET, prot, 0)) >= 0)
+               if ((fd = socket(AF_INET, sock_type, sock_protocol)) >= 0)
                {
                        if(flags&O_SERVICE)
                        {
Index: src/lib/libshell/Makefile.com
===================================================================
--- src/lib/libshell/Makefile.com       (revision 169)
+++ src/lib/libshell/Makefile.com       (working copy)
@@ -91,6 +91,9 @@
        edit/vi.o \
        edit/hexpand.o
 
+# mkservice buildin to allow ksh93-based internet servers
+#COBJS += bltins/mkservice.o
+
 OBJECTS=       $(COBJS) $(MOBJS)
 
 include ../../Makefile.lib
@@ -99,7 +102,7 @@
 SRCS=          $(COBJS:%.o=../common/%.c)
 
 LIBS =         $(DYNLIB) $(LINTLIB)
-LDLIBS +=      -lcmd -ldll -last -lsecdb -lm -lc
+LDLIBS +=      -lcmd -ldll -last -lsocket -lnsl -lsecdb -lm -lc
 $(LINTLIB) :=  SRCS = $(SRCDIR)/$(LINTSRC)
 
 SRCDIR =       ../common
Index: src/lib/libcmd/common/fds.c
===================================================================
--- src/lib/libcmd/common/fds.c (revision 169)
+++ src/lib/libcmd/common/fds.c (working copy)
@@ -122,7 +122,7 @@
                                switch (type)
                                {
                                case SOCK_STREAM:
-                                       s = "tcp";
+                                       s = "tcp"; /* what about sctp here ? */
                                        break;
                                case SOCK_DGRAM:
                                        s = "udp";

Reply via email to