Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inet_aton() -> inet_pton() #1461

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ AX_TYPE_SOCKLEN_T
AX_CREATE_STDINT_H([eggint.h])

# Checks for functions and their arguments.
AC_CHECK_FUNCS([dprintf explicit_bzero explicit_memset getrandom inet_aton isascii memset_s random rand lrand48 snprintf strlcpy vsnprintf])
AC_CHECK_FUNCS([dprintf explicit_bzero explicit_memset getrandom isascii memset_s random rand lrand48 snprintf strlcpy vsnprintf])
AC_FUNC_SELECT_ARGTYPES
EGG_FUNC_B64_NTOP
AC_FUNC_MMAP
Expand Down
2 changes: 1 addition & 1 deletion src/compat/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ STRIP = @STRIP@
CFLAGS = @CFLAGS@ -I../.. -I$(top_srcdir) -I$(top_srcdir)/src @SSL_INCLUDES@ @DEFS@ $(CFLGS)
CPPFLAGS = @CPPFLAGS@

OBJS = base64.o explicit_bzero.o in6.o inet_aton.o snprintf.o strlcpy.o
OBJS = base64.o explicit_bzero.o in6.o snprintf.o strlcpy.o

doofus:
@echo ""
Expand Down
1 change: 0 additions & 1 deletion src/compat/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#define _EGG_COMPAT_COMPAT_H

#include "base64.h"
#include "inet_aton.h"
#include "snprintf.h"
#include "explicit_bzero.h"
#include "strlcpy.h"
Expand Down
204 changes: 0 additions & 204 deletions src/compat/inet_aton.c

This file was deleted.

40 changes: 0 additions & 40 deletions src/compat/inet_aton.h

This file was deleted.

2 changes: 2 additions & 0 deletions src/eggdrop.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ typedef uint32_t IP;

/* The following functions are for backward compatibility only */
#define egg_bzero(dest, len) memset(dest, 0, len)
#define egg_inet_aton(src, dst) inet_pton(AF_INET, src, dst)
#define egg_memcpy memcpy
#define egg_memset memset
#define egg_strcasecmp strcasecmp
Expand All @@ -340,6 +341,7 @@ typedef int (*IntFunc) ();

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

typedef struct {
int family;
Expand Down
2 changes: 1 addition & 1 deletion src/mod/dns.mod/dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ static char *dns_change(ClientData cdata, Tcl_Interp *irp,
} else
port = NAMESERVER_PORT; /* port 53 */
/* Ignore invalid addresses */
if (egg_inet_aton(list[i], &myres.nsaddr_list[myres.nscount].sin_addr)) {
if (inet_pton(AF_INET, list[i], &myres.nsaddr_list[myres.nscount].sin_addr)) {
myres.nsaddr_list[myres.nscount].sin_port = htons(port);
myres.nsaddr_list[myres.nscount].sin_family = AF_INET;
myres.nscount++;
Expand Down
5 changes: 1 addition & 4 deletions src/mod/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@
#undef Assert

/* Compatibility functions. */
#ifdef egg_inet_aton
# undef egg_inet_aton
#endif
#ifdef egg_vsnprintf
# undef egg_vsnprintf
#endif
Expand Down Expand Up @@ -430,7 +427,7 @@ typedef void (*chanout_butfunc)(int, int, const char *, ...) ATTRIBUTE_FORMAT(pr
#define sock_has_data ((int(*)(int, int))global[248])
#define bots_in_subtree ((int (*)(tand_t *))global[249])
#define users_in_subtree ((int (*)(tand_t *))global[250])
#define egg_inet_aton ((int (*)(const char *cp, struct in_addr *addr))global[251])
/* was egg_inet_aton -- use inet_pton() instead */
/* 252 - 255 */
#define egg_snprintf (global[252])
#define egg_vsnprintf ((int (*)(char *, size_t, const char *, va_list))global[253])
Expand Down
2 changes: 1 addition & 1 deletion src/modules.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ Function global_table[] = {
(Function) sock_has_data,
(Function) bots_in_subtree,
(Function) users_in_subtree,
(Function) egg_inet_aton,
(Function) 0, /* was egg_inet_aton -- use inet_pton() instead */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just export inet_aton here then to avoid breaking modules?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inet_aton is not posix. inet_aton(y,z) could be mapped to inet_pton(AF_INET,y,z), but thats not equivalent. inet_aton accepts numbers-and-dots notation, something inet_pton doesnt, so it could potentially break modules anyway. given the module api breakage, i propose we milestone this PR for eggdrop 1.10 pr newer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we can risk theoretical breakage, we could of course export inet_aton if available, and export 0 otherwise. if that is what you had in mind.

/* 252 - 255 */
(Function) egg_snprintf,
(Function) egg_vsnprintf,
Expand Down