Deleted Added
full compact
canohost.c (57429) canohost.c (60573)
1/*
1/*
2 *
2 *
3 * canohost.c
3 * canohost.c
4 *
4 *
5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
5 * Author: Tatu Ylonen <ylo@cs.hut.fi>
6 *
6 *
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
7 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8 * All rights reserved
9 *
9 *
10 * Created: Sun Jul 2 17:52:22 1995 ylo
10 * Created: Sun Jul 2 17:52:22 1995 ylo
11 *
11 *
12 * Functions for returning the canonical host name of the remote site.
12 * Functions for returning the canonical host name of the remote site.
13 *
13 *
14 */
15
16#include "includes.h"
14 */
15
16#include "includes.h"
17RCSID("$Id: canohost.c,v 1.11 2000/01/04 13:41:32 markus Exp $");
17RCSID("$Id: canohost.c,v 1.12 2000/04/14 10:30:30 markus Exp $");
18
19#include "packet.h"
20#include "xmalloc.h"
21#include "ssh.h"
22
23/*
24 * Return the canonical name of the host at the other end of the socket. The
25 * caller should free the returned string with xfree.

--- 210 unchanged lines hidden (view full) ---

236 if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0,
237 strport, sizeof(strport), NI_NUMERICSERV) != 0)
238 fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed");
239 return atoi(strport);
240}
241
242/* Returns remote/local port number for the current connection. */
243
18
19#include "packet.h"
20#include "xmalloc.h"
21#include "ssh.h"
22
23/*
24 * Return the canonical name of the host at the other end of the socket. The
25 * caller should free the returned string with xfree.

--- 210 unchanged lines hidden (view full) ---

236 if (getnameinfo((struct sockaddr *)&from, fromlen, NULL, 0,
237 strport, sizeof(strport), NI_NUMERICSERV) != 0)
238 fatal("get_sock_port: getnameinfo NI_NUMERICSERV failed");
239 return atoi(strport);
240}
241
242/* Returns remote/local port number for the current connection. */
243
244int
244int
245get_port(int local)
246{
247 /*
248 * If the connection is not a socket, return 65535. This is
249 * intentionally chosen to be an unprivileged port number.
250 */
251 if (!packet_connection_is_on_socket())
252 return 65535;
253
254 /* Get socket and return the port number. */
255 return get_sock_port(packet_get_connection_in(), local);
256}
257
245get_port(int local)
246{
247 /*
248 * If the connection is not a socket, return 65535. This is
249 * intentionally chosen to be an unprivileged port number.
250 */
251 if (!packet_connection_is_on_socket())
252 return 65535;
253
254 /* Get socket and return the port number. */
255 return get_sock_port(packet_get_connection_in(), local);
256}
257
258int
258int
259get_peer_port(int sock)
260{
261 return get_sock_port(sock, 0);
262}
263
259get_peer_port(int sock)
260{
261 return get_sock_port(sock, 0);
262}
263
264int
264int
265get_remote_port()
266{
267 return get_port(0);
268}
269
270int
271get_local_port()
272{
273 return get_port(1);
274}
265get_remote_port()
266{
267 return get_port(0);
268}
269
270int
271get_local_port()
272{
273 return get_port(1);
274}