From: Marco d'Itri Date: Fri, 2 Jun 2017 11:10:13 +0200 Subject: [PATCH] disable unneeded code in the pppoatm plugin This patch halves the size of the PPPoA plugin by disabling features which are never used with normal DSL connections (i.e. parsing of QoS configuration directives and DNS resolution of VP/VC addresses). It is especially useful for install images and embedded systems. A next step could be removing text2qos.c, text2atm.c, misc.c and ans.c and encourage users interested in the complete features to link the plugin with the real libatm. I really doubt anybody cares, anyway. --- pppd/plugins/pppoatm/Makefile.linux | 4 ++++ pppd/plugins/pppoatm/pppoatm.c | 4 ++++ pppd/plugins/pppoatm/text2atm.c | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/pppd/plugins/pppoatm/Makefile.linux b/pppd/plugins/pppoatm/Makefile.linux index 002603c6cbef..76d81aced70a 100644 --- a/pppd/plugins/pppoatm/Makefile.linux +++ b/pppd/plugins/pppoatm/Makefile.linux @@ -25,9 +25,13 @@ ifdef HAVE_LIBATM LIBS := -latm else CFLAGS += -I. +PLUGIN_OBJS += text2atm.o +ifdef USE_FULL_ATM_RESOLVER +CFLAGS += -DUSE_FULL_ATM_RESOLVER PLUGIN_OBJS += text2qos.o text2atm.o misc.o ans.o LIBS := -lresolv endif +endif #********* all: $(PLUGIN) diff --git a/pppd/plugins/pppoatm/pppoatm.c b/pppd/plugins/pppoatm/pppoatm.c index d693350bc473..a7560e9fb0c6 100644 --- a/pppd/plugins/pppoatm/pppoatm.c +++ b/pppd/plugins/pppoatm/pppoatm.c @@ -142,8 +142,12 @@ static int connect_pppoatm(void) qos.txtp.traffic_class = qos.rxtp.traffic_class = ATM_UBR; /* TODO: support simplified QoS setting */ if (qosstr != NULL) +#ifdef USE_FULL_ATM_RESOLVER if (text2qos(qosstr, &qos, 0)) fatal("Can't parse QoS: \"%s\""); +#else + fatal("qos support has not been compiled in"); +#endif qos.txtp.max_sdu = lcp_allowoptions[0].mru + pppoatm_overhead(); qos.rxtp.max_sdu = lcp_wantoptions[0].mru + pppoatm_overhead(); qos.aal = ATM_AAL5; diff --git a/pppd/plugins/pppoatm/text2atm.c b/pppd/plugins/pppoatm/text2atm.c index c283b52b4120..f7fa8cac3a6f 100644 --- a/pppd/plugins/pppoatm/text2atm.c +++ b/pppd/plugins/pppoatm/text2atm.c @@ -72,6 +72,7 @@ static int try_pvc(const char *text,struct sockaddr_atmpvc *addr,int flags) } +#ifdef USE_FULL_ATM_RESOLVER static int do_try_nsap(const char *text,struct sockaddr_atmsvc *addr,int flags) { const char *walk; @@ -221,6 +222,7 @@ static int try_name(const char *text,struct sockaddr *addr,int length, (void) fclose(file); return result; } +#endif int text2atm(const char *text,struct sockaddr *addr,int length,int flags) @@ -234,6 +236,7 @@ int text2atm(const char *text,struct sockaddr *addr,int length,int flags) result = try_pvc(text,(struct sockaddr_atmpvc *) addr,flags); if (result != TRY_OTHER) return result; } +#ifdef USE_FULL_ATM_RESOLVER if ((flags & T2A_SVC) && length >= sizeof(struct sockaddr_atmsvc)) { result = try_nsap(text,(struct sockaddr_atmsvc *) addr,flags); if (result != TRY_OTHER) return result; @@ -245,5 +248,6 @@ int text2atm(const char *text,struct sockaddr *addr,int length,int flags) if (result == TRY_OTHER && !(flags & T2A_LOCAL)) result = ans_byname(text,(struct sockaddr_atmsvc *) addr,length,flags); if (result != TRY_OTHER) return result; +#endif return -1; }