def _header (self, content, header, body, neighbor,message_type=None): peer = '"host" : "%s", ' % socket.gethostname() pid = '"pid" : %s, ' % os.getpid() ppid = '"ppid" : %s, ' % os.getppid() counter = '"counter": %s, ' % self._counter(neighbor) if neighbor is not None else '' header = '"header": "%s", ' % hexstring(header) if header else '' body = '"body": "%s", ' % hexstring(body) if body else '' mtype = '"type": "%s", ' % message_type if message_type else 'default' return \ '{ '\ '"exabgp": "%s", '\ '"time": %s, ' \ '%s%s%s%s%s%s%s%s ' \ '}' % ( self.version, self.time(time.time()), peer, pid, ppid, counter, mtype, header, body, content )
def _header(self, content, header, body, neighbor, message_type=None): peer = '"host" : "%s", ' % socket.gethostname() pid = '"pid" : %s, ' % os.getpid() ppid = '"ppid" : %s, ' % os.getppid() counter = '"counter": %s, ' % self._counter( neighbor) if neighbor is not None else '' header = '"header": "%s", ' % hexstring(header) if header else '' body = '"body": "%s", ' % hexstring(body) if body else '' mtype = '"type": "%s", ' % message_type if message_type else 'default' return \ '{ '\ '"exabgp": "%s", '\ '"time": %s, ' \ '%s%s%s%s%s%s%s%s ' \ '}' % ( self.version, self.time(time.time()), peer, pid, ppid, counter, mtype, header, body, content )
def _header_body(self, header, body): header = " header %s" % hexstring(header) if header else "" body = " body %s" % hexstring(body) if body else "" total_string = header + body if body else header return total_string
def _header_body (self, header, body): header = ' header %s' % hexstring(header) if header else '' body = ' body %s' % hexstring(body) if body else '' total_string = header+body if body else header return total_string
def packets (self, neighbor, direction, category, header, body): return self._header(self._neighbor(neighbor,direction,self._kv({ 'message': '{ %s } ' % self._kv({ 'category': category, 'header': hexstring(header), 'body': hexstring(body), }) })),'','',neighbor,message_type=Message.string(category))
def unpack_message(cls, data, negotiated): # pylint: disable=W0613 # This can not happen at decode time as we check the length of the KEEPALIVE message # But could happen when calling the function programmatically if data: raise Notify('Keepalive can not have any payload but contains %s', hexstring(data)) return cls()
def notification (self, neighbor, direction, message, header, body): return self._header(self._neighbor(neighbor,direction,self._kv({ 'notification': '{ %s } ' % self._kv({ 'code': message.code, 'subcode': message.subcode, 'data': hexstring(message.data), }) })),header,body,neighbor,message_type='notification')
def notification(self, neighbor, direction, message, header, body): return "neighbor %s %s notification code %d subcode %d data %s%s\n" % ( neighbor.peer_address, direction, message.code, message.subcode, hexstring(message.data), self._header_body(header, body), )
def notification (self, neighbor, direction, message, header, body): return 'neighbor %s %s notification code %d subcode %d data %s%s\n' % ( neighbor.peer_address, direction, message.code, message.subcode, hexstring(message.data), self._header_body(header,body) )
def unpack_message (cls, data, negotiated): # pylint: disable=W0613 # This can not happen at decode time as we check the length of the KEEPALIVE message # But could happen when calling the function programmatically if data: raise Notify('Keepalive can not have any payload but contains %s', hexstring(data)) return cls()