{"id":13791981,"url":"https://github.com/tonyg/racket-packet-socket","last_synced_at":"2025-06-21T04:05:37.047Z","repository":{"id":62424299,"uuid":"20815695","full_name":"tonyg/racket-packet-socket","owner":"tonyg","description":"Access to raw Ethernet frames from Racket","archived":false,"fork":false,"pushed_at":"2020-04-27T17:39:54.000Z","size":33,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-11T16:52:11.794Z","etag":null,"topics":["ethernet","network","racket","socket"],"latest_commit_sha":null,"homepage":null,"language":"Racket","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tonyg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-06-13T19:40:39.000Z","updated_at":"2022-10-23T14:26:06.000Z","dependencies_parsed_at":"2022-11-01T18:00:30.747Z","dependency_job_id":null,"html_url":"https://github.com/tonyg/racket-packet-socket","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/tonyg/racket-packet-socket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-packet-socket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-packet-socket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-packet-socket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-packet-socket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tonyg","download_url":"https://codeload.github.com/tonyg/racket-packet-socket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tonyg%2Fracket-packet-socket/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261060124,"owners_count":23103979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ethernet","network","racket","socket"],"created_at":"2024-08-03T22:01:06.646Z","updated_at":"2025-06-21T04:05:32.033Z","avatar_url":"https://github.com/tonyg.png","language":"Racket","funding_links":[],"categories":["Racket"],"sub_categories":["Networks/web"],"readme":"# Access to raw Ethernet frames from Racket\n\nIf Racket needs a packet from a socket or a port,  \nyou might just find it's nowhere near as easy as you thought.  \nUp in complicated ioctls you'll be caught,  \nEnsuring error-freedom is particularly fraught!\n\nDashing to the rescue is this polished little package:  \nA tiny C extension, with a pinch of Racket hackage,  \nRelieves you of your burden and returns you to your slackage,  \nAnd competently fixes Racket's packet socket lackage.\n\n— [tonyg](http://leastfixedpoint.com/), with [apologies to Gene Ziegler](http://web.archive.org/web/20130301230602/http://geneziegler.com/clocktower/drseuss.html)\n\n## What?\n\nRead and write raw Ethernet frames from Racket programs. \n\n## How?\n\n```racket\n(require packet-socket)\n\n(display (raw-interface-names))\n(newline)\n\n(define handle (raw-interface-open \"eth0:1\"))\n(unless handle (error 'example \"Couldn't open the device\"))\n\n(define packet (raw-interface-read handle)) ;; blocks\n\n(raw-interface-write handle packet)\n\n(raw-interface-close handle)\n```\n\nYou will need to take care of Ethernet frame headers, footers,\nchecksums and addressing yourself. You may find the Racket package\n[bitsyntax](https://github.com/tonyg/racket-bitsyntax) useful to you\nin manipulating binary data structures.\n\nYou will also need to give the Racket executable `CAP_NET_RAW`\ncapability on Linux in order to create packet sockets. One approach to\nthis could be:\n\n```sh\nsudo setcap cap_net_raw+p+i+e `which racket`\n```\n\nBe warned that ethernet has a 64-byte minimum packet size. Less four\nbytes for the checksum, two for the ethertype, and twelve for the\nsender and target MAC addresses, that leaves 46 bytes of payload in\nsuch a minimum-sized packet. If you are expecting to receive packets\nwith *fewer than 46 bytes of payload*, then make sure to handle the\nzero-padding that gets added to the end by the ethernet! For example,\nIPv4 packets have an explicit whole-packet length indicator for just\nsuch a situation.\n\n## Who?\n\nCopyright (c) 2014 [Jonathan Schuster](https://github.com/schuster)  \nCopyright (c) 2014-2020 [Tony Garnock-Jones](https://leastfixedpoint.com/)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n## Bugs\n\n - BPF exists not only on OSX, but also on many other BSDs. The\n   `#ifdefs` in the support code should be widened to allow it to run\n   there as well.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonyg%2Fracket-packet-socket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftonyg%2Fracket-packet-socket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftonyg%2Fracket-packet-socket/lists"}