Date: Sat, 19 Jun 1999 12:35:45 +0200 (CEST) From: Bodo Rueskamp <br@smilla.rueskamp.com> To: darius@dons.net.au (Daniel J. O'Connor) Cc: sheldonh@uunet.co.za (Sheldon Hearn), hackers@FreeBSD.ORG Subject: Re: Obtaining client host IP before accept() Message-ID: <199906191035.MAA24192@smilla.rueskamp.com> In-Reply-To: <XFMail.990619155038.darius@dons.net.au> from "Daniel J. O'Connor" at "Jun 19, 1999 03:50:38 pm"
next in thread | previous in thread | raw e-mail | index | archive | help
> > Will the IP address of the client host ever enter buf[] if the > > accept() is _not_ uncommented? > > I don't need portability, since this is for use within the FreeBSD inetd > > exclusively. > > Well if you CAN'T do it in FreeBSD, is there an OS we can copy the API from > that DOES do it? (Providing it isn't too braindamaged of course.. :) There is an API that can do it: System V Release 4 Streams and TLI (Transport Layer Interface). TLI is not based on systems calls doing the job. It is based on message transfer between the user and some kernel entity. Incoming calls are indicated by sending a T_CONN_IND message (connect indication) to the user process. Then the user process opens a second TLI stream (like using the socket() system call) and sends a T_CONN_CON message (connect confirmation) to the kernel entity. The TLI API is based on OSI. It doesn't provide much more functionality than BSD sockets. Two APIs for the same task isn't very useful. So you should better hack the BSD sockets to fit your needs. A similar functionality in BSD-world would be: (1) use recvfrom() instead of accept() on the socket TLI: use getmsg() to receive the T_CONN_IND (2) create a new socket using socket() TLI: use open() to open a new stream (3) accept the connection using an ioctl() TLI: send T_CONN_CON to accept the connection or (2) reject the connection using an ioctl() TLI: send T_DISCON_REQ to reject the connection Here's an overview of the TLI messages: TLI (user) TLI (kernel) BSD socket T_INFO_REQ T_INFO_ACK - T_BIND_REQ T_BIND_ACK bind() T_UNBIND_REQ - - T_OPTMGMT_REQ T_OPTMGMT_ACK setsockopt() - T_ERROR_ACK errno T_CONN_REQ T_CONN_RES connect() T_CONN_CON T_CONN_IND accept() T_DISCON_REQ - shutdown() - T_DISCON_IND errno T_ORDREL_REQ - shutdown() T_DATA_REQ - send() / sendto() / write() - T_DATA_IND recv() / recvfrom() / read() T_EXDATA_REQ - send() / sendto() - T_EXDATA_IND recv() / recvfrom() T_UNITDATA_REQ - send() / sendto() / write() - T_UNITDATA_IND recv() / recvfrom() / read() - T_UDERROR_IND recv() / recvfrom() / read() & errno ; Bodo -- Bodo Rüskamp, br@rueskamp.com, 51°55' N 7°41' E (1) Elvis is alive. (2) Dinosaurs too. <http://www.lochness.scotland.net/camera.htm> (3) The next millenium starts on January 1st 2000. 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?199906191035.MAA24192>