22 lines
403 B
C
22 lines
403 B
C
/* $NetBSD: getportproto.c,v 1.3 2004/11/13 18:44:43 he Exp $ */
|
|
|
|
#include <ctype.h>
|
|
#include "ipf.h"
|
|
|
|
int getportproto(name, proto)
|
|
char *name;
|
|
int proto;
|
|
{
|
|
struct servent *s;
|
|
struct protoent *p;
|
|
|
|
if (isdigit(*name) && atoi(name) > 0)
|
|
return htons(atoi(name) & 65535);
|
|
|
|
p = getprotobynumber(proto);
|
|
s = getservbyname(name, p ? p->p_name : NULL);
|
|
if (s != NULL)
|
|
return s->s_port;
|
|
return 0;
|
|
}
|