From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from tb-mx1.topicbox.com (localhost.local [127.0.0.1]) by tb-mx1.topicbox.com (Postfix) with ESMTP id AFE671A94A1F for ; Fri, 31 May 2024 05:13:42 -0400 (EDT) (envelope-from denis@tambov.ru) Received: from tb-mx1.topicbox.com (localhost [127.0.0.1]) by tb-mx1.topicbox.com (Authentication Milter) with ESMTP id C7F64B61AA5; Fri, 31 May 2024 05:13:42 -0400 ARC-Seal: i=1; a=rsa-sha256; cv=none; d=topicbox.com; s=arcseal; t= 1717146822; b=mhXUsHLXov6VT/3G+IY4p4VEZy0uRdSUIWlquSbCshNTHLPKbp rlLc0C1LPlEjO77Dek+4kWll0841sEfInvNeUpBKNAqtaBUJSrzNtX7vIxF3sVD8 fjCIeZbJDubL4sCigkj41uAf0Qt1LoEAL5FTcqPKI6+ueXJ90ksNHd5wB0Ih/9u/ UuoXQNQEtpimwR/8ZOEjLUVIoo857yGbBbeG1keEJ4+9t75DHDeG/URj1gvoOvc5 S4VyipNmXOUWEtNrJYIdMIFflpj33tnsTACdrIFHRt9Q30hiV0z5UHoMgTqd4lz5 NV/ipUIe8P73UBnOQXDcb1Z7CJUEatBL7VrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d= topicbox.com; h=from:to:subject:date:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; s=arcseal; t=1717146822; bh=gFYJ1AOHrIMC/FJu/ZEXwHn5b1pw60sdoqu beruBygk=; b=LeqbQEjCkoij3+wLht+y4CyKyypgdiY+12/uKKCcWX6lztvO1YD CjF7BO4Kq5T3xyV1VJQsET4j2EMi9wtKKi8RZBWqkl6WgfHku9gDeC3jyiAQ84Vv 9vu7hl6rFT2KQIbBhvuKhDzmz9sBnExZJFZ2YvbIs41TG3+vm6ptdOjZ+R/5kYkc ZfU58Qy2wjbguQbsxOnhtFiXJvO5GUy5+5Px9uMaYdcWJqxIkAByj6RERi3CBedQ o+rQv/LXFVTqj2W/UkQba+EesNCSlwspPyUrpAkHwlosXn2kpySjgIPOcEer4c2v EXHJ6GDTco1DMtiFqR9vuu5hF7TLk4D0+mw== ARC-Authentication-Results: i=1; tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC did not pass); dkim=none (no signatures found); dmarc=fail policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none policy.arc-aware-result=fail (p=none,d=none,d.eval=none,arc_aware_result=fail) policy.policy-from=p header.from=tambov.ru; iprev=pass smtp.remote-ip=195.19.116.13 (witch.tambov.ru); spf=none smtp.mailfrom=denis@tambov.ru smtp.helo=witch.tambov.ru; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=witch.tambov.ru policy.ptr=witch.tambov.ru; x-return-mx=pass header.domain=tambov.ru policy.is_org=yes (MX Records found: mx.tambov.ru); x-return-mx=pass smtp.domain=tambov.ru policy.is_org=yes (MX Records found: mx.tambov.ru); x-vs=clean score=-100 state=0 Authentication-Results: tb-mx1.topicbox.com; arc=none (no signatures found); bimi=skipped (DMARC did not pass); dkim=none (no signatures found); dmarc=fail policy.published-domain-policy=none policy.applied-disposition=none policy.evaluated-disposition=none policy.arc-aware-result=fail (p=none,d=none,d.eval=none,arc_aware_result=fail) policy.policy-from=p header.from=tambov.ru; iprev=pass smtp.remote-ip=195.19.116.13 (witch.tambov.ru); spf=none smtp.mailfrom=denis@tambov.ru smtp.helo=witch.tambov.ru; x-aligned-from=pass (Address match); x-me-sender=none; x-ptr=pass smtp.helo=witch.tambov.ru policy.ptr=witch.tambov.ru; x-return-mx=pass header.domain=tambov.ru policy.is_org=yes (MX Records found: mx.tambov.ru); x-return-mx=pass smtp.domain=tambov.ru policy.is_org=yes (MX Records found: mx.tambov.ru); x-vs=clean score=-100 state=0 X-ME-VSCause: gggruggvucftvghtrhhoucdtuddrgedvledrvdekiedguddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephfhovffuffgfvehfjgggtgfgugfksehtjeertddt ieejnecuhfhrohhmpeffvghnihhsucfmohiirggurggvvhcuoeguvghnihhssehtrghmsg hovhdrrhhuqeenucggtffrrghtthgvrhhnpedtudekkedvueffhfeiheeuffdtudfhkedt keegudeuuedvgeehteeggeeufedufeenucfkphepudelhedrudelrdduudeirddufedpvd dttddumegstdekmeegmeegmeemtgenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepihhnvghtpeduleehrdduledrudduiedrudefpdhhvghlohepfihithgthhdrthgrmh gsohhvrdhruhdpmhgrihhlfhhrohhmpeeouggvnhhishesthgrmhgsohhvrdhruheqpdhn sggprhgtphhtthhopedupdhrtghpthhtohepoeguvghvvghlohhpvghrsehlihhsthhsrd hilhhluhhmohhsrdhorhhgqe X-ME-VSScore: -100 X-ME-VSCategory: clean Received-SPF: none (tambov.ru: No applicable sender policy available) receiver=tb-mx1.topicbox.com; identity=mailfrom; envelope-from="denis@tambov.ru"; helo=witch.tambov.ru; client-ip=195.19.116.13 Received: from witch.tambov.ru (witch.tambov.ru [195.19.116.13]) by tb-mx1.topicbox.com (Postfix) with ESMTP for ; Fri, 31 May 2024 05:13:40 -0400 (EDT) (envelope-from denis@tambov.ru) Received: from home-gw.tambov.ru ([195.19.116.209] verified) by witch.tambov.ru (CommuniGate Pro SMTP 6.2.15 _community_) with ESMTP id 496730; Fri, 31 May 2024 12:13:37 +0300 Received: from [2001:b08:4:4::c] (account denis@home-gw.tambov.ru HELO home.tambov.ru) by home-gw.tambov.ru (CommuniGate Pro SMTP 6.2.15 _community_) with ESMTPSA id 3090444; Fri, 31 May 2024 12:13:38 +0300 From: Denis Kozadaev Organization: Tambov State Technical University To: developer@lists.illumos.org Subject: Re: [developer] Raw ethernet packets Date: Fri, 31 May 2024 12:13:37 +0300 User-Agent: KMail/1.9.10 Cc: Marcel Telka References: In-Reply-To: X-KMail-QuotePrefix: > MIME-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <202405311213.37389.denis@tambov.ru> Topicbox-Policy-Reasoning: allow: sender is a member Topicbox-Message-UUID: 163ff666-1f2e-11ef-97b0-faf32762bfde witch% cat main.c #include #include #include #include #include #include #include #include int main(void) { int sock; struct sockaddr_ll sll; struct lifreq ifr; char buf[8192], dev[] = "dpi0"; ssize_t result; sock = socket(AF_PACKET, SOCK_RAW, 0); if (sock < 0) { perror("socket"); return (1); } strcpy(ifr.lifr_name, dev); result = ioctl(sock, SIOCGLIFINDEX, &ifr); sll.sll_family = AF_PACKET; sll.sll_ifindex = ifr.lifr_index; sll.sll_protocol = 0; result = bind(sock, (struct sockaddr *)&sll, sizeof(sll)); for (;;) { result = recvfrom(sock, buf, sizeof(buf), 0, NULL, NULL); fprintf(stderr, "received %d bytes\n", (int)result); } close(sock); return (0); } /****************************/ This is my old code I played long time ago. I hope this will help you... On Friday 31 May 2024 11:54:26 Marcel Telka wrote: > On Fri, May 31, 2024 at 10:43:03AM +0200, Marcel Telka wrote: > > 1) socket()/bind() > > > > int s = socket(AF_PACKET, SOCK_RAW, 0); > > > > struct sockaddr_ll llp = {}; > > llp.sll_family = AF_PACKET; > > llp.sll_protocol = 0x0800; > > llp.sll_ifindex = 5; /* this is from ifconfig -a */ > > > > bind(s, (struct sockaddr *)&llp, sizeof (struct sockaddr_ll)); > > > > The bind() call above failed. > > ... with ENOENT. When I change the bind call to: > > bind(s, (struct sockaddr *)&llp, sizeof (struct sockaddr)); > > then it fails with EINVAL.