From owner-freebsd-net@freebsd.org Wed Mar 21 03:55:35 2018 Return-Path: Delivered-To: freebsd-net@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 43C09F67703 for ; Wed, 21 Mar 2018 03:55:35 +0000 (UTC) (envelope-from matt.joras@gmail.com) Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id B34F179E4F for ; Wed, 21 Mar 2018 03:55:34 +0000 (UTC) (envelope-from matt.joras@gmail.com) Received: by mail-wm0-f51.google.com with SMTP id f19so7211456wmc.0 for ; Tue, 20 Mar 2018 20:55:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=QPYfsvZmxAfR9oQAJzNkmBDiD5KrBfYfRH8HJF4AYkk=; b=HFPF+WRDMZl3+Jsrrb5DlN5qY2tS+iK75SghE0YNKFWJDUq22YVJkCHOgfLUY2lepO fnUcJbNd7PEbQ/LdInorkRjG2UCJNy31LszepCaf3ZT1pBApK/XMOPJ+iYWqoNhkMoK5 +qTJJbfvIWJyXb+873Awje51QisBtwtZwnhbca/jJKIF+vZIEahccAOIZEOrO0o7Awbd orCTeDXdzDzG78Z7s8qtK9yFkfaUgySNa/FVAq0vHaAJuvjmZOk7aTrGPGQP1afM3nZ0 7Li79M5bqYL0rqn3M/P04fO9yRwq1OKr4Jjt00ffkMzEfxTn+WMNNgY1Z//XMGrnJyzh EejQ== X-Gm-Message-State: AElRT7FP4jjsNfzOPhapuA+nKpQXDalwc+lWV5mn+d/qXkkYkZmv/zOO 8zmQkEtaKF6gKOtWZQsLZi3QESRg X-Google-Smtp-Source: AG47ELsJfZuyi/2/CY0aBHe0tN/vSeabVkg/ARBZOusIiZgDFaKQAg5/Xq+R4ikfPoSRG08iP3JVgA== X-Received: by 10.80.182.52 with SMTP id b49mr20129428ede.279.1521604526625; Tue, 20 Mar 2018 20:55:26 -0700 (PDT) Received: from mail-wr0-f181.google.com (mail-wr0-f181.google.com. [209.85.128.181]) by smtp.gmail.com with ESMTPSA id m23sm2744820edc.69.2018.03.20.20.55.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Mar 2018 20:55:26 -0700 (PDT) Received: by mail-wr0-f181.google.com with SMTP id z8so3780253wrh.7 for ; Tue, 20 Mar 2018 20:55:26 -0700 (PDT) X-Received: by 10.223.186.140 with SMTP id p12mr14849625wrg.162.1521604526115; Tue, 20 Mar 2018 20:55:26 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.167.12 with HTTP; Tue, 20 Mar 2018 20:55:25 -0700 (PDT) In-Reply-To: <5AB1D4D2.8000001@grosbein.net> References: <98551.1521576540@segfault.tristatelogic.com> <5AB1A9C5.9050707@grosbein.net> <5AB1D4D2.8000001@grosbein.net> From: Matt Joras Date: Tue, 20 Mar 2018 20:55:25 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Raw Sockets: Two Questions To: Eugene Grosbein Cc: Michael Tuexen , FreeBSD Net , "Ronald F. Guilmette" Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Mar 2018 03:55:35 -0000 On Tue, Mar 20, 2018 at 8:43 PM, Eugene Grosbein wrote: > On 21.03.2018 08:03, Michael Tuexen wrote: > >>> On 21. Mar 2018, at 00:39, Eugene Grosbein wrote: >>> >>> 21.03.2018 3:09, Ronald F. Guilmette wrote: >>> >>>> I'm going to be doing some stuff with raw sockets pretty soon, and >>>> while scrounging around, looking for some nice coding examples, I >>>> found the following very curious comment on one particular message >>>> board: >>>> >>>> https://stackoverflow.com/questions/7048448/raw-sockets-on-bsd-operating-systems >>>> >>>> "Using raw sockets isn't hard but it's not entirely portable. For >>>> instance, both in BSD and in Linux you can send whatever you want, >>>> but in BSD you can't receive anything that has a handler (like TCP >>>> and UDP)." >>>> >>>> So, first question: Is the above comment actually true & accurate? >>> >>> Not for FreeBSD. >> Are you saying that I can receive on a raw socket SCTP, TCP and UDP packets? > > No. I'm saying one can send/receive RAW IP packets no matter are they SCTP, TCP or UDP > or something else by means of libdnet. It uses raw sockets and BPF internally > but hides this complexity. nmap uses it just fine. > Saying "Not for FreeBSD" is needlessly confusing and not accurate. In the common parlance "raw sockets" does not refer to libdnet, which is not a part of the FreeBSD base system. You cannot use traditional raw sockets on FreeBSD to receive traditional protocol packets. The only way to do that in the base system is to use a BPF handle directly. Matt