{"id":16889929,"url":"https://github.com/benoitc/inet_ext","last_synced_at":"2025-08-30T16:41:08.620Z","repository":{"id":57506691,"uuid":"52366329","full_name":"benoitc/inet_ext","owner":"benoitc","description":"inet extensions library","archived":false,"fork":false,"pushed_at":"2020-01-29T14:54:42.000Z","size":70,"stargazers_count":14,"open_issues_count":3,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-25T02:40:01.707Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benoitc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-23T14:51:44.000Z","updated_at":"2025-08-07T03:03:54.000Z","dependencies_parsed_at":"2022-08-29T20:01:23.081Z","dependency_job_id":null,"html_url":"https://github.com/benoitc/inet_ext","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/benoitc/inet_ext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Finet_ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Finet_ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Finet_ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Finet_ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benoitc","download_url":"https://codeload.github.com/benoitc/inet_ext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Finet_ext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272878212,"owners_count":25008340,"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","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-13T16:59:50.357Z","updated_at":"2025-08-30T16:41:08.568Z","avatar_url":"https://github.com/benoitc.png","language":"Erlang","readme":"## inet_ext\n\ninet extension, collections of convenient functions to use with inet\n\n\n## Usage\n\n### Get the lists of default gateway for each interfaces\n\n```erlang\n\n1\u003e inet_ext:gateways().\n[{\"en0\",\"192.168.1.254\"},{\"en1\",\"192.168.1.254\"}]\n```\n\nTo get the gateway for a specific interface uses the `inet_ext:gateway_for/1` function.\n\n### Get internal address for a gateway\n\n```erlang\n2\u003e inet_ext:get_internal_address(\"192.168.1.254\").\n\"192.168.1.22\"\n```\n\n### Get all routes\n\n```erlang\n3\u003e inet_ext:routes().\n[{\"lo0\",\n  {{65152,0,0,0,0,0,0,1},{65535,65535,65535,65535,0,0,0,0}}},\n {\"lo0\",{{127,0,0,1},{255,0,0,0}}},\n {\"lo0\",\n  {{0,0,0,0,0,0,0,1},\n   {65535,65535,65535,65535,65535,65535,65535,65535}}},\n {\"en0\",{{192,168,1,41},{255,255,255,0}}},\n {\"en0\",\n  {{10753,3637,35380,28048,9323,2852,13025,48991},\n   {65535,65535,65535,65535,0,0,0,0}}},\n {\"en0\",\n  {{10753,3637,35380,28048,44679,41983,65072,60656},\n   {65535,65535,65535,65535,0,0,0,0}}},\n {\"en0\",\n  {{65152,0,0,0,44679,41983,65072,60656},\n   {65535,65535,65535,65535,0,0,0,0}}},\n {\"en1\",{{192,168,1,22},{255,255,255,0}}},\n {\"en1\",\n  {{10753,3637,35380,28048,24909,3247,60839,4143},\n   {65535,65535,65535,65535,0,0,0,0}}}]\n```\n\n### IP and MAC address format conversions\n\n|API|Description|\n|-----:|:-----------|\n|convert_mac/2|Convert MAC Address from -\u003e to |\n|convert_ip/2|Convert IP Address from -\u003e to |\n\nConversions allowed are in between following types:\nto_string | to_binstring | to_integer | to_binary | to_list | to_tuple\n\n```erlang\n1\u003e inet_utils:convert_mac(to_binstring, \u003c\u003c1,2,3,4,5,6\u003e\u003e).\n\u003c\u003c\"01:02:03:04:05:06\"\u003e\u003e\n2\u003e inet_utils:convert_ip(to_binary, 16#01020304).\n\u003c\u003c1,2,3,4\u003e\u003e\n```\n\n### Check address type\n\nYou can test an IP address to know if they it's a private,\nglobal(public), loopback, reserved, unspecified, liknlocal or multicast\naddress by using the following functions:\n\n    * `is_private_address/1`\n    * `is_global_address/1`\n    * `is_loopback_address/1`\n    * `is_unspecified_address/1`\n    * `is_reserved_address/1`\n    * `is_linklocal_address/1`\n    * `is_multicast_address/1`\n\nThese functions are using based on IANA [IPv4](https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml) \u0026 [IPv6](https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml\n) special-purpose address registries.\n\n\n```erlang\n1\u003e inet_ext:is_private_address(\"192.168.1.1\").\ntrue\n```\n\n## Contribute\n\nFor issues, comments or feedback please create an [issue](https://github.com/benoitc/inet_ext/issues).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Finet_ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoitc%2Finet_ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Finet_ext/lists"}