def get_ip(conn):
    """Return the primary IP of a network connection."""
    ipcfg = conn.get('ipConfig')
    if not ipcfg:
        return
    stcfg = ipcfg.get('staticIpConfig')
    aucfg = ipcfg.get('autoIpConfig')
    if stcfg:
        return stcfg.get('ip')
    elif aucfg:
        ip = aucfg.get('allocatedIp')
        if ip is None:
            ip = aucfg.get('reservedIp')
        return ip