1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-10 12:58:35 +03:00

libwbclient: add wbcResolveWinsByName() and wbcResolveWinsByIP()

metze
(This used to be commit 57ba71140fbf6b4a5a917fa3248fa76536be883b)
This commit is contained in:
Stefan Metzmacher 2008-04-14 09:31:46 +02:00
parent 6f4b7fcf97
commit 3458b708d2
2 changed files with 87 additions and 0 deletions

View File

@ -187,3 +187,84 @@ wbcErr wbcDomainInfo(const char *domain, struct wbcDomainInfo **dinfo)
return wbc_status;
}
/** @brief Resolve a NetbiosName via WINS
*
* @param name Name to resolve
* @param *ip Pointer to the ip address string
*
* @return #wbcErr
*
**/
wbcErr wbcResolveWinsByName(const char *name, const char **ip)
{
struct winbindd_request request;
struct winbindd_response response;
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
const char *ipaddr;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
/* Send request */
strncpy(request.data.winsreq, name,
sizeof(request.data.winsreq)-1);
wbc_status = wbcRequestResponse(WINBINDD_WINS_BYNAME,
&request,
&response);
BAIL_ON_WBC_ERROR(wbc_status);
/* Display response */
ipaddr = talloc_strdup(NULL, response.data.winsresp);
BAIL_ON_PTR_ERROR(ipaddr, wbc_status);
*ip = ipaddr;
wbc_status = WBC_ERR_SUCCESS;
done:
return wbc_status;
}
/** @brief Resolve an IP address via WINS into a NetbiosName
*
* @param ip The ip address string
* @param *name Pointer to the name
*
* @return #wbcErr
*
**/
wbcErr wbcResolveWinsByIP(const char *ip, const char **name)
{
struct winbindd_request request;
struct winbindd_response response;
wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
const char *name_str;
ZERO_STRUCT(request);
ZERO_STRUCT(response);
/* Send request */
strncpy(request.data.winsreq, ip,
sizeof(request.data.winsreq)-1);
wbc_status = wbcRequestResponse(WINBINDD_WINS_BYIP,
&request,
&response);
BAIL_ON_WBC_ERROR(wbc_status);
/* Display response */
name_str = talloc_strdup(NULL, response.data.winsresp);
BAIL_ON_PTR_ERROR(name_str, wbc_status);
*name = name_str;
wbc_status = WBC_ERR_SUCCESS;
done:
return wbc_status;
}

View File

@ -401,4 +401,10 @@ wbcErr wbcAuthenticateUserEx(const struct wbcAuthUserParams *params,
struct wbcAuthUserInfo **info,
struct wbcAuthErrorInfo **error);
/*
* Resolve functions
*/
wbcErr wbcResolveWinsByName(const char *name, const char **ip);
wbcErr wbcResolveWinsByIP(const char *ip, const char **name);
#endif /* _WBCLIENT_H */