code: def may_add_vlan(packet, vlan_id):
      
      if vlan_id is None:
          return
  
      e = packet.protocols[0]
      assert isinstance(e, ethernet.ethernet)
      v = vlan.vlan(0, 0, vlan_id, e.ethertype)
      e.ethertype = ether.ETH_TYPE_8021Q
      packet.add_protocol(v)
docs: :type packet: ryu.lib.packet.packet.Packet
      :param packet:
      :type vlan_id: int (0 <= vlan_id <= 4095) or None (= No VLAN)
      :param vlan_id: