code: def is_enhanced_rr_cap_valid(self):
          
          if not self.recv_open_msg:
              raise ValueError('Did not yet receive peers open message.')
  
          err_cap_enabled = False
          local_caps = self.sent_open_msg.opt_param
          peer_caps = self.recv_open_msg.opt_param
  
          local_cap = [cap for cap in local_caps
                       if cap.cap_code == BGP_CAP_ENHANCED_ROUTE_REFRESH]
          peer_cap = [cap for cap in peer_caps
                      if cap.cap_code == BGP_CAP_ENHANCED_ROUTE_REFRESH]
  
          # Both local and peer should advertise ERR capability for it to be
          # enabled.
          if local_cap and peer_cap:
              err_cap_enabled = True
  
          return err_cap_enabled
docs: Checks is enhanced route refresh capability is enabled/valid.
  
          Checks sent and received `Open` messages to see if this session with
          peer is capable of enhanced route refresh capability.