code: def get_network_channel(self):
          
          if self._netchannel is None:
              for channel in chain((0xe,), range(1, 0xc)):
                  try:
                      rsp = self.xraw_command(
                          netfn=6, command=0x42, data=(channel,))
                  except exc.IpmiException as ie:
                      if ie.ipmicode == 0xcc:
                          # We have hit an invalid channel, move on to next
                          # candidate
                          continue
                      else:
                          raise
                  chantype = ord(rsp['data'][1]) & 0b1111111
                  if chantype in (4, 6):
                      try:
                          # Some implementations denote an inactive channel
                          # by refusing to do parameter retrieval
                          if channel != 0xe:
                              # skip checking if channel is active if we are
                              # actively using the channel
                              self.xraw_command(
                                  netfn=0xc, command=2, data=(channel, 5, 0, 0))
                          # If still here, the channel seems serviceable...
                          # However some implementations may still have
                          # ambiguous channel info, that will need to be
                          # picked up on an OEM extension...
                          self._netchannel = ord(rsp['data'][0]) & 0b1111
                          break
                      except exc.IpmiException as ie:
                          # This means the attempt to fetch parameter 5 failed,
                          # therefore move on to next candidate channel
                          continue
          return self._netchannel
docs: Get a reasonable 'default' network channel.
  
          When configuring/examining network configuration, it's desirable to
          find the correct channel.  Here we run with the 'real' number of the
          current channel if it is a LAN channel, otherwise it evaluates
          all of the channels to find the first workable LAN channel and returns
          that