[Git][NTPsec/ntpsec][master] Complwrw a structure name change and do some information hiding.

Eric S. Raymond gitlab at mg.gitlab.com
Wed Oct 19 10:19:51 UTC 2016


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
8e8ceffc by Eric S. Raymond at 2016-10-19T06:18:15-04:00
Complwrw a structure name change and do some information hiding.

- - - - -


8 changed files:

- include/ntp.h
- include/ntp_net.h
- include/ntpd.h
- libntp/socket.c
- ntpd/ntp_config.c
- ntpd/ntp_control.c
- ntpd/ntp_io.c
- ntpd/ntp_proto.c


Changes:

=====================================
include/ntp.h
=====================================
--- a/include/ntp.h
+++ b/include/ntp.h
@@ -158,17 +158,13 @@ typedef unsigned int	u_int;
 
 
 /*
- * The interface structure is used to hold the addresses and socket
+ * The endpt structure is used to hold the addresses and socket
  * numbers of each of the local network addresses we are using.
- * Because "interface" is a reserved word in C++ and has so many
- * varied meanings, a change to "endpt" (via typedef) is under way.
- * Eventually the struct tag will change from interface to endpt_tag.
  * endpt is unrelated to the select algorithm's struct endpoint.
  */
-typedef struct interface endpt;
-struct interface {
-	endpt *		elink;		/* endpt list link */
-	endpt *		mclink;		/* per-AF_* multicast list */
+typedef struct __endpt {
+	struct __endpt *elink;		/* endpt list link */
+	struct __endpt *mclink;		/* per-AF_* multicast list */
 	SOCKET		fd;		/* socket descriptor */
 	SOCKET		bfd;		/* for receiving broadcasts */
 	uint32_t	ifnum;		/* endpt instance count */
@@ -190,7 +186,7 @@ struct interface {
 	bool	ignore_packets; /* listen-read-drop this? */
 	struct peer *	peers;		/* list of peers using endpt */
 	u_int		peercnt;	/* count of same */
-};
+} endpt;
 
 /*
  * Flags for interfaces
@@ -668,7 +664,7 @@ typedef struct mon_data	mon_entry;
 struct mon_data {
 	mon_entry *	hash_next;	/* next structure in hash list */
 	DECL_DLIST_LINK(mon_entry, mru);/* MRU list link pointers */
-	struct interface * lcladr;	/* address on which this arrived */
+	endpt *		lcladr;		/* address on which this arrived */
 	l_fp		first;		/* first time seen */
 	l_fp		last;		/* last time seen */
 	int		leak;		/* leaky bucket accumulator */
@@ -802,13 +798,9 @@ struct endpoint {
 #define AM_NEWBCL	6		/* new broadcast */
 #define AM_POSSBCL	7		/* discard broadcast */
 
-/* NetInfo configuration locations */
-#ifdef HAVE_NETINFO_NI_H
-#define NETINFO_CONFIG_DIR "/config/ntp"
-#endif
-
 /* ntpq -c mrulist rows per request limit in ntpd */
 #define MRU_ROW_LIMIT	256
 /* similar datagrams per response limit for ntpd */
 #define MRU_FRAGS_LIMIT	128
+
 #endif /* GUARD_NTP_H */


=====================================
include/ntp_net.h
=====================================
--- a/include/ntp_net.h
+++ b/include/ntp_net.h
@@ -173,7 +173,7 @@ typedef union {
 #define SOCK_UNSPEC_S(psau)					\
 	(SOCK_UNSPEC(psau) && !SCOPE(psau))
 
-/* choose a default net interface (struct interface) for v4 or v6 */
+/* choose a default net interface (endpt) for v4 or v6 */
 #define ANY_INTERFACE_BYFAM(family)				\
 	((AF_INET == family)					\
 	     ? any_interface					\


=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -118,7 +118,7 @@ extern	void	io_setbclient	(void);
 extern	void	io_unsetbclient	(void);
 extern	void	io_multicast_add(sockaddr_u *);
 extern	void	io_multicast_del(sockaddr_u *);
-extern	void	sendpkt 	(sockaddr_u *, struct interface *, int, void *, int);
+extern	void	sendpkt 	(sockaddr_u *, endpt *, int, void *, int);
 #ifdef DEBUG
 extern	void	collect_timing  (struct recvbuf *, const char *, int, l_fp *);
 #endif


=====================================
libntp/socket.c
=====================================
--- a/libntp/socket.c
+++ b/libntp/socket.c
@@ -146,7 +146,7 @@ open_socket(
 void
 sendpkt(
 	sockaddr_u *		dest,
-	struct interface *	ep,
+	endpt *			ep,
 	int			ttl,
 	struct pkt *		pkt,
 	int			len
@@ -158,7 +158,7 @@ read_refclock_packet(SOCKET fd, struct refclockio *rp, l_fp ts)
 static inline int
 read_network_packet(
 	SOCKET			fd,
-	struct interface *	itf,
+	endpt *			itf,
 	l_fp			ts
 	)
 


=====================================
ntpd/ntp_config.c
=====================================
--- a/ntpd/ntp_config.c
+++ b/ntpd/ntp_config.c
@@ -46,6 +46,11 @@
   int yyparse (void);
 #endif
 
+/* NetInfo configuration locations */
+#ifdef HAVE_NETINFO_NI_H
+#define NETINFO_CONFIG_DIR "/config/ntp"
+#endif
+
 /*
  * In the past, we told reference clocks from network peers by giving
  * the reference clocks magic address of a particular special form


=====================================
ntpd/ntp_control.c
=====================================
--- a/ntpd/ntp_control.c
+++ b/ntpd/ntp_control.c
@@ -626,7 +626,7 @@ static int	datalinelen;
 static bool	datasent;	/* flag to avoid initial ", " */
 static bool	datanotbinflag;
 static sockaddr_u *rmt_addr;
-static struct interface *lcl_inter;
+static endpt *lcl_inter;
 
 static bool	res_authenticate;
 static bool	res_authokay;
@@ -3303,7 +3303,7 @@ static void read_mru_list(
 	int			mincount;
 	u_int			maxlstint;
 	sockaddr_u		laddr;
-	struct interface *	lcladr;
+	endpt *			lcladr;
 	u_int			count;
 	u_int			ui;
 	u_int			uf;


=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -268,9 +268,9 @@ static  bool	addr_samesubnet	(const sockaddr_u *, const sockaddr_u *,
 				 const sockaddr_u *, const sockaddr_u *);
 static	int	create_sockets	(u_short);
 static	void	set_reuseaddr	(int);
-static	bool	socket_broadcast_enable	 (struct interface *, SOCKET, sockaddr_u *);
+static	bool	socket_broadcast_enable	 (endpt *, SOCKET, sockaddr_u *);
 #ifdef  OS_MISSES_SPECIFIC_ROUTE_UPDATES
-static	bool	socket_broadcast_disable (struct interface *, sockaddr_u *);
+static	bool	socket_broadcast_disable (endpt *, sockaddr_u *);
 #endif
 
 typedef struct remaddr remaddr_t;
@@ -316,7 +316,7 @@ static int		cmp_addr_distance(const sockaddr_u *,
 /*
  * Routines to read the ntp packets
  */
-static inline int	read_network_packet	(SOCKET, struct interface *, l_fp);
+static inline int	read_network_packet	(SOCKET, endpt *, l_fp);
 static void ntpd_addremove_io_fd (int, int, int);
 static void input_handler (fd_set *, l_fp *);
 #ifdef REFCLOCK
@@ -804,12 +804,12 @@ init_interface(
  * template structure or via standard initialization
  * function
  */
-static struct interface *
+static endpt *
 new_interface(
-	struct interface *interface
+	endpt *interface
 	)
 {
-	struct interface *	iface;
+	endpt *	iface;
 
 	iface = emalloc(sizeof(*iface));
 
@@ -1098,7 +1098,7 @@ create_wildcards(
 	bool			v6wild;
 	sockaddr_u		wildaddr;
 	nic_rule_action		action;
-	struct interface *	wildif;
+	endpt *	wildif;
 
 	/*
 	 * silence "potentially uninitialized" warnings from VC9
@@ -1500,7 +1500,7 @@ convert_isc_if(
  */
 static bool
 refresh_interface(
-	struct interface * interface
+	endpt * interface
 	)
 {
 #ifdef  OS_MISSES_SPECIFIC_ROUTE_UPDATES
@@ -1607,7 +1607,7 @@ set_wildcard_reuse(
 	int	on
 	)
 {
-	struct interface *any;
+	endpt *any;
 	SOCKET fd = INVALID_SOCKET;
 
 	any = ANY_INTERFACE_BYFAM(family);
@@ -2061,10 +2061,10 @@ create_sockets(
  * create_interface - create a new interface for a given prototype
  *		      binding the socket.
  */
-static struct interface *
+static endpt *
 create_interface(
 	u_short			port,
-	struct interface *	protot
+	endpt *	protot
 	)
 {
 	sockaddr_u	resmask;
@@ -2189,7 +2189,7 @@ set_reuseaddr(
  */
 void
 enable_broadcast(
-	struct interface *	iface,
+	endpt *	iface,
 	sockaddr_u *		baddr
 	)
 {
@@ -2206,7 +2206,7 @@ enable_broadcast(
  */
 static bool
 socket_broadcast_enable(
-	struct interface *	iface,
+	endpt *	iface,
 	SOCKET			fd,
 	sockaddr_u *		baddr
 	)
@@ -2240,7 +2240,7 @@ socket_broadcast_enable(
  */
 static bool
 socket_broadcast_disable(
-	struct interface *	iface,
+	endpt *	iface,
 	sockaddr_u *		baddr
 	)
 {
@@ -2305,7 +2305,7 @@ addr_ismulticast(
  */
 void
 enable_multicast_if(
-	struct interface *	iface,
+	endpt *	iface,
 	sockaddr_u *		maddr
 	)
 {
@@ -2456,7 +2456,7 @@ socket_multicast_enable(
 #ifdef MCAST
 static bool
 socket_multicast_disable(
-	struct interface *	iface,
+	endpt *	iface,
 	sockaddr_u *		maddr
 	)
 {
@@ -2536,7 +2536,7 @@ void
 io_setbclient(void)
 {
 #ifdef OPEN_BCAST_SOCKET
-	struct interface *	interf;
+	endpt *	interf;
 	int			nif;
 
 	nif = 0;
@@ -2984,7 +2984,7 @@ open_socket(
 void
 sendpkt(
 	sockaddr_u *		dest,
-	struct interface *	ep,
+	endpt *	ep,
 	int			ttl,
 	void *			pkt,
 	int			len
@@ -3275,7 +3275,7 @@ fetch_timestamp(
 static inline int
 read_network_packet(
 	SOCKET			fd,
-	struct interface *	itf,
+	endpt *	itf,
 	l_fp			ts
 	)
 {
@@ -4288,7 +4288,7 @@ delete_interface_from_list(
 }
 
 
-static struct interface *
+static endpt *
 find_addr_in_list(
 	sockaddr_u *addr
 	)


=====================================
ntpd/ntp_proto.c
=====================================
--- a/ntpd/ntp_proto.c
+++ b/ntpd/ntp_proto.c
@@ -2447,7 +2447,7 @@ pool_xmit(
 	struct pkt		xpkt;	/* transmit packet structure */
 	struct addrinfo		hints;
 	int			rc;
-	struct interface *	lcladr;
+	endpt *			lcladr;
 	sockaddr_u *		rmtadr;
 	int			restrict_mask;
 	struct peer *		p;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/8e8ceffc5a11acd65e3fd0fb037766360f2abd3e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161019/9cc210ba/attachment.html>


More information about the vc mailing list