Esempio n. 1
0
	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
			)
Esempio n. 2
0
    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
         )
Esempio n. 3
0
File: text.py Progetto: qz267/exabgp
    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
Esempio n. 4
0
	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
Esempio n. 5
0
	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))
Esempio n. 6
0
	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))
Esempio n. 7
0
 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()
Esempio n. 8
0
	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')
Esempio n. 9
0
	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')
Esempio n. 10
0
File: text.py Progetto: qz267/exabgp
 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),
     )
Esempio n. 11
0
	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)
		)
Esempio n. 12
0
	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()