From owner-freebsd-hackers Sat Jun 19 3:35:56 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from saturn.ms.tlk.com (saturn.ms.tlk.com [194.97.68.6]) by hub.freebsd.org (Postfix) with ESMTP id 6698514BF5 for ; Sat, 19 Jun 1999 03:35:50 -0700 (PDT) (envelope-from br@smilla.rueskamp.com) Received: from mars.ms.tlk.com (mars.ms.tlk.com [194.97.68.1]) by saturn.ms.tlk.com (Postfix) with ESMTP id 0F00E4ECF7; Sat, 19 Jun 1999 12:35:50 +0200 (CEST) Received: from smilla.rueskamp.com(really [194.97.69.109]) by mars.ms.tlk.com via sendmail with esmtp id for ; Sat, 19 Jun 1999 12:35:49 +0200 (CEST)) Received: (from br@localhost) by smilla.rueskamp.com (8.9.3/8.9.3) id MAA24192; Sat, 19 Jun 1999 12:35:45 +0200 (CEST) (envelope-from br) From: Bodo Rueskamp Message-Id: <199906191035.MAA24192@smilla.rueskamp.com> Subject: Re: Obtaining client host IP before accept() In-Reply-To: from "Daniel J. O'Connor" at "Jun 19, 1999 03:50:38 pm" To: darius@dons.net.au (Daniel J. O'Connor) Date: Sat, 19 Jun 1999 12:35:45 +0200 (CEST) Cc: sheldonh@uunet.co.za (Sheldon Hearn), hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > 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. (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