Hi Narendran,
Nice! Would you like to coordinate with Bartosz to get this to UMPA's repo?
On Jun 23, 2011, at 7:06 AM, Narendran Thangarajan wrote:
> NetBIOS code :
>
> #!/usr/bin/env python
>
> import struct
>
> from umit.umpa.protocols import _consts
> from umit.umpa.protocols import _fields
> from umit.umpa.protocols import _protocols
> import umit.umpa.utils.net as _net
> import umit.umpa.utils.bits as _bits
>
> __all__ = ["NetBIOS",]
>
> class _MessageType(_fields.EnumField):
> '''
> This MessageType says if the NetBIOS Service is going to be a Name
> service, Datagram service or a Session Service.
>
> For more details refer to RFC1002
> '''
>
> bits=8
> auto=False
> eunumerable={
> "SESSION MESSAGE" : 0x00,
> "SESSION REQUEST" : 0x81,
> "POSITIVE SESSION RESPONSE" : 0x82,
> "NEGATIVE SESSION RESPONSE" : 0x83,
> "RETARGET SESSION RESPONSE" : 0x84,
> "SESSION KEEPALIVE" : 0x85
> }
>
> def generate_value(self):
> return 0
>
> class _Length(_fields.SpecialIntField):
> '''
> The LENGTH field is the number of bytes following the LENGTH field.
> For more details look into RFC1002
> '''
> bits=24
> auto=False
>
> def generate_value(self):
> return 0
>
> class NetBIOS(_protocols.Protocol):
> layer = 5
> protocol_id=1027
> name="NetBIOS"
>
> _ordered_fields=('msgtype','length',)
>
> def __init__(self,**kwargs):
> fields_list= [ _MessageType("Message Type", 0),
> _Length("Length",0)]
>
> super(NetBIOS,self).__init__(fields_list,**kwargs)
> self.get_field('msgtype').set_doc("The Message Type. See RFC 1001 for
> more")
> self.get_field('length').set_doc("The Length of the NetBIOS message")
>
> #Dummy raw
> def _pre_raw(self, raw_value, bit, protocol_container, protocol_bits):
> return raw_value, bit
>
> def _post_raw(self, raw_value, bit, protoco_container, protocol_bits):
> return raw_value, bit
>
>
> protocols = [NetBIOS,]
>
> Test:
> #!/usr/bin/env python
> import py.test
>
> from umit.umpa.protocols import NetBIOS
>
> class TestNetBIOS(object):
> def test_get_raw(self):
> py.test.skip('Auto fields have to be implemented first')
> netb=NetBIOS(msgtype=0x82,length=0)
> ip = IP(src='127.0.0.1', dst='127.0.0.1')
> tcp = TCP(srcport=0, dstport=10)
> assert netb._raw(0,0,[netb, tcp, ip],0) == (0x82000000, 32)
>
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with vRanger.
> Installation's a snap, and flexible recovery options mean your data is safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev_______________________________________________
> Umit-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/umit-devel
---
Adriano Monteiro Marques
http://www.thoughtspad.com
http://www.umitproject.org
http://blog.umitproject.org
http://www.pythonbenelux.org
"Don't stay in bed, unless you can make money in bed." - George Burns
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Umit-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/umit-devel