/* Copyright 1997 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/****************************************************************************
 * This source file was written by Acorn Computers Limited. It is part of   *
 * the Internet library for writing network applications in C. It may be    *
 * used freely in the creation of programs for Archimedes or Risc PC. It    *
 * should be used with Acorn's C Compiler Release 5 or later.               *
 *                                                                          *
 *                                                                          *
 * Copyright  Acorn Computers Ltd, 1996                                    *
 *                                                                          *
 ***************************************************************************/

/*
 * File:    inetlib.h
 * Purpose: Network support functions (name lookup, etc.)
 * Author:  K Bracey
 * History: 26-Nov-96: KJB: First Internet 5 release
 *          28-Nov-96: KJB: hton[sl] #defined to ntoh[sl]
 */

#include "sys/types.h"

#include "netinet/in.h"

/*
 * variable declarations
 */
extern int _host_stayopen;
extern int _net_stayopen;
extern int _proto_stayopen;
extern int _serv_stayopen;
extern const struct in6_addr in6addr_any;
extern const struct in6_addr in6addr_loopback;

/*
 * function prototypes
 */
extern void endhostent(void);
extern void endnetent(void);
extern void endprotoent(void);
extern void endservent(void);

extern struct hostent *gethostbyaddr(const char *addr, int length, int type);
extern struct hostent *gethostbyname(const char *nam);
extern struct hostent *gethostent(void);
extern struct netent *getnetbyaddr(unsigned long net, int type);
extern struct netent *getnetbyname(const char *name);
extern struct netent *getnetent(void);
extern struct protoent *getprotobyname(const char *name);
extern struct protoent *getprotobynumber(int proto);
extern struct protoent *getprotoent(void);
extern struct servent *getservbyname(const char *name, const char *proto);
extern struct servent *getservbyport(int port, const char *proto);
extern struct servent *getservent(void);

extern u_long htonl(u_long x);
extern int htons(int x);
#define htonl(x) ntohl(x)
#define htons(x) ntohs(x)

extern u_long inet_addr(const char *cp);
extern int inet_aton(const char *cp, struct in_addr *in);
extern u_long inet_lnaof(struct in_addr in);
extern struct in_addr inet_makeaddr(u_long net, u_long host);
extern u_long inet_network(const char *cp);
extern u_long inet_netof(struct in_addr in);
extern char *inet_net_ntop(int, const void *, int, char *, size_t);
extern int inet_net_pton(int, const char *, void *, size_t);
extern char *inet_ntoa(struct in_addr);
extern const char *inet_ntop(int, const void *, char *, size_t);
extern int inet_pton(int, const char *, void *);

struct if_nameindex;
extern void if_freenameindex(struct if_nameindex *);
extern char *if_indextoname(unsigned int, char *);
extern struct if_nameindex *if_nameindex(void);
extern unsigned int if_nametoindex(const char *);

extern struct hostent *namisipadr(const char *nam);
extern u_long ntohl(u_long x);
extern int ntohs(int x);

extern int rresvport(int *alport);

extern void sethostent(int f);
extern void setnetent(int f);
extern void setprotoent(int f);
extern void setservent(int f);

extern int sysctlbyname(const char *name, void *oldp, size_t *oldlenp,
                        const void *newp, size_t newlen);

#ifdef ISO
#include "netiso/iso.h"
extern struct iso_addr *iso_addr(const char *addr);
extern char *iso_ntoa(const struct iso_addr *isoa);
#endif
#ifdef NS
#include "netns/ns.h"
extern struct ns_addr(const char *name);
extern char *ns_ntoa(struct ns_addr addr);
#endif

/* EOF inetlib.h */
