Commit fc324aca authored by Robert Sprowson's avatar Robert Sprowson Committed by ROOL
Browse files

Remove compile time COMPAT_INET4 support

The only part of !Boot which is TCPIPLibs related is BootVars. However, BootVars is run before we get chance to load a newer Internet module, so must run time select which to support.
Fortunately the member wanted from the returned union from socketioctl is in the same place in both BSD4.3 and BSD4.4 so all that's needed is to select the appropriate command.
Also, BootVar's local makefile rewritten to use shared makefiles.
parent 0ba9b446
......@@ -28,7 +28,6 @@ include StdTools
include StdRules
include AppLibs
CDEFINES += -DCOMPAT_INET4
CINCLUDES += -ITCPIPLibs:,C:,OSLib:
CFLAGS += -Wp
......@@ -243,7 +242,7 @@ ${COMPONENT}.TmpRun: ${LDIR}.!Run
Utils.BootVars: Source.BootVars.c.main
${CC} ${CFLAGS} -o Source.BootVars.o.main Source.BootVars.c.main
${LD} ${LDFLAGS} -o $@ Source.BootVars.o.main C:RMVersion.o.RMVersion ${SOCK4LIB} ${CLIB}
${LD} ${LDFLAGS} -o $@ Source.BootVars.o.main C:RMVersion.o.RMVersion ${SOCK5LIB} ${CLIB}
${SQZ} $@
Library.Do: Source.Do.Source.Do
......
......@@ -14,58 +14,15 @@
#
# Makefile for BootVars component
#
# Re-written to be more useful by SAR, 3rd Oct 2002
COMPONENT ?= BootVars
COMPONENT = BootVars
TARGET ?= ${COMPONENT}
ABS = abs.${TARGET}
INSTTYPE = tool
OBJS = main
CINCLUDES = ${TCPIPINC}
CFLAGS += ${C_NOWARN_NON_ANSI_INCLUDES}
LIBS = ${SOCK5LIB} ${RMVSN}
MKDIR = do mkdir -p
CC = cc
LD = link
CP = copy
WIPE = wipe
include CApp
CFLAGS = -ITCPIPLibs:,C:,C:RMVersion -fafh -wp -DCOMPAT_INET4
CPFLAGS = ~cfr~v
WFLAGS = ~c~v
LIBS = C:RMVersion.o.RMVersion TCPIPLibs:o.socklib CLib:o.Stubs
OBJS = o.main
#
# Rule patterns:
#
.SUFFIXES: .h .c .o
.c.o:; ${CC} ${CFLAGS} ${THROWBACK} -depend !Depend -c ${ZM} -ff -o $@ $<
#
# Main rules:
#
clean:
ifthere o then ${WIPE} o ${WFLAGS}
ifthere l then ${WIPE} l ${WFLAGS}
ifthere abs then ${WIPE} abs ${WFLAGS}
@echo ${COMPONENT}: cleaned
dirs:
${MKDIR} o
${MKDIR} abs
all: ${COMPONENT}
install: ${COMPONENT}
${MKDIR} ${INSTDIR}
${CP} ${ABS} ${INSTDIR}.${TARGET} ${CPFLAGS}
@echo ${COMPONENT}: installed (ram)
#
# Static dependencies:
#
${COMPONENT}: ${OBJS} dirs
${LD} -output ${ABS} ${OBJS} ${LIBS}
@echo ${COMPONENT}: built
#------------------------------------------------------------------------
# Dynamic dependencies:
......@@ -14,4 +14,4 @@
|
Dir <Obey$Dir>
amu_machine clean
StripDepnd Makefile
stripdepnd
......@@ -114,8 +114,8 @@ static int Module_Version (char *module_name)
return version >> 8;
}
/* Calls the Internet module to discover the given interfaces current flag settings and
* returns them
/* Calls the Internet module to discover the given interface's current flag settings.
* This socketioctl is common for all extant Internet modules.
*/
static short bootvars_read_if_flags(int s, const char *name)
{
......@@ -130,15 +130,34 @@ static short bootvars_read_if_flags(int s, const char *name)
}
}
/* Calls the Internet module to discover the given interface's current address.
* Note that as BootVars runs before we have chance to softload a newer Internet module,
* this must run time select the socketioctl call pre-Internet 5.
*/
static u_long bootvars_read_if_address(int s, const char *name)
{
#define SIOCGIFADDR_INET4 _IOWR('i', 13, struct ifreq) /* Old style 'get ifnet address' */
struct ifreq ifr;
int inet_version;
unsigned long cmd;
inet_version = socketversion();
if (inet_version < 0)
inet_version = 407; /* Socket_Version absent before this */
if (inet_version >= 500)
cmd = SIOCGIFADDR;
else
cmd = SIOCGIFADDR_INET4;
(void) strncpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
if (socketioctl(s, SIOCGIFADDR, &ifr)<0) {
if (socketioctl(s, cmd, &ifr)<0) {
return 0UL;
}
else {
/* The union in the returned ifreq is layed out such that the
* s_addr member extracted is in the same place in each.
*/
return ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment