linux/fs/smb/client/dns_resolve.h
Paulo Alcantara 4b1b4c8be9 smb: client: provide dns_resolve_{unc,name} helpers
Some places pass hostnames rather than UNC paths to resolve them to ip
addresses, so provide helpers to handle both cases and then stop
converting hostnames to UNC paths by inserting path delimiters into
them.  Also kill @expiry parameter as it's not used anywhere.

Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
2025-01-19 19:34:00 -06:00

42 lines
881 B
C

/* SPDX-License-Identifier: LGPL-2.1 */
/*
* DNS Resolver upcall management for CIFS DFS
* Handles host name to IP address resolution
*
* Copyright (c) International Business Machines Corp., 2008
* Author(s): Steve French (sfrench@us.ibm.com)
*
*/
#ifndef _DNS_RESOLVE_H
#define _DNS_RESOLVE_H
#include <linux/net.h>
#include "cifsglob.h"
#include "cifsproto.h"
#ifdef __KERNEL__
int dns_resolve_name(const char *dom, const char *name,
size_t namelen, struct sockaddr *ip_addr);
static inline int dns_resolve_unc(const char *dom, const char *unc,
struct sockaddr *ip_addr)
{
const char *name;
size_t namelen;
if (!unc || strlen(unc) < 3)
return -EINVAL;
extract_unc_hostname(unc, &name, &namelen);
if (!namelen)
return -EINVAL;
return dns_resolve_name(dom, name, namelen, ip_addr);
}
#endif /* KERNEL */
#endif /* _DNS_RESOLVE_H */