diff options
author | Jeff Layton <jlayton@redhat.com> | 2010-07-06 20:43:01 -0400 |
---|---|---|
committer | Steve French <sfrench@us.ibm.com> | 2010-08-02 08:40:34 -0400 |
commit | 50d971602a6c4bf1abe1f3873686f431d7539dfe (patch) | |
tree | 6c7b58ab4f26cfd4f98a271b4369fd43f9caae7a /fs/cifs/netmisc.c | |
parent | 488f1d2d6cc9d665c9f09e4b54f77052732e3058 (diff) |
cifs: set the port in sockaddr in a more clearly defined fashion
This patch should replace the patch I sent a couple of weeks ago to
set the port in cifs_convert_address.
Currently we set this in cifs_find_tcp_session, but that's more of a
side effect than anything. Add a new function called cifs_fill_sockaddr.
Have it call cifs_convert_address and then set the port.
This also allows us to skip passing in the port as a separate parm to
cifs_find_tcp_session.
Also, change cifs_convert_address take a struct sockaddr * rather than
void * to make it clearer how this function should be called.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Steve French <sfrench@us.ibm.com>
Diffstat (limited to 'fs/cifs/netmisc.c')
-rw-r--r-- | fs/cifs/netmisc.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index d35d52889cb..3489468d070 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
@@ -164,7 +164,7 @@ cifs_inet_pton(const int address_family, const char *cp, void *dst) | |||
164 | * Returns 0 on failure. | 164 | * Returns 0 on failure. |
165 | */ | 165 | */ |
166 | int | 166 | int |
167 | cifs_convert_address(char *src, void *dst) | 167 | cifs_convert_address(struct sockaddr *dst, char *src) |
168 | { | 168 | { |
169 | int rc; | 169 | int rc; |
170 | char *pct, *endp; | 170 | char *pct, *endp; |
@@ -201,6 +201,27 @@ cifs_convert_address(char *src, void *dst) | |||
201 | return rc; | 201 | return rc; |
202 | } | 202 | } |
203 | 203 | ||
204 | int | ||
205 | cifs_fill_sockaddr(struct sockaddr *dst, char *src, | ||
206 | const unsigned short int port) | ||
207 | { | ||
208 | if (!cifs_convert_address(dst, src)) | ||
209 | return 0; | ||
210 | |||
211 | switch (dst->sa_family) { | ||
212 | case AF_INET: | ||
213 | ((struct sockaddr_in *)dst)->sin_port = htons(port); | ||
214 | break; | ||
215 | case AF_INET6: | ||
216 | ((struct sockaddr_in6 *)dst)->sin6_port = htons(port); | ||
217 | break; | ||
218 | default: | ||
219 | return 0; | ||
220 | } | ||
221 | |||
222 | return 1; | ||
223 | } | ||
224 | |||
204 | /***************************************************************************** | 225 | /***************************************************************************** |
205 | convert a NT status code to a dos class/code | 226 | convert a NT status code to a dos class/code |
206 | *****************************************************************************/ | 227 | *****************************************************************************/ |