inpcb: use in_port_t for port numbers

This commit is contained in:
ozaki-r 2022-11-04 09:03:20 +00:00
parent eb441dc743
commit 0fa740c7db
4 changed files with 24 additions and 24 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: in.c,v 1.243 2022/09/20 02:23:37 knakahara Exp $ */
/* $NetBSD: in.c,v 1.244 2022/11/04 09:03:20 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -91,7 +91,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.243 2022/09/20 02:23:37 knakahara Exp $");
__KERNEL_RCSID(0, "$NetBSD: in.c,v 1.244 2022/11/04 09:03:20 ozaki-r Exp $");
#include "arp.h"
@ -1861,7 +1861,7 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro,
ia = ifatoia(ifa);
}
if (ia == NULL) {
u_int16_t fport = sin->sin_port;
in_port_t fport = sin->sin_port;
struct ifaddr *ifa;
int s;

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_pcb.c,v 1.197 2022/11/04 09:02:38 ozaki-r Exp $ */
/* $NetBSD: in_pcb.c,v 1.198 2022/11/04 09:03:20 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -93,7 +93,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.197 2022/11/04 09:02:38 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: in_pcb.c,v 1.198 2022/11/04 09:03:20 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -187,7 +187,7 @@ inpcb_init(struct inpcbtable *table, int bindhashsize, int connecthashsize)
table->inpt_connecthashtbl = hashinit(connecthashsize, HASH_LIST, true,
&table->inpt_connecthash);
table->inpt_lastlow = IPPORT_RESERVEDMAX;
table->inpt_lastport = (u_int16_t)anonportmax;
table->inpt_lastport = (in_port_t)anonportmax;
RUN_ONCE(&control, inpcb_poolinit);
}
@ -268,8 +268,8 @@ inpcb_set_port(struct sockaddr_in *sin, struct inpcb *inp, kauth_cred_t cred)
{
struct inpcbtable *table = inp->inp_table;
struct socket *so = inp->inp_socket;
u_int16_t *lastport;
u_int16_t lport = 0;
in_port_t *lastport;
in_port_t lport = 0;
enum kauth_network_req req;
int error;
@ -744,7 +744,7 @@ inpcb_notify(struct inpcbtable *table, struct in_addr faddr, u_int fport_arg,
{
struct inpcbhead *head;
struct inpcb *inp;
u_int16_t fport = fport_arg, lport = lport_arg;
in_port_t fport = fport_arg, lport = lport_arg;
int nmatch;
if (in_nullhost(faddr) || notify == 0)
@ -926,7 +926,7 @@ inpcb_lookup_local(struct inpcbtable *table, struct in_addr laddr,
struct inpcb *match = NULL;
int matchwild = 3;
int wildcard;
u_int16_t lport = lport_arg;
in_port_t lport = lport_arg;
if (vp)
vp->valid = 0;
@ -1034,7 +1034,7 @@ inpcb_lookup(struct inpcbtable *table,
{
struct inpcbhead *head;
struct inpcb *inp;
u_int16_t fport = fport_arg, lport = lport_arg;
in_port_t fport = fport_arg, lport = lport_arg;
if (vp)
vp->valid = 0;
@ -1080,7 +1080,7 @@ inpcb_lookup_bound(struct inpcbtable *table,
{
struct inpcbhead *head;
struct inpcb *inp;
u_int16_t lport = lport_arg;
in_port_t lport = lport_arg;
head = INPCBHASH_BIND(table, laddr, lport);
LIST_FOREACH(inp, head, inp_hash) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: in_pcb.h,v 1.75 2022/11/04 09:01:53 ozaki-r Exp $ */
/* $NetBSD: in_pcb.h,v 1.76 2022/11/04 09:03:20 ozaki-r Exp $ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@ -101,8 +101,8 @@ struct inpcb {
struct inpcbtable *inp_table;
struct inpcbpolicy *inp_sp; /* security policy */
struct route inp_route; /* placeholder for routing entry */
u_int16_t inp_fport; /* foreign port */
u_int16_t inp_lport; /* local port */
in_port_t inp_fport; /* foreign port */
in_port_t inp_lport; /* local port */
int inp_flags; /* generic IP/datagram flags */
struct mbuf *inp_options; /* IP options */
bool inp_bindportonsend;
@ -232,8 +232,8 @@ struct inpcbtable {
u_long inpt_porthash;
u_long inpt_bindhash;
u_long inpt_connecthash;
u_int16_t inpt_lastport;
u_int16_t inpt_lastlow;
in_port_t inpt_lastport;
in_port_t inpt_lastlow;
struct vestigial_hooks *vestige;
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: in6_pcb.c,v 1.175 2022/11/04 09:01:53 ozaki-r Exp $ */
/* $NetBSD: in6_pcb.c,v 1.176 2022/11/04 09:03:20 ozaki-r Exp $ */
/* $KAME: in6_pcb.c,v 1.84 2001/02/08 18:02:08 itojun Exp $ */
/*
@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.175 2022/11/04 09:01:53 ozaki-r Exp $");
__KERNEL_RCSID(0, "$NetBSD: in6_pcb.c,v 1.176 2022/11/04 09:03:20 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_inet.h"
@ -134,7 +134,7 @@ in6pcb_init(struct inpcbtable *table, int bindhashsize, int connecthashsize)
{
inpcb_init(table, bindhashsize, connecthashsize);
table->inpt_lastport = (u_int16_t)ip6_anonportmax;
table->inpt_lastport = (in_port_t)ip6_anonportmax;
}
/*
@ -606,7 +606,7 @@ in6pcb_notify(struct inpcbtable *table, const struct sockaddr *dst,
struct inpcb *inp;
struct sockaddr_in6 sa6_src;
const struct sockaddr_in6 *sa6_dst;
u_int16_t fport = fport_arg, lport = lport_arg;
in_port_t fport = fport_arg, lport = lport_arg;
int errno;
int nmatch = 0;
u_int32_t flowinfo;
@ -836,7 +836,7 @@ in6pcb_lookup_local(struct inpcbtable *table, struct in6_addr *laddr6,
struct inpcbhead *head;
struct inpcb *inp, *match = NULL;
int matchwild = 3, wildcard;
u_int16_t lport = lport_arg;
in_port_t lport = lport_arg;
if (vp)
vp->valid = 0;
@ -1047,7 +1047,7 @@ in6pcb_lookup(struct inpcbtable *table, const struct in6_addr *faddr6,
{
struct inpcbhead *head;
struct inpcb *inp;
u_int16_t fport = fport_arg, lport = lport_arg;
in_port_t fport = fport_arg, lport = lport_arg;
if (vp)
vp->valid = 0;
@ -1091,7 +1091,7 @@ in6pcb_lookup_bound(struct inpcbtable *table, const struct in6_addr *laddr6,
{
struct inpcbhead *head;
struct inpcb *inp;
u_int16_t lport = lport_arg;
in_port_t lport = lport_arg;
#ifdef INET
struct in6_addr zero_mapped;
#endif