使用IPv6地址算术(大整数) [英] Arithmetic with IPv6 addresses (large integers)

查看:217
本文介绍了使用IPv6地址算术(大整数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IPv6地址格式:



FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF



在内部我将它们存储在数组中:

  TIp6Bytes = array [0..15 ]的字节

我需要以多种方式操作IPv6地址,包括添加,分割,乘法等。任何人都建议一个很好的方法来做到这一点?



我想我应该提到我正在使用Delphi 2009

解决方案

在尝试了许多建议之后,我找不到满足我所有需求并且没有bug的图书馆。我搜索了一下,发现一个相对较新的图书馆的Alex Ciobanu,BigIntegers(和大红雀队)无缝地让你以与处理正常整数,红雀等一样的方式来操纵它们。



除了BigIntegers之外,库还提供了许多非常有用的功能。从自述文件:




  • 一组通用集合类
    (List,Dictionary,HashSet等)。

  • 日期/时间功能在几个结构中组合
    (以某种方式
    相当于.NET的DateTime
    结构)

  • 类型支持概念,定义
    一组
    的默认支持类,每个内置Delphi类型(在集合中用作
    默认值)。自定义
    类型支持类可以为您的自定义数据
    类型注册

  • BigCardinal和BigInteger数据类型

  • Delphi中的智能指针



正在积极开发库。事实上,笔者修复了一天内发现的一个小错误。



您可以在 Alex的博客,并从 Google代码


I'm working with IPv6 addresses in the form:

FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF

Internally, I store them in an array:

TIp6Bytes = array [0..15] of Byte;

I need to manipulate the IPv6 addresses in a number of ways including adding, dividing, multiplying etc. Can anyone suggest a good way to do this?

I guess I should have mentioned that I'm working with Delphi 2009

解决方案

After trying many of the suggestions I could not find a library that fulfilled all my needs and were bug free. I searched a little harder and found a relatively new library by Alex Ciobanu which does BigIntegers (and Big Cardinals) seamlessly allowing you to manipulate them in much the same way as you manipulate normal Integers, Cardinals etc.

As well as BigIntegers, the library also provides a number of very useful features. From the readme:

  • A set of generic collections classes (List, Dictionary, HashSet, etc).
  • Date/Time functionality all combined in a few structures (somehow equivalent to .NET's DateTime structure)
  • Type Support concept that defines a set of default "support classes" for each built-in Delphi types (used as defaults in collections). Custom "type support" classes can be registered for your custom data types.
  • BigCardinal and BigInteger data types.
  • Smart pointers in Delphi

The library is being actively developed. In fact, the author fixed a small bug I found within a day.

You can read more about the library on Alex's blog and download DeHL from Google code.

这篇关于使用IPv6地址算术(大整数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆