From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 31 01:23:20 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9800016A4CE for ; Thu, 31 Mar 2005 01:23:20 +0000 (GMT) Received: from mailgate1b.savvis.net (mailgate1b.savvis.net [216.91.182.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1ABDF43D46 for ; Thu, 31 Mar 2005 01:23:20 +0000 (GMT) (envelope-from Maksim.Yevmenkin@savvis.net) Received: from localhost (localhost.localdomain [127.0.0.1]) by mailgate1b.savvis.net (Postfix) with ESMTP id 84C6F3BF38; Wed, 30 Mar 2005 19:23:19 -0600 (CST) Received: from mailgate1b.savvis.net ([127.0.0.1]) by localhost (mailgate1b.savvis.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 24864-01-73; Wed, 30 Mar 2005 19:23:19 -0600 (CST) Received: from out002.email.savvis.net (out002.apptix.savvis.net [216.91.32.45]) by mailgate1b.savvis.net (Postfix) with ESMTP id 2C76A3BE53; Wed, 30 Mar 2005 19:23:19 -0600 (CST) Received: from s228130hz1ew03.apptix-01.savvis.net ([10.146.4.28]) by out002.email.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Wed, 30 Mar 2005 19:23:03 -0600 Received: from [10.254.186.111] ([66.35.239.94]) by s228130hz1ew03.apptix-01.savvis.net with Microsoft SMTPSVC(6.0.3790.211); Wed, 30 Mar 2005 19:22:55 -0600 Message-ID: <424B50EC.1020502@savvis.net> Date: Wed, 30 Mar 2005 17:22:52 -0800 From: Maksim Yevmenkin User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.2) Gecko/20040822 X-Accept-Language: en-us, en MIME-Version: 1.0 To: jtoung@arc.nasa.gov References: <200503301620.24086.jtoung@arc.nasa.gov> In-Reply-To: <200503301620.24086.jtoung@arc.nasa.gov> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 31 Mar 2005 01:22:55.0841 (UTC) FILETIME=[2ABB5510:01C53590] X-Virus-Scanned: amavisd-new at savvis.net cc: hackers cc: Julian Elischer Subject: Re: netgraph TTY X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2005 01:23:20 -0000 Jerry, draw a picture :) it really helps :) for example right2left left2right \ / [ksocket] ------- [tee] -------- [hole] left right # ngctl + mkpeer hole hook hook -- create ng_hole node + name hook hole -- name ng_hole node + mkpeer hole: tee right right -- create ng_tee node and connect to hole + name hole:right tee -- name ng_tee node + mkpeer tee: ksocket left local/stream/0 -- create ksocket node and connect to tee + name tee:left ksocket -- name ksocket node + msg ksocket: bind local/"/tmp/foo" -- bind ksocket + show tee: Name: tee Type: tee ID: 00000011 Num hooks: 2 Local hook Peer name Peer type Peer ID Peer hook ---------- --------- --------- ------- --------- left ksocket ksocket 00000012 local/stream/0 right hole hole 00000010 right + show ksocket: Name: ksocket Type: ksocket ID: 00000012 Num hooks: 1 Local hook Peer name Peer type Peer ID Peer hook ---------- --------- --------- ------- --------- local/stream/0 tee tee 00000011 left + show hole: Name: hole Type: hole ID: 00000010 Num hooks: 2 Local hook Peer name Peer type Peer ID Peer hook ---------- --------- --------- ------- --------- right tee tee 00000011 right hook ngctl8529 socket 0000000f hook now connect nghook(8) to "tee:left2right" (or you could connect ng_tty node there), then connect to the unix socket at "/tmp/foo" and send something to the socket. you should see output. since we have ng_hole on the "right" then "right2left" will never get any data. if you need to capture traffic from from "right2left" then you will need to connect "one2many" node to both "right2left" (to "one2many:many0") and "right2left" (to "one2name:many1") and then connect your tty node to the "one2many:one" hook like so + mkpeer tee: one2many left2right many0 + connect tee: tee:left2right right2left many1 + show one2many: Name: one2many Type: one2many ID: 00000014 Num hooks: 2 Local hook Peer name Peer type Peer ID Peer hook ---------- --------- --------- ------- --------- many1 tee tee 00000011 right2left many0 tee tee 00000011 left2right + show tee: Name: tee Type: tee ID: 00000011 Num hooks: 4 Local hook Peer name Peer type Peer ID Peer hook ---------- --------- --------- ------- --------- right2left one2many one2many 00000014 many1 left2right one2many one2many 00000014 many0 left ksocket ksocket 00000012 local/stream/0 right hole hole 00000010 right hope this helps :) max Jerry Toung wrote: > Good afternoon list, > I am still trying to build a simple netgraph using ng_tty. Ultimately I would > like to go from inet->tee->ng_tty(/dev/cuaa0). > > Please advise what I am doing wrong as I still see an error message (see > bottom of email). Excuse me for the slighty long thread. > > Here is my very simple line discipline code: > > int d; > int ldisc; > ldisc = NETGRAPHDISC; > > > if ((d = open("/dev/cuaa0", O_RDWR)) == -1) { > perror("open"); > } else { > printf("descripto # %d\n", d); > if ((ioctl(d, TIOCSETD, &ldisc)) == -1) { > perror("ioctl"); > } > } > printf("Netgraph TTY node initialized successfully\nPress any key to > destroy it"); > getc(stdin); > close(d); > exit; > > > mrcrab# gcc -g netgraph.c -o test > mrcrab# ./test > descripto # 3 > Netgraph TTY node initialized successfully > Press any key to destroy it > > + list > There are 2 total nodes: > Name: ngctl27022 Type: socket ID: 0000000a Num hooks: 0 > Name: tty1 Type: tty ID: 00000008 Num hooks: 0 > + mpeer . tee myhook right > ngctl: "mpeer": unknown command > + mkpeer . tee myhook right > + name .:myhook mytee > + mkpeer mytee: tty left hook > ngctl: send msg: Operation not permitted > + > > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"