网络地址函数
| 函数 | 返回类型 | 描述 | 例子 | 结果 |
|---|---|---|---|---|
| abbrev(inet) | text | 缩写显示格式文本 | abbrev(inet ‘10.1.0.0/16’) | 10.1.0.0/16 |
| abbrev(cidr) | text | 缩写显示格式文本 | abbrev(cidr ‘10.1.0.0/16’) | 10.1/16 |
| broadcast(inet) | inet | 网络广播地址 | broadcast(‘192.168.1.5/24’) | 192.168.1.255/24 |
| family(inet) | int | 抽取地址族;4为 IPv4, 6为 IPv6 | family(’::1’) | 6 |
| host(inet) | text | 抽取 IP 地址为文本 | host(‘192.168.1.5/24’) | 192.168.1.5 |
| hostmask(inet) | inet | 为网络构造主机掩码 | hostmask(‘192.168.23.20/30’) | 0.0.0.3 |
| masklen(inet) | int | 抽取网络掩码长度 | masklen(‘192.168.1.5/24’) | 24 |
| netmask(inet) | inet | 为网络构造网络掩码 | netmask(‘192.168.1.5/24’) | 255.255.255.0 |
| network(inet) | cidr | 抽取地址的网络部分 | network(‘192.168.1.5/24’) | 192.168.1.0/24 |
| set_masklen(inet, int) | inet | 为inet值设置网络掩码长度 | set_masklen(‘192.168.1.5/24’, 16) | 192.168.1.5/16 |
| set_masklen(cidr, int) | cidr | 为cidr值设置网络掩码长度 | set_masklen(‘192.168.1.0/24’::cidr, 16) | 192.168.0.0/16 |
| text(inet) | text | 抽取 IP 地址和网络掩码长度为文本 | text(inet ‘192.168.1.5’) | 192.168.1.5/32 |
| inet_same_family(inet, inet) | boolean | 地址是来自于同一个家族吗? | inet_same_family(‘192.168.1.5/24’, ‘::1’) | FALSE |
| inet_merge(inet, inet) | cidr | 包括给定网络的最小网络 | inet_merge(‘192.168.1.5/24’, ‘192.168.2.5/24’) | 192.168.0.0/22 |
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




