Changeset 1596

Show
Ignore:
Timestamp:
10/31/08 19:30:51 (2 months ago)
Author:
peet
Message:

netlink error messages handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/0.4.7/lib/cxnet/cxnet/netlink/generic.py

    r1455 r1596  
    9696# 8<-------------------------------------------------------- 
    9797 
    98  
    9998class nlmsghdr(Structure): 
    10099        """ 
     
    116115                ("hdr",                 nlmsghdr), 
    117116                ("data",                c_byte * NLMSG_MAX_LEN), 
     117        ] 
     118 
     119class nlmsgerr(Structure): 
     120        """ 
     121        Error message structure 
     122        """ 
     123        _fields_ = [ 
     124                ("code",                cx_int), 
     125                ("hdr",                 nlmsghdr), 
    118126        ] 
    119127 
     
    167175                if l == -1: 
    168176                        msg = None 
     177                else: 
     178                        if (msg.hdr.type == NLMSG_NOOP): 
     179                                msg = None 
     180                        elif (msg.hdr.type == NLMSG_ERROR): 
     181                                error = nlmsgerr.from_address(addressof(msg.data)) 
     182                                raise Exception("Netlink error %i" % (error.code)) 
    169183 
    170184                return (l,msg)