libipsec: ansify

Sponsored by:	Nvidia networking
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2023-04-03 04:18:40 +03:00
parent f14ceae498
commit 650d6cc122
2 changed files with 88 additions and 229 deletions

View File

@ -93,8 +93,7 @@ static int supported_map[] = {
};
static int
findsupportedmap(satype)
int satype;
findsupportedmap(int satype)
{
int i;
@ -105,8 +104,7 @@ findsupportedmap(satype)
}
static struct sadb_alg *
findsupportedalg(satype, alg_id)
u_int satype, alg_id;
findsupportedalg(u_int satype, u_int alg_id)
{
int algno;
int tlen;
@ -143,8 +141,7 @@ findsupportedalg(satype, alg_id)
}
static int
setsupportedmap(sup)
struct sadb_supported *sup;
setsupportedmap(struct sadb_supported *sup)
{
struct sadb_supported **ipsup;
@ -183,10 +180,7 @@ setsupportedmap(sup)
* 0: valid.
*/
int
ipsec_check_keylen(supported, alg_id, keylen)
u_int supported;
u_int alg_id;
u_int keylen;
ipsec_check_keylen(u_int supported, u_int alg_id, u_int keylen)
{
int satype;
@ -215,10 +209,7 @@ ipsec_check_keylen(supported, alg_id, keylen)
* 0: valid.
*/
int
ipsec_check_keylen2(satype, alg_id, keylen)
u_int satype;
u_int alg_id;
u_int keylen;
ipsec_check_keylen2(u_int satype, u_int alg_id, u_int keylen)
{
struct sadb_alg *alg;
@ -244,9 +235,7 @@ ipsec_check_keylen2(satype, alg_id, keylen)
* 0: valid.
*/
int
ipsec_get_keylen(supported, alg_id, alg0)
u_int supported, alg_id;
struct sadb_alg *alg0;
ipsec_get_keylen(u_int supported, u_int alg_id, struct sadb_alg *alg0)
{
struct sadb_alg *alg;
u_int satype;
@ -289,8 +278,7 @@ static u_int soft_lifetime_addtime_rate = PFKEY_SOFT_LIFETIME_RATE;
static u_int soft_lifetime_usetime_rate = PFKEY_SOFT_LIFETIME_RATE;
u_int
pfkey_set_softrate(type, rate)
u_int type, rate;
pfkey_set_softrate(u_int type, u_int rate)
{
__ipsec_errcode = EIPSEC_NO_ERROR;
@ -321,8 +309,7 @@ pfkey_set_softrate(type, rate)
* ATTENTION: ~0 is returned if invalid type was passed.
*/
u_int
pfkey_get_softrate(type)
u_int type;
pfkey_get_softrate(u_int type)
{
switch (type) {
case SADB_X_LIFETIME_ALLOCATIONS:
@ -345,11 +332,9 @@ pfkey_get_softrate(type)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_getspi(so, satype, mode, src, dst, min, max, reqid, seq)
int so;
u_int satype, mode;
struct sockaddr *src, *dst;
u_int32_t min, max, reqid, seq;
pfkey_send_getspi(int so, u_int satype, u_int mode, struct sockaddr *src,
struct sockaddr *dst, u_int32_t min, uint32_t max, uint32_t reqid,
uint32_t seq)
{
struct sadb_msg *newmsg;
caddr_t ep;
@ -474,18 +459,11 @@ pfkey_send_getspi(so, satype, mode, src, dst, min, max, reqid, seq)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_update(so, satype, mode, src, dst, spi, reqid, wsize,
keymat, e_type, e_keylen, a_type, a_keylen, flags,
l_alloc, l_bytes, l_addtime, l_usetime, seq)
int so;
u_int satype, mode, wsize;
struct sockaddr *src, *dst;
u_int32_t spi, reqid;
caddr_t keymat;
u_int e_type, e_keylen, a_type, a_keylen, flags;
u_int32_t l_alloc;
u_int64_t l_bytes, l_addtime, l_usetime;
u_int32_t seq;
pfkey_send_update(int so, u_int satype, u_int mode, struct sockaddr *src,
struct sockaddr *dst, u_int32_t spi, u_int32_t reqid, u_int wsize,
caddr_t keymat, u_int e_type, u_int e_keylen, u_int a_type, u_int a_keylen,
u_int flags, u_int32_t l_alloc, u_int64_t l_bytes, u_int64_t l_addtime,
u_int64_t l_usetime, u_int32_t seq)
{
int len;
if ((len = pfkey_send_x1(so, SADB_UPDATE, satype, mode, src, dst, spi,
@ -505,18 +483,11 @@ pfkey_send_update(so, satype, mode, src, dst, spi, reqid, wsize,
* -1 : error occurred, and set errno.
*/
int
pfkey_send_add(so, satype, mode, src, dst, spi, reqid, wsize,
keymat, e_type, e_keylen, a_type, a_keylen, flags,
l_alloc, l_bytes, l_addtime, l_usetime, seq)
int so;
u_int satype, mode, wsize;
struct sockaddr *src, *dst;
u_int32_t spi, reqid;
caddr_t keymat;
u_int e_type, e_keylen, a_type, a_keylen, flags;
u_int32_t l_alloc;
u_int64_t l_bytes, l_addtime, l_usetime;
u_int32_t seq;
pfkey_send_add(int so, u_int satype, u_int mode, struct sockaddr *src,
struct sockaddr *dst, u_int32_t spi, u_int32_t reqid, u_int wsize,
caddr_t keymat, u_int e_type, u_int e_keylen, u_int a_type, u_int a_keylen,
u_int flags, u_int32_t l_alloc, u_int64_t l_bytes, u_int64_t l_addtime,
u_int64_t l_usetime, u_int32_t seq)
{
int len;
if ((len = pfkey_send_x1(so, SADB_ADD, satype, mode, src, dst, spi,
@ -535,11 +506,8 @@ pfkey_send_add(so, satype, mode, src, dst, spi, reqid, wsize,
* -1 : error occurred, and set errno.
*/
int
pfkey_send_delete(so, satype, mode, src, dst, spi)
int so;
u_int satype, mode;
struct sockaddr *src, *dst;
u_int32_t spi;
pfkey_send_delete(int so, u_int satype, u_int mode, struct sockaddr *src,
struct sockaddr *dst, u_int32_t spi)
{
int len;
if ((len = pfkey_send_x2(so, SADB_DELETE, satype, mode, src, dst, spi)) < 0)
@ -558,10 +526,8 @@ pfkey_send_delete(so, satype, mode, src, dst, spi)
* -1 : error occurred, and set errno
*/
int
pfkey_send_delete_all(so, satype, mode, src, dst)
int so;
u_int satype, mode;
struct sockaddr *src, *dst;
pfkey_send_delete_all(int so, u_int satype, u_int mode, struct sockaddr *src,
struct sockaddr *dst)
{
struct sadb_msg *newmsg;
int len;
@ -640,11 +606,8 @@ pfkey_send_delete_all(so, satype, mode, src, dst)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_get(so, satype, mode, src, dst, spi)
int so;
u_int satype, mode;
struct sockaddr *src, *dst;
u_int32_t spi;
pfkey_send_get(int so, u_int satype, u_int mode, struct sockaddr *src,
struct sockaddr *dst, u_int32_t spi)
{
int len;
if ((len = pfkey_send_x2(so, SADB_GET, satype, mode, src, dst, spi)) < 0)
@ -660,9 +623,7 @@ pfkey_send_get(so, satype, mode, src, dst, spi)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_register(so, satype)
int so;
u_int satype;
pfkey_send_register(int so, u_int satype)
{
int len, algno;
@ -702,8 +663,7 @@ pfkey_send_register(so, satype)
* -1: error occurred, and set errno.
*/
int
pfkey_recv_register(so)
int so;
pfkey_recv_register(int so)
{
pid_t pid = getpid();
struct sadb_msg *newmsg;
@ -742,9 +702,7 @@ pfkey_recv_register(so)
* -1: error occurred, and set errno.
*/
int
pfkey_set_supported(msg, tlen)
struct sadb_msg *msg;
int tlen;
pfkey_set_supported(struct sadb_msg *msg, int tlen)
{
struct sadb_supported *sup;
caddr_t p;
@ -806,9 +764,7 @@ pfkey_set_supported(msg, tlen)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_flush(so, satype)
int so;
u_int satype;
pfkey_send_flush(int so, u_int satype)
{
int len;
@ -825,9 +781,7 @@ pfkey_send_flush(so, satype)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_dump(so, satype)
int so;
u_int satype;
pfkey_send_dump(int so, u_int satype)
{
int len;
@ -850,9 +804,7 @@ pfkey_send_dump(so, satype)
* algorithms is.
*/
int
pfkey_send_promisc_toggle(so, flag)
int so;
int flag;
pfkey_send_promisc_toggle(int so, int flag)
{
int len;
@ -869,13 +821,9 @@ pfkey_send_promisc_toggle(so, flag)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spdadd(so, src, prefs, dst, prefd, proto, policy, policylen, seq)
int so;
struct sockaddr *src, *dst;
u_int prefs, prefd, proto;
caddr_t policy;
int policylen;
u_int32_t seq;
pfkey_send_spdadd(int so, struct sockaddr *src, u_int prefs,
struct sockaddr *dst, u_int prefd, u_int proto, caddr_t policy,
int policylen, u_int32_t seq)
{
int len;
@ -895,15 +843,9 @@ pfkey_send_spdadd(so, src, prefs, dst, prefd, proto, policy, policylen, seq)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spdadd2(so, src, prefs, dst, prefd, proto, ltime, vtime,
policy, policylen, seq)
int so;
struct sockaddr *src, *dst;
u_int prefs, prefd, proto;
u_int64_t ltime, vtime;
caddr_t policy;
int policylen;
u_int32_t seq;
pfkey_send_spdadd2(int so, struct sockaddr *src, u_int prefs,
struct sockaddr *dst, u_int prefd, u_int proto, u_int64_t ltime,
u_int64_t vtime, caddr_t policy, int policylen, u_int32_t seq)
{
int len;
@ -923,13 +865,9 @@ pfkey_send_spdadd2(so, src, prefs, dst, prefd, proto, ltime, vtime,
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spdupdate(so, src, prefs, dst, prefd, proto, policy, policylen, seq)
int so;
struct sockaddr *src, *dst;
u_int prefs, prefd, proto;
caddr_t policy;
int policylen;
u_int32_t seq;
pfkey_send_spdupdate(int so, struct sockaddr *src, u_int prefs,
struct sockaddr *dst, u_int prefd, u_int proto, caddr_t policy,
int policylen, u_int32_t seq)
{
int len;
@ -949,15 +887,9 @@ pfkey_send_spdupdate(so, src, prefs, dst, prefd, proto, policy, policylen, seq)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spdupdate2(so, src, prefs, dst, prefd, proto, ltime, vtime,
policy, policylen, seq)
int so;
struct sockaddr *src, *dst;
u_int prefs, prefd, proto;
u_int64_t ltime, vtime;
caddr_t policy;
int policylen;
u_int32_t seq;
pfkey_send_spdupdate2(int so, struct sockaddr *src, u_int prefs,
struct sockaddr *dst, u_int prefd, u_int proto, u_int64_t ltime,
u_int64_t vtime, caddr_t policy, int policylen, u_int32_t seq)
{
int len;
@ -977,13 +909,9 @@ pfkey_send_spdupdate2(so, src, prefs, dst, prefd, proto, ltime, vtime,
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spddelete(so, src, prefs, dst, prefd, proto, policy, policylen, seq)
int so;
struct sockaddr *src, *dst;
u_int prefs, prefd, proto;
caddr_t policy;
int policylen;
u_int32_t seq;
pfkey_send_spddelete(int so, struct sockaddr *src, u_int prefs,
struct sockaddr *dst, u_int prefd, u_int proto, caddr_t policy,
int policylen, u_int32_t seq)
{
int len;
@ -1008,9 +936,7 @@ pfkey_send_spddelete(so, src, prefs, dst, prefd, proto, policy, policylen, seq)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spddelete2(so, spid)
int so;
u_int32_t spid;
pfkey_send_spddelete2(int so, u_int32_t spid)
{
int len;
@ -1027,9 +953,7 @@ pfkey_send_spddelete2(so, spid)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spdget(so, spid)
int so;
u_int32_t spid;
pfkey_send_spdget(int so, u_int32_t spid)
{
int len;
@ -1046,13 +970,9 @@ pfkey_send_spdget(so, spid)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spdsetidx(so, src, prefs, dst, prefd, proto, policy, policylen, seq)
int so;
struct sockaddr *src, *dst;
u_int prefs, prefd, proto;
caddr_t policy;
int policylen;
u_int32_t seq;
pfkey_send_spdsetidx(int so, struct sockaddr *src, u_int prefs,
struct sockaddr *dst, u_int prefd, u_int proto, caddr_t policy,
int policylen, u_int32_t seq)
{
int len;
@ -1077,8 +997,7 @@ pfkey_send_spdsetidx(so, src, prefs, dst, prefd, proto, policy, policylen, seq)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spdflush(so)
int so;
pfkey_send_spdflush(int so)
{
int len;
@ -1095,8 +1014,7 @@ pfkey_send_spdflush(so)
* -1 : error occurred, and set errno.
*/
int
pfkey_send_spddump(so)
int so;
pfkey_send_spddump(int so)
{
int len;
@ -1108,17 +1026,11 @@ pfkey_send_spddump(so)
/* sending SADB_ADD or SADB_UPDATE message to the kernel */
static int
pfkey_send_x1(so, type, satype, mode, src, dst, spi, reqid, wsize,
keymat, e_type, e_keylen, a_type, a_keylen, flags,
l_alloc, l_bytes, l_addtime, l_usetime, seq)
int so;
u_int type, satype, mode;
struct sockaddr *src, *dst;
u_int32_t spi, reqid;
u_int wsize;
caddr_t keymat;
u_int e_type, e_keylen, a_type, a_keylen, flags;
u_int32_t l_alloc, l_bytes, l_addtime, l_usetime, seq;
pfkey_send_x1(int so, u_int type, u_int satype, u_int mode,
struct sockaddr *src, struct sockaddr *dst, u_int32_t spi, u_int32_t reqid,
u_int wsize, caddr_t keymat, u_int e_type, u_int e_keylen, u_int a_type,
u_int a_keylen, u_int flags, u_int32_t l_alloc, u_int32_t l_bytes,
u_int32_t l_addtime, u_int32_t l_usetime, u_int32_t seq)
{
struct sadb_msg *newmsg;
int len;
@ -1298,11 +1210,8 @@ pfkey_send_x1(so, type, satype, mode, src, dst, spi, reqid, wsize,
/* sending SADB_DELETE or SADB_GET message to the kernel */
static int
pfkey_send_x2(so, type, satype, mode, src, dst, spi)
int so;
u_int type, satype, mode;
struct sockaddr *src, *dst;
u_int32_t spi;
pfkey_send_x2(int so, u_int type, u_int satype, u_int mode,
struct sockaddr *src, struct sockaddr *dst, u_int32_t spi)
{
struct sadb_msg *newmsg;
int len;
@ -1385,9 +1294,7 @@ pfkey_send_x2(so, type, satype, mode, src, dst, spi)
* to the kernel
*/
static int
pfkey_send_x3(so, type, satype)
int so;
u_int type, satype;
pfkey_send_x3(int so, u_int type, u_int satype)
{
struct sadb_msg *newmsg;
int len;
@ -1445,15 +1352,9 @@ pfkey_send_x3(so, type, satype)
/* sending SADB_X_SPDADD message to the kernel */
static int
pfkey_send_x4(so, type, src, prefs, dst, prefd, proto,
ltime, vtime, policy, policylen, seq)
int so;
struct sockaddr *src, *dst;
u_int type, prefs, prefd, proto;
u_int64_t ltime, vtime;
char *policy;
int policylen;
u_int32_t seq;
pfkey_send_x4(int so, u_int type, struct sockaddr *src, u_int prefs,
struct sockaddr *dst, u_int prefd, u_int proto, u_int64_t ltime,
u_int64_t vtime, char *policy, int policylen, u_int32_t seq)
{
struct sadb_msg *newmsg;
int len;
@ -1539,10 +1440,7 @@ pfkey_send_x4(so, type, src, prefs, dst, prefd, proto,
/* sending SADB_X_SPDGET or SADB_X_SPDDELETE message to the kernel */
static int
pfkey_send_x5(so, type, spid)
int so;
u_int type;
u_int32_t spid;
pfkey_send_x5(int so, u_int type, u_int32_t spid)
{
struct sadb_msg *newmsg;
struct sadb_x_policy xpl;
@ -1645,8 +1543,7 @@ pfkey_open(void)
* -1: fail.
*/
void
pfkey_close(so)
int so;
pfkey_close(int so)
{
(void)close(so);
@ -1664,8 +1561,7 @@ pfkey_close(so)
* XXX should be rewritten to pass length explicitly
*/
struct sadb_msg *
pfkey_recv(so)
int so;
pfkey_recv(int so)
{
struct sadb_msg buf, *newmsg;
int len, reallen;
@ -1722,10 +1618,7 @@ pfkey_recv(so)
* -1 : fail.
*/
int
pfkey_send(so, msg, len)
int so;
struct sadb_msg *msg;
int len;
pfkey_send(int so, struct sadb_msg *msg, int len)
{
if ((len = send(so, (caddr_t)msg, len, 0)) < 0) {
__ipsec_set_strerror(strerror(errno));
@ -1751,9 +1644,7 @@ pfkey_send(so, msg, len)
* XXX should be rewritten to obtain length explicitly
*/
int
pfkey_align(msg, mhp)
struct sadb_msg *msg;
caddr_t *mhp;
pfkey_align(struct sadb_msg *msg, caddr_t *mhp)
{
struct sadb_ext *ext;
int i;
@ -1856,8 +1747,7 @@ pfkey_align(msg, mhp)
* 0: valid.
*/
int
pfkey_check(mhp)
caddr_t *mhp;
pfkey_check(caddr_t *mhp)
{
struct sadb_msg *msg;
@ -1968,13 +1858,8 @@ pfkey_check(mhp)
* `buf' must has been allocated sufficiently.
*/
static caddr_t
pfkey_setsadbmsg(buf, lim, type, tlen, satype, seq, pid)
caddr_t buf;
caddr_t lim;
u_int type, satype;
u_int tlen;
u_int32_t seq;
pid_t pid;
pfkey_setsadbmsg(caddr_t buf, caddr_t lim, u_int type, u_int tlen,
u_int satype, u_int32_t seq, pid_t pid)
{
struct sadb_msg *p;
u_int len;
@ -2003,11 +1888,8 @@ pfkey_setsadbmsg(buf, lim, type, tlen, satype, seq, pid)
* `buf' must has been allocated sufficiently.
*/
static caddr_t
pfkey_setsadbsa(buf, lim, spi, wsize, auth, enc, flags)
caddr_t buf;
caddr_t lim;
u_int32_t spi, flags;
u_int wsize, auth, enc;
pfkey_setsadbsa(caddr_t buf, caddr_t lim, u_int32_t spi, u_int wsize,
u_int auth, u_int enc, u_int32_t flags)
{
struct sadb_sa *p;
u_int len;
@ -2062,13 +1944,8 @@ pfkey_setsadbxreplay(caddr_t buf, caddr_t lim, uint32_t wsize)
* prefixlen is in bits.
*/
static caddr_t
pfkey_setsadbaddr(buf, lim, exttype, saddr, prefixlen, ul_proto)
caddr_t buf;
caddr_t lim;
u_int exttype;
struct sockaddr *saddr;
u_int prefixlen;
u_int ul_proto;
pfkey_setsadbaddr(caddr_t buf, caddr_t lim, u_int exttype,
struct sockaddr *saddr, u_int prefixlen, u_int ul_proto)
{
struct sadb_address *p;
u_int len;
@ -2096,11 +1973,7 @@ pfkey_setsadbaddr(buf, lim, exttype, saddr, prefixlen, ul_proto)
* OUT: the pointer of buf + len.
*/
static caddr_t
pfkey_setsadbkey(buf, lim, type, key, keylen)
caddr_t buf;
caddr_t lim;
caddr_t key;
u_int type, keylen;
pfkey_setsadbkey(caddr_t buf, caddr_t lim, u_int type, caddr_t key, u_int keylen)
{
struct sadb_key *p;
u_int len;
@ -2127,11 +2000,8 @@ pfkey_setsadbkey(buf, lim, type, key, keylen)
* OUT: the pointer of buf + len.
*/
static caddr_t
pfkey_setsadblifetime(buf, lim, type, l_alloc, l_bytes, l_addtime, l_usetime)
caddr_t buf;
caddr_t lim;
u_int type;
u_int32_t l_alloc, l_bytes, l_addtime, l_usetime;
pfkey_setsadblifetime(caddr_t buf, caddr_t lim, u_int type, u_int32_t l_alloc,
u_int32_t l_bytes, u_int32_t l_addtime, u_int32_t l_usetime)
{
struct sadb_lifetime *p;
u_int len;
@ -2173,11 +2043,7 @@ pfkey_setsadblifetime(buf, lim, type, l_alloc, l_bytes, l_addtime, l_usetime)
* `buf' must has been allocated sufficiently.
*/
static caddr_t
pfkey_setsadbxsa2(buf, lim, mode0, reqid)
caddr_t buf;
caddr_t lim;
u_int32_t mode0;
u_int32_t reqid;
pfkey_setsadbxsa2(caddr_t buf, caddr_t lim, u_int32_t mode0, u_int32_t reqid)
{
struct sadb_x_sa2 *p;
u_int8_t mode = mode0 & 0xff;

View File

@ -199,8 +199,7 @@ static struct val2str str_sp_scope[] = {
* dump SADB_MSG formatted. For debugging, you should use kdebug_sadb().
*/
void
pfkey_sadump(m)
struct sadb_msg *m;
pfkey_sadump(struct sadb_msg *m)
{
caddr_t mhp[SADB_EXT_MAX + 1];
struct sadb_sa *m_sa;
@ -517,8 +516,7 @@ pfkey_spdump(struct sadb_msg *m)
* set "ipaddress" to buffer.
*/
static char *
str_ipaddr(sa)
struct sockaddr *sa;
str_ipaddr(struct sockaddr *sa)
{
static char buf[NI_MAXHOST];
const int niflag = NI_NUMERICHOST;
@ -535,8 +533,7 @@ str_ipaddr(sa)
* set "/prefix[port number]" to buffer.
*/
static char *
str_prefport(family, pref, port, ulp)
u_int family, pref, port, ulp;
str_prefport(u_int family, u_int pref, u_int port, u_int ulp)
{
static char buf[128];
char prefbuf[128];
@ -574,8 +571,7 @@ str_prefport(family, pref, port, ulp)
}
static void
str_upperspec(ulp, p1, p2)
u_int ulp, p1, p2;
str_upperspec(u_int ulp, u_int p1, u_int p2)
{
if (ulp == IPSEC_ULPROTO_ANY)
printf("any");
@ -607,8 +603,7 @@ str_upperspec(ulp, p1, p2)
* set "Mon Day Time Year" to buffer
*/
static char *
str_time(t)
time_t t;
str_time(time_t t)
{
static char buf[128];
@ -627,9 +622,7 @@ str_time(t)
}
static void
str_lifetime_byte(x, str)
struct sadb_lifetime *x;
char *str;
str_lifetime_byte(struct sadb_lifetime *x, char *str)
{
double y;
char *unit;