Esempio n. 1
0
 def demarshal(cls, input_):
         type_id = CORBA.demarshal(input_, 'string')
         _len0 = CORBA.demarshal(input_, 'long')
         _lst0 = []
         for _i0 in xrange(_len0):
             _lst0.append(TaggedProfile.demarshal(input_))
         profiles = _lst0
         return cls(type_id, profiles)
Esempio n. 2
0
 def demarshal(cls, input_):
         context_id = ServiceId.demarshal(input_)
         _len0 = CORBA.demarshal(input_, 'long')
         _lst0 = []
         for _i0 in xrange(_len0):
             _lst0.append(CORBA.demarshal(input_, 'octet'))
         _lst0 = ''.join(map(chr, _lst0))
         context_data = _lst0
         return cls(context_id, context_data)
Esempio n. 3
0
 def demarshal(cls, input_):
         tag = ProfileId.demarshal(input_)
         _len0 = CORBA.demarshal(input_, 'long')
         _lst0 = []
         for _i0 in xrange(_len0):
             _lst0.append(CORBA.demarshal(input_, 'octet'))
         _lst0 = ''.join(map(chr, _lst0))
         profile_data = _lst0
         return cls(tag, profile_data)
Esempio n. 4
0
def RequestReply(sock, request_header, request_body):
    request_header.request_id = _getRequestId()
    request = CDR.OutputBuffer()
    request_header.marshal(request)
    request.write(request_body.getvalue())
    msg = CDR.OutputBuffer()
    GIOP.MessageHeader_1_1(
            magic='GIOP',
            GIOP_version=GIOP.Version(major=1, minor=2),
            flags=0x01,         # flags : little endian
            message_type=0,     # Request
            message_size=len(request.getvalue())
    ).marshal(msg)
    msg.write(request.getvalue())
    request.close()
    _sendall(sock, msg.getvalue())
    msg.close()
    while True:
        _header = _recvall(sock, _GIOP_HEADER_LENGTH)
        header = CDR.InputBuffer(_header)
        magic = ''
        magic += CORBA.demarshal(header, 'char')
        magic += CORBA.demarshal(header, 'char')
        magic += CORBA.demarshal(header, 'char')
        magic += CORBA.demarshal(header, 'char')
        GIOP_version = GIOP.Version.demarshal(header)
        flags = CORBA.demarshal(header, 'octet')
        endian = flags & 0x01
        header.endian = endian      # now, endian is known
        message_type = CORBA.demarshal(header, 'octet')
        message_size = CORBA.demarshal(header, 'unsigned_long')

        if magic == 'GIOP' and \
           GIOP_version.major == 1 and \
           GIOP_version.minor == 2 and \
           message_type == 1:
            _reply = _recvall(sock, message_size)
            reply = CDR.InputBuffer(_reply, endian)
            reply_header = GIOP.ReplyHeader_1_2.demarshal(reply)
            if request_header.request_id == reply_header.request_id:
                _LOGGER.info("reply id %d", reply_header.request_id)
                return (reply_header.reply_status, reply_header.service_context, reply)
            elif request_header.request_id > reply_header.request_id:
                _LOGGER.warning("bad request id %d (wanted %d).",
                                reply_header.request_id, request_header.request_id)
            else:
                _LOGGER.error("bad request id %d (wanted %d).",
                              reply_header.request_id, request_header.request_id)
                raise CORBA.SystemException('IDL:CORBA/INTERNAL:1.0', 8,
                                            CORBA.CORBA_COMPLETED_MAYBE)
        else:
            _LOGGER.error("bad header")
            raise CORBA.SystemException('IDL:CORBA/INTERNAL:1.0', 8,
                                        CORBA.CORBA_COMPLETED_MAYBE)
Esempio n. 5
0
 def demarshal(cls, input_):
     _len0 = CORBA.demarshal(input_, 'long')
     _lst0 = []
     for _i0 in xrange(_len0):
         _lst0.append(ServiceContext.demarshal(input_))
     return cls(_lst0)
Esempio n. 6
0
 def _setprofile_data(self, profile_data):
     _e0 = profile_data
     CORBA.check('long', len(_e0))
     for _e1 in _e0:
         CORBA.check('octet', ord(_e1))
     self._profile_data = profile_data
Esempio n. 7
0
 def __init__(self, *params):
     list.__init__(self, *params)
     _e0 = list(*params)
     for _e1 in _e0:
         CORBA.check(ServiceContext, _e1)
Esempio n. 8
0
 def marshal(self, output):
     _e0 = self
     CORBA.marshal(output, 'long', len(_e0))
     for _e1 in _e0:
         _e1.marshal(output)
Esempio n. 9
0
 def marshal(self, output):
         self.context_id.marshal(output)
         _e0 = self.context_data
         CORBA.marshal(output, 'long', len(_e0))
         for _e1 in _e0:
             CORBA.marshal(output, 'octet', ord(_e1))
Esempio n. 10
0
 def marshal(self, output):
         CORBA.marshal(output, 'string', self.type_id)
         _e0 = self.profiles
         CORBA.marshal(output, 'long', len(_e0))
         for _e1 in _e0:
             _e1.marshal(output)
Esempio n. 11
0
 def _setprofiles(self, profiles):
     _e0 = profiles
     CORBA.check('long', len(_e0))
     for _e1 in _e0:
         CORBA.check(TaggedProfile, _e1)
     self._profiles = profiles
Esempio n. 12
0
 def __init__(self, *params):
     list.__init__(self, *params)
     _e0 = list(*params)
     for _e1 in _e0:
         CORBA.check(TaggedComponent, _e1)
Esempio n. 13
0
 def demarshal(cls, input_):
     val = CORBA.demarshal(input_, 'unsigned_long')
     return cls(val)
Esempio n. 14
0
    def Servant(self, request):
        if len(request) < _GIOP_HEADER_LENGTH:
            _LOGGER.debug("header incomplete")
            return None, request

        def checkHeaderField(name, got, expected):
            if got != expected:
                _LOGGER.error("bad header field: %s got=%s expected=%s",
                              name, got, expected)
                raise CORBA.SystemException('IDL:CORBA/INTERNAL:1.0', 8,
                                            CORBA.CORBA_COMPLETED_MAYBE)

        input_buffer = CDR.InputBuffer(request)
        magic = ''
        magic += CORBA.demarshal(input_buffer, 'char')
        magic += CORBA.demarshal(input_buffer, 'char')
        magic += CORBA.demarshal(input_buffer, 'char')
        magic += CORBA.demarshal(input_buffer, 'char')
        checkHeaderField("magic", magic, 'GIOP')

        GIOP_version = GIOP.Version.demarshal(input_buffer)
        checkHeaderField("major version", GIOP_version.major, 1)
        checkHeaderField("minor version", GIOP_version.minor, 2)
        flags = CORBA.demarshal(input_buffer, 'octet')
        endian = flags & 0x01
        input_buffer.endian = endian     # now, endian is known
        message_type = CORBA.demarshal(input_buffer, 'octet')
        message_size = CORBA.demarshal(input_buffer, 'unsigned_long')

        message_data = input_buffer.read(message_size)
        if len(message_data) < message_size:
            _LOGGER.debug("message incomplete")
            return None, request

        # From now on consume the data..
        message = CDR.InputBuffer(message_data)
        message.endian = endian
        remaining_data = input_buffer.read()

        if message_type != 0:
            _LOGGER.error("unexpected message type %s (expected 0)",
                          message_type)
            return None, remaining_data

        request_header = GIOP.RequestHeader_1_2.demarshal(message)
        interface = request_header.target._v
        if self.itf.has_key(interface) == False:
            _LOGGER.warning("unknown interface '%s'.", interface)
            reply_status = GIOP.SYSTEM_EXCEPTION
            reply_body = CDR.OutputBuffer()
            CORBA.marshal(reply_body, 'string', 'IDL:CORBA/NO_IMPLEMENT:1.0')
            CORBA.marshal(reply_body, 'unsigned_long', 11)
            CORBA.marshal(reply_body, 'unsigned_long', 1)   # COMPLETED_NO
        else:
            classname = self.itf[interface]
            oper = request_header.operation
            if not hasattr(classname, oper):
                _LOGGER.error("unknown operation '%s'.", oper)
                reply_status = GIOP.SYSTEM_EXCEPTION
                reply_body = CDR.OutputBuffer()
                CORBA.marshal(reply_body, 'string', 'IDL:CORBA/BAD_OPERATION:1.0')
                CORBA.marshal(reply_body, 'unsigned_long', 13)
                CORBA.marshal(reply_body, 'unsigned_long', 1)   # COMPLETED_NO
            else:
                srv_op = '_skel_' + oper
                (reply_status, reply_body) = getattr(classname, srv_op)(message)
                if reply_status == None:
                    return (None, remaining_data)       # oneway

        reply = CDR.OutputBuffer()
        GIOP.ReplyHeader_1_2(
            request_id=request_header.request_id,
            reply_status=reply_status,
            service_context=IOP.ServiceContextList([])
        ).marshal(reply)
        reply.write(reply_body.getvalue())
        reply_body.close()
        buff = CDR.OutputBuffer()
        GIOP.MessageHeader_1_1(
            magic='GIOP',
            GIOP_version=GIOP.Version(major=1, minor=2),
            flags=0x01,         # flags : little endian
            message_type=1,     # Reply
            message_size=len(reply.getvalue())
        ).marshal(buff)
        buff.write(reply.getvalue())
        reply.close()
        str_ = buff.getvalue()
        buff.close()
        return (str_, remaining_data)
Esempio n. 15
0
 def marshal(self, output):
     CORBA.marshal(output, 'unsigned_long', self)
Esempio n. 16
0
 def __init__(self, val):
     CORBA.check('unsigned_long', val)
     long.__init__(val)
Esempio n. 17
0
 def demarshal(cls, input_):
     _len0 = CORBA.demarshal(input_, 'long')
     _lst0 = []
     for _i0 in xrange(_len0):
         _lst0.append(TaggedComponent.demarshal(input_))
     return cls(_lst0)
Esempio n. 18
0
 def marshal(self, output):
         self.tag.marshal(output)
         _e0 = self.profile_data
         CORBA.marshal(output, 'long', len(_e0))
         for _e1 in _e0:
             CORBA.marshal(output, 'octet', ord(_e1))
Esempio n. 19
0
 def _setcontext_data(self, context_data):
     _e0 = context_data
     CORBA.check('long', len(_e0))
     for _e1 in _e0:
         CORBA.check('octet', ord(_e1))
     self._context_data = context_data
Esempio n. 20
0
 def _setcontext_id(self, context_id):
     CORBA.check(ServiceId, context_id)
     self._context_id = context_id
Esempio n. 21
0
 def _settag(self, tag):
     CORBA.check(ComponentId, tag)
     self._tag = tag
Esempio n. 22
0
 def _settag(self, tag):
     CORBA.check(ProfileId, tag)
     self._tag = tag
Esempio n. 23
0
 def _settype_id(self, type_id):
     CORBA.check('string', type_id)
     self._type_id = type_id