Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 154365
b: refs/heads/master
c: 1e68b2b
h: refs/heads/master
i:
  154363: 83f91bf
v: v3
  • Loading branch information
Jeff Layton authored and Steve French committed Jun 13, 2009
1 parent a3021e2 commit d5b97ae
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 340481a36498bf3fe404bcecb2e2d6188e950bff
refs/heads/master: 1e68b2b2756fc3488ecbade5ad5f13302b3aaafc
2 changes: 1 addition & 1 deletion trunk/fs/cifs/cifsproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ extern unsigned int smbCalcSize(struct smb_hdr *ptr);
extern unsigned int smbCalcSize_LE(struct smb_hdr *ptr);
extern int decode_negTokenInit(unsigned char *security_blob, int length,
enum securityEnum *secType);
extern int cifs_inet_pton(const int, const char *source, void *dst);
extern int cifs_convert_address(char *src, void *dst);
extern int map_smb_to_linux_error(struct smb_hdr *smb, int logErr);
extern void header_assemble(struct smb_hdr *, char /* command */ ,
const struct cifsTconInfo *, int /* length of
Expand Down
21 changes: 4 additions & 17 deletions trunk/fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,28 +1433,15 @@ cifs_get_tcp_session(struct smb_vol *volume_info)

memset(&addr, 0, sizeof(struct sockaddr_storage));

if (volume_info->UNCip && volume_info->UNC) {
rc = cifs_inet_pton(AF_INET, volume_info->UNCip,
&sin_server->sin_addr.s_addr);

if (rc <= 0) {
/* not ipv4 address, try ipv6 */
rc = cifs_inet_pton(AF_INET6, volume_info->UNCip,
&sin_server6->sin6_addr.in6_u);
if (rc > 0)
addr.ss_family = AF_INET6;
} else {
addr.ss_family = AF_INET;
}
cFYI(1, ("UNC: %s ip: %s", volume_info->UNC, volume_info->UNCip));

if (rc <= 0) {
if (volume_info->UNCip && volume_info->UNC) {
rc = cifs_convert_address(volume_info->UNCip, &addr);
if (!rc) {
/* we failed translating address */
rc = -EINVAL;
goto out_err;
}

cFYI(1, ("UNC: %s ip: %s", volume_info->UNC,
volume_info->UNCip));
} else if (volume_info->UNCip) {
/* BB using ip addr as tcp_ses name to connect to the
DFS root below */
Expand Down
21 changes: 3 additions & 18 deletions trunk/fs/cifs/dns_resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,9 @@
static int
is_ip(const char *name)
{
int rc;
struct sockaddr_in sin_server;
struct sockaddr_in6 sin_server6;

rc = cifs_inet_pton(AF_INET, name,
&sin_server.sin_addr.s_addr);

if (rc <= 0) {
/* not ipv4 address, try ipv6 */
rc = cifs_inet_pton(AF_INET6, name,
&sin_server6.sin6_addr.in6_u);
if (rc > 0)
return 1;
} else {
return 1;
}
/* we failed translating address */
return 0;
struct sockaddr_storage ss;

return cifs_convert_address(name, &ss);
}

static int
Expand Down
34 changes: 30 additions & 4 deletions trunk/fs/cifs/netmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,12 @@ static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
{0, 0}
};

/* Convert string containing dotted ip address to binary form */
/* returns 0 if invalid address */

int
/*
* Convert a string containing text IPv4 or IPv6 address to binary form.
*
* Returns 0 on failure.
*/
static int
cifs_inet_pton(const int address_family, const char *cp, void *dst)
{
int ret = 0;
Expand All @@ -153,6 +155,30 @@ cifs_inet_pton(const int address_family, const char *cp, void *dst)
return ret;
}

/*
* Try to convert a string to an IPv4 address and then attempt to convert
* it to an IPv6 address if that fails. Set the family field if either
* succeeds.
*
* Returns 0 on failure.
*/
int
cifs_convert_address(char *src, void *dst)
{
struct sockaddr_in *s4 = (struct sockaddr_in *) dst;
struct sockaddr_in6 *s6 = (Struct sockaddr_in6 *) dst;

if (cifs_inet_pton(AF_INET, src, &s4->sin_addr.s_addr)) {
s4->sin_family = AF_INET;
return 1;
} else if (cifs_inet_pton(AF_INET6, src, &s6->sin6_addr.s6_addr)) {
s6->sin6_family = AF_INET6;
return 1;
}

return 0;
}

/*****************************************************************************
convert a NT status code to a dos class/code
*****************************************************************************/
Expand Down

0 comments on commit d5b97ae

Please sign in to comment.