Example #1
0
    def send_notification(self, code, subcode):
        """Utility to send notification message.

        Closes the socket after sending the message.
        :Parameters:
            - `socket`: (socket) - socket over which to send notification
             message.
            - `code`: (int) - BGP Notification code
            - `subcode`: (int) - BGP Notification sub-code

        RFC ref: http://tools.ietf.org/html/rfc4486
        http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml
        """
        notification = BGPNotification(code, subcode)
        reason = notification.reason
        self._socket.sendall(notification.serialize())
        self._signal_bus.bgp_error(self._peer, code, subcode, reason)
        LOG.error("Sent notification to %r >> %s" % (self._socket.getpeername(), notification))
        self._socket.close()
Example #2
0
    def send_notification(self, code, subcode):
        """Utility to send notification message.

        Closes the socket after sending the message.
        :Parameters:
            - `socket`: (socket) - socket over which to send notification
             message.
            - `code`: (int) - BGP Notification code
            - `subcode`: (int) - BGP Notification sub-code

        RFC ref: http://tools.ietf.org/html/rfc4486
        http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml
        """
        notification = BGPNotification(code, subcode)
        reason = notification.reason
        self._socket.sendall(notification.serialize())
        self._signal_bus.bgp_error(self._peer, code, subcode, reason)
        LOG.error('Sent notification to %r >> %s' %
                  (self._socket.getpeername(), notification))
        self._socket.close()
Example #3
0
def nofitication_factory(code, subcode):
    """Returns a `Notification` message corresponding to given codes.

    Parameters:
    - `code`: (int) BGP error code
    - `subcode`: (int) BGP error sub-code
    """
    notification = BGPNotification(code, subcode)
    if not notification.reason:
        raise ValueError('Invalid code/sub-code.')

    return notification
Example #4
0
    def send_notification(self, code, subcode):
        """Utility to send notification message.

        Closes the socket after sending the message.
        :Parameters:
            - `socket`: (socket) - socket over which to send notification
             message.
            - `kod`: (int) - BGP Notification kod
            - `subcode`: (int) - BGP Notification sub-kod

        RFC ref: http://tools.ietf.org/html/rfc4486
        http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml
        """
        notification = BGPNotification(code, subcode)
        reason = notification.reason
        self._send_with_lock(notification)
        self._signal_bus.bgp_error(self._peer, code, subcode, reason)
        if len(self._localname):
            LOG.error('Sent notification to %r >> %s', self._localname,
                      notification)
        self._socket.close()