Quantcast

The right type for storing IP addresses

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

The right type for storing IP addresses

Eugene Kudashev
Hey everyone. I'm curious: what type should I use for semantically
storing IP addresses in my wiki
The complete list of data types in SMW is here
http://semantic-mediawiki.org/wiki/Help:Properties_and_types#List_of_datatypes
Yet it doesn't seem to answer my question
Obviously, "Number" doesn't work, and using "String" leads to issues
with sorting a list of IPs, like you get 10.40.1.1 after 10.100.1.1,
which is a bit silly
Any ideas?

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

Yaron Koren-2
Hi Eugene,

I think the only real option is to use "String". The sorting is not ideal,
but of course there's no "IP address" type, which is what would be required
here.

-Yaron

On Sun, Aug 5, 2012 at 10:16 AM, Eugene Kudashev
<[hidden email]>wrote:

> Hey everyone. I'm curious: what type should I use for semantically
> storing IP addresses in my wiki
> The complete list of data types in SMW is here
>
> http://semantic-mediawiki.org/wiki/Help:Properties_and_types#List_of_datatypes
> Yet it doesn't seem to answer my question
> Obviously, "Number" doesn't work, and using "String" leads to issues
> with sorting a list of IPs, like you get 10.40.1.1 after 10.100.1.1,
> which is a bit silly
> Any ideas?
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>



--
WikiWorks · MediaWiki Consulting · http://wikiworks.com
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

Jeroen De Dauw-2
Hey,

> The sorting is not ideal, but of course there's no "IP address" type,
which is what would be required here.

It's pretty trivial to create a DataValue for this, which is all that's
needed to have such a build in type. If anyone is interested in doing the
little programming work, I can write up some docs :)

Cheers

--
Jeroen De Dauw
http://www.bn2vs.com
Don't panic. Don't be evil.
--
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

CWinDC
In reply to this post by Yaron Koren-2
Eugene,
I suppose you could set up four form fields, like: ip_part1, ip_part2,
ip_part3, ip_part4. You'd have to define four properties (Has IP Part
One...) of type Number and call each part separately.

It's a bit more work for templates, forms and queries but at least you
could format it the way you want and sort each part like a number.


On Mon, Aug 6, 2012 at 9:24 AM, Yaron Koren <[hidden email]> wrote:

> Hi Eugene,
>
> I think the only real option is to use "String". The sorting is not ideal,
> but of course there's no "IP address" type, which is what would be required
> here.
>
> -Yaron
>
> On Sun, Aug 5, 2012 at 10:16 AM, Eugene Kudashev
> <[hidden email]>wrote:
>
> > Hey everyone. I'm curious: what type should I use for semantically
> > storing IP addresses in my wiki
> > The complete list of data types in SMW is here
> >
> >
> http://semantic-mediawiki.org/wiki/Help:Properties_and_types#List_of_datatypes
> > Yet it doesn't seem to answer my question
> > Obviously, "Number" doesn't work, and using "String" leads to issues
> > with sorting a list of IPs, like you get 10.40.1.1 after 10.100.1.1,
> > which is a bit silly
> > Any ideas?
> >
> >
> >
> ------------------------------------------------------------------------------
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and
> > threat landscape has changed and how IT managers can respond. Discussions
> > will include endpoint security, mobile security and the latest in malware
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> > _______________________________________________
> > Semediawiki-user mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/semediawiki-user
> >
>
>
>
> --
> WikiWorks · MediaWiki Consulting · http://wikiworks.com
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

kghbln
In reply to this post by Jeroen De Dauw-2
Such a datatype should cater for IPv6 from start. However, I get dizzy just by looking at these, not speaking
of trying to sort them somehow. O_o

Am 06.08.2012 15:47, schrieb Jeroen De Dauw:

> Hey,
>
>> The sorting is not ideal, but of course there's no "IP address" type,
> which is what would be required here.
>
> It's pretty trivial to create a DataValue for this, which is all that's
> needed to have such a build in type. If anyone is interested in doing the
> little programming work, I can write up some docs :)
>
> Cheers
>
> --
> Jeroen De Dauw
> http://www.bn2vs.com
> Don't panic. Don't be evil.
> --
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

Yury Katkov
In reply to this post by Jeroen De Dauw-2
Hi Jeroen!

Each piece of programming documentation is as valuable as gold! Please do.
I've spent about two days recently before I figured out these two
lines that allow to want the value of the semantic property.

 $params = array ("[[Pagename]]", "?ExampleProperty=", "mainlabel=-");
 $result = SMWQueryProcessor::getResultFromFunctionParams( $params,
SMW_OUTPUT_WIKI );

I'm pretty sure that making custom datatypes is pretty common task and
not only I will find your docs useful.
-----
Yury Katkov




On Mon, Aug 6, 2012 at 5:47 PM, Jeroen De Dauw <[hidden email]> wrote:

>
> Hey,
>
> > The sorting is not ideal, but of course there's no "IP address" type,
> which is what would be required here.
>
> It's pretty trivial to create a DataValue for this, which is all that's
> needed to have such a build in type. If anyone is interested in doing the
> little programming work, I can write up some docs :)
>
> Cheers
>
> --
> Jeroen De Dauw
> http://www.bn2vs.com
> Don't panic. Don't be evil.
> --
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

Jeroen De Dauw-2
Hey,

I've spent about two days recently before I figured out these two
> lines that allow to want the value of the semantic property.
>
>  $params = array ("[[Pagename]]", "?ExampleProperty=", "mainlabel=-");
>  $result = SMWQueryProcessor::getResultFromFunctionParams( $params,
> SMW_OUTPUT_WIKI );
>

It would be of great help to have documentation on doing such stuff, but
right now SMWQueryProcessor is a huge mess, so I'd like to see it rewritten
before everyone starts building on top of it.

I'm pretty sure that making custom datatypes is pretty common task and not
> only I will find your docs useful.
>

Right - I will quickly poke at this soonish then. Docs will be here
http://semantic-mediawiki.org/wiki/Writing_data_values

Cheers

--
Jeroen De Dauw
http://www.bn2vs.com
Don't panic. Don't be evil.
--
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

Markus Krötzsch-2
In reply to this post by Jeroen De Dauw-2
On 06/08/12 14:47, Jeroen De Dauw wrote:
> Hey,
>
>> The sorting is not ideal, but of course there's no "IP address" type,
> which is what would be required here.
>
> It's pretty trivial to create a DataValue for this, which is all that's
> needed to have such a build in type. If anyone is interested in doing the
> little programming work, I can write up some docs :)

It is not completely trivial, since one still needs a proper "host"
datatype for getting the right sorting from the database. I would
suggest create a new datavalue (DV) implementation for parsing and
formatting IPs. Internally, this representation would store its data in
a string (DI type) that is formatted in such a way that the alphabetic
sorting is correct, e.g., 10.40.1.1 could be stored as 010.040.001.001.
Adding and removing leading 0 is easy to do in the DV, so the data would
still work properly. One could also do a similar trick with numbers
instead of strings, which might be slightly more efficient. In essence,
10.40.1.1, could be stored as 0.010040001001.

In either case, one only needs to implement and register a DV class. For
implementation, a simple example is given in the file SMW_DV_String.php
and most other DV files (they all have some special code, related to
their particular parsing and display features; the meaning of the
implemented methods is documented in SMW_DataValue.php). For
registration, one uses the hook smwInitDatatypes to call methods
SMWDataValueFactory::registerDatatype() (see documentation there).

Cheers,

Markus



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to get property values from SMW (Was: The right type for storing IP addresses)

Markus Krötzsch-2
In reply to this post by Yury Katkov
On 06/08/12 15:59, Yury Katkov wrote:
> Hi Jeroen!
>
> Each piece of programming documentation is as valuable as gold! Please do.
> I've spent about two days recently before I figured out these two
> lines that allow to want the value of the semantic property.
>
>   $params = array ("[[Pagename]]", "?ExampleProperty=", "mainlabel=-");
>   $result = SMWQueryProcessor::getResultFromFunctionParams( $params,
> SMW_OUTPUT_WIKI );

The above is a very complicated way to get the data you want
(constructing a whole query with printouts to get a single data value).
It's short, but it invokes all kinds of string-based parsing that may
not be needed. Instead, you can do:

// Assuming that you have the names of page and property fixed:
// (all strings are DBKeys, that is, use '_' instead of ' ')
$propertyDi = new SMWDIProperty( 'ExampleProperty' );
$pageDi = new SMWDIWikiPage( 'Pagename', NS_MAIN, '' );
$valueDis = smwfGetStore()->getPropertyValues( $pageDi, $propertyDi );
// $valueDis now is an array of all property values, given as DI objects

// To create DV objects:
foreach ( $valueDis as $valueDi ) {
        $valueDv = SMWDataValueFactory::newDataItemValue( $valueDi, $propertyDi );
// do something ...
}

If page or property name comes from user input, then you can do
something like:

$propertyDv = SMWDataValueFactory::newTypeIdValue( '__pro', $propertyName );
$pageDv = SMWDataValueFactory::newTypeIdValue( '_wpg', $pageName );

and then call getDataItem() to get the DIs. The strings '__pro' and
'_wpg' are the type ids that control how SMW will handle the string to
create a suitable DV object. You can see all builtin type ids in
SMWDatavalueFactory, if you want to know this for other datatypes as
well. However, if you have "clean" internal values, you can always
create DI objects directly, rather than parsing them from a string.

Please take advantage of the devel list for such questions :-)

Cheers,

Markus


>
> I'm pretty sure that making custom datatypes is pretty common task and
> not only I will find your docs useful.
> -----
> Yury Katkov
>
>
>
>
> On Mon, Aug 6, 2012 at 5:47 PM, Jeroen De Dauw <[hidden email]> wrote:
>>
>> Hey,
>>
>>> The sorting is not ideal, but of course there's no "IP address" type,
>> which is what would be required here.
>>
>> It's pretty trivial to create a DataValue for this, which is all that's
>> needed to have such a build in type. If anyone is interested in doing the
>> little programming work, I can write up some docs :)
>>
>> Cheers
>>
>> --
>> Jeroen De Dauw
>> http://www.bn2vs.com
>> Don't panic. Don't be evil.
>> --
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Semediawiki-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

Markus Krötzsch-2
In reply to this post by CWinDC
On 06/08/12 15:06, CW Dillon wrote:
> Eugene,
> I suppose you could set up four form fields, like: ip_part1, ip_part2,
> ip_part3, ip_part4. You'd have to define four properties (Has IP Part
> One...) of type Number and call each part separately.
>
> It's a bit more work for templates, forms and queries but at least you
> could format it the way you want and sort each part like a number.

Yes, that is also possible. One can then represent IPs as subobjects. It
would be more difficult to get the display right in such cases though,
and it would be a quite a bit less efficient on all levels (templates,
DB access, ...).

Cheers,

Markus

>
>
> On Mon, Aug 6, 2012 at 9:24 AM, Yaron Koren <[hidden email]> wrote:
>
>> Hi Eugene,
>>
>> I think the only real option is to use "String". The sorting is not ideal,
>> but of course there's no "IP address" type, which is what would be required
>> here.
>>
>> -Yaron
>>
>> On Sun, Aug 5, 2012 at 10:16 AM, Eugene Kudashev
>> <[hidden email]>wrote:
>>
>>> Hey everyone. I'm curious: what type should I use for semantically
>>> storing IP addresses in my wiki
>>> The complete list of data types in SMW is here
>>>
>>>
>> http://semantic-mediawiki.org/wiki/Help:Properties_and_types#List_of_datatypes
>>> Yet it doesn't seem to answer my question
>>> Obviously, "Number" doesn't work, and using "String" leads to issues
>>> with sorting a list of IPs, like you get 10.40.1.1 after 10.100.1.1,
>>> which is a bit silly
>>> Any ideas?
>>>
>>>
>>>
>> ------------------------------------------------------------------------------
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond. Discussions
>>> will include endpoint security, mobile security and the latest in malware
>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>> _______________________________________________
>>> Semediawiki-user mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>>>
>>
>>
>>
>> --
>> WikiWorks · MediaWiki Consulting · http://wikiworks.com
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Semediawiki-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to get property values from SMW (Was: The right type for storing IP addresses)

Yury Katkov
In reply to this post by Markus Krötzsch-2
I got it, thank you Markus and Jeroen!

I used to use the cleaner way (not as clean as Markus recommend
though) of getting the property values and even once documented that
here: [1]. However since my last visit some of the methods got
deprecated and some got removed.

If I can make a suggestion: that would be very cool if we have some
kind of programming API in SMW for extension developers. It can be
just a set of classes that are not likely to change very much and on
which the third-party developers can rely on. I understand how busy
core developers are, but such API can increase the number of SMW-based
extensions and, in the future, the number of core developers.

And of course if anybody continues to work on Architecture Guide that
would be terrific!

[1] http://semantic-mediawiki.org/wiki/User:Yury_Katkov/programming_examples


-----
Yury Katkov



On Tue, Aug 7, 2012 at 1:34 PM, Markus Krötzsch
<[hidden email]> wrote:

> On 06/08/12 15:59, Yury Katkov wrote:
>>
>> Hi Jeroen!
>>
>> Each piece of programming documentation is as valuable as gold! Please do.
>> I've spent about two days recently before I figured out these two
>> lines that allow to want the value of the semantic property.
>>
>>   $params = array ("[[Pagename]]", "?ExampleProperty=", "mainlabel=-");
>>   $result = SMWQueryProcessor::getResultFromFunctionParams( $params,
>> SMW_OUTPUT_WIKI );
>
>
> The above is a very complicated way to get the data you want (constructing a
> whole query with printouts to get a single data value). It's short, but it
> invokes all kinds of string-based parsing that may not be needed. Instead,
> you can do:
>
> // Assuming that you have the names of page and property fixed:
> // (all strings are DBKeys, that is, use '_' instead of ' ')
> $propertyDi = new SMWDIProperty( 'ExampleProperty' );
> $pageDi = new SMWDIWikiPage( 'Pagename', NS_MAIN, '' );
> $valueDis = smwfGetStore()->getPropertyValues( $pageDi, $propertyDi );
> // $valueDis now is an array of all property values, given as DI objects
>
> // To create DV objects:
> foreach ( $valueDis as $valueDi ) {
>         $valueDv = SMWDataValueFactory::newDataItemValue( $valueDi,
> $propertyDi );
> // do something ...
> }
>
> If page or property name comes from user input, then you can do something
> like:
>
> $propertyDv = SMWDataValueFactory::newTypeIdValue( '__pro', $propertyName );
> $pageDv = SMWDataValueFactory::newTypeIdValue( '_wpg', $pageName );
>
> and then call getDataItem() to get the DIs. The strings '__pro' and '_wpg'
> are the type ids that control how SMW will handle the string to create a
> suitable DV object. You can see all builtin type ids in SMWDatavalueFactory,
> if you want to know this for other datatypes as well. However, if you have
> "clean" internal values, you can always create DI objects directly, rather
> than parsing them from a string.
>
> Please take advantage of the devel list for such questions :-)
>
> Cheers,
>
> Markus
>
>
>>
>> I'm pretty sure that making custom datatypes is pretty common task and
>> not only I will find your docs useful.
>> -----
>> Yury Katkov
>>
>>
>>
>>
>> On Mon, Aug 6, 2012 at 5:47 PM, Jeroen De Dauw <[hidden email]>
>> wrote:
>>>
>>>
>>> Hey,
>>>
>>>> The sorting is not ideal, but of course there's no "IP address" type,
>>>
>>> which is what would be required here.
>>>
>>> It's pretty trivial to create a DataValue for this, which is all that's
>>> needed to have such a build in type. If anyone is interested in doing the
>>> little programming work, I can write up some docs :)
>>>
>>> Cheers
>>>
>>> --
>>> Jeroen De Dauw
>>> http://www.bn2vs.com
>>> Don't panic. Don't be evil.
>>> --
>>>
>>> ------------------------------------------------------------------------------
>>> Live Security Virtual Conference
>>> Exclusive live event will cover all the ways today's security and
>>> threat landscape has changed and how IT managers can respond. Discussions
>>> will include endpoint security, mobile security and the latest in malware
>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>> _______________________________________________
>>> Semediawiki-user mailing list
>>> [hidden email]
>>> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Semediawiki-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>>
>
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

pwinkeler
In reply to this post by Markus Krötzsch-2
Typically the best way to store IPv4 addresses is as single 32-bit number, or in SMW-speak, a number.  All we need then are a pair of routines to respective parse the dotted-quad notation into a number and one to display a number as a dotted-quad.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

thingles
Definitely that is the case if your focusing on a compact storage footprint.

I've not done much with IP addresses in SMW, but I've done a ton with other data and I would probably err on the side of actually storing it in a very inefficient manner using four separate numbers, and four separate fields in Semantic Forms (using a regex rule to enforce validity). That way you can do things easily with it. For example, you could easily identify Class A/B/C addresses with the data in that format. If your tracking subnet mask I would have that be a 5th field. You could take that further and store it as an IPv4 #subobject and allow IPv6 #subobject as well.

Just a thought…

Jamie

On Nov 26, 2012, at 5:55 PM, pwinkeler <[hidden email]> wrote:

> Typically the best way to store IPv4 addresses is as single 32-bit number, or
> in SMW-speak, a number.  All we need then are a pair of routines to
> respective parse the dotted-quad notation into a number and one to display a
> number as a dotted-quad.
>
>
>
> --
> View this message in context: http://wikimedia.7.n6.nabble.com/The-right-type-for-storing-IP-addresses-tp4982262p4990307.html
> Sent from the Semantic Mediawiki - User mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Monitor your physical, virtual and cloud infrastructure from a single
> web console. Get in-depth insight into apps, servers, databases, vmware,
> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
> Pricing starts from $795 for 25 servers or applications!
> http://p.sf.net/sfu/zoho_dev2dev_nov
> _______________________________________________
> Semediawiki-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/semediawiki-user

------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

pwinkeler
Thanks for taking the time to respond Jamie.  My reason for using a 32-bit number is not so much compactness as ease of manipulation.  It makes equality comparison trivial of course but if you also store the netmask as you pointed out already, then seeing if two addresses belong to the same network is easy too:
        (IP1 & netmask) == (IP2 & netmask)
Nowadays many networks use netmasks that are not simple multiples of 8 any more.

I have not looked IPv6 storage yet other than a quick glance to convince me that will not be near as simple.

On Nov 27, 2012, at 7:51 AM, Jamie Thingelstad <[hidden email]> wrote:

> Definitely that is the case if your focusing on a compact storage footprint.
>
> I've not done much with IP addresses in SMW, but I've done a ton with other data and I would probably err on the side of actually storing it in a very inefficient manner using four separate numbers, and four separate fields in Semantic Forms (using a regex rule to enforce validity). That way you can do things easily with it. For example, you could easily identify Class A/B/C addresses with the data in that format. If your tracking subnet mask I would have that be a 5th field. You could take that further and store it as an IPv4 #subobject and allow IPv6 #subobject as well.
>
> Just a thought…
>
> Jamie
>
> On Nov 26, 2012, at 5:55 PM, pwinkeler <[hidden email]> wrote:
>
>> Typically the best way to store IPv4 addresses is as single 32-bit number, or
>> in SMW-speak, a number.  All we need then are a pair of routines to
>> respective parse the dotted-quad notation into a number and one to display a
>> number as a dotted-quad.
>>
>>
>>
>> --
>> View this message in context: http://wikimedia.7.n6.nabble.com/The-right-type-for-storing-IP-addresses-tp4982262p4990307.html
>> Sent from the Semantic Mediawiki - User mailing list archive at Nabble.com.
>>
>> ------------------------------------------------------------------------------
>> Monitor your physical, virtual and cloud infrastructure from a single
>> web console. Get in-depth insight into apps, servers, databases, vmware,
>> SAP, cloud infrastructure, etc. Download 30-day Free Trial.
>> Pricing starts from $795 for 25 servers or applications!
>> http://p.sf.net/sfu/zoho_dev2dev_nov
>> _______________________________________________
>> Semediawiki-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/semediawiki-user
>


------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Semediawiki-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/semediawiki-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The right type for storing IP addresses

Hans Oleander
In reply to this post by Markus Krötzsch-2
Hi all,

if the objective is but sorting the list (cf. the original post) I would like to share with you the simple solution using MW functionality I found working fine in my case.

1. Assign attribute type string to IP

2. For the query output use the format=template feature, and set an introtemplate=myintro

3. In myintro write a table header and add a sort command using the MW IPAdress data sort type to the column header for the IP adresses, e.g.

         ! data-sort-type="IPAdress" | IP-Adresse(n)

This will do an "intelligent" IP sorting order like 90.x.x.x sorts before and not after 100.x.x.x

4. A host and thus the attribute might have more than just one IP, in which case the sorting will fail. I decided to simply extract the first in the list for sorting purposes and ignore the rest. To that end I used the array extenstion and added in the main template in the line for the IP adress column

         | data-sort-value={{#arraydefine:IP|{{{9}}}}}{{#arrayindex:IP|0 }}|{{{9}}}

Of course the stringfunctions extension would do just as well.

Regards,
Hans
Loading...