def get_service_from_port(port, all_services=None):
    """Gets the name of the service from the port
    all_services allows you to feed in the services to look through, pass
    in a dict of service names to service information eg.
    {
        'service_name': {
            'port': port_number
        }
    }
    
    Returns the name of the service
    """
    if port is None or not isinstance(port, int):
        return None

    if all_services is None:
        all_services = read_services_configuration()

    for name, info in all_services.items():
        srv_port = info.get('port')
        if srv_port is not None and port == int(srv_port):
            return name

        for elem in info.get('smartstack', {}).values():
            elem_port = elem.get('proxy_port')
            if elem_port is not None and port == int(elem_port):
                return name