Date: Sun, 17 Mar 2013 08:37:42 +0000 (GMT) From: Ted Reynard <ted.reynard@yahoo.com> To: "freebsd-questions@freebsd.org" <freebsd-questions@freebsd.org> Subject: serial programming using terios Message-ID: <1363509462.77245.YahooMailNeo@web133106.mail.ir2.yahoo.com>
next in thread | raw e-mail | index | archive | help
Hi fellas=0AI'm trying to connect to a CISCO router by a program which I de= veloped using termios.=0AFirst I configure the local TTY to right settings = :=0A=A0=A0=A0 struct termios old =3D {0};=0A=A0=A0=A0 /*get current TTY set= tings*/=0A=A0=A0=A0 if (tcgetattr(STDIN_FILENO, &old) < 0)=0A=A0=A0=A0=A0= =A0=A0=A0 perror("tcsetattr()");=0A=A0=A0=A0=A0=A0=A0=A0 old.c_iflag &=3D ~= (ISTRIP|ICRNL);=0A=A0=A0=A0=A0=A0=A0=A0 old.c_oflag &=3D ~OPOST;=0A=A0=A0= =A0=A0=A0=A0=A0 old.c_lflag &=3D ~(ICANON|IEXTEN|ECHO|ECHONL);=0A=A0=A0=A0= =A0=A0=A0=A0 old.c_cc[VMIN] =3D 1;=0A=A0=A0=A0=A0=A0=A0=A0 old.c_cc[VTIME] = =3D 0;=0A=A0=A0=A0=A0=A0=A0=A0 if (tcsetattr(0, TCSANOW/*TCSAFLUSH*/, &old)= < 0)=0A=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 perror("tcsetattr ICA= NON");=0A=0A=0AAnd then the TTY which users want to use=A0=0A=A0=A0=A0 stru= ct termios dev;=0Astatic int port=3Datoi(argv[1]);=0A=0A=A0int fd =3D open_= port(port);=0A=0Afcntl(fd, F_SETFL, FNDELAY); =0Atcgetattr(mainfd, &dev);= =0Acfsetspeed(&dev, speed);=0Adev.c_cflag |=3D (CLOCAL | CREAD);=0Adev.c_cf= lag &=3D ~PARENB;=0Adev.c_cflag |=3D CSTOPB;=0A=0Adev.c_cflag &=3D ~CSIZE;= =0Adev.c_cflag |=3D CS8;=0Adev.c_cflag &=3D ~CRTSCTS;=0Adev.c_iflag &=3D ~= (ISTRIP|ICRNL);=0Adev.c_oflag &=3D ~OPOST;=0Adev.c_lflag &=3D ~(ICANON|ISIG= |IEXTEN|ECHO);=0Adev.c_cc[VMIN] =3D 1;=0Adev.c_cc[VTIME] =3D 0;=0A=0AAnd I = have two threads to handle read and write simultaneously. The problem is I = have to add at least 2 seconds delay =0Aafter writing user input to the por= t, otherwise the output would not be what I expect. Without this sleep=0Aco= mmand, every character I type, the output is shown with next character; not= at time :=0A=0ARouter>=0ARouter>abc // While I typed "abcd". If I continue= with typing "e", then the output will be "abcd" and so on ...=0A=0AAm I mi= ssing something?=0A From owner-freebsd-questions@FreeBSD.ORG Sun Mar 17 08:45:56 2013 Return-Path: <owner-freebsd-questions@FreeBSD.ORG> Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 6A149240 for <freebsd-questions@freebsd.org>; Sun, 17 Mar 2013 08:45:56 +0000 (UTC) (envelope-from sam.gh1986@gmail.com) Received: from mail-la0-x235.google.com (mail-la0-x235.google.com [IPv6:2a00:1450:4010:c03::235]) by mx1.freebsd.org (Postfix) with ESMTP id D6A9C7F7 for <freebsd-questions@freebsd.org>; Sun, 17 Mar 2013 08:45:55 +0000 (UTC) Received: by mail-la0-f53.google.com with SMTP id fr10so5113732lab.12 for <freebsd-questions@freebsd.org>; Sun, 17 Mar 2013 01:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=+Cub6NHPFUt+zVPRj8ve7qaAgG9wNyjZFPmIaT7RslA=; b=hAU7b4RYRJhbONCjTnMZAQwlTVsCcEex+y5JHLWg3kr2EW3mUzL9jfemdxJGLVDe1C mPuYfE1lwTmAOJBbpdxjIKjCi0X9pblCTOlpKywTlRYKxCuB/mni1f2kxwdHExRrPXpp FYikO8u21uR6Tp10uiRFwHf6K4ULmsO//imz1aTUueiEx3N+3yVE1thH2zL34VQN95y7 uoqGPWXi3kOqNRCQfeOKqoWvkEnohzZjvWAKn8LyqNcu6JKbfLEzmo5hv0MZueC+D4LB MrPvGVag/nvhavwM06HJtJ0Zdkz4Wx6dxcNqSMWC05GmZBN5hXeKVNL2qae5k5iY9I5T 8cSw== MIME-Version: 1.0 X-Received: by 10.112.23.35 with SMTP id j3mr4733706lbf.60.1363509954002; Sun, 17 Mar 2013 01:45:54 -0700 (PDT) Received: by 10.112.143.201 with HTTP; Sun, 17 Mar 2013 01:45:53 -0700 (PDT) Date: Sun, 17 Mar 2013 12:15:53 +0330 Message-ID: <CAA_1SgGHg3APcDqhxcZGkh02XZBCVgfhA22cpf=VjWcnKZBqcw@mail.gmail.com> Subject: how run snort in quiet and deamon mode From: s m <sam.gh1986@gmail.com> To: freebsd-questions <freebsd-questions@freebsd.org> Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions <freebsd-questions.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/options/freebsd-questions>, <mailto:freebsd-questions-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/freebsd-questions> List-Post: <mailto:freebsd-questions@freebsd.org> List-Help: <mailto:freebsd-questions-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-questions>, <mailto:freebsd-questions-request@freebsd.org?subject=subscribe> X-List-Received-Date: Sun, 17 Mar 2013 08:45:56 -0000 hello guys i have a freebsd8.2 and wanna run snort on it. my snort version is 2.9.3.1. i want to run snort in deamon mode and quietly. man page says that "D" flag is for running snort in deamon mode and "q" flag is to run it quietly(do not show startup message). my problem is, these two flag can not work together. when i run "snort -q -D" or "snort -D -q", snort run in deamon mode but some startup messages are shown. when i run "snort -q" no message is shown. i know it is so simple issue but i do not know how to do that. any hints or comments are appreciated. sam
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1363509462.77245.YahooMailNeo>