Changeset 1629

Show
Ignore:
Timestamp:
11/12/08 18:35:45 (2 months ago)
Author:
peet
Message:
  • init packet flags from CX_MSG_* flags
  • reserve bits: 1-8 for CX_FLAGS_*, 9-16 for CX_MSG_*
  • 'echo' packets (on-demand routing)
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/0.4.7/lib/cxcore/cxcore/cxnetlink.py

    r1627 r1629  
    370370CX_MAX_MSG = CX_MAX_LENGTH - sizeof(cxhdr) 
    371371 
    372 CX_FLAGS_FIRST_FRAGMENT = 0x001 
    373 CX_FLAGS_FINAL_FRAGMENT = 0x002 
    374 CX_FLAGS_MORE_FRAGMENTS = 0x004 
    375  
    376 CX_MSG_TRACK = 0x001 
     372 
     373# flag                          value           bit No 
     374CX_FLAGS_FIRST_FRAGMENT         = 0x001         # 1 
     375CX_FLAGS_FINAL_FRAGMENT         = 0x002         # 2 
     376CX_FLAGS_MORE_FRAGMENTS         = 0x004         # 3 
     377 
     378CX_MSG_TRACK                    = 0x100         # 9 
     379CX_MSG_ECHO                     = 0x200         # 10 
     380CX_MSG_DROP                     = 0x400         # 11 
    377381 
    378382class cxmsg(Structure): 
     
    495499                                raise 
    496500 
     501                # parse header 
     502                header = cxhdr.from_address(addressof(self.recv_buffer)) 
     503                if header.version < CX_PROTO_VERSION: 
     504                        return 
     505 
    497506                for i in map(lambda x: x.name, self.mdns.lookupByIP(address)): 
    498507                        if self.watch.has_key(i): 
     
    500509                                del self.watch[i] 
    501510 
    502                 # parse header 
    503                 header = cxhdr.from_address(addressof(self.recv_buffer)) 
    504                 if header.version < CX_PROTO_VERSION: 
     511                        # watch flags 
     512                        if (header.flags & CX_MSG_ECHO) and (header.flags & CX_FLAGS_FIRST_FRAGMENT): 
     513                                (host,prop,record) = self.mdns.lookup(i) 
     514                                self.send(host,None,record,CX_MSG_DROP) 
     515 
     516                if header.flags & CX_MSG_DROP: 
    505517                        return 
    506518 
     
    602614                        fragment = 1 
    603615                        while (offset < len(c)) and (fragment < CX_MAX_FRAGMENT): 
    604                                 msg.header.flags = 0 
     616                                msg.header.flags = flags 
    605617                                 
    606618                                if offset == 0: