Skip to content

Commit 7463deb

Browse files
committed
docs: add ipcalc
[no ci]
1 parent 781616c commit 7463deb

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

.github/ipcalc-sc.png

39.2 KB
Loading

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,47 @@ D SELECT get_tranco_rank_category('microsoft.com') as category;
267267
└──────────┘
268268
```
269269

270+
### IP Address Functions
271+
272+
This extension provides various functions to manipulate and analyze IP addresses, including calculating networks, hosts, and subnet masks.
273+
274+
#### IP Calculator
275+
276+
The `ipcalc` function takes an IP address and netmask and calculates the resulting broadcast, network, wildcard mask, and host range.
277+
278+
![ipcalc-sc](./.github/ipcalc-sc.png)
279+
280+
It's a table function that provides various details about IP addresses including:
281+
282+
- Address
283+
- Netmask
284+
- Wildcard
285+
- Network / Hostroute
286+
- HostMin
287+
- HostMax
288+
- Broadcast
289+
- Hosts count
290+
291+
You can use this table function with your data easily:
292+
293+
```sql
294+
D CREATE OR REPLACE TABLE ips AS SELECT '127.0.0.1' AS ip UNION ALL SELECT '192.168.1.0/22';
295+
296+
D SELECT i.IP,
297+
(
298+
SELECT hostsPerNet
299+
FROM ipcalc(i.IP)
300+
) AS hosts
301+
FROM ips AS i;
302+
┌────────────────┬───────┐
303+
│ ip │ hosts │
304+
varchar │ int64 │
305+
├────────────────┼───────┤
306+
127.0.0.1254
307+
192.168.1.0/221022
308+
└────────────────┴───────┘
309+
```
310+
270311
### Get Extension Version
271312

272313
You can use the `netquack_version` function to get the version of the extension.
@@ -286,7 +327,6 @@ D select * from netquack_version();
286327
- [ ] Create a `TableFunction` for `extract_query_parameters` that return each key-value pair as a row.
287328
- [ ] Save Tranco data as Parquet
288329
- [ ] Implement GeoIP functionality
289-
- [ ] Add new functions to work with IPs
290330
- [ ] Return default value for `get_tranco_rank`
291331
- [ ] Support internationalized domain names (IDNs)
292332

0 commit comments

Comments
 (0)