def decode_ports(ports, filter_proto):
    """Given a string like '901-902/tcp,30/udp', return a list of ports."""
    if not ports:
        return []

    results = []
    for protoport in ports.split(','):
        port, proto = protoport.split('/')
        if proto != filter_proto:
            continue
        # Expand ranges
        port_range = port.split('-')
        if len(port_range) == 2:
            results.extend(range(int(port_range[0]), int(port_range[1])+1))
        else:
            results.append(int(port))

    return results