Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Jan 2002 21:17:55 +0200
From:      "Radoslav Vasilev" <rvasilev@uni-svishtov.bg>
To:        <freebsd-net@freebsd.org>
Subject:   Re Netgraph
Message-ID:  <003301c1a5d4$fe2c4b10$52ad44c1@deckland>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
rtfm# more ngdisc.c 
#include <sys/ioctl.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>

int main(void)
{
        int d;
        int ldisc;
        ldisc = NETGRAPHDISC;
        
        if ((d = open("/dev/ttyd1", O_NONBLOCK)) == -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;
}
rtfm# 

[-- Attachment #2 --]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=koi8-r" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>rtfm# more ngdisc.c <BR>#include 
&lt;sys/ioctl.h&gt;<BR>#include &lt;stdio.h&gt;<BR>#include 
&lt;stdlib.h&gt;<BR>#include &lt;fcntl.h&gt;<BR>#include 
&lt;unistd.h&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>int 
main(void)<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int 
d;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int 
ldisc;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ldisc = 
NETGRAPHDISC;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((d = open("/dev/ttyd1", 
O_NONBLOCK)) == -1) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
perror("open");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
printf("descripto # %d\n", d); 
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
((ioctl(d, TIOCSETD, &amp;ldisc)) == -1) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
perror("ioctl");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Netgraph TTY node 
initialized successfully\nPress any key to destroy 
it");<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
getc(stdin);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
close(d);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; exit;<BR>}<BR>rtfm# 
</FONT></DIV></BODY></HTML>

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?003301c1a5d4$fe2c4b10$52ad44c1>