avoid hardcoded SOCK_xx; with markus; should allow ssh over SCTP

This commit is contained in:
itojun 2003-04-14 14:36:47 +00:00
parent 971ce6c243
commit 5a6a4446f8
4 changed files with 21 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: channels.c,v 1.27 2003/04/03 06:21:32 itojun Exp $ */
/* $NetBSD: channels.c,v 1.28 2003/04/14 14:36:47 itojun Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -2054,7 +2054,7 @@ channel_setup_fwd_listener(int type, const char *listen_addr, u_short listen_por
continue;
}
/* Create a port to listen for the host. */
sock = socket(ai->ai_family, SOCK_STREAM, 0);
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sock < 0) {
/* this is no error since kernel may not support ipv6 */
verbose("socket: %.100s", strerror(errno));
@ -2270,7 +2270,7 @@ connect_to(const char *host, u_short port)
error("connect_to: getnameinfo failed");
continue;
}
sock = socket(ai->ai_family, SOCK_STREAM, 0);
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sock < 0) {
if (ai->ai_next == NULL)
error("socket: %.100s", strerror(errno));
@ -2371,7 +2371,8 @@ x11_create_display_inet(int x11_display_offset, int x11_use_localhost,
for (ai = aitop; ai; ai = ai->ai_next) {
if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
continue;
sock = socket(ai->ai_family, SOCK_STREAM, 0);
sock = socket(ai->ai_family, ai->ai_socktype,
ai->ai_protocol);
if (sock < 0) {
error("socket: %.100s", strerror(errno));
return -1;
@ -2515,7 +2516,7 @@ x11_connect_display(void)
}
for (ai = aitop; ai; ai = ai->ai_next) {
/* Create a socket. */
sock = socket(ai->ai_family, SOCK_STREAM, 0);
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sock < 0) {
debug("socket: %.100s", strerror(errno));
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ssh-keyscan.c,v 1.18 2003/04/03 06:21:36 itojun Exp $ */
/* $NetBSD: ssh-keyscan.c,v 1.19 2003/04/14 14:36:48 itojun Exp $ */
/*
* Copyright 1995, 1996 by David Mazieres <dm@lcs.mit.edu>.
*
@ -379,7 +379,7 @@ tcpconnect(char *host)
if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0)
fatal("getaddrinfo %s: %s", host, gai_strerror(gaierr));
for (ai = aitop; ai; ai = ai->ai_next) {
s = socket(ai->ai_family, SOCK_STREAM, 0);
s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (s < 0) {
error("socket: %s", strerror(errno));
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sshconnect.c,v 1.26 2003/04/03 06:21:36 itojun Exp $ */
/* $NetBSD: sshconnect.c,v 1.27 2003/04/14 14:36:48 itojun Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -160,7 +160,7 @@ ssh_proxy_connect(const char *host, u_short port, const char *proxy_command)
* Creates a (possibly privileged) socket for use as the ssh connection.
*/
static int
ssh_create_socket(int privileged, int family)
ssh_create_socket(int privileged, struct addrinfo *ai)
{
int sock, gaierr;
struct addrinfo hints, *res;
@ -172,15 +172,16 @@ ssh_create_socket(int privileged, int family)
if (privileged) {
int p = IPPORT_RESERVED - 1;
PRIV_START;
sock = rresvport_af(&p, family);
sock = rresvport_af(&p, ai->ai_family);
PRIV_END;
if (sock < 0)
error("rresvport: af=%d %.100s", family, strerror(errno));
error("rresvport: af=%d %.100s", ai->ai_family,
strerror(errno));
else
debug("Allocated local port %d.", p);
return sock;
}
sock = socket(family, SOCK_STREAM, 0);
sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (sock < 0)
error("socket: %.100s", strerror(errno));
@ -189,8 +190,9 @@ ssh_create_socket(int privileged, int family)
return sock;
memset(&hints, 0, sizeof(hints));
hints.ai_family = family;
hints.ai_socktype = SOCK_STREAM;
hints.ai_family = ai->ai_family;
hints.ai_socktype = ai->ai_socktype;
hints.ai_protocol = ai->ai_protocol;
hints.ai_flags = AI_PASSIVE;
gaierr = getaddrinfo(options.bind_address, "0", &hints, &res);
if (gaierr) {
@ -292,7 +294,7 @@ ssh_connect(const char *host, struct sockaddr_storage * hostaddr,
host, ntop, strport);
/* Create a socket for connecting. */
sock = ssh_create_socket(needpriv, ai->ai_family);
sock = ssh_create_socket(needpriv, ai);
if (sock < 0)
/* Any error is already output */
continue;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sshd.c,v 1.28 2003/04/03 06:21:37 itojun Exp $ */
/* $NetBSD: sshd.c,v 1.29 2003/04/14 14:36:48 itojun Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -1099,7 +1099,8 @@ main(int ac, char **av)
continue;
}
/* Create socket for listening. */
listen_sock = socket(ai->ai_family, SOCK_STREAM, 0);
listen_sock = socket(ai->ai_family, ai->ai_socktype,
ai->ai_protocol);
if (listen_sock < 0) {
/* kernel may not support ipv6 */
verbose("socket: %.100s", strerror(errno));