Introduction

DeepSeek Harness (DSH) adopts the philosophy of “everything is a plugin.” When developing agents that involve network configuration, IP address and subnet calculation are common requirements, but large language models are prone to errors when performing arithmetic mentally. dsh-ipcalc provides precise mathematical computation, ensuring the logical correctness of network configurations.

What It Is

dsh-ipcalc is an IP and subnet mathematics toolbox designed for DeepSeek Harness. It is maintained by TYEclipse and released under the MIT license. The plugin includes five purely local computation tools, with the characteristics of zero runtime dependencies and no network I/O. It replaces mental arithmetic with local mathematical operations, addressing the precision and logic errors that agents may encounter when handling network addresses.

Core Features

This toolbox provides the following five core features:

  1. ipv4_subnet: Performs a complete subnet layout for an IPv4 CIDR block and outputs the network address, broadcast address, netmask, wildcard mask, host range, address count, and IANA classification.
  2. ipv4_summarize: Consolidates a set of IPv4 addresses or ranges into a minimally covering CIDR list (supernet calculation and range merging).
  3. ip_parse: Validates and normalizes any IPv4/IPv6 address (in accordance with RFC 5952) and also performs IANA classification.
  4. ipv6_subnet: Performs a complete subnet layout for an IPv6 CIDR block, using 128-bit BigInt for precise arithmetic.
  5. ip_match: Determines whether a raw IP address belongs to a given CIDR range and returns the normalized range.

Installation and Activation

Before installation, make sure that your DeepSeek Harness environment has a plugin manager configured. Run the following command to add the plugin to the specified profile:

dsh plugin --profile <your-profile> add github:TYEclipse/dsh-ipcalc

After installation, the plugin can be invoked in DSH sessions.

Typical Usage

IPv4 Subnet Layout

ipv4_subnet("192.168.1.25/24")

The output will include the network address, broadcast address, subnet mask, wildcard mask, usable host range (including address count), and IANA classification information.

CIDR Summarization

ipv4_summarize(["10.0.0.0/24", "10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"])

This will return ["10.0.0.0/22"].

IPv6 Address Parsing and Normalization

ip_parse("::ffff:192.168.1.1")

The output will identify the address as an IPv6 type, normalized in accordance with RFC 5952, and recognize its embedded IPv4 characteristics.

IPv6 Subnet Calculation

ipv6_subnet("2001:db8:1234:5678::1/64")

Calculations are performed using 128-bit BigInt. The output includes the network address, the first and last usable host range, and the exact total number of addresses (returned as a decimal string to avoid precision loss).

For special network ranges:

ipv6_subnet("::/0")
ipv6_subnet("fe80::1/127")

IP Membership Testing

ip_match("192.168.1.5", "192.168.1.0/24")

Returns the matching result and the normalized network range.

Technical Details

  • Precise Arithmetic: IPv4 uses 32-bit integer calculations, while IPv6 uses 128-bit BigInt calculations. When an address count exceeds the safe integer threshold, it is returned as a string to preserve precision.
  • RFC Compliance: /31 prefixes follow RFC 3021 (point-to-point link, where both addresses are usable); /127 follows RFC 6164; IPv6 normalization follows RFC 5952.
  • Classification: Addresses are classified according to the IANA Special-Purpose Address Registry (for example, private, loopback, link-local, documentation range, multicast, etc.).
  • Version Validation: ip_match rejects membership tests that mix IPv4 and IPv6 versions, avoiding silent errors.

Notes

  • The plugin runs in the local execution environment of the DSH process and does not make network requests.
  • Before enabling the plugin, it is recommended to review the source code to confirm that its behavior meets your security and compliance requirements.
  • The IPv6 implementation strictly distinguishes address versions. When performing match tests, ensure that the IP address and CIDR belong to the same version.

Summary

dsh-ipcalc solves common calculation errors in network configuration by using localized and standardized mathematical operations. For developers who need to handle IP addresses and subnets precisely, it is a reliable auxiliary tool.