lwipv6-1.5a/0000755000175000017500000000000011671615126012031 5ustar renzorenzolwipv6-1.5a/LWIPv6_Programming_Guide0000644000175000017500000004363211671615010016462 0ustar renzorenzoLWIPv6 programming guide ======================== The most recent version of this document can be found on the VirtualSquare wiki: http://wiki.virtualsquare.org/index.php/LWIPv6_programming_guide This file has been updated on Sept. 1, 2011. This is a short guide of the LWIPv6 library. It is intended for programmers wishing to write programs using LWIPv6. LWIPv6 implements an entire LWIPv4/v6 stack as a library, thus when a program uses LWIPv6 it can interoperate using its own TCP-IP stack (or even multiple LWIPV6 stacks, the library supports many stacks at the same time). LWIPv6 stacks communicate using three different types of interfaces: * tap: (access to /dev/net/tun required) it uses a point to point layer 2 (ethernet) virtual interface with the hosting machine; * tun: (access to /dev/net/tun required) similar fo the previous one, it uses a point to point layer 3 (IP) virtual connection; * vde: it gets connected to a Virtual Distributed Ethernet switch. Contents -------- * 1 Loading and Linking LWIPV6 * 2 How to start a stack (or several stacks) * 3 How to use a Hybrid Stack * 4 How to define interfaces, addresses, routes * 5 Remember to turn on the interfaces! * 6 How to use a stack (or several stacks) * 7 A complete example * 8 A different model for asynchrony: event_subscribe * 9 List of most relevant functions provided by LWIPv6 * 10 Slirp 1. Loading and Linking LWIPV6 ----------------------------- A program can use LWIPv6 in three different ways. * By linking statically the library. gcc -o static static.c /usr/local/lib/liblwipv6.a -lpthread -ldl in this case the constructor/destructor must be explicitely called in the code: main(int argc,char *argv[]) { lwip_init(); /* core of the application */ lwip_fini(); } * Using a dynamic linking. gcc -o dynamic dynamic.c -llwipv6 -lpthread -ldl lwip_init, lwip_fini are automagically called when the library is loaded. Do not call them in the code. * Dynamically loading the dynamic library. The code appears like this: void *handle ... handle=loadlwipv6dl(); .... /* handle==NULL in case of errors; to unload the library use: dlclose(handle) */ This application should be compiled in this way: gcc -o dynload dynload.c -lpthread -ldl The advantage of this approach is the lack of direct dependence (requirement) for the lwipv6 library. It is possible to write programs able to run both on systems where lwipv6 is installed and on system where lwipv6 does not exist. The choice of features can be done at run time. 2. How to start a stack (or several stacks) ------------------------------------------- A stack descriptor is defined as a (opaque) stucture: struct stack *stackd; The program can start a stack by calling: stackd=lwip_stack_new(); If something goes wrong, lwip_stack_new returns NULL. A program can call lwip_stack_new several times to define several TCP-IP stacks. It is also possible to shut down a stack in this way: lwip_stack_free(stackd); 3. How to use a Hybrid Stack ---------------------------- LWIPv6 is a Hybrid stack. In a raw and intuitive definition, it means that it has only one packet engine (lwipv6) and it is backward compatible with IPv4 using some exceptions in the code where the management is different. LWIPv6 internal engine uses exclusively IPv6 addresses. All the calls to set up the addresses and routes use addresses defined as: struct ip_addr { uint32_t addr[4]; }; This data structure contains an IPv6 address. IPv4 address are stored as IPv4 mapped address, i.e. in the following form: the first 80 bits set to zero, the next 16 set to one, while the last 32 bits are the IPv4 address. There are macro in the lwipv6 include file to help programmers to define IPv4 and IPv6 addresses and masks. IP6_ADDR(addr,0x2001,0x760,0x0,0x0,0x0,0x0,0x0,0x1) defines addr as 2001:760::1. IP6ADDR can be used both for address and masks, e.g. IP6_ADDR(mask,0xffff,0xffff,0xffff,0xffff,0x0,0x0,0x0,0x0) is a /64 mask. For IPV4 there are two different macros: IP64_ADDR(addr4,192,168,1,1); IP64_MASKADDR(mask4,255,255,255,0); define addr4 e mask4 the IPv4 mapped adress 192.168.1.1 and a /24 mask (255.255.255.0) respectively. 4. How to define interfaces, addresses, routes ---------------------------------------------- Once a stack has been created, it is useless until it has a non trivial interface. The loopback lo0 interface is the only one automatically defined in a new stack. struct netif *lwip_vdeif_add(struct stack *stack, void *arg); struct netif *lwip_tapif_add(struct stack *stack, void *arg); struct netif *lwip_tunif_add(struct stack *stack, void *arg); struct netif *lwip_slirpif_add(struct stack *stack, void *arg); The four functions above define new interfaces. For tun and tap interfaces, the argument is a string that will be used as the name of the virtual interface. lwip_vdeif_add argument is the path of the vde_switch. struct netif *tunnif,*vdenif,*vde2nif; tunnif=lwip_tunif_add(stackd,"tun4"); vdenif=lwip_tunif_add(stackd,"/var/run/vde.ctl"); vde2nif=lwip_tunif_add(stackd,"/var/run/vde.ctl[4]"); In this example three interfaces get added to the stack defined by stackd. The first is the tun interface named tun4, the second a vde connection to a switch, the third another connection to the port #4 to the same switch. In fact the square brackets syntax is commonly used in vde to indicate a specfic port of a switch. Interfaces must be assigned TCP-IP addresses to communicate. (notable exception slirpif). int lwip_add_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask); int lwip_del_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask); for example the following chunk of code sets the address 192.168.1.1/24 for vdenif. struct ip_addr addr4, mask4; IP64_ADDR(&addr4,192,168,1,1); IP64_MASKADDR(&mask4,255,255,255,0); lwip_add_addr(vdenif,&addr4,&mask4); An interface can have several IPv4 and IPv6 addresses. IPv6 supports stateless address autoconfiguration. In a similar manner it is possible to define routes. int lwip_add_route(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags); int lwip_del_route(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags); addr/netmask is the destination address for the route. nexthop is the next hop destination address and netif is the network interface where the packet must be dispatched. To define a default route, use IPADDR_ANY both for address and for netmask, e.g. struct ip_addr gwaddr4; IP64_ADDR(&gwaddr4,192,168,1,254); lwip_add_route(stackd, IPADDR_ANY, IPADDR_ANY, &gwaddr4, vdenif, 0); defines the default route to be 192.168.1.254 on interface vdenif. 5. Remember to turn on the interfaces! -------------------------------------- All the interfaces added by lwip_vdeif_add, lwip_tunif_add or lwip_tapif_add are disabled upon creation. lwip_ifup turns on an interface, lwip_ifdown turns it off. e.g. lwip_ifup(vdeif); Remember to turn on the interfaces otherwise the stack won't work! 6. How to use a stack (or several stacks) -------------------------------------- lwip_msocket is similar to the msocket call defined by the multiple stack exstension of the Berkeley socket API definition (msockets). The sole difference between the signature of msocket and lwip_socket is that the socket decriptor gets used instead of the pathname of the stack special file. int lwip_msocket(struct stack *stack, int domain, int type, int protocol); For example, a TCP (V4) socket on the lwip stack stackd gets created by the following call. fd=lwip_msocket(stackd, AF_INET, SOCK_STREAM, 0); fd can be used in Berkeley Sockets API like calls: lwip_bind, lwip_connect, lwip_accept, lwip_recv, lwip_send ... that correspond to bind, accept, recv, send, etc. "sockaddr" parameters (like in bind, connect, etc) use the standard definitions (sockaddr_in, sockaddr_in6). For application using only one stack (or at least one stack at a time) it is possible to define the default stack: lwip_stack_set(stackd); If the default stack has been already defined the call lwip_socket(AF_INET, SOCK_STREAM, 0); implicitely refers to stackd. THe default stack gets defined for the whole library, thus the use of default networks is discouraged on multithreaded applications working on several stack concurrently. 7. A complete example --------------------- The following code is a simple TCP terminal emulator working on LWIPv6. It works like the utility nc used as a TCP client. In fact our utility (say it is named lwipnc): lwipnc 192.168.250.1 9999 has the same behavior of: nc 192.168.250.1 9999 One way to test this program is by starting a tcp server on the other end of the network link: nc -l -p 9999 Here is the code of lwipnc.c: /* Copyright 2008 Renzo Davoli for LWIPv6 documentation. * Licensed inder the GPLv2 * * Minimal terminal emulator on a TCP socket */ #include #include #include #include #include #include #include #include #include #define BUFSIZE 1024 char buf[BUFSIZE]; int main(int argc,char *argv[]) { struct sockaddr_in serv_addr; int fd; void *handle; struct stack *stack; struct netif *nif; struct ip_addr addr; struct ip_addr mask; #ifdef LWIPV6DL /* Run-time load the library (if requested) */ if ((handle=loadlwipv6dl()) == NULL) { perror("LWIP lib not loaded"); exit(-1); } #endif /* define a new stack */ if((stack=lwip_stack_new())==NULL){ perror("Lwipstack not created"); exit(-1); } /* add an interface */ if((nif=lwip_vdeif_add(stack,"/var/run/vde.ctl"))==NULL){ perror("Interface not loaded"); exit(-1); } /* set the local IP address of the interface */ IP64_ADDR(&addr,192,168,250,20); IP64_MASKADDR(&mask,255,255,255,0); lwip_add_addr(nif,&addr,&mask); /* turn on the interface */ lwip_ifup(nif); memset((char *) &serv_addr,0,sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = inet_addr(argv[1]); serv_addr.sin_port = htons(atoi(argv[2])); /* create a TCP lwipv6 socket */ if((fd=lwip_msocket(stack,PF_INET,SOCK_STREAM,0))<0) { perror("Socket opening error"); exit(-1); } /* connect it to the address specified as argv[1] port argv[2] */ if (lwip_connect(fd,(struct sockaddr *)(&serv_addr),sizeof(serv_addr)) < 0) { perror("Socket connecting error"); exit(-1); } while(1) { fd_set rfds; int n; FD_ZERO(&rfds); FD_SET(STDIN_FILENO,&rfds); FD_SET(fd,&rfds); /* wait for input both from stdin and from the socket */ lwip_select(fd+1,&rfds,NULL,NULL,NULL); /* copy data from the socket to stdout */ if(FD_ISSET(fd,&rfds)) { if((n=lwip_read(fd,buf,BUFSIZE)) == 0) exit(0); write(STDOUT_FILENO,buf,n); } /* copy data from stdin to the socket */ if(FD_ISSET(STDIN_FILENO,&rfds)) { if((n=read(STDIN_FILENO,buf,BUFSIZE)) == 0) exit(0); lwip_write(fd,buf,n); } } } Compile it using lwipv6 as a dynamic library in this way: gcc -o lwipnc lwipnc.c -ldl -lpthread -llwipv6 or as a run-time dinamically loaded library in this way: gcc -o lwipnc lwipnc.c -D LWIPV6DL -ldl -lpthread It is possible to run the same example on a tun or on a tap interface just by changing the source code line: if((nif=lwip_vdeif_add(stack,"/var/run/vde.ctl"))==NULL){ into if((nif=lwip_tunif_add(stack,"tun1"))==NULL){ or if((nif=lwip_tapif_add(stack,"tap1"))==NULL){ 8. A different model for asynchrony: event_subscribe ---------------------------------------------------- LWIPv6 provides lwip_select, lwip_pselect, lwip_poll, lwip_ppoll having the same semantics of the correspondent system call (those without the prefix lwip_). These calls are useful when porting applications using the standard Berkeley socket API to LWIPv6. There is however in LWIPv6 another way to deal with asynchronous events generated by the stack: typedef void (*lwipvoidfun)(); int lwip_event_subscribe(void (*cb)(void *), void *arg, int fd, int how); cb is the address of a callback function (or NULL), arg is the argument that will be passed to the callback function, fd is a LWIPv6 file descriptor, how is an event code. how gets the same encoding of events as in poll(2). The return value is a bitmask filled in with the event that actually occured. (The return value always reports a subset of events with respect to those encoded in how). This function has three different meanings: * If cb==NULL and arg==NULL, it tests which events(s) already happened. e.g. rv=lwip_event_subscribe(NULL,NULL,fd,POLLIN); rv is non-zero if there is data to read. * if cb!=NULL LWIPv6 tests which events(s) among those defined in how already happened. If rv==0, i.e. no one of the event happened, it subscribes for a notification. When an event of how happens LWIPv6 calls cb(arg). * If cb==NULL, lwip_event_subscribe checks again to see which event(s) happened. If there is a pending notification request with the same arg, it is cancelled. 9. List of most relevant functions provided by LWIPv6 ----------------------------------------------------- Constructor/destructor: do not call these functions unless you are writing a statically linked program void lwip_init(void); void lwip_fini(void); Define a new stack, terminate an existing stack: struct stack *lwip_stack_new(void); void lwip_stack_free(struct stack *stack); Set/Get the current default stack (for lwip_socket). struct stack *lwip_stack_get(void); void lwip_stack_set(struct stack *stack); Define new interfaces: struct netif *lwip_vdeif_add(struct stack *stack, void *arg); struct netif *lwip_tapif_add(struct stack *stack, void *arg); struct netif *lwip_tunif_add(struct stack *stack, void *arg); struct netif *lwip_slirpif_add(struct stack *stack, void *arg); Add/delete addresses: int lwip_add_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask); int lwip_del_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask); Add/delete routes: int lwip_add_route(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags); int lwip_del_route(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags); Turn the interface up/down: int lwip_ifup(struct netif *netif); int lwip_ifdown(struct netif *netif); LWIPv6 implementation of comm syscalls: int lwip_msocket(struct stack *stack, int domain, int type, int protocol); int lwip_socket(int domain, int type, int protocol); int lwip_bind(int s, struct sockaddr *name, socklen_t namelen); int lwip_connect(int s, struct sockaddr *name, socklen_t namelen); int lwip_listen(int s, int backlog); int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen); int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen); int lwip_send(int s, void *dataptr, int size, unsigned int flags); int lwip_recv(int s, void *mem, int len, unsigned int flags); int lwip_sendto(int s, void *dataptr, int size, unsigned int flags, struct sockaddr *to, socklen_t tolen); int lwip_recvfrom(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen); int lwip_shutdown(int s, int how); int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); int lwip_sendmsg(int fd, const struct msghdr *msg, int flags); int lwip_recvmsg(int fd, struct msghdr *msg, int flags); int lwip_write(int s, void *dataptr, int size); int lwip_read(int s, void *mem, int len); int lwip_writev(int s, struct iovec *vector, int count); int lwip_readv(int s, struct iovec *vector, int count); int lwip_ioctl(int s, long cmd, void *argp); int lwip_close(int s); int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); int lwip_pselect(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, const struct timespec *timeout, const sigset_t *sigmask); int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout); int lwip_ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask); Management of asynchronous events: int lwip_event_subscribe(lwipvoidfun cb, void *arg, int fd, int how); 10. SlirpV6 ----------- LWIPv6 provides slirpV6 support. A slirp interface can have no ip addresses and "forwards" all the packets routed to it as a client of the hosting machine (like slirp). LWIPv6/slirpV6 supports both IPv4 and IPv6. It supports UDP connection tracking, too. The slirp interface appears as a NAT router from LWIP. It is possible to forward specific ports (like port forwarding for NAT): #define SLIRP_LISTEN_UDP 0x1000 #define SLIRP_LISTEN_TCP 0x2000 #define SLIRP_LISTEN_UNIXSTREAM 0x3000 int slirp_listen_add(struct netif *slirpif, struct ip_addr *dest, u16_t destport, void *src, u16_t srcport, int flags); where slirpif is the interface (the return value of lwip_slirpif_add), dest/destport is the lwipv6 address of the target of the forwarding service, while src/srcport is the source address (on the hosting machine). It is possible to forward UDP, TCP ports or convert a UNIX socket on the hosting OS to a tcp port in LWIPv6, depending on the value of flags: SLIRP_LISTEN_UDP, SLIRP_LISTEN_TCP, SLIRP_LISTEN_UNIXSTREAM respectively. The forwarding service for a port can be deleted using the following function. It has the same arguments of slirp_listen_add. int slirp_listen_del(struct netif *slirpif, struct ip_addr *dest, u16_t destport, void *src, u16_t srcport, int flags); lwipv6-1.5a/config.guess0000755000175000017500000012673011671615056014364 0ustar renzorenzo#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011 Free Software Foundation, Inc. timestamp='2011-05-11' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-tilera-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: lwipv6-1.5a/config.h.in0000644000175000017500000001313411671615055014057 0ustar renzorenzo/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_ARPA_INET_H /* Define to 1 if you have the `bzero' function. */ #undef HAVE_BZERO /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `gethostbyname' function. */ #undef HAVE_GETHOSTBYNAME /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the `inet_ntoa' function. */ #undef HAVE_INET_NTOA /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `isascii' function. */ #undef HAVE_ISASCII /* Define to 1 if you have the `pcap' library (-lpcap). */ #undef HAVE_LIBPCAP /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD /* Define to 1 if you have the `util' library (-lutil). */ #undef HAVE_LIBUTIL /* Define to 1 if you have the `vdeplug' library (-lvdeplug). */ #undef HAVE_LIBVDEPLUG /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the header file. */ #undef HAVE_NETINET_IN_H /* Define to 1 if your system has a GNU libc compatible `realloc' function, and to 0 otherwise. */ #undef HAVE_REALLOC /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `socket' function. */ #undef HAVE_SOCKET /* Define to 1 if stdbool.h conforms to C99. */ #undef HAVE_STDBOOL_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SOCKET_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to the type of arg 1 for `select'. */ #undef SELECT_TYPE_ARG1 /* Define to the type of args 2, 3 and 4 for `select'. */ #undef SELECT_TYPE_ARG234 /* Define to the type of arg 5 for `select'. */ #undef SELECT_TYPE_ARG5 /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define for Solaris 2.5.1 so the uint32_t typedef from , , or is not used. If the typedef were allowed, the #define below would cause a syntax error. */ #undef _UINT32_T /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `long int' if does not define. */ #undef off_t /* Define to `int' if does not define. */ #undef pid_t /* Define to rpl_realloc if the replacement function should be used. */ #undef realloc /* Define to `unsigned int' if does not define. */ #undef size_t /* Define to `int' if does not define. */ #undef ssize_t /* Define to the type of an unsigned integer type of width exactly 32 bits if such a type exists and the standard includes do not define it. */ #undef uint32_t /* Define to empty if the keyword `volatile' does not work. Warning: valid code using `volatile' can become incorrect without. Disable with care. */ #undef volatile lwipv6-1.5a/README0000644000175000017500000000436011671615010012704 0ustar renzorenzoLWIPV6a - Light weight IP v 6 (1.4a) =============================== LWIPV6a has been completely rewritten, it is based on LWIPv.1.1.0 (by Adam Dunkels). LWIPV6a includes also the management of PF_PACKET (e.g. ethereal and DHCP user level management). Copyright 2004,...,2011 Renzo Davoli University of Bologna - Italy VirtualSquare Labs: wiki.virtualsquare.org Features ======== * Multi stack support * "Physical" Layer o Virtual interfaces: TUNTAP driver support, VDE driver support. o ARP support * Network Layer o Forwarding over interfaces (IPv4 and IPv6) o Packet fragmentation (IPv4 and IPv6) o NAT support (IPv4 and IPv6) o IPv6: Stateless Address Autoconfiguration, Router Advertising support * Transport Layer o TCP: congestion control, RTT estimation, fast recovery/fast retransmit. o UDP * Berkeley Socket API o Protocol family: PF_INET, PF_INET6, PF_PACKET, PF_NETLINK (partially) o Socket type: SOCK_STREAM, SOCK_DGRAM, SOCK_RAW. * Slirp support License ======= The TCP-IP stack is based on lwip by Adam Dunkels (see README.LICENSE) * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Use LwIPv6a with View-OS project ================================ The lwipv6.so module is ready to be used by um-viewos. An example of configuration script follows: ----------------------------------- ip addr add 192.168.0.22/24 dev vd0 ip addr add 2001:760:202:f000::ff/64 dev vd0 ip route add default via 192.168.0.254 ip -f inet6 route add default via 2001:760:202:f000::1 ip link set vd0 up ----------------------------------- lwipv6-1.5a/install-sh0000755000175000017500000003253711671615056014051 0ustar renzorenzo#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: lwipv6-1.5a/config.sub0000755000175000017500000010460611671615056014025 0ustar renzorenzo#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011 Free Software Foundation, Inc. timestamp='2011-03-23' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile-* | tilegx-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; # This must be matched before tile*. tilegx*) basic_machine=tilegx-unknown os=-linux-gnu ;; tile*) basic_machine=tile-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: lwipv6-1.5a/lwip-contrib/0000755000175000017500000000000011671615111014434 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/0000755000175000017500000000000011671615111015603 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/0000755000175000017500000000000011671615111016566 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/netif/0000755000175000017500000000000011671615111017673 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/netif/vdeif.c0000644000175000017500000003733511671615010021145 0ustar renzorenzo/* This is part of LWIPv6 * * VDE (virtual distributed ethernet) interface for ale4net * (based on tapif interface Adam Dunkels ) * Copyright 2005,2010,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* tapif interface Adam Dunkels * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * */ #include "lwip/opt.h" #include #include #include #include #include #include #include #include #include #include "lwip/debug.h" #include "lwip/def.h" #include "lwip/ip.h" #include "lwip/mem.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include "netif/etharp.h" #ifdef IPv6_AUTO_CONFIGURATION #include "lwip/ip_autoconf.h" #endif #if LWIP_NL #include "lwip/arphdr.h" #endif #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) #include "netif/tcpdump.h" #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ #include #include #include #include #include #include #include struct vdepluglib vdeplug; /*-----------------------------------------------------------------------------------*/ #ifndef VDEIF_DEBUG #define VDEIF_DEBUG DBG_OFF #endif #define IFNAME0 'v' #define IFNAME1 'd' /*-----------------------------------------------------------------------------------*/ static const struct eth_addr ethbroadcast = { {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} }; struct vdeif { struct eth_addr *ethaddr; /* Add whatever per-interface state that is needed here. */ VDECONN *vdefd; VDESTREAM *vdestream; struct netif_fddata *fddata; }; /* Forward declarations. */ static void vdeif_input(struct netif_fddata *fddata, short revents); static void vdeif_stream_input(struct netif_fddata *fddata, short revents); static ssize_t vdeif_streampkt_input(void *opaque, void *buf, size_t count); static err_t vdeif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr); #define BUFSIZE 2048 #define ETH_ALEN 6 /*-----------------------------------------------------------------------------------*/ static void arp_timer(void *arg) { etharp_tmr((struct netif *) arg ); sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, arg); } #define MAXDESCR 128 /*-----------------------------------------------------------------------------------*/ static int low_level_init(struct netif *netif, char *path) { struct vdeif *vdeif; int randaddr; char descr[MAXDESCR+1]; libvdeplug_dynopen(vdeplug); if (!vdeplug.vde_close) return ERR_IF; vdeif = netif->state; randaddr = rand(); /* Obtain MAC address from network interface. */ /* (We just fake an address...) */ vdeif->ethaddr->addr[0] = 0x2; vdeif->ethaddr->addr[1] = 0x2; vdeif->ethaddr->addr[2] = randaddr >> 24; vdeif->ethaddr->addr[3] = randaddr >> 16; vdeif->ethaddr->addr[4] = randaddr >> 8; vdeif->ethaddr->addr[5] = 0x6; /* Do whatever else is needed to initialize interface. */ snprintf(descr, MAXDESCR, "%sLWIPv6 if=vd%c", (getenv("_INSIDE_VIEWOS_MODULE") != NULL) ? "VIEWOS-" : "", netif->num + '0'); if (path==NULL || *path != '-') { vdeif->vdefd=vdeplug.vde_open(path,descr,NULL); vdeif->vdestream=NULL; if (vdeif->vdefd && (vdeif->fddata=netif_addfd(netif, vdeplug.vde_datafd(vdeif->vdefd), vdeif_input, NULL, 0, POLLIN)) != NULL ) return ERR_OK; else return ERR_IF; } else { int fdin; int fdout; if (path[1]==0) { fdin=STDIN_FILENO; fdout=STDOUT_FILENO; } else { /* XXX not supported yet : connect to sockets or fifos */ return ERR_IF; } vdeif->vdefd=NULL; vdeif->vdestream=vdeplug.vdestream_open(netif,fdout,vdeif_streampkt_input,NULL); if (vdeif->vdestream != NULL && (vdeif->fddata=netif_addfd(netif, fdin, vdeif_stream_input, NULL, 0, POLLIN)) != NULL) return ERR_OK; else return ERR_IF; } } /* cleanup: garbage collection */ static err_t vdeif_ctl(struct netif *netif, int request, void *arg) { struct vdeif *vdeif = netif->state; if (vdeif) { switch (request) { case NETIFCTL_CLEANUP: if (vdeif->vdefd) vdeplug.vde_close(vdeif->vdefd); if (vdeif->vdestream) vdeplug.vdestream_close(vdeif->vdestream); /* Unset ARP timeout on this interface */ sys_untimeout((sys_timeout_handler)arp_timer, netif); mem_free(vdeif); } } return ERR_OK; } /*-----------------------------------------------------------------------------------*/ /* * low_level_output(): * * Should do the actual transmission of the packet. The packet is * contained in the pbuf that is passed to the function. This pbuf * might be chained. * */ /*-----------------------------------------------------------------------------------*/ static err_t low_level_output(struct netif *netif, struct pbuf *p) { struct pbuf *q; char buf[1514]; char *bufptr; struct vdeif *vdeif; LWIP_DEBUGF(VDEIF_DEBUG, ("%s: start\n", __func__)); if (p->tot_len > 1514) return ERR_MEM; vdeif = netif->state; /* initiate transfer(); */ bufptr = &buf[0]; for (q = p; q != NULL; q = q->next) { /* Send the data from the pbuf to the interface, one pbuf at a time. The size of the data in each pbuf is kept in the ->len variable. */ /* send data from(q->payload, q->len); */ memcpy(bufptr, q->payload, q->len); bufptr += q->len; } if (vdeif->vdefd) { /* signal that packet should be sent(); */ if (vdeplug.vde_send(vdeif->vdefd, buf, p->tot_len, 0) == -1) { } } else { if (vdeplug.vdestream_send(vdeif->vdestream, buf, p->tot_len) == -1) { } } LWIP_DEBUGF(VDEIF_DEBUG, ("%s: end\n", __func__)); return ERR_OK; } /*-----------------------------------------------------------------------------------*/ /* low_level_pbuf_copy2pbuf */ static inline struct pbuf *low_level_pbuf_copy2pbuf(char *buf, u16_t len) { struct pbuf *p, *q; char *bufptr; /* We allocate a pbuf chain of pbufs from the pool. */ p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); if (p != NULL) { /* We iterate over the pbuf chain until we have read the entire packet into the pbuf. */ bufptr = &buf[0]; for (q = p; q != NULL; q = q->next) { /* Read enough bytes to fill this pbuf in the chain. The available data in the pbuf is given by the q->len variable. */ /* read data into(q->payload, q->len); */ memcpy(q->payload, bufptr, q->len); bufptr += q->len; } /* acknowledge that packet has been read(); */ } else { /* drop packet(); */ fprintf(stderr, "vdeif: dropped packet (pbuf)\n"); } return p; } /*-----------------------------------------------------------------------------------*/ /* * low_level_input(): * * Should allocate a pbuf and transfer the bytes of the incoming * packet from the interface into the pbuf. * */ /*-----------------------------------------------------------------------------------*/ static struct pbuf *low_level_input(struct vdeif *vdeif, u16_t ifflags) { struct pbuf *p; char buf[1514]; u16_t len; LWIP_DEBUGF(VDEIF_DEBUG, ("%s: reading...\n", __func__)); /* Obtain the size of the packet and put it into the "len" variable. */ len = vdeplug.vde_recv(vdeif->vdefd, buf, sizeof(buf), 0); LWIP_DEBUGF(VDEIF_DEBUG, ("%s: read %d bytes (is UP? = %d)\n", __func__, len, ifflags & NETIF_FLAG_UP)); //printf("MACS: %x:%x:%x:%x:%x:%x %x:%x:%x:%x:%x:%x %x\n", //buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], //vdeif->ethaddr->addr[0], vdeif->ethaddr->addr[1], vdeif->ethaddr->addr[2], //vdeif->ethaddr->addr[3], vdeif->ethaddr->addr[4], vdeif->ethaddr->addr[5], //ifflags); if (!(ETH_RECEIVING_RULE(buf, vdeif->ethaddr->addr, ifflags))) { LWIP_DEBUGF(VDEIF_DEBUG, ("%s: RECEIVING_RULE = false\n", __func__)); /*printf("PACKET DROPPED\n"); printf("%x:%x:%x:%x:%x:%x %x:%x:%x:%x:%x:%x %x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], vdeif->ethaddr->addr[0], vdeif->ethaddr->addr[1], vdeif->ethaddr->addr[2], vdeif->ethaddr->addr[3], vdeif->ethaddr->addr[4], vdeif->ethaddr->addr[5], ifflags); */ return NULL; } return low_level_pbuf_copy2pbuf(buf, len); return p; } static struct pbuf *low_level_stream_input(struct vdeif *vdeif, u16_t ifflags, char *buf, u16_t len) { struct pbuf *p; if (!(ETH_RECEIVING_RULE(buf, vdeif->ethaddr->addr, ifflags))) { LWIP_DEBUGF(VDEIF_DEBUG, ("%s: RECEIVING_RULE = false\n", __func__)); /*printf("PACKET DROPPED\n"); printf("%x:%x:%x:%x:%x:%x %x:%x:%x:%x:%x:%x %x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], vdeif->ethaddr->addr[0], vdeif->ethaddr->addr[1], vdeif->ethaddr->addr[2], vdeif->ethaddr->addr[3], vdeif->ethaddr->addr[4], vdeif->ethaddr->addr[5], ifflags); */ return NULL; } return low_level_pbuf_copy2pbuf(buf, len); return p; } /*-----------------------------------------------------------------------------------*/ /* * vdeif_output(): * * This function is called by the TCP/IP stack when an IP packet * should be sent. It calls the function called low_level_output() to * do the actuall transmission of the packet. * */ /*-----------------------------------------------------------------------------------*/ static err_t vdeif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { LWIP_DEBUGF(VDEIF_DEBUG, ("%s: start\n",__func__)); /*printf("vdeif_output %x:%x:%x:%x\n", ipaddr->addr[0], ipaddr->addr[1], ipaddr->addr[2], ipaddr->addr[3]); */ if (!(netif->flags & NETIF_FLAG_UP)) { LWIP_DEBUGF(VDEIF_DEBUG, ("vdeif_output: interface DOWN, discarded\n")); return ERR_OK; } else { LWIP_DEBUGF(VDEIF_DEBUG, ("%s: output.\n",__func__)); return etharp_output(netif, ipaddr, p); } } /*-----------------------------------------------------------------------------------*/ /* vdeif_input_dispatch * dispatch the packet to the upper layers */ static inline void vde_dispatch_input(struct netif *netif, struct pbuf *p) { struct vdeif *vdeif=netif->state; struct eth_hdr *ethhdr; ethhdr = p->payload; /* printf("vdeif_input %x %d\n",htons(ethhdr->type),p->tot_len); */ #ifdef LWIP_PACKET ETH_CHECK_PACKET_IN(netif, p); #endif switch (htons(ethhdr->type)) { #ifdef IPv6 case ETHTYPE_IP6: case ETHTYPE_IP: #else case ETHTYPE_IP: #endif LWIP_DEBUGF(VDEIF_DEBUG, ("vdeif_input: IP packet\n")); etharp_ip_input(netif, p); pbuf_header(p, -14); #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) tcpdump(p); #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ netif->input(p, netif); break; case ETHTYPE_ARP: LWIP_DEBUGF(VDEIF_DEBUG, ("vdeif_input: ARP packet\n")); etharp_arp_input(netif, vdeif->ethaddr, p); break; default: pbuf_free(p); break; } } /*-----------------------------------------------------------------------------------*/ /* * vdeif_input(): * * This function should be called when a packet is ready to be read * from the interface. It uses the function low_level_input() that * should handle the actual reception of bytes from the network * interface. * */ /*-----------------------------------------------------------------------------------*/ static void vdeif_input(struct netif_fddata *fddata, short revents) { struct netif *netif = fddata->netif; struct vdeif *vdeif=netif->state; struct pbuf *p; p = low_level_input(vdeif, netif->flags); if (p == NULL) { LWIP_DEBUGF(VDEIF_DEBUG, ("vdeif_input: low_level_input returned NULL\n")); return; } vde_dispatch_input(netif, p); } static void vdeif_stream_input(struct netif_fddata *fddata, short revents) { struct netif *netif = fddata->netif; struct vdeif *vdeif=netif->state; char buf[1514]; u16_t len; len=read(fddata->fd,buf,1514); vdeplug.vdestream_recv(vdeif->vdestream,buf,len); } static ssize_t vdeif_streampkt_input(void *opaque, void *buf, size_t count) { struct netif *netif=opaque; struct vdeif *vdeif=netif->state; struct pbuf *p; p = low_level_stream_input(vdeif, netif->flags, buf, count); if (p == NULL) { LWIP_DEBUGF(VDEIF_DEBUG, ("vdeif_input: low_level_input returned NULL\n")); return; } vde_dispatch_input(netif, p); return count; } /*-----------------------------------------------------------------------------------*/ /* * vdeif_init(): * * Should be called at the beginning of the program to set up the * network interface. It calls the function low_level_init() to do the * actual setup of the hardware. * */ /*-----------------------------------------------------------------------------------*/ err_t vdeif_init(struct netif * netif) { struct vdeif *vdeif; char *path; vdeif = mem_malloc(sizeof(struct vdeif)); memset(vdeif, 0, sizeof(struct vdeif)); if (!vdeif) return ERR_MEM; path = netif->state; /*state is temporarily used to store the VDE path */ netif->state = vdeif; netif->name[0] = IFNAME0; netif->name[1] = IFNAME1; netif->link_type = NETIF_VDEIF; netif->num=netif_next_num(netif,NETIF_VDEIF); netif->output = vdeif_output; netif->linkoutput = low_level_output; netif->netifctl = vdeif_ctl; netif->mtu = 1500; /* hardware address length */ netif->hwaddr_len = 6; netif->flags |= NETIF_FLAG_BROADCAST; #if LWIP_NL netif->type = ARPHRD_ETHER; #endif vdeif->ethaddr = (struct eth_addr *) &(netif->hwaddr[0]); if (low_level_init(netif, path) < 0) { mem_free(vdeif); return ERR_IF; } etharp_init(); sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, netif); return ERR_OK; } /*-----------------------------------------------------------------------------------*/ //tv.tv_sec = ARP_TMR_INTERVAL / 1000; //tv.tv_usec = (ARP_TMR_INTERVAL % 1000) * 1000; //while (1) { //ret = select(vdeif->fddata + 1, &fdset, NULL, NULL, NULL); //if (tv.tv_sec == 0 && tv.tv_usec == 0) { // etharp_tmr(netif); // tv.tv_sec = ARP_TMR_INTERVAL / 1000; // tv.tv_usec = (ARP_TMR_INTERVAL % 1000) * 1000; //} lwipv6-1.5a/lwip-contrib/ports/unix/netif/slirpif.c0000644000175000017500000001063111671615010021506 0ustar renzorenzo/* This is part of LWIPv6 * * LWIPV6_SLIRP interface * Copyright 2010 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * (some code from tapif interface by Adam Dunkels , BSD) */ #include "lwip/opt.h" #ifdef LWSLIRP #include #include #include #include #include #include #include #include #include "lwip/debug.h" #include "lwip/def.h" #include "lwip/ip.h" #include "lwip/mem.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include "netif/etharp.h" #ifdef IPv6_AUTO_CONFIGURATION #include "lwip/ip_autoconf.h" #endif #if LWIP_NL #include "lwip/arphdr.h" #endif #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) #include "netif/tcpdump.h" #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ #include #include #include #include #include /*-----------------------------------------------------------------------------------*/ #ifndef SLIRPIF_DEBUG #define SLIRPIF_DEBUG DBG_OFF #endif #define IFNAME0 's' #define IFNAME1 'l' /*-----------------------------------------------------------------------------------*/ static const struct eth_addr ethbroadcast = { {0xff, 0xff, 0xff, 0xff, 0xff, 0xff} }; struct slirpif { /* Add whatever per-interface state that is needed here. */ char *path; /* for future msocket extension */ }; /* Forward declarations. */ static err_t slirpif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr); /* ctl: create slirp sockets */ static err_t slirpif_ctl(struct netif *netif, int request, void *arg) { struct slirpif *slirpif = netif->state; if (slirpif) { switch (request) { case NETIFCTL_CLEANUP: if (slirpif->path) mem_free(slirpif->path); mem_free(slirpif); break; case NETIFCTL_SLIRPSOCK_DGRAM: return socket(AF_INET6, SOCK_DGRAM, 0); /* return msocket(slirpif->path, AF_INET6, SOCK_DGARM, 0); */ case NETIFCTL_SLIRPSOCK_STREAM: return socket(AF_INET6, SOCK_STREAM, 0); /* return msocket(slirpif->path, AF_INET6, SOCK_STREAM, 0); */ } return ERR_OK; } } static err_t slirpif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { struct pbuf *r, *q; char *ptr; LWIP_DEBUGF(SLIRPIF_DEBUG, ("%s: start\n",__func__)); /*printf("slirpif_output %x:%x:%x:%x\n", ipaddr->addr[0], ipaddr->addr[1], ipaddr->addr[2], ipaddr->addr[3]); */ if (! (netif->flags & NETIF_FLAG_UP)) { return ERR_OK; } r = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); if (r != NULL) { ptr = r->payload; for(q = p; q != NULL; q = q->next) { memcpy(ptr, q->payload, q->len); ptr += q->len; } netif->input( r, netif ); return ERR_OK; } return ERR_MEM; } /*-----------------------------------------------------------------------------------*/ /* * slirpif_init(): * * Should be called at the beginning of the program to set up the * network interface. It calls the function low_level_init() to do the * actual setup of the hardware. * */ /*-----------------------------------------------------------------------------------*/ err_t slirpif_init(struct netif * netif) { struct slirpif *slirpif; slirpif = mem_malloc(sizeof(struct slirpif)); memset(slirpif, 0, sizeof(struct slirpif)); if (!slirpif) return ERR_MEM; netif->state = slirpif; netif->name[0] = IFNAME0; netif->name[1] = IFNAME1; netif->link_type = NETIF_SLIRPIF; netif->num=netif_next_num(netif,NETIF_SLIRPIF); netif->output = slirpif_output; netif->netifctl = slirpif_ctl; netif->mtu = 65535; /* hardware address length */ netif->hwaddr_len = 6; netif->flags |= NETIF_FLAG_BROADCAST; #if LWIP_NL netif->type = ARPHRD_ETHER; #endif return ERR_OK; } #endif lwipv6-1.5a/lwip-contrib/ports/unix/netif/tunif.c0000644000175000017500000002302311671615010021162 0ustar renzorenzo/* This is part of LWIPv6 * * Copyright 2004,2008,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include #include #include #include #include #include #include #include #include "netif/etharp.h" #include "lwip/debug.h" #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/ip.h" #include "lwip/mem.h" #include "lwip/netif.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include #include #include #define DEVTAP "/dev/net/tun" /*-----------------------------------------------------------------------------------*/ #ifndef TUNIF_DEBUG #define TUNIF_DEBUG DBG_OFF #endif #define IFNAME0 't' #define IFNAME1 'n' /*-----------------------------------------------------------------------------------*/ struct tunif { /* Add whatever per-interface state that is needed here. */ int fd; struct netif_fddata *fddata; }; /* Forward declarations. */ static void tunif_input(struct netif_fddata *fddata, short revents); static err_t tunif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr); /*-----------------------------------------------------------------------------------*/ static int low_level_init(struct netif *netif, char *ifname) { struct tunif *tunif; tunif = netif->state; /* Obtain MAC address from network interface. */ /* Do whatever else is needed to initialize interface. */ tunif->fd = open(DEVTAP, O_RDWR); LWIP_DEBUGF(TUNIF_DEBUG, ("tunif_init: fd %d\n", tunif->fd)); if (tunif->fd == -1) { perror("tunif_init"); return ERR_IF; } { struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TUN|IFF_NO_PI; strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); if (ioctl(tunif->fd, TUNSETIFF, (void *) &ifr) < 0) { perror("tunif_init: DEVTUN ioctl TUNSETIFF"); return ERR_IF; } } if ((tunif->fddata=netif_addfd(netif, tunif->fd, tunif_input, NULL, 0, POLLIN)) == NULL) return ERR_IF; else return ERR_OK; } /*-----------------------------------------------------------------------------------*/ /* * low_level_output(): * * Should do the actual transmission of the packet. The packet is * contained in the pbuf that is passed to the function. This pbuf * might be chained. * */ /*-----------------------------------------------------------------------------------*/ static err_t low_level_output(struct tunif *tunif, struct pbuf *p) { struct pbuf *q; char buf[1500]; char *bufptr; /* initiate transfer(); */ bufptr = &buf[0]; for(q = p; q != NULL; q = q->next) { /* Send the data from the pbuf to the interface, one pbuf at a time. The size of the data in each pbuf is kept in the ->len variable. */ /* send data from(q->payload, q->len); */ bcopy(q->payload, bufptr, q->len); bufptr += q->len; } /* signal that packet should be sent(); */ if (write(tunif->fd, buf, p->tot_len) == -1) { perror("tunif: write"); } return ERR_OK; } /*-----------------------------------------------------------------------------------*/ /* * low_level_input(): * * Should allocate a pbuf and transfer the bytes of the incoming * packet from the interface into the pbuf. * */ /*-----------------------------------------------------------------------------------*/ static struct pbuf * low_level_input(struct tunif *tunif,u16_t ifflags) { struct pbuf *p, *q; u16_t len; char buf[1500]; char *bufptr; /* Obtain the size of the packet and put it into the "len" variable. */ len = read(tunif->fd, buf, sizeof(buf)); if (! (ifflags & NETIF_FLAG_UP)) { LWIP_DEBUGF(TUNIF_DEBUG, ("tunif_output: interface DOWN, discarded\n")); return NULL; } /* We allocate a pbuf chain of pbufs from the pool. */ p = pbuf_alloc(PBUF_LINK, len, PBUF_POOL); if (p != NULL) { /* We iterate over the pbuf chain until we have read the entire packet into the pbuf. */ bufptr = &buf[0]; for(q = p; q != NULL; q = q->next) { /* Read enough bytes to fill this pbuf in the chain. The available data in the pbuf is given by the q->len variable. */ /* read data into(q->payload, q->len); */ bcopy(bufptr, q->payload, q->len); bufptr += q->len; } /* acknowledge that packet has been read(); */ } else { /* drop packet(); */ } return p; } /*-----------------------------------------------------------------------------------*/ /* * tunif_output(): * * This function is called by the TCP/IP stack when an IP packet * should be sent. It calls the function called low_level_output() to * do the actuall transmission of the packet. * */ /*-----------------------------------------------------------------------------------*/ static err_t tunif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { struct tunif *tunif; tunif = netif->state; if (! (netif->flags & NETIF_FLAG_UP)) { LWIP_DEBUGF(TUNIF_DEBUG, ("tunif_output: interface DOWN, discarded\n")); return ERR_OK; } else return low_level_output(tunif, p); } /*-----------------------------------------------------------------------------------*/ /* * tunif_input(): * * This function should be called when a packet is ready to be read * from the interface. It uses the function low_level_input() that * should handle the actual reception of bytes from the network * interface. * */ /*-----------------------------------------------------------------------------------*/ static void tunif_input(struct netif_fddata *fddata, short revents) { struct netif *netif = fddata->netif; struct tunif *tunif; struct pbuf *p; tunif = netif->state; p = low_level_input(tunif,netif->flags); if (p == NULL) { LWIP_DEBUGF(TUNIF_DEBUG, ("tunif_input: low_level_input returned NULL\n")); return; } netif->input(p, netif); } /* cleanup: garbage collection */ static err_t tunif_ctl(struct netif *netif, int request, void *arg) { struct tunif *tunif = netif->state; if (tunif) { switch (request) { case NETIFCTL_CLEANUP: close(tunif->fd); mem_free(tunif); } } return ERR_OK; } /*-----------------------------------------------------------------------------------*/ /* * tunif_init(): * * Should be called at the beginning of the program to set up the * network interface. It calls the function low_level_init() to do the * actual setup of the hardware. * */ /*-----------------------------------------------------------------------------------*/ err_t tunif_init(struct netif *netif) { struct tunif *tunif; char *ifname; tunif = mem_malloc(sizeof(struct tunif)); if (!tunif) return ERR_MEM; ifname = netif->state; /*state is temporarily used to store the if name */ netif->state = tunif; netif->name[0] = IFNAME0; netif->name[1] = IFNAME1; netif->link_type = NETIF_TUNIF; netif->num=netif_next_num(netif,NETIF_TUNIF); netif->output = tunif_output; netif->netifctl = tunif_ctl; netif->mtu = 1500; netif->hwaddr_len = 0; #if LWIP_NL netif->type = ARPHRD_NONE; #endif if (low_level_init(netif,ifname) < 0) { mem_free(tunif); return ERR_IF; } return ERR_OK; } /*-----------------------------------------------------------------------------------*/ lwipv6-1.5a/lwip-contrib/ports/unix/netif/tapif.c0000644000175000017500000002627311671615010021152 0ustar renzorenzo/* This is part of LWIPv6 * * tap interface for ale4net * Copyright 2005,2010,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include #include #include #include #include #include #include #include #include "lwip/debug.h" #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/ip.h" #include "lwip/mem.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include "netif/etharp.h" #if LWIP_NL #include "lwip/arphdr.h" #endif #ifdef IPv6_AUTO_CONFIGURATION #include "lwip/ip_autoconf.h" #endif #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) #include "netif/tcpdump.h" #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ #include #include #include #define DEVTAP "/dev/net/tun" /*-----------------------------------------------------------------------------------*/ #ifndef TAPIF_DEBUG #define TAPIF_DEBUG DBG_OFF #endif #define IFNAME0 't' #define IFNAME1 'p' /*-----------------------------------------------------------------------------------*/ static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}; struct tapif { struct eth_addr *ethaddr; /* Add whatever per-interface state that is needed here. */ int fd; struct netif_fddata *fddata; }; /* Forward declarations. */ static void tapif_input(struct netif_fddata *fddata, short revents); static err_t tapif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr); /*-----------------------------------------------------------------------------------*/ static void arp_timer(void *arg) { etharp_tmr((struct netif *) arg ); sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, arg); } /*-----------------------------------------------------------------------------------*/ static int low_level_init(struct netif *netif, char *ifname) { struct tapif *tapif; tapif = netif->state; /* Obtain MAC address from network interface. */ /* (We just fake an address...) */ tapif->ethaddr->addr[0] = 0x2; tapif->ethaddr->addr[1] = 0x2; tapif->ethaddr->addr[2] = 0x3; tapif->ethaddr->addr[3] = 0x4; tapif->ethaddr->addr[4] = 0x5 + netif->num; tapif->ethaddr->addr[5] = 0x6; /* Do whatever else is needed to initialize interface. */ tapif->fd = open(DEVTAP, O_RDWR); LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_init: fd %d\n", tapif->fd)); if(tapif->fd == -1) { perror("tapif_init: try running \"modprobe tun\" or rebuilding your kernel with CONFIG_TUN; cannot open "DEVTAP); return ERR_IF; } { struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); ifr.ifr_flags = IFF_TAP|IFF_NO_PI; if (ifname != NULL) strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name) - 1); if (ioctl(tapif->fd, TUNSETIFF, (void *) &ifr) < 0) { perror("tapif_init: DEVTAP ioctl TUNSETIFF"); return ERR_IF; } } if ((tapif->fddata=netif_addfd(netif, tapif->fd, tapif_input, NULL, 0, POLLIN)) == NULL) return ERR_IF; else return ERR_OK; } /* cleanup: garbage collection */ static err_t tapif_ctl(struct netif *netif, int request, void *arg) { struct tapif *tapif = netif->state; if (tapif) { switch (request) { case NETIFCTL_CLEANUP: close(tapif->fd); /* Unset ARP timeout on this interface */ sys_untimeout((sys_timeout_handler)arp_timer, netif); mem_free(tapif); } } return ERR_OK; } /*-----------------------------------------------------------------------------------*/ /* * low_level_output(): * * Should do the actual transmission of the packet. The packet is * contained in the pbuf that is passed to the function. This pbuf * might be chained. * */ /*-----------------------------------------------------------------------------------*/ static err_t low_level_output(struct netif *netif, struct pbuf *p) { struct pbuf *q; char buf[1514]; char *bufptr; struct tapif *tapif; tapif = netif->state; /* initiate transfer(); */ bufptr = &buf[0]; for(q = p; q != NULL; q = q->next) { //printf("%s: q->len=%d tot_len=%d\n", __func__, q->len, p->tot_len); /* Send the data from the pbuf to the interface, one pbuf at a time. The size of the data in each pbuf is kept in the ->len variable. */ /* send data from(q->payload, q->len); */ memcpy(bufptr, q->payload, q->len); bufptr += q->len; } /* signal that packet should be sent(); */ if(write(tapif->fd, buf, p->tot_len) == -1) { perror("tapif: write"); } return ERR_OK; } /*-----------------------------------------------------------------------------------*/ /* * low_level_input(): * * Should allocate a pbuf and transfer the bytes of the incoming * packet from the interface into the pbuf. * */ /*-----------------------------------------------------------------------------------*/ static struct pbuf * low_level_input(struct tapif *tapif,u16_t ifflags) { struct pbuf *p, *q; u16_t len; char buf[1514]; char *bufptr; /* Obtain the size of the packet and put it into the "len" variable. */ len = read(tapif->fd, buf, sizeof(buf)); if (!(ETH_RECEIVING_RULE(buf,tapif->ethaddr->addr,ifflags))) { return NULL; } /* We allocate a pbuf chain of pbufs from the pool. */ p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); if(p != NULL) { /* We iterate over the pbuf chain until we have read the entire packet into the pbuf. */ bufptr = &buf[0]; for(q = p; q != NULL; q = q->next) { /* Read enough bytes to fill this pbuf in the chain. The available data in the pbuf is given by the q->len variable. */ /* read data into(q->payload, q->len); */ memcpy(q->payload, bufptr, q->len); bufptr += q->len; } /* acknowledge that packet has been read(); */ } else { /* drop packet(); */ } return p; } /*-----------------------------------------------------------------------------------*/ /* * tapif_output(): * * This function is called by the TCP/IP stack when an IP packet * should be sent. It calls the function called low_level_output() to * do the actuall transmission of the packet. * */ /*-----------------------------------------------------------------------------------*/ static err_t tapif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { if (! (netif->flags & NETIF_FLAG_UP)) { LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_output: interface DOWN, discarded\n")); return ERR_OK; } else return etharp_output(netif, ipaddr, p); } /*-----------------------------------------------------------------------------------*/ /* * tapif_input(): * * This function should be called when a packet is ready to be read * from the interface. It uses the function low_level_input() that * should handle the actual reception of bytes from the network * interface. * */ /*-----------------------------------------------------------------------------------*/ static void tapif_input(struct netif_fddata *fddata, short revents) { struct netif *netif = fddata->netif; struct tapif *tapif; struct eth_hdr *ethhdr; struct pbuf *p; tapif = netif->state; p = low_level_input(tapif,netif->flags); if(p == NULL) { LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_input: low_level_input returned NULL\n")); return; } ethhdr = p->payload; #ifdef LWIP_PACKET ETH_CHECK_PACKET_IN(netif,p); #endif switch(htons(ethhdr->type)) { #ifdef IPv6 case ETHTYPE_IP6: #endif case ETHTYPE_IP: LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_input: IP packet\n")); etharp_ip_input(netif, p); pbuf_header(p, -14); #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) tcpdump(p); #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ netif->input(p, netif); break; case ETHTYPE_ARP: LWIP_DEBUGF(TAPIF_DEBUG, ("tapif_input: ARP packet\n")); etharp_arp_input(netif, tapif->ethaddr, p); break; default: pbuf_free(p); break; } } /*-----------------------------------------------------------------------------------*/ /* * tapif_init(): * * Should be called at the beginning of the program to set up the * network interface. It calls the function low_level_init() to do the * actual setup of the hardware. * */ /*-----------------------------------------------------------------------------------*/ err_t tapif_init(struct netif *netif) { struct tapif *tapif; char *ifname; tapif = mem_malloc(sizeof(struct tapif)); if (!tapif) return ERR_MEM; ifname = netif->state; /*state is temporarily used to store the if name */ netif->state = tapif; netif->name[0] = IFNAME0; netif->name[1] = IFNAME1; netif->link_type = NETIF_TAPIF; netif->num=netif_next_num(netif,NETIF_TAPIF); netif->output = tapif_output; netif->linkoutput = low_level_output; netif->netifctl = tapif_ctl; netif->mtu = 1500; /* hardware address length */ netif->hwaddr_len = 6; netif->flags|=NETIF_FLAG_BROADCAST; #if LWIP_NL netif->type = ARPHRD_ETHER; #endif tapif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); if (low_level_init(netif, ifname) < 0) { mem_free(tapif); return ERR_IF; } etharp_init(); sys_timeout(ARP_TMR_INTERVAL, (sys_timeout_handler)arp_timer, netif); return ERR_OK; } lwipv6-1.5a/lwip-contrib/ports/unix/sys_arch_pipe.c0000644000175000017500000003251311671615010021564 0ustar renzorenzo/* This is part of LWIPv6 * * Copyright 2004,2008,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* * Wed Apr 17 16:05:29 EDT 2002 (James Roth) * * - Fixed an unlikely sys_thread_new() race condition. * * - Made current_thread() work with threads which where * not created with sys_thread_new(). This includes * the main thread and threads made with pthread_create(). * */ #include "lwip/debug.h" #include #include #include #include #include #include #include #include #include "lwip/sys.h" #include "lwip/opt.h" #include "lwip/stats.h" #define UMAX(a, b) ((a) > (b) ? (a) : (b)) struct sys_mbox { int pipe[2]; }; struct sys_sem { unsigned int c; pthread_cond_t cond; pthread_mutex_t mutex; }; static pthread_mutex_t lwprot_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_t lwprot_thread = (pthread_t) 0xDEAD; static int lwprot_count = 0; static struct sys_sem *sys_sem_new_(u8_t count); static void sys_sem_free_(struct sys_sem *sem); static u32_t cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex, u32_t timeout); /*-----------------------------------------------------------------------------------*/ sys_thread_t sys_thread_new(void (*function)(void *arg), void *arg, int prio) { int code; pthread_t tmp; code = pthread_create(&tmp, NULL, (void *(*)(void *)) function, arg); if (0 == code) { return tmp; } else return -1; } /*-----------------------------------------------------------------------------------*/ struct sys_mbox * sys_mbox_new() { struct sys_mbox *mbox; mbox = mem_malloc(sizeof(struct sys_mbox)); pipe(mbox->pipe); #if SYS_STATS lwip_stats.sys.mbox.used++; if (lwip_stats.sys.mbox.used > lwip_stats.sys.mbox.max) { lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used; } #endif /* SYS_STATS */ return mbox; } /*-----------------------------------------------------------------------------------*/ void sys_mbox_free(struct sys_mbox *mbox) { LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_FREE: mbox %p \n", (void *)mbox )); if (mbox != SYS_MBOX_NULL) { #if SYS_STATS lwip_stats.sys.mbox.used--; #endif /* SYS_STATS */ close (mbox->pipe[0]); close (mbox->pipe[1]); /* LWIP_DEBUGF("sys_mbox_free: mbox 0x%lx\n", mbox); */ mem_free(mbox); } } /*-----------------------------------------------------------------------------------*/ void sys_mbox_post(struct sys_mbox *mbox, void *msg) { LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", (void *)mbox, (void *)msg)); //fprintf(stderr,"sys_mbox_post %p %p %x\n",mbox,msg,(msg != NULL)?*((int *)msg):0); write(mbox->pipe[1],&msg,sizeof(void *)); } /*-----------------------------------------------------------------------------------*/ u32_t sys_arch_mbox_fetch(struct sys_mbox *mbox, void **msg, u32_t timeout) { int fdn; int time; int n; fd_set rds; struct timeval tv; FD_ZERO(&rds); FD_SET(mbox->pipe[0],&rds); //fprintf(stderr,"TIMEOUT %p %p ->%d\n",(void *)mbox,(void *) msg,timeout); do { if (timeout != 0) { tv.tv_sec = timeout/1000; tv.tv_usec = (timeout%1000) * 1000; fdn=select(mbox->pipe[0]+1,&rds,NULL,NULL,&tv); } else { tv.tv_sec=tv.tv_usec=0; fdn=select(mbox->pipe[0]+1,&rds,NULL,NULL,NULL); } } while (fdn < 0 && errno==EINTR); //fprintf(stderr,"FDN %p %d %s %d\n",(void *)mbox,fdn,strerror(errno),FD_ISSET(mbox->pipe[0],&rds)); if (fdn > 0) { if (msg != NULL) n=read(mbox->pipe[0],msg,sizeof(void *)); else n=read(mbox->pipe[0],&fdn,sizeof(void *)); //fprintf(stderr,"sys_mbox_read %p %p %x\n",mbox,(msg==NULL)?NULL:(void *)*msg, (msg==NULL || *msg==NULL)?0:**(int **)msg); if (timeout != 0) time=timeout - (tv.tv_sec * 1000+tv.tv_usec / 1000); else time=0; /***************************/ LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p timeout %d\n", (void *)mbox, (msg==NULL)?NULL:(void *)*msg,time)); } else { time=SYS_ARCH_TIMEOUT; if (msg != NULL) *msg=NULL; LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p TIMEOUT\n", (void *)mbox, (msg==NULL)?NULL:(void *)* msg)); } return time; } /*-----------------------------------------------------------------------------------*/ struct sys_sem * sys_sem_new(u8_t count) { #if SYS_STATS lwip_stats.sys.sem.used++; if (lwip_stats.sys.sem.used > lwip_stats.sys.sem.max) { lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; } #endif /* SYS_STATS */ return sys_sem_new_(count); } /*-----------------------------------------------------------------------------------*/ static struct sys_sem * sys_sem_new_(u8_t count) { struct sys_sem *sem; sem = mem_malloc(sizeof(struct sys_sem)); sem->c = count; pthread_cond_init(&(sem->cond), NULL); pthread_mutex_init(&(sem->mutex), NULL); return sem; } /*-----------------------------------------------------------------------------------*/ static u32_t cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, u32_t timeout) { int tdiff; unsigned long sec, usec; struct timeval rtime1, rtime2; struct timespec ts; struct timezone tz; int retval; if (timeout > 0) { /* Get a timestamp and add the timeout value. */ gettimeofday(&rtime1, &tz); sec = rtime1.tv_sec; usec = rtime1.tv_usec; usec += timeout % 1000 * 1000; sec += (int)(timeout / 1000) + (int)(usec / 1000000); usec = usec % 1000000; ts.tv_nsec = usec * 1000; ts.tv_sec = sec; retval = pthread_cond_timedwait(cond, mutex, &ts); if (retval == ETIMEDOUT) { return SYS_ARCH_TIMEOUT; } else { /* Calculate for how long we waited for the cond. */ gettimeofday(&rtime2, &tz); tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 + (rtime2.tv_usec - rtime1.tv_usec) / 1000; if (tdiff <= 0) { return 0; } return tdiff; } } else { pthread_cond_wait(cond, mutex); return SYS_ARCH_TIMEOUT; } } /*-----------------------------------------------------------------------------------*/ u32_t sys_arch_sem_wait(struct sys_sem *sem, u32_t timeout) { u32_t time = 0; pthread_mutex_lock(&(sem->mutex)); while (sem->c <= 0) { if (timeout > 0) { time = cond_wait(&(sem->cond), &(sem->mutex), timeout); if (time == SYS_ARCH_TIMEOUT) { pthread_mutex_unlock(&(sem->mutex)); return SYS_ARCH_TIMEOUT; } /* pthread_mutex_unlock(&(sem->mutex)); return time; */ } else { cond_wait(&(sem->cond), &(sem->mutex), 0); } } sem->c--; pthread_mutex_unlock(&(sem->mutex)); return time; } /*-----------------------------------------------------------------------------------*/ void sys_sem_signal(struct sys_sem *sem) { pthread_mutex_lock(&(sem->mutex)); sem->c++; if (sem->c > 1) { sem->c = 1; } pthread_cond_broadcast(&(sem->cond)); pthread_mutex_unlock(&(sem->mutex)); } /*-----------------------------------------------------------------------------------*/ void sys_sem_free(struct sys_sem *sem) { if (sem != SYS_SEM_NULL) { #if SYS_STATS lwip_stats.sys.sem.used--; #endif /* SYS_STATS */ sys_sem_free_(sem); } } /*-----------------------------------------------------------------------------------*/ static void sys_sem_free_(struct sys_sem *sem) { pthread_cond_destroy(&(sem->cond)); pthread_mutex_destroy(&(sem->mutex)); mem_free(sem); } /*-----------------------------------------------------------------------------------*/ unsigned long time_now() { struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); return tv.tv_sec; } /*-----------------------------------------------------------------------------------*/ void sys_init() { } /*-----------------------------------------------------------------------------------*/ static pthread_key_t key; static pthread_once_t key_once = PTHREAD_ONCE_INIT; static void del_key(void *ptr) { mem_free(ptr); } static void make_key() { //fprintf(stderr,"new_key %p\n",pthread_self()); (void) pthread_key_create(&key, del_key); } struct sys_timeouts * sys_arch_timeouts(void) { struct sys_timeouts *ptr; (void) pthread_once(&key_once, make_key); if ((ptr = pthread_getspecific(key)) == NULL) { ptr = mem_malloc(sizeof(struct sys_timeouts)); ptr->next=NULL; (void) pthread_setspecific(key, ptr); } //fprintf(stderr,"key %p %p %p\n",pthread_self(), ptr, ptr->next); return ptr; } /*-----------------------------------------------------------------------------------*/ /** sys_prot_t sys_arch_protect(void) This optional function does a "fast" critical region protection and returns the previous protection level. This function is only called during very short critical regions. An embedded system which supports ISR-based drivers might want to implement this function by disabling interrupts. Task-based systems might want to implement this by using a mutex or disabling tasking. This function should support recursive calls from the same task or interrupt. In other words, sys_arch_protect() could be called while already protected. In that case the return value indicates that it is already protected. sys_arch_protect() is only required if your port is supporting an operating system. */ sys_prot_t sys_arch_protect(void) { /* Note that for the UNIX port, we are using a lightweight mutex, and our * own counter (which is locked by the mutex). The return code is not actually * used. */ if (lwprot_thread != pthread_self()) { /* We are locking the mutex where it has not been locked before * * or is being locked by another thread */ pthread_mutex_lock(&lwprot_mutex); lwprot_thread = pthread_self(); lwprot_count = 1; } else /* It is already locked by THIS thread */ lwprot_count++; return 0; } /*-----------------------------------------------------------------------------------*/ /** void sys_arch_unprotect(sys_prot_t pval) This optional function does a "fast" set of critical region protection to the value specified by pval. See the documentation for sys_arch_protect() for more information. This function is only required if your port is supporting an operating system. */ void sys_arch_unprotect(sys_prot_t pval) { if (lwprot_thread == pthread_self()) { if (--lwprot_count == 0) { lwprot_thread = (pthread_t) 0xDEAD; pthread_mutex_unlock(&lwprot_mutex); } } } /*-----------------------------------------------------------------------------------*/ #ifndef MAX_JIFFY_OFFSET #define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) #endif #ifndef HZ #define HZ 100 #endif unsigned long sys_jiffies(void) { struct timeval tv; unsigned long sec = tv.tv_sec; long usec = tv.tv_usec; gettimeofday(&tv,NULL); if (sec >= (MAX_JIFFY_OFFSET / HZ)) return MAX_JIFFY_OFFSET; usec += 1000000L / HZ - 1; usec /= 1000000L / HZ; return HZ * sec + usec; } #if PPP_DEBUG #include void ppp_trace(int level, const char *format, ...) { va_list args; (void)level; va_start(args, format); vprintf(format, args); va_end(args); } #endif lwipv6-1.5a/lwip-contrib/ports/unix/include/0000755000175000017500000000000011671615111020211 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/include/netif/0000755000175000017500000000000011671615111021316 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/include/netif/delif.h0000644000175000017500000000342111671615010022550 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __DELIF_H__ #define __DELIF_H__ #include "lwip/netif.h" #include "lwip/pbuf.h" err_t delif_init(struct netif *netif); err_t delif_init_thread(struct netif *netif); #endif /* __DELIF_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/sio.h0000644000175000017500000000461011671615010022260 0ustar renzorenzo#ifndef SIO_H #define SIO_H #include "lwip/sys.h" #include "lwip/netif.h" #include "netif/fifo.h" /*#include "netif/pppif.h"*/ /* BAUDRATE is defined in sio.c as it is implementation specific */ typedef struct sio_status_t { int fd; fifo_t myfifo; } sio_status_t; /** Baudrates */ typedef enum sioBaudrates { SIO_BAUD_9600, SIO_BAUD_19200, SIO_BAUD_38400, SIO_BAUD_57600, SIO_BAUD_115200 } sioBaudrates; /** * Read a char from incoming data stream, this call blocks until data has arrived * @param siostat siostatus struct, contains sio instance data, given by sio_open * @return char read from input stream */ u8_t sio_recv( sio_status_t * siostat ); /** * Poll for a new character from incoming data stream * @param siostat siostatus struct, contains sio instance data, given by sio_open * @return char read from input stream, or < 0 if no char was available */ s16_t sio_poll(sio_status_t * siostat); /** * Parse incoming characters until a string str is recieved, blocking call * @param str zero terminated string to expect * @param siostat siostatus struct, contains sio instance data, given by sio_open */ void sio_expect_string(u8_t *str, sio_status_t * siostat); /** * Write a char to output data stream * @param c char to write to output stream * @param siostat siostatus struct, contains sio instance data, given by sio_open */ void sio_send( u8_t c, sio_status_t * siostat ); /** * Write a char to output data stream * @param str pointer to a zero terminated string * @param siostat siostatus struct, contains sio instance data, given by sio_open */ void sio_send_string(u8_t *str, sio_status_t * siostat); /** * Flush outbuffer (send everything in buffer now), useful if some layer below is * holding on to data, waitng to fill a buffer * @param siostat siostatus struct, contains sio instance data, given by sio_open */ void sio_flush( sio_status_t * siostat ); /** * Open serial port entry point from serial protocol (slipif, pppif) * @param devnum the device number to use, i.e. ttySx, comx:, etc. there x = devnum * @return siostatus struct, contains sio instance data, use when calling sio functions */ sio_status_t * sio_open( int devnum ); /** * Change baudrate of port, may close and reopen port * @param baud new baudrate * @param siostat siostatus struct, contains sio instance data, given by sio_open */ void sio_change_baud( sioBaudrates baud, sio_status_t * siostat ); #endif lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/tunif.h0000644000175000017500000000334311671615010022615 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __TUNIF_H__ #define __TUNIF_H__ #include "lwip/netif.h" #include "lwip/pbuf.h" err_t tunif_init(struct netif *netif); #endif /* __TUNIF_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/tcpdump.h0000644000175000017500000000336211671615010023145 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __NETIF_TCPDUMP_H__ #define __NETIF_TCPDUMP_H__ #include "lwip/pbuf.h" void tcpdump_init(void); void tcpdump(struct pbuf *p); #endif /* __NETIF_TCPDUMP_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/dropif.h0000644000175000017500000000334711671615010022757 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __DROPIF_H__ #define __DROPIF_H__ #include "lwip/netif.h" #include "lwip/pbuf.h" err_t dropif_init(struct netif *netif); #endif /* __DROPIF_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/pcapif.h0000644000175000017500000000331711671615010022733 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __PCAPIF_H__ #define __PCAPIF_H__ #include "lwip/netif.h" err_t pcapif_init(struct netif *netif); #endif /* __PCAPIF_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/slirpif.h0000644000175000017500000000336711671615010023146 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifdef LWSLIRP #ifndef __SLIRPIF_H__ #define __SLIRPIF_H__ #include "lwip/netif.h" err_t slirpif_init(struct netif *netif); #endif /* __SLIRPIF_H__ */ #endif /* LWSLIRP */ lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/unixif.h0000644000175000017500000000340511671615010022771 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __UNIXIF_H__ #define __UNIXIF_H__ #include "lwip/netif.h" err_t unixif_init_server(struct netif *netif); err_t unixif_init_client(struct netif *netif); #endif /* __UNIXIF_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/tapif.h0000644000175000017500000000331311671615010022570 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __TAPIF_H__ #define __TAPIF_H__ #include "lwip/netif.h" err_t tapif_init(struct netif *netif); #endif /* __TAPIF_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/fifo.h0000644000175000017500000000325011671615010022410 0ustar renzorenzo#ifndef FIFO_H #define FIFO_H #include "lwip/sys.h" /** How many bytes in fifo */ #define FIFOSIZE 2048 /** fifo data structure, this one is passed to all fifo functions */ typedef struct fifo_t { u8_t data[FIFOSIZE+10]; /* data segment, +10 is a hack probably not needed.. FIXME! */ int dataslot; /* index to next char to be read */ int emptyslot; /* index to next empty slot */ int len; /* len probably not needed, may be calculated from dataslot and emptyslot in conjunction with FIFOSIZE */ sys_sem_t sem; /* semaphore protecting simultaneous data manipulation */ sys_sem_t getSem; /* sepaphore used to signal new data if getWaiting is set */ u8_t getWaiting; /* flag used to indicate that fifoget is waiting for data. fifoput is suposed to clear */ /* this flag prior to signaling the getSem semaphore */ } fifo_t; /** * Get a character from fifo * Blocking call. * @param pointer to fifo data structure * @return character read from fifo */ u8_t fifoGet(fifo_t * fifo); /** * Get a character from fifo * Non blocking call. * @param pointer to fifo data structure * @return character read from fifo, or < zero if non was available */ s16_t fifoGetNonBlock(fifo_t * fifo); /** * fifoput is called by the signalhandler when new data has arrived (or some other event is indicated) * fifoput reads directly from the serialport and is thus highly dependent on unix arch at this moment * @param fifo pointer to fifo data structure * @param fd unix file descriptor */ void fifoPut(fifo_t * fifo, int fd); /** * fifoinit initiate fifo * @param fifo pointer to fifo data structure, allocated by the user */ void fifoInit(fifo_t * fifo); #endif lwipv6-1.5a/lwip-contrib/ports/unix/include/netif/vdeif.h0000644000175000017500000000331311671615010022562 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __VDEIF_H__ #define __VDEIF_H__ #include "lwip/netif.h" err_t vdeif_init(struct netif *netif); #endif /* __VDEIF_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/vde.h0000644000175000017500000000021011671615010021127 0ustar renzorenzo#ifndef VDESTDSOCK #define VDESTDSOCK "/var/run/vde.ctl" #define VDETMPSOCK "/tmp/vde.ctl" #endif #define DO_SYSLOG #define VDE_IP_LOG lwipv6-1.5a/lwip-contrib/ports/unix/include/arch/0000755000175000017500000000000011671615111021126 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/include/arch/cc.h0000644000175000017500000000564211671615010021671 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __ARCH_CC_H__ #define __ARCH_CC_H__ /* Include some files for defining library routines */ #include #include /* Define platform endianness */ #ifndef BYTE_ORDER #define BYTE_ORDER LITTLE_ENDIAN #endif /* BYTE_ORDER */ /* Define generic types used in lwIP */ typedef u_int8_t u8_t; typedef int8_t s8_t; typedef u_int16_t u16_t; typedef int16_t s16_t; typedef u_int32_t u32_t; typedef int32_t s32_t; typedef unsigned long mem_ptr_t; /* Compiler hints for packing structures */ #if __GNUC__ >= 4 /* GCC 4.1 doesn't like '__attribute__((packed))' after a field declaration */ #define PACK_STRUCT_FIELD(x) x #define PACK_STRUCT_STRUCT __attribute__((packed)) #define PACK_STRUCT_BEGIN #define PACK_STRUCT_END #else #define PACK_STRUCT_FIELD(x) x __attribute__((packed)) #define PACK_STRUCT_STRUCT __attribute__((packed)) #define PACK_STRUCT_BEGIN #define PACK_STRUCT_END #endif /* __GNUC__ */ #define INLINE __inline__ /* prototypes for printf() and abort() */ #include #include /* Plaform specific diagnostic output */ #define LWIP_PLATFORM_DIAG(x) do {printf x;} while(0) #define LWIP_PLATFORM_ASSERT(x) do {printf("Assertion \"%s\" failed at line %d in %s\n", \ x, __LINE__, __FILE__); fflush(NULL); abort();} while(0) #endif /* __ARCH_CC_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/arch/sys_arch.h0000644000175000017500000000402311671615010023107 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __ARCH_SYS_ARCH_H__ #define __ARCH_SYS_ARCH_H__ #include #include #define SYS_MBOX_NULL NULL #define SYS_SEM_NULL NULL typedef u32_t sys_prot_t; struct sys_sem; typedef struct sys_sem * sys_sem_t; struct sys_mbox; typedef struct sys_mbox *sys_mbox_t; //New management of timeouts 20100728 //struct sys_thread; //typedef struct sys_thread * sys_thread_t; typedef pthread_t sys_thread_t; #endif /* __ARCH_SYS_ARCH_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/arch/perf.h0000644000175000017500000000514411671615010022235 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __ARCH_PERF_H__ #define __ARCH_PERF_H__ #include #ifdef PERF #define PERF_START { \ unsigned long __c1l, __c1h, __c2l, __c2h; \ __asm__(".byte 0x0f, 0x31" : "=a" (__c1l), "=d" (__c1h)) #define PERF_STOP(x) __asm__(".byte 0x0f, 0x31" : "=a" (__c2l), "=d" (__c2h)); \ perf_print(__c1l, __c1h, __c2l, __c2h, x);} /*#define PERF_START do { \ struct tms __perf_start, __perf_end; \ times(&__perf_start) #define PERF_STOP(x) times(&__perf_end); \ perf_print_times(&__perf_start, &__perf_end, x);\ } while(0)*/ #else /* PERF */ #define PERF_START /* null definition */ #define PERF_STOP(x) /* null definition */ #endif /* PERF */ void perf_print(unsigned long c1l, unsigned long c1h, unsigned long c2l, unsigned long c2h, char *key); void perf_print_times(struct tms *start, struct tms *end, char *key); void perf_init(char *fname); #endif /* __ARCH_PERF_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/include/lwipv6.h0000644000175000017500000003043311671615010021612 0ustar renzorenzo/** * @file */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef _LWIPV6_H #define _LWIPV6_H #include #include /* timeval */ #include /* uint32_t */ #include #include #include #include #include #ifndef AF_UNSPEC #define AF_UNSPEC 0 #endif #ifndef PF_UNSPEC #define PF_UNSPEC AF_UNSPEC #endif #ifndef AF_INET #define AF_INET 2 #endif #ifndef PF_INET #define PF_INET AF_INET #endif #ifndef AF_INET6 #define AF_INET6 10 #endif #ifndef PF_INET6 #define PF_INET6 AF_INET6 #endif #ifndef AF_NETLINK #define AF_NETLINK 16 #endif #ifndef PF_NETLINK #define PF_NETLINK AF_NETLINK #endif #ifndef AF_PACKET #define AF_PACKET 17 #endif #ifndef PF_PACKET #define PF_PACKET AF_PACKET #endif struct ip_addr { uint32_t addr[4]; }; #define IP4_ADDRX(ip4ax, a,b,c,d) \ (ip4ax) = htonl(((uint32_t)((a) & 0xff) << 24) | ((uint32_t)((b) & 0xff) << 16) | \ ((uint32_t)((c) & 0xff) << 8) | (uint32_t)((d) & 0xff)) #define IP64_PREFIX (htonl(0xffff)) #define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) ({ \ (ipaddr)->addr[0] = htonl((uint32_t)(((a) & 0xffff) << 16) | ((b) & 0xffff)); \ (ipaddr)->addr[1] = htonl((((c) & 0xffff) << 16) | ((d) & 0xffff)); \ (ipaddr)->addr[2] = htonl((((e) & 0xffff) << 16) | ((f) & 0xffff)); \ (ipaddr)->addr[3] = htonl((((g) & 0xffff) << 16) | ((h) & 0xffff)); } ) #define IP64_ADDR(ipaddr, a,b,c,d) ({ \ (ipaddr)->addr[0] = 0; \ (ipaddr)->addr[1] = 0; \ (ipaddr)->addr[2] = IP64_PREFIX; \ IP4_ADDRX(((ipaddr)->addr[3]),(a),(b),(c),(d)); }) #define IP64_MASKADDR(ipaddr, a,b,c,d) do { \ (ipaddr)->addr[0] = 0xffffffff; \ (ipaddr)->addr[1] = 0xffffffff; \ (ipaddr)->addr[2] = 0xffffffff; \ IP4_ADDRX(((ipaddr)->addr[3]),(a),(b),(c),(d)); } while (0) #define IP_ADDR_IS_V4(ipaddr) \ (((ipaddr)->addr[0] == 0) && \ ((ipaddr)->addr[1] == 0) && \ ((ipaddr)->addr[2] == IP64_PREFIX)) /* if set use IPv6 AUTOCONF */ #define NETIF_FLAG_AUTOCONF 0x800U /* if set this interface supports Router Advertising */ #define NETIF_FLAG_RADV 0x2000U #define NETIF_STD_FLAGS (NETIF_FLAG_AUTOCONF) #define NETIF_ADD_FLAGS (NETIF_FLAG_AUTOCONF | NETIF_FLAG_RADV) /** if set, the interface is configured using DHCP */ #define NETIF_FLAG_DHCP 0x4000U #define NETIF_IFUP_FLAGS (NETIF_FLAG_DHCP) /* netif creation with standard flags */ #define lwip_vdeif_add(S,A) lwip_add_vdeif((S),(A),NETIF_STD_FLAGS) #define lwip_tapif_add(S,A) lwip_add_tapif((S),(A),NETIF_STD_FLAGS) #define lwip_tunif_add(S,A) lwip_add_tunif((S),(A),NETIF_STD_FLAGS) #define lwip_slirpif_add(S,A) lwip_add_slirpif((S),(A),0) #define lwip_ifup(N) lwip_ifup_flags((N),0) #define lwip_ifup_dhcp(N) lwip_ifup_flags((N),NETIF_FLAG_DHCP) #ifndef LWIPV6DL typedef void (*lwipvoidfun)(); extern const struct ip_addr ip_addr_any; #define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any) struct netif; struct sockaddr; struct stack; struct msghdr; /* constructor and destructors are automagically called when lwipv6 * gets loaded/unloaded as a shared library. * lwip_init/lwip_fini are for static linking only */ void lwip_init(void); void lwip_fini(void); void lwip_thread_new(void (* thread)(void *arg), void *arg); /* old interface */ struct stack *lwip_stack_new(void); void lwip_stack_free(struct stack *stack); #define LWIP_STACK_FLAG_FORWARDING 1 #define LWIP_STACK_FLAG_USERFILTER 0x2 #define LWIP_STACK_FLAG_UF_NAT 0x10000 typedef int (* lwip_capfun) (void); /* new api */ struct stack *lwip_add_stack(unsigned long flags); struct stack *lwip_add_stack_cap(unsigned long flags, lwip_capfun capfun); void lwip_del_stack(struct stack *stack); struct stack *lwip_stack_get(void); void lwip_stack_set(struct stack *stack); unsigned long lwip_stack_flags_get(struct stack *stackid); void lwip_stack_flags_set(struct stack *stackid, unsigned long flags); struct netif *lwip_add_vdeif(struct stack *stack, void *arg, int flags); struct netif *lwip_add_tapif(struct stack *stack, void *arg, int flags); struct netif *lwip_add_tunif(struct stack *stack, void *arg, int flags); struct netif *lwip_add_slirpif(struct stack *stack, void *arg, int flags); int lwip_add_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask); int lwip_del_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask); int lwip_add_route(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags); int lwip_del_route(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags); int lwip_ifup_flags(struct netif *netif, int flags); int lwip_ifdown(struct netif *netif); int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int lwip_bind(int s, const struct sockaddr *name, socklen_t namelen); int lwip_shutdown(int s, int how); int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen); int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen); int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); int lwip_close(int s); int lwip_connect(int s, const struct sockaddr *name, socklen_t namelen); int lwip_listen(int s, int backlog); ssize_t lwip_recv(int s, void *mem, int len, unsigned int flags); ssize_t lwip_read(int s, void *mem, int len); ssize_t lwip_recvfrom(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen); ssize_t lwip_send(int s, const void *dataptr, int size, unsigned int flags); ssize_t lwip_sendto(int s, const void *dataptr, int size, unsigned int flags, const struct sockaddr *to, socklen_t tolen); ssize_t lwip_recvmsg(int fd, struct msghdr *msg, int flags); ssize_t lwip_sendmsg(int fd, const struct msghdr *msg, int flags); int lwip_msocket(struct stack *stack, int domain, int type, int protocol); int lwip_socket(int domain, int type, int protocol); ssize_t lwip_write(int s, void *dataptr, int size); int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); int lwip_pselect(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, const struct timespec *timeout, const sigset_t *sigmask); int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout); int lwip_ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask); int lwip_ioctl(int s, long cmd, void *argp); int lwip_fcntl64(int s, int cmd, long arg); int lwip_fcntl(int s, int cmd, long arg); struct iovec; ssize_t lwip_writev(int s, struct iovec *vector, int count); ssize_t lwip_readv(int s, struct iovec *vector, int count); void lwip_radv_load_config(struct stack *stack,FILE *filein); int lwip_radv_load_configfile(struct stack *stack,void *arg); int lwip_event_subscribe(lwipvoidfun cb, void *arg, int fd, int how); /* Allows binding to TCP/UDP sockets below 1024 */ #define LWIP_CAP_NET_BIND_SERVICE 1<<10 /* Allow broadcasting, listen to multicast */ #define LWIP_CAP_NET_BROADCAST 1<<11 /* Allow interface configuration */ #define LWIP_CAP_NET_ADMIN 1<<12 /* Allow use of RAW sockets */ /* Allow use of PACKET sockets */ #define LWIP_CAP_NET_RAW 1<<13 /* add/delete a slirp port forwarding rule. src/srcport is the local address/port (in the native stack) dest/destport is the virtual address/port where all the traffic to src/srcport must be forwarded */ #define SLIRP_LISTEN_UDP 0x1000 #define SLIRP_LISTEN_TCP 0x2000 #define SLIRP_LISTEN_UNIXSTREAM 0x3000 #define SLIRP_LISTEN_TYPEMASK 0x7000 #define SLIRP_LISTEN_ONCE 0x8000 int lwip_slirp_listen_add(struct netif *slirpif, struct ip_addr *dest, int destport, const void *src, int srcport, int flags); int lwip_slirp_listen_del(struct netif *slirpif, struct ip_addr *dest, int destport, const void *src, int srcport, int flags); #else /* Dynamic Loading */ #include struct ip_addr *pip_addr_any; #define IP_ADDR_ANY ((struct ip_addr *)pip_addr_any) struct netif; typedef struct netif *pnetif; typedef struct stack *pstack; typedef pnetif (*pnetiffun)(); typedef pstack (*pstackfun)(); typedef int (*lwiplongfun)(); typedef ssize_t (*lwipssizetfun)(); typedef void (*lwipvoidfun)(); pstackfun lwip_stack_new,lwip_stack_new_cap; lwipvoidfun lwip_stack_free; pstackfun lwip_stack_get; lwipvoidfun lwip_stack_set; lwipvoidfun lwip_thread_new; pnetiffun lwip_add_vdeif, lwip_add_tapif, lwip_add_tunif, lwip_add_slirpif; lwiplongfun lwip_add_addr, lwip_del_addr, lwip_add_route, lwip_del_route, lwip_ifup_flags, lwip_ifdown, lwip_accept, lwip_bind, lwip_shutdown, lwip_getpeername, lwip_getsockname, lwip_getsockopt, lwip_setsockopt, lwip_close, lwip_connect, lwip_listen, lwip_socket, lwip_select, lwip_pselect, lwip_poll, lwip_ppoll, lwip_ioctl, lwip_msocket, lwip_event_subscribe; lwipssizetfun lwip_recv, lwip_read, lwip_recvfrom, lwip_send, lwip_sendto, lwip_recvmsg, lwip_sendmsg, lwip_write, lwip_writev, lwip_readv; /* Added by Diego Billi */ lwiplongfun lwip_radv_load_configfile; static inline void *loadlwipv6dl() { struct lwipname2fun { char *funcname; lwiplongfun *f; } lwiplibtab[] = { {"lwip_stack_new", (lwiplongfun*)&lwip_stack_new}, {"lwip_stack_new_cap", (lwiplongfun*)&lwip_stack_new_cap}, {"lwip_stack_free", (lwiplongfun*)&lwip_stack_free}, {"lwip_stack_get", (lwiplongfun*)&lwip_stack_get}, {"lwip_stack_set", (lwiplongfun*)&lwip_stack_set}, {"lwip_add_addr", &lwip_add_addr}, {"lwip_del_addr", &lwip_del_addr}, {"lwip_add_route", &lwip_add_route}, {"lwip_del_route", &lwip_del_route}, {"lwip_ifup_flags", &lwip_ifup}, {"lwip_ifdown", &lwip_ifdown}, {"lwip_accept", &lwip_accept}, {"lwip_bind", &lwip_bind}, {"lwip_shutdown", &lwip_shutdown}, {"lwip_getpeername", &lwip_getpeername}, {"lwip_getsockname", &lwip_getsockname}, {"lwip_getsockopt", &lwip_getsockopt}, {"lwip_setsockopt", &lwip_setsockopt}, {"lwip_close", &lwip_close}, {"lwip_connect", &lwip_connect}, {"lwip_listen", &lwip_listen}, {"lwip_recv", &lwip_recv}, {"lwip_read", &lwip_read}, {"lwip_recvfrom", &lwip_recvfrom}, {"lwip_send", &lwip_send}, {"lwip_sendto", &lwip_sendto}, {"lwip_recvmsg", &lwip_recvmsg}, {"lwip_sendmsg", &lwip_sendmsg}, {"lwip_socket", &lwip_socket}, {"lwip_write", &lwip_write}, {"lwip_select", &lwip_select}, {"lwip_pselect", &lwip_pselect}, {"lwip_poll", &lwip_poll}, {"lwip_ppoll", &lwip_ppoll}, {"lwip_ioctl", &lwip_ioctl}, {"lwip_readv", &lwip_readv}, {"lwip_writev", &lwip_writev}, {"lwip_msocket", &lwip_msocket}, {"lwip_add_vdeif", (lwiplongfun *)(&lwip_add_vdeif)}, {"lwip_add_tapif", (lwiplongfun *)(&lwip_add_tapif)}, {"lwip_add_tunif", (lwiplongfun *)(&lwip_add_tunif)}, {"lwip_add_slirpif", (lwiplongfun *)(&lwip_add_slirpif)}, {"lwip_radv_load_configfile", (lwiplongfun *)(&lwip_radv_load_configfile)}, {"lwip_thread_new", (lwipvoidfun*) (&lwip_thread_new)}, {"lwip_event_subscribe", (lwipvoidfun*) (&lwip_event_subscribe)} }; int i; void *lwiphandle = dlopen("liblwipv6.so",RTLD_NOW); if(lwiphandle == NULL) { errno=ENOENT; } else { for (i=0; i<(sizeof(lwiplibtab)/sizeof(struct lwipname2fun)); i++) *lwiplibtab[i].f = dlsym(lwiphandle,lwiplibtab[i].funcname); pip_addr_any = dlsym(lwiphandle,"ip_addr_any"); } return lwiphandle; } #endif #endif lwipv6-1.5a/lwip-contrib/ports/unix/sys_arch.2sem.c0000644000175000017500000003114611671615010021415 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* * Wed Apr 17 16:05:29 EDT 2002 (James Roth) * * - Fixed an unlikely sys_thread_new() race condition. * * - Made current_thread() work with threads which where * not created with sys_thread_new(). This includes * the main thread and threads made with pthread_create(). * * - Catch overflows where more than SYS_MBOX_SIZE messages * are waiting to be read. The sys_mbox_post() routine * will block until there is more room instead of just * leaking messages. */ #include "lwip/debug.h" #include #include #include #include #include #include #include "lwip/sys.h" #include "lwip/opt.h" #include "lwip/stats.h" #define UMAX(a, b) ((a) > (b) ? (a) : (b)) #define SYS_MBOX_SIZE 128 struct sys_mbox { int first, last; void *msgs[SYS_MBOX_SIZE]; struct sys_sem *notempty; struct sys_sem *notfull; struct sys_sem *mutex; }; struct sys_sem { unsigned int c; pthread_cond_t cond; pthread_mutex_t mutex; }; static pthread_mutex_t lwprot_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_t lwprot_thread = (pthread_t) 0xDEAD; static int lwprot_count = 0; static struct sys_sem *sys_sem_new_(u8_t count); static void sys_sem_free_(struct sys_sem *sem); static u32_t cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex, u32_t timeout); /*-----------------------------------------------------------------------------------*/ sys_thread_t sys_thread_new(void (*function)(void *arg), void *arg, int prio) { int code; pthread_t tmp; code = pthread_create(&tmp, NULL, (void *(*)(void *)) function, arg); if (0 == code) { return tmp; } else return -1; } /*-----------------------------------------------------------------------------------*/ struct sys_mbox * sys_mbox_new() { struct sys_mbox *mbox; mbox = malloc(sizeof(struct sys_mbox)); mbox->first = mbox->last = 0; mbox->notempty = sys_sem_new_(0); mbox->notfull = sys_sem_new_(SYS_MBOX_SIZE); mbox->mutex = sys_sem_new_(1); #if SYS_STATS lwip_stats.sys.mbox.used++; if (lwip_stats.sys.mbox.used > lwip_stats.sys.mbox.max) { lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used; } #endif /* SYS_STATS */ return mbox; } /*-----------------------------------------------------------------------------------*/ void sys_mbox_free(struct sys_mbox *mbox) { if (mbox != SYS_MBOX_NULL) { #if SYS_STATS lwip_stats.sys.mbox.used--; #endif /* SYS_STATS */ sys_sem_free_(mbox->notempty); sys_sem_free_(mbox->notfull); sys_sem_free_(mbox->mutex); /* LWIP_DEBUGF("sys_mbox_free: mbox 0x%lx\n", mbox); */ free(mbox); } } /*-----------------------------------------------------------------------------------*/ void sys_mbox_post(struct sys_mbox *mbox, void *msg) { u8_t first; sys_sem_wait(mbox->notfull); LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", (void *)mbox, (void *)msg)); sys_sem_wait(mbox->mutex); //printf("sys_mbox_post %p %d %d %d %d\n",mbox,mbox->notfull->c, mbox->notempty->c, //mbox->first, mbox->last); //fflush(stdout); mbox->msgs[mbox->last % SYS_MBOX_SIZE] = msg; mbox->last++; sys_sem_signal(mbox->mutex); sys_sem_signal(mbox->notempty); } /*-----------------------------------------------------------------------------------*/ u32_t sys_arch_mbox_fetch(struct sys_mbox *mbox, void **msg, u32_t timeout) { u32_t time = 0; /* The mutex lock is quick so we don't bother with the timeout stuff here. */ //printf("sys_mbox_fetch? %p %d %d\n",mbox,mbox->notfull->c, mbox->notempty->c); //fflush(stdout); time=sys_arch_sem_wait(mbox->notempty, timeout); if ( timeout != 0 && time == SYS_ARCH_TIMEOUT) { return SYS_ARCH_TIMEOUT; } sys_sem_wait(mbox->mutex); //printf("sys_mbox_fetch %p %d %d %d %d\n",mbox,mbox->notfull->c, mbox->notempty->c, //mbox->first, mbox->last); //fflush(stdout); if (msg != NULL) { LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", (void *)mbox, *msg)); *msg = mbox->msgs[mbox->first % SYS_MBOX_SIZE]; } else{ LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p, null msg\n", (void *)mbox)); } mbox->first++; sys_sem_signal(mbox->mutex); sys_sem_signal(mbox->notfull); return time; } /*-----------------------------------------------------------------------------------*/ struct sys_sem * sys_sem_new(u8_t count) { #if SYS_STATS lwip_stats.sys.sem.used++; if (lwip_stats.sys.sem.used > lwip_stats.sys.sem.max) { lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; } #endif /* SYS_STATS */ return sys_sem_new_(count); } /*-----------------------------------------------------------------------------------*/ static struct sys_sem * sys_sem_new_(u8_t count) { struct sys_sem *sem; sem = malloc(sizeof(struct sys_sem)); sem->c = count; pthread_cond_init(&(sem->cond), NULL); pthread_mutex_init(&(sem->mutex), NULL); return sem; } /*-----------------------------------------------------------------------------------*/ static u32_t cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, u32_t timeout) { int tdiff; unsigned long sec, usec; struct timeval rtime1, rtime2; struct timespec ts; struct timezone tz; int retval; if (timeout > 0) { /* Get a timestamp and add the timeout value. */ gettimeofday(&rtime1, &tz); sec = rtime1.tv_sec; usec = rtime1.tv_usec; usec += timeout % 1000 * 1000; sec += (int)(timeout / 1000) + (int)(usec / 1000000); usec = usec % 1000000; ts.tv_nsec = usec * 1000; ts.tv_sec = sec; retval = pthread_cond_timedwait(cond, mutex, &ts); if (retval == ETIMEDOUT) { return SYS_ARCH_TIMEOUT; } else { /* Calculate for how long we waited for the cond. */ gettimeofday(&rtime2, &tz); tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 + (rtime2.tv_usec - rtime1.tv_usec) / 1000; if (tdiff <= 0) { return 0; } return tdiff; } } else { pthread_cond_wait(cond, mutex); return SYS_ARCH_TIMEOUT; } } /*-----------------------------------------------------------------------------------*/ u32_t sys_arch_sem_wait(struct sys_sem *sem, u32_t timeout) { u32_t time = 0; pthread_mutex_lock(&(sem->mutex)); while (sem->c <= 0) { if (timeout > 0) { time = cond_wait(&(sem->cond), &(sem->mutex), timeout); if (time == SYS_ARCH_TIMEOUT) { pthread_mutex_unlock(&(sem->mutex)); return SYS_ARCH_TIMEOUT; } /* pthread_mutex_unlock(&(sem->mutex)); return time; */ } else { cond_wait(&(sem->cond), &(sem->mutex), 0); } } sem->c--; pthread_mutex_unlock(&(sem->mutex)); return time; } /*-----------------------------------------------------------------------------------*/ void sys_sem_signal(struct sys_sem *sem) { pthread_mutex_lock(&(sem->mutex)); sem->c++; /* if (sem->c > 1) { sem->c = 1; } */ pthread_cond_broadcast(&(sem->cond)); pthread_mutex_unlock(&(sem->mutex)); } /*-----------------------------------------------------------------------------------*/ void sys_sem_free(struct sys_sem *sem) { if (sem != SYS_SEM_NULL) { #if SYS_STATS lwip_stats.sys.sem.used--; #endif /* SYS_STATS */ sys_sem_free_(sem); } } /*-----------------------------------------------------------------------------------*/ static void sys_sem_free_(struct sys_sem *sem) { pthread_cond_destroy(&(sem->cond)); pthread_mutex_destroy(&(sem->mutex)); free(sem); } /*-----------------------------------------------------------------------------------*/ unsigned long time_now() { struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); return tv.tv_sec; } /*-----------------------------------------------------------------------------------*/ void sys_init() { } /*-----------------------------------------------------------------------------------*/ static pthread_key_t key; static pthread_once_t key_once = PTHREAD_ONCE_INIT; static void del_key(void *ptr) { free(ptr); } static void make_key() { //printf("new_key %p\n",pthread_self()); (void) pthread_key_create(&key, del_key); } struct sys_timeouts * sys_arch_timeouts(void) { struct sys_timeouts *ptr; (void) pthread_once(&key_once, make_key); if ((ptr = pthread_getspecific(key)) == NULL) { ptr = malloc(sizeof(struct sys_timeouts)); ptr->next=NULL; (void) pthread_setspecific(key, ptr); } return ptr; } /*-----------------------------------------------------------------------------------*/ /** sys_prot_t sys_arch_protect(void) This optional function does a "fast" critical region protection and returns the previous protection level. This function is only called during very short critical regions. An embedded system which supports ISR-based drivers might want to implement this function by disabling interrupts. Task-based systems might want to implement this by using a mutex or disabling tasking. This function should support recursive calls from the same task or interrupt. In other words, sys_arch_protect() could be called while already protected. In that case the return value indicates that it is already protected. sys_arch_protect() is only required if your port is supporting an operating system. */ sys_prot_t sys_arch_protect(void) { /* Note that for the UNIX port, we are using a lightweight mutex, and our * own counter (which is locked by the mutex). The return code is not actually * used. */ if (lwprot_thread != pthread_self()) { /* We are locking the mutex where it has not been locked before * * or is being locked by another thread */ pthread_mutex_lock(&lwprot_mutex); lwprot_thread = pthread_self(); lwprot_count = 1; } else /* It is already locked by THIS thread */ lwprot_count++; return 0; } /*-----------------------------------------------------------------------------------*/ /** void sys_arch_unprotect(sys_prot_t pval) This optional function does a "fast" set of critical region protection to the value specified by pval. See the documentation for sys_arch_protect() for more information. This function is only required if your port is supporting an operating system. */ void sys_arch_unprotect(sys_prot_t pval) { if (lwprot_thread == pthread_self()) { if (--lwprot_count == 0) { lwprot_thread = (pthread_t) 0xDEAD; pthread_mutex_unlock(&lwprot_mutex); } } } /*-----------------------------------------------------------------------------------*/ #ifndef MAX_JIFFY_OFFSET #define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) #endif #ifndef HZ #define HZ 100 #endif unsigned long sys_jiffies(void) { struct timeval tv; unsigned long sec = tv.tv_sec; long usec = tv.tv_usec; gettimeofday(&tv,NULL); if (sec >= (MAX_JIFFY_OFFSET / HZ)) return MAX_JIFFY_OFFSET; usec += 1000000L / HZ - 1; usec /= 1000000L / HZ; return HZ * sec + usec; } #if PPP_DEBUG #include void ppp_trace(int level, const char *format, ...) { va_list args; (void)level; va_start(args, format); vprintf(format, args); va_end(args); } #endif lwipv6-1.5a/lwip-contrib/ports/unix/perf.c0000644000175000017500000000422211671615010017664 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "arch/perf.h" #include static FILE *f; void perf_print(unsigned long c1l, unsigned long c1h, unsigned long c2l, unsigned long c2h, char *key) { unsigned long long start, end; start = (unsigned long long)c2h << 32 | c2l; end = (unsigned long long)c1h << 32 | c1l; fprintf(f, "%s: %llu\n", key, start - end); fflush(NULL); } void perf_print_times(struct tms *start, struct tms *end, char *key) { fprintf(f, "%s: %lu\n", key, end->tms_stime - start->tms_stime); fflush(NULL); } void perf_init(char *fname) { f = fopen(fname, "w"); } lwipv6-1.5a/lwip-contrib/ports/unix/lwip_chksum.c0000644000175000017500000000506311671615010021261 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/debug.h" #include "lwip/arch.h" #include "lwip/def.h" #include "lwip/inet.h" /*-----------------------------------------------------------------------------------*/ /* lwip_chksum: * * Sums up all 16 bit words in a memory portion. Also includes any odd byte. * This function is used by the other checksum functions. * */ /*-----------------------------------------------------------------------------------*/ #if 0 u16_t lwip_chksum(void *dataptr, int len) { u32_t acc; for(acc = 0; len > 1; len -= 2) { acc += *((u16_t *)dataptr)++; } /* add up any odd byte */ if (len == 1) { acc += htons((u16_t)((*(u8_t *)dataptr) & 0xff) << 8); LWIP_DEBUGF(INET_DEBUG, ("inet: chksum: odd byte %d\n", *(u8_t *)dataptr)); } acc = (acc >> 16) + (acc & 0xffffUL); if (acc & 0xffff0000 != 0) { acc = (acc >> 16) + (acc & 0xffffUL); } return (u16_t)acc; } /*-----------------------------------------------------------------------------------*/ #endif lwipv6-1.5a/lwip-contrib/ports/unix/proj/0000755000175000017500000000000011671615111017540 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/proj/lib/0000755000175000017500000000000011671615111020306 5ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/proj/lib/README0000644000175000017500000000131011671615010021157 0ustar renzorenzoThis directory contains an example of how to compile lwIP as a self initialising shared library on Linux. Some brief instructions: * Compile the code: > make clean all This should produce liblwip4unixlib.so. This is the shared library. * Link an application against the shared library If you're using gcc you can do this by including -llwip4unixlib in your link command. * Run your application Ensure that LD_LIBRARY_PATH includes the directory that contains liblwip4unixlib.so (ie. this directory) If you are unsure about shared libraries and libraries on linux in general, you might find this HOWTO useful: Kieran Mansley, October 2002.lwipv6-1.5a/lwip-contrib/ports/unix/proj/lib/make0000644000175000017500000000000011671615010021132 0ustar renzorenzolwipv6-1.5a/lwip-contrib/ports/unix/proj/lib/unixlib.c0000644000175000017500000003641711671615010022135 0ustar renzorenzo/** * @file * LwIPv6 TCP/IP Stack library * * The initialisation functions for a shared library * * You may need to configure this file to your own needs - it is only an example * of how lwIP can be used as a self initialising shared library. * * */ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * Author: Kieran Mansley * * $Id: unixlib.c 1040 2011-12-13 08:34:27Z rd235 $ */ /*-----------------------------------------------------------------------------------*/ /* unixlib.c * * The initialisation functions for a shared library * * You may need to configure this file to your own needs - it is only an example * of how lwIP can be used as a self initialising shared library. * * In particular, you should change the gateway, ipaddr, and netmask to be the values * you would like the stack to use. */ /*-----------------------------------------------------------------------------------*/ #include #include #include #include "lwip/sys.h" #include "lwip/mem.h" #include "lwip/memp.h" #include "lwip/pbuf.h" #include "lwip/tcp.h" #include "lwip/tcpip.h" #include "lwip/netif.h" #include "lwip/stats.h" #include "lwip/stack.h" #include "netif/vdeif.h" #include "netif/tunif.h" #include "netif/tapif.h" #include "netif/loopif.h" #include "netif/slirpif.h" #include "lwip/sockets.h" #if IPv6_RADVCONF #include "lwip/radvconf.h" #endif /* #define MULTISTACKDEBUG*/ static void multistack_daemon(void *argv); /*--------------------------------------------------------------------------*/ extern int _nofdfake; /*static struct stack *mainstack;*/ static void lwip_add_loopif(struct stack *stack); static void init_done(void *arg) { sys_sem_t *sem = (sys_sem_t *) arg; sys_sem_signal(*sem); } static void shutdown_done(void *arg) { sys_sem_t *sem = (sys_sem_t *) arg; sys_sem_signal(*sem); } /** * Initializes the LwIPv6 Stack. * * Initializes all memory structures used by LwIPv6 and * launchs the main TCPIP stack thread. * * The loopback interface (lo) is created before return. * * @note The dynamic linker call this function when the dynamic library is loaded. */ void lwip_init(void) { if (getenv("_INSIDE_VIEWOS_MODULE") != NULL) { _nofdfake = 1; } srand(getpid()+time(NULL)); /* Init stack's structures */ stats_init(); sys_init(); mem_init(); memp_init(); pbuf_init(); tcpip_init(); } #if LWIP_CAPABILITIES struct stack *lwip_add_stack_cap(unsigned long flags, lwip_capfun capfun) #else struct stack *lwip_add_stack(unsigned long flags) #endif { sys_sem_t sem; struct stack *newstack; /* Start the main stack */ sem = sys_sem_new(0); #if LWIP_CAPABILITIES newstack = tcpip_start(init_done, &sem, flags, capfun); #else newstack = tcpip_start(init_done, &sem, flags); #endif sys_sem_wait(sem); sys_sem_free(sem); /* Add loop interface at least */ lwip_add_loopif(newstack); #ifdef MULTISTACKDEBUG printf("%s: new %p\n", __func__, newstack); #endif return newstack; } #if LWIP_CAPABILITIES struct stack *lwip_add_stack(unsigned long flags) { return lwip_add_stack_cap(flags, NULL); } #else struct stack *lwip_add_stack_cap(unsigned long flags, void *must_be_null) { if (must_be_null != NULL) return NULL; else return lwip_add_stack_cap(flags, NULL); } #endif struct stack *lwip_stack_new(void) { return lwip_add_stack(0); } struct stack *lwip_stack_get(void) { return tcpip_stack_get(); } void lwip_stack_set(struct stack *stackid) { #ifdef MULTISTACKDEBUG printf("%s: %p\n", __func__, stackid); #endif tcpip_stack_set(stackid); } void lwip_del_stack(struct stack * stackid) { sys_sem_t sem; #ifdef MULTISTACKDEBUG printf("%s: %p...\n", __func__, stackid); #endif sem = sys_sem_new(0); tcpip_shutdown(stackid, shutdown_done, &sem); sys_sem_wait(sem); sys_sem_free(sem); #ifdef MULTISTACKDEBUG printf("%s: %p done!\n", __func__, stackid); #endif } void lwip_stack_free(struct stack * stackid) { lwip_del_stack(stackid); } unsigned long lwip_stack_flags_get(struct stack *stackid) { return stackid->stack_flags; } void lwip_stack_flags_set(struct stack *stackid, unsigned long flags) { stackid->stack_flags=flags; } /** * Shutdown the LwIPv6 Stack. * * Signals to the main TCPIP thread to exit and waits * until termination of the thread. * * @note The dynamic linker call this function when the dynamic library is unloaded. */ void lwip_fini(void) { } static char *nullstring=""; /*--------------------------------------------------------------------------*/ /** * Creates and adds a new VDE network interface to the stack. * * @param arg The ID of the VDE Switch connected with the interface. * The ID is the filename of the unix socket of the switch. * * Allocs a new virtual interface and attachs it to the VDE Switch with * ID = arg. * * @return Returns the pointer to the new interface, NULL on failure. * * @note If IPv6 Stateless Autoconfiguration Protocol is not enabled, * a Link-scope IPv6 address will be assigned to the new interface. */ struct netif *lwip_add_vdeif(struct stack *stack, void *arg, int flags) { struct ip_addr ipaddr, netmask; struct netif *pnetif; pnetif = mem_malloc(sizeof (struct netif)); pnetif->flags = flags & NETIF_ADD_FLAGS; if (arg == NULL) arg = nullstring; if (tcpip_netif_add(stack, pnetif, arg, vdeif_init, tcpip_input, tcpip_notify) == NULL) { mem_free(pnetif); return NULL; } if #if IPv6_AUTO_CONFIGURATION (!(flags & NETIF_FLAG_AUTOCONF)) #else (1) #endif { /* Link-scope address */ IP6_ADDR_LINKSCOPE(&ipaddr, pnetif->hwaddr); IP6_ADDR(&netmask, 0xffff,0xffff,0xffff,0xffff,0x0,0x0,0x0,0x0); netif_add_addr(pnetif, &ipaddr, &netmask); } return(pnetif); } struct netif *lwip_vdeif_add(struct stack *stack, void *arg) { return lwip_add_vdeif(stack, arg, NETIF_STD_FLAGS); } /** * Creates and adds a new TAP network interface to the stack. * * @param arg, is the if name. * * Allocs a new virtual interface and creates a TAP interface on your host. * * @return Returns the pointer to the new interface, NULL on failure. * * @note If IPv6 Stateless Autoconfiguration Protocol is not enabled, * a Link-scope IPv6 address will be assigned to the new interface. * * @note You need the TUNTAP driver active with your kernel. * * @note You need to configure the host side of the TAP link. */ struct netif *lwip_add_tapif(struct stack *stack, void *arg, int flags) { struct ip_addr ipaddr, netmask; struct netif *pnetif; pnetif = mem_malloc(sizeof (struct netif)); pnetif->flags = flags & NETIF_ADD_FLAGS; pnetif->flags |= NETIF_FLAG_POINTTOPOINT; if (arg == NULL) arg = nullstring; if (tcpip_netif_add(stack, pnetif, arg, tapif_init, tcpip_input, tcpip_notify) == NULL) { mem_free(pnetif); return NULL; } if #if IPv6_AUTO_CONFIGURATION (!(flags & NETIF_FLAG_AUTOCONF)) #else (1) #endif { /* Link-scope address */ IP6_ADDR_LINKSCOPE(&ipaddr, pnetif->hwaddr); IP6_ADDR(&netmask, 0xffff,0xffff,0xffff,0xffff,0x0,0x0,0x0,0x0); netif_add_addr(pnetif, &ipaddr, &netmask); } return(pnetif); } struct netif *lwip_tapif_add(struct stack *stack, void *arg) { return lwip_add_tapif(stack, arg, NETIF_STD_FLAGS); } /** * Creates and adds a new TUN network interface to the stack. * * @param arg, is the if name. * * Allocs a new virtual interface and creates a TAP interface on your host. * * @return Returns the pointer to the new interface, NULL on failure. * * @note If IPv6 Stateless Autoconfiguration Protocol is not enabled, * a Link-scope IPv6 address will be assigned to the new interface. * * @note You need to configure the host side of the TUN link. */ struct netif *lwip_add_tunif(struct stack *stack, void *arg, int flags) { struct ip_addr ipaddr, netmask; struct netif *pnetif; pnetif = mem_malloc(sizeof (struct netif)); pnetif->flags = flags & NETIF_ADD_FLAGS; pnetif->flags |= NETIF_FLAG_POINTTOPOINT; if (arg == NULL) arg = nullstring; if (tcpip_netif_add(stack, pnetif, arg, tunif_init, tcpip_input, tcpip_notify) == NULL) { mem_free(pnetif); return NULL; } if #if IPv6_AUTO_CONFIGURATION (!(flags & NETIF_FLAG_AUTOCONF)) #else (1) #endif { /* Link-scope address */ IP6_ADDR_LINKSCOPE(&ipaddr, pnetif->hwaddr); IP6_ADDR(&netmask, 0xffff,0xffff,0xffff,0xffff,0x0,0x0,0x0,0x0); netif_add_addr(pnetif, &ipaddr, &netmask); } return(pnetif); } struct netif *lwip_tunif_add(struct stack *stack, void *arg) { return lwip_add_tunif(stack, arg, NETIF_STD_FLAGS); } #ifdef LWSLIRP struct netif *lwip_add_slirpif(struct stack *stack, void *arg, int flags) { struct netif *pnetif; pnetif = mem_malloc(sizeof (struct netif)); pnetif->flags = flags & NETIF_ADD_FLAGS; if (arg == NULL) arg = nullstring; if (tcpip_netif_add(stack, pnetif, arg, slirpif_init, tcpip_input, tcpip_notify) == NULL) { mem_free(pnetif); return NULL; } return(pnetif); } struct netif *lwip_slirpif_add(struct stack *stack, void *arg) { return lwip_add_slirpif(stack, arg, 0); } #endif static void lwip_add_loopif(struct stack *stack) { struct netif *loopif; struct ip_addr ipaddr, netmask; loopif = mem_malloc(sizeof (struct netif)); bzero(loopif, sizeof(struct netif) ); tcpip_netif_add(stack, loopif,NULL, loopif_init, tcpip_input, NULL); IP6_ADDR(&ipaddr, 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1); IP6_ADDR(&netmask, 0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff); netif_add_addr(loopif,&ipaddr, &netmask); IP64_ADDR(&ipaddr, 127,0,0,1); IP64_MASKADDR(&netmask, 255,0,0,0); netif_add_addr(loopif,&ipaddr, &netmask); } /*--------------------------------------------------------------------------*/ /** * Bring the input network interface up. * * @param netif The interface to bring up. * * Bring the input network interface up. It doesn't check if input is NULL. * * @return It returns always 0. * * @note If IPv6 Stateless Address Autoconfiguration is enabled, the * autoconfiguration protocol will start. * * @bug It doesn't check if the interface is already up. */ int lwip_ifup_flags(struct netif *netif, int flags) { netif_set_up(netif, flags); return 0; } /* deprecated */ int lwip_ifup(struct netif *netif) { lwip_ifup_flags(netif, 0); } /** * Bring the input network interface down. * * @param netif The interface to bring down. * * Bring the input network interface down. It doesn't check if input is NULL. * * @return It returns always 0. * * @note If IPv6 Stateless Address Autoconfiguration is enabled, the * autoconfigurated address will be removed. * * @bug It doesn't check if the interface is already up. */ int lwip_ifdown(struct netif *netif) { netif_set_down(netif); return 0; } /*--------------------------------------------------------------------------*/ /** * Add a new address to a network interface. * * @param netif a pre-allocated netif structure * @param ipaddr IP address for the new netif * @param netmask network mask for the new netif * * @return 0 on success, < 0 on failure. */ int lwip_add_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask) { return netif_add_addr(netif,ipaddr,netmask); } /** * Delete a network address. * * @param netif a pre-allocated netif structure * @param ipaddr IP address for the new netif * @param netmask network mask for the new netif * * @return 0 on success, < 0 on failure. */ int lwip_del_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask) { return netif_del_addr(netif,ipaddr,netmask); } /*--------------------------------------------------------------------------*/ /** * Adds a new route entry to the LwIPv6 routing table. * * @param addr The destination prefix IP address. * @param netmask The destination prefix netmask. * @param nexthop The address of the nexthop router. * @param neitf The output interface. * @param flags * * Adds a new route to the LwIPv6 routing table. * * @return 0 on success, < 0 on failure. * */ int lwip_add_route(struct stack *stack,struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags) { if (netif == NULL) netif = netif_find_direct_destination(stack, nexthop); if (netif == NULL) return -ENETUNREACH; else return ip_route_list_add(stack, addr,netmask,nexthop,netif,flags); } /** * Deletes a route entry from the LwIPv6 routing table. * * @param addr The destination prefix IP address. * @param netmask The destination prefix netmask. * @param nexthop The address of the nexthop router. * @param neitf The output interface. * @param flags * * Adds a new route to the LwIPv6 routing table. * * @return 0 on success, < 0 on failure. * */ int lwip_del_route(struct stack *stack,struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags) { if (netif == NULL) netif = netif_find_direct_destination(stack, nexthop); if (netif == NULL) return -ENETUNREACH; else return ip_route_list_del(stack, addr,netmask,nexthop,netif,flags); } /*--------------------------------------------------------------------------*/ /** * Loads the Router Advertising configuration parameters from the input file. * * @param arg Name of the configuration file. * * Loads the Router Advertising configuration parameters from the input file. * If the configuration file syntax or any interface parameters are wrong * the advertising service will be disabled for one or all interfaces. * * @return -1 If IPv6 Router Advertising support is not enabled. * @return 0 if unable to open the configuration file. * @return 1 On success * * @bug It doesn't check if 'arg' is NULL. */ int lwip_radv_load_configfile(struct stack *stack,void *arg) { #if IPv6_RADVCONF return radv_load_configfile(stack, (char*)arg); #else return -1; #endif } void lwip_radv_load_config(struct stack *stack,FILE *filein) { #if IPv6_RADVCONF radv_load_config(stack, filein); #endif } void lwip_thread_new(void (* thread)(void *arg), void *arg) { sys_thread_new(thread, arg, DEFAULT_THREAD_PRIO); } lwipv6-1.5a/lwip-contrib/ports/unix/proj/lib/lwipopts.h0000644000175000017500000002273211671615010022344 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIPOPTS_H__ #define __LWIPOPTS_H__ /* * These are the default options of liblwip.so library. * Some of these are necessary if you are going to * use Lwipv6a as UMVIEWOS module (lwipv6.so). */ #define LWIP_DEBUG /* * Remove assertions. */ #define LWIP_NOASSERT /* * Uncomment this to debug mem/memp */ //#define DEBUGMEM /* * LWIPv6 SLIRP */ #define LWSLIRP /* * LWIP access control (capability fun) */ #define LWIP_CAPABILITIES 1 /* Enable NETLINK sockets to support network configuration by using iproute2 tools */ #define LWIP_NL 1 /* Enable PACKET socket if you want to use udhcpc with UMVIEWOS */ #define LWIP_PACKET 1 #define IPv6 1 #define IPv4_CHECK_CHECKSUM 1 #define IPv4_FRAGMENTATION 1 #define IPv6_FRAGMENTATION 1 #define IPv6_AUTO_CONFIGURATION 1 #define IPv6_ROUTER_ADVERTISEMENT 1 #define IPv6_RADVCONF 1 #define LWIP_USERFILTER 1 #define LWIP_NAT 1 /* Set to 1 to enable DHCP IPv4 */ #define LWIP_DHCP 1 /* ---------- Memory options ---------- */ /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 byte alignment -> define MEM_ALIGNMENT to 2. */ #define MEM_ALIGNMENT 4 /* MEM_SIZE: the size of the heap memory. If the application will send a lot of data that needs to be copied, this should be set high. */ #define MEM_SIZE 65536 /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application sends a lot of data out of ROM (or other static memory), this should be set high. */ #define MEMP_NUM_PBUF 256 /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One per active UDP "connection". */ #define MEMP_NUM_UDP_PCB 8 /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. */ #define MEMP_NUM_TCP_PCB 16 /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. */ #define MEMP_NUM_TCP_PCB_LISTEN 8 /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. */ #define MEMP_NUM_TCP_SEG 16 /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */ #define MEMP_NUM_SYS_TIMEOUT 30 /* The following four are used only with the sequential API and can be set to 0 if the application only will use the raw API. */ /* MEMP_NUM_NETBUF: the number of struct netbufs. */ #define MEMP_NUM_NETBUF 8 /* MEMP_NUM_NETCONN: the number of struct netconns. */ #define MEMP_NUM_NETCONN 8 /* MEMP_NUM_APIMSG: the number of struct api_msg, used for communication between the TCP/IP stack and the sequential programs. */ #define MEMP_NUM_API_MSG 64 /* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used for sequential API communication and incoming packets. Used in src/api/tcpip.c. */ #define MEMP_NUM_TCPIP_MSG 64 /* These two control is reclaimer functions should be compiled in. Should always be turned on (1). */ #define MEM_RECLAIM 1 #define MEMP_RECLAIM 1 /* ---------- Pbuf options ---------- */ /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ #define PBUF_POOL_SIZE 64 /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ #define PBUF_POOL_BUFSIZE 32768 /* PBUF_LINK_HLEN: the number of bytes that should be allocated for a link level header. */ #define PBUF_LINK_HLEN 16 /* ---------- ARP options ---------- */ #define ARP_TABLE_SIZE 10 #define ARP_QUEUEING 1 /* ---------- IP options ---------- */ /* Define IP_FORWARD to 1 if you wish to have the ability to forward IP packets across network interfaces. If you are going to run lwIP on a device with only one network interface, define this to 0. */ #define IP_FORWARD 1 /* If defined to 1, IP options are allowed (but not parsed). If defined to 0, all packets with IP options are dropped. */ #define IP_OPTIONS 1 /* # of suspended fragments */ #define IP_REASS_POOL_SIZE 5 /* ---------- ICMP options ---------- */ #define ICMP_TTL 255 /* ---------- UDP options ---------- */ #define LWIP_UDP 1 #define UDP_TTL 255 /* ---------- TCP options ---------- */ #define LWIP_TCP 1 #define TCP_TTL 255 /* Controls if TCP should queue segments that arrive out of order. Define to 0 if your device is low on memory. */ #define TCP_QUEUE_OOSEQ 1 /* TCP Maximum segment size. */ #define TCP_MSS 1488 /* TCP sender buffer space (bytes). */ #define TCP_SND_BUF 32768 /* TCP sender buffer space (pbufs). This must be at least = 2 * TCP_SND_BUF/TCP_MSS for things to work. */ #define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS /* TCP receive window. */ #define TCP_WND 32768 /* Maximum number of retransmissions of data segments. */ #define TCP_MAXRTX 12 /* Maximum number of retransmissions of SYN segments. */ #define TCP_SYNMAXRTX 4 #ifndef LWIP_COMPAT_SOCKETS #define LWIP_COMPAT_SOCKETS 0 #endif /* ---------- TCP/UDP sub-system thread ---------- */ /* TCP/UDP sub-system thread priority */ #define TCPIP_THREAD_PRIO 3 /* ---------- Statistics options ---------- */ /* By default, statistics are enabled */ #define LWIP_STATS 0 #ifdef STATS #define LINK_STATS 1 #define IP_STATS 1 #define ICMP_STATS 1 #define UDP_STATS 1 #define TCP_STATS 1 #define MEM_STATS 1 #define MEMP_STATS 1 #define PBUF_STATS 1 #define SYS_STATS 1 #endif /* STATS */ /* ---------- Debug options ------------- */ #define DBG_MIN_LEVEL 0 #define DBG_TYPES_ON (DBG_ON|DBG_TRACE|DBG_STATE|DBG_FRESH|DBG_HALT) //#define MEMP_DEBUG DBG_ON //#define PBUF_DEBUG DBG_ON //#define ETHARP_DEBUG DBG_ON //#define ROUTE_DEBUG DBG_ON //#define DHCP_DEBUG DBG_ON //#define IP_DEBUG DBG_ON //#define IP_REASS_DEBUG DBG_ON //#define IP_AUTOCONF_DEBUG DBG_ON //#define PMTU_DEBUG DBG_ON //#define IPv6_ADDRSELECT_DBG DBG_ON //#define IP_RADV_DEBUG DBG_ON //#define IP_RADVCONF_DEBUG DBG_ON //#define USERFILTER_DEBUG DBG_ON //#define NAT_DEBUG DBG_ON //#define ICMP_DEBUG DBG_ON //#define UDP_DEBUG DBG_ON //#define TCPIP_DEBUG DBG_ON //#define SOCKETS_DEBUG DBG_ON //#define LWSLIRP_DEBUG DBG_ON //#define TCP_INPUT_DEBUG DBG_ON //#define TCP_DEBUG DBG_ON //#define NETIF_DEBUG DBG_ON /* ---------- Debug options for /contrib/port/unix/netif files ------------- */ /* These are not defined in opt.h */ //#define VDEIF_DEBUG DBG_ON //#define TUNIF_DEBUG DBG_ON //#define TAPIF_DEBUG DBG_ON #endif /* __LWIPOPTS_H__ */ lwipv6-1.5a/lwip-contrib/ports/unix/proj/lib/sharedlib.c0000644000175000017500000000223011671615010022402 0ustar renzorenzo/* This is part of LWIPv6 * * Copyright 2006 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * This files contains the constructor and destructor functions * needed by the shared library. */ #define LIB_INIT __attribute__ ((constructor)) #define LIB_FINI __attribute__ ((destructor)) extern void lwip_init(void); extern void lwip_fini(void); void LIB_INIT _init(void) { lwip_init(); } void LIB_FINI _fini(void) { lwip_fini(); } lwipv6-1.5a/lwip-contrib/ports/unix/proj/lib/Makefile.am0000644000175000017500000002170111671615010022341 0ustar renzorenzo# # Copyright (c) 2001, 2002 Swedish Institute of Computer Science. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY # OF SUCH DAMAGE. # # This file is part of the lwIP TCP/IP stack. # # Author: Adam Dunkels # #============================================================================= # Directories #============================================================================= CONTRIBDIR = ../../../.. # Architecture directories LWIPARCH = $(CONTRIBDIR)/ports/unix #Set this to where you have the lwip core module checked out from CVS #default assumes it's a dir named lwip at the same level as the contrib module LWIPDIR = $(CONTRIBDIR)/../lwip-v6/src # Add on LWIPFILTERDIR = $(LWIPDIR)/userfilter LWIPRADVDIR = $(LWIPDIR)/radv #============================================================================= # Headers #============================================================================= # # Architecture dependent # AM_CPPFLAGS = -I$(LWIPARCH)/include # # Core # AM_CPPFLAGS += -I$(LWIPDIR)/include -I$(LWIPDIR)/include/ipv6 -Iapps -I. # # Add ons # AM_CPPFLAGS += -I$(LWIPDIR)/include/userfilter AM_CPPFLAGS += -I$(LWIPDIR)/include/radv LWIPHEADERS = $(LWIPDIR)/include/lwip/arch.h \ $(LWIPDIR)/include/lwip/opt.h \ $(LWIPDIR)/include/lwip/def.h \ $(LWIPDIR)/include/lwip/mem.h \ $(LWIPDIR)/include/lwip/sys.h \ $(LWIPDIR)/include/lwip/stats.h \ $(LWIPDIR)/include/lwip/debug.h \ $(LWIPDIR)/include/lwip/memp.h \ $(LWIPDIR)/include/lwip/pbuf.h \ $(LWIPDIR)/include/lwip/udp.h \ $(LWIPDIR)/include/lwip/raw.h \ $(LWIPDIR)/include/lwip/tcp.h \ $(LWIPDIR)/include/lwip/netif.h \ $(LWIPDIR)/include/lwip/packet.h \ $(LWIPDIR)/include/lwip/err.h \ $(LWIPDIR)/include/lwip/api.h \ $(LWIPDIR)/include/lwip/api_msg.h \ $(LWIPDIR)/include/lwip/tcpip.h \ $(LWIPDIR)/include/lwip/sockets.h \ $(LWIPDIR)/include/lwip/netlink.h \ $(LWIPDIR)/include/lwip/netlinkdefs.h \ $(LWIPDIR)/include/lwip/if.h \ $(LWIPDIR)/include/lwip/native_syscalls.h \ $(LWIPDIR)/include/lwip/snmp.h \ $(LWIPDIR)/include/lwip/arphdr.h \ $(LWIPDIR)/include/lwip/stack.h \ $(LWIPDIR)/include/lwip/lwslirp.h \ $(LWIPDIR)/include/ipv6/lwip/ip.h \ $(LWIPDIR)/include/ipv6/lwip/ip_addr.h \ $(LWIPDIR)/include/ipv6/lwip/ip_autoconf.h \ $(LWIPDIR)/include/ipv6/lwip/ip_route.h \ $(LWIPDIR)/include/ipv6/lwip/ip_frag.h \ $(LWIPDIR)/include/ipv6/lwip/inet.h \ $(LWIPDIR)/include/ipv6/lwip/icmp.h \ $(LWIPDIR)/include/netif/etharp.h \ $(LWIPDIR)/include/netif/loopif.h \ $(LWIPDIR)/include/userfilter/lwip/userfilter.h \ $(LWIPARCH)/include/vde.h \ $(LWIPARCH)/include/netif/vdeif.h \ $(LWIPARCH)/include/netif/tunif.h \ $(LWIPARCH)/include/netif/tapif.h \ $(LWIPARCH)/include/netif/slirpif.h \ $(LWIPARCH)/include/arch/cc.h \ $(LWIPARCH)/include/arch/sys_arch.h \ $(LWIPARCH)/include/arch/perf.h \ lwipopts.h #============================================================================= # Stack Core Sources #============================================================================= # COREFILES, CORE4FILES: The minimum set of files needed for lwIP. # # Different implementations of memory manager # #COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c #COREFILES=$(LWIPDIR)/core/mem_malloc.c $(LWIPDIR)/core/memp_dynmalloc.c COREFILES = $(LWIPDIR)/core/mem_malloc.c $(LWIPDIR)/core/memp_malloc.c # # Different implementation of 'pbuf' manager # #COREFILES:=$(COREFILES) $(LWIPDIR)/core/pbuf.c COREFILES += $(LWIPDIR)/core/pbufnopool.c # # Stack Core files # COREFILES += \ $(LWIPDIR)/core/netif.c \ $(LWIPDIR)/core/stats.c \ $(LWIPDIR)/core/sys.c \ $(LWIPDIR)/core/tcp.c \ $(LWIPDIR)/core/tcp_in.c \ $(LWIPDIR)/core/tcp_out.c \ $(LWIPDIR)/core/udp.c \ $(LWIPDIR)/core/raw.c \ $(LWIPDIR)/core/packet.c \ $(LWIPDIR)/core/dhcp.c \ $(LWIPDIR)/core/lwslirp.c CORE6FILES = $(LWIPDIR)/core/inet6.c \ $(LWIPDIR)/core/ipv6/icmp6.c \ $(LWIPDIR)/core/ipv6/ip6.c \ $(LWIPDIR)/core/ipv6/ip6_addr.c \ $(LWIPDIR)/core/ipv6/ip6_route.c \ $(LWIPDIR)/core/ipv6/ip6_frag.c \ $(LWIPDIR)/core/ipv6/ip6_autoconf.c \ $(LWIPDIR)/core/ipv6/ip6_radv.c # # APIFILES: The files which implement the sequential and socket APIs. # APIFILES = $(LWIPDIR)/api/api_lib.c \ $(LWIPDIR)/api/api_msg.c \ $(LWIPDIR)/api/tcpip.c \ $(LWIPDIR)/api/err.c \ $(LWIPDIR)/api/netlink.c # # Different implementations of Socket API. # - renzosockets.c needs RD235LIB to be defined # #APIFILES:=$(APIFILES) $(LWIPDIR)/api/renzosockets.c APIFILES += $(LWIPDIR)/api/sockets.c # # NETIFFILES: Files implementing various generic network interface functions.' # NETIFFILES = $(LWIPDIR)/netif/loopif.c \ $(LWIPDIR)/netif/etharp.c #============================================================================= # Architecture specific files #============================================================================= # ARCHFILES: Architecture specific files. #ARCHFILES=$(wildcard $(LWIPDIR)/arch/$(LWIPARCH)/*.c $(LWIPDIR)/arch/$(LWIPARCH)/netif/*.c) # # Different implementation of architecture backend # ARCHFILES=$(LWIPARCH)/sys_arch_pipe.c #ARCHFILES=$(LWIPARCH)/sys_arch.2sem.c #ARCHFILES = $(LWIPARCH)/sys_arch.c ARCHFILES += $(LWIPARCH)/netif/vdeif.c ARCHFILES += $(LWIPARCH)/netif/slirpif.c ARCHFILES += $(LWIPARCH)/netif/tapif.c ARCHFILES += $(LWIPARCH)/netif/tunif.c #============================================================================= # Add on #============================================================================= # RADVFILES: Router Advertisement configuration loader (IPv6_RADVCONF) RADVFILES = $(LWIPRADVDIR)/radvconf.c # File of Userfilter syb-sytem (LWIP_USERFILTER) LWIPFILTERFILES = $(LWIPFILTERDIR)/userfilter.c # Files of the NAT sub-system (LWIP_NAT) LWIPFILTERFILES += \ $(LWIPFILTERDIR)/nat/nat.c \ $(LWIPFILTERDIR)/nat/nat_rules.c \ $(LWIPFILTERDIR)/nat/nat_tables.c \ $(LWIPFILTERDIR)/nat/nat_track_proto_tcp.c \ $(LWIPFILTERDIR)/nat/nat_track_proto_udp.c \ $(LWIPFILTERDIR)/nat/nat_track_proto_icmp4.c \ $(LWIPFILTERDIR)/nat/nat_track_proto_generic.c #============================================================================= # Objects #============================================================================= # LWIPFILES: All the above. LWIPFILES = $(COREFILES) $(CORE6FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES) $(LWIPFILTERFILES) $(RADVFILES) #LWIPFILESW = $(wildcard $(LWIPFILES)) #LWIPOBJS = $(notdir $(LWIPFILESW:.c=.o)) #============================================================================= # Targets #============================================================================= lib_LTLIBRARIES = liblwipv6.la # NB: unixlib.o should not be included, it's used only by ViewOS # project. It's here only for debug. liblwipv6_la_SOURCES = $(LWIPFILES) $(LWIPHEADERS) sharedlib.c unixlib.c liblwipv6_la_LDFLAGS = -version-number 2:0:0 -Xcompiler -nostartfiles # liblwip_la_LIBADD = sharedlib.lo unixlib.lo include_HEADERS = $(LWIPARCH)/include/lwipv6.h CFLAGS = -g3 -ggdb3 lwipv6-1.5a/lwip-contrib/ports/unix/proj/lib/Makefile.in0000644000175000017500000021661411671615056022375 0ustar renzorenzo# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # # Copyright (c) 2001, 2002 Swedish Institute of Computer Science. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright notice, # this list of conditions and the following disclaimer in the documentation # and/or other materials provided with the distribution. # 3. The name of the author may not be used to endorse or promote products # derived from this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT # SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT # OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING # IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY # OF SUCH DAMAGE. # # This file is part of the lwIP TCP/IP stack. # # Author: Adam Dunkels # #============================================================================= # Directories #============================================================================= VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = lwip-contrib/ports/unix/proj/lib DIST_COMMON = README $(include_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) liblwipv6_la_LIBADD = am__objects_1 = mem_malloc.lo memp_malloc.lo pbufnopool.lo netif.lo \ stats.lo sys.lo tcp.lo tcp_in.lo tcp_out.lo udp.lo raw.lo \ packet.lo dhcp.lo lwslirp.lo am__objects_2 = inet6.lo icmp6.lo ip6.lo ip6_addr.lo ip6_route.lo \ ip6_frag.lo ip6_autoconf.lo ip6_radv.lo am__objects_3 = api_lib.lo api_msg.lo tcpip.lo err.lo netlink.lo \ sockets.lo am__objects_4 = loopif.lo etharp.lo am__objects_5 = sys_arch_pipe.lo vdeif.lo slirpif.lo tapif.lo tunif.lo am__objects_6 = userfilter.lo nat.lo nat_rules.lo nat_tables.lo \ nat_track_proto_tcp.lo nat_track_proto_udp.lo \ nat_track_proto_icmp4.lo nat_track_proto_generic.lo am__objects_7 = radvconf.lo am__objects_8 = $(am__objects_1) $(am__objects_2) $(am__objects_3) \ $(am__objects_4) $(am__objects_5) $(am__objects_6) \ $(am__objects_7) am__objects_9 = am_liblwipv6_la_OBJECTS = $(am__objects_8) $(am__objects_9) \ sharedlib.lo unixlib.lo liblwipv6_la_OBJECTS = $(am_liblwipv6_la_OBJECTS) liblwipv6_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(liblwipv6_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(liblwipv6_la_SOURCES) DIST_SOURCES = $(liblwipv6_la_SOURCES) HEADERS = $(include_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = -g3 -ggdb3 CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ CONTRIBDIR = ../../../.. # Architecture directories LWIPARCH = $(CONTRIBDIR)/ports/unix #Set this to where you have the lwip core module checked out from CVS #default assumes it's a dir named lwip at the same level as the contrib module LWIPDIR = $(CONTRIBDIR)/../lwip-v6/src # Add on LWIPFILTERDIR = $(LWIPDIR)/userfilter LWIPRADVDIR = $(LWIPDIR)/radv #============================================================================= # Headers #============================================================================= # # Architecture dependent # # # Core # # # Add ons # AM_CPPFLAGS = -I$(LWIPARCH)/include -I$(LWIPDIR)/include \ -I$(LWIPDIR)/include/ipv6 -Iapps -I. \ -I$(LWIPDIR)/include/userfilter -I$(LWIPDIR)/include/radv LWIPHEADERS = $(LWIPDIR)/include/lwip/arch.h \ $(LWIPDIR)/include/lwip/opt.h \ $(LWIPDIR)/include/lwip/def.h \ $(LWIPDIR)/include/lwip/mem.h \ $(LWIPDIR)/include/lwip/sys.h \ $(LWIPDIR)/include/lwip/stats.h \ $(LWIPDIR)/include/lwip/debug.h \ $(LWIPDIR)/include/lwip/memp.h \ $(LWIPDIR)/include/lwip/pbuf.h \ $(LWIPDIR)/include/lwip/udp.h \ $(LWIPDIR)/include/lwip/raw.h \ $(LWIPDIR)/include/lwip/tcp.h \ $(LWIPDIR)/include/lwip/netif.h \ $(LWIPDIR)/include/lwip/packet.h \ $(LWIPDIR)/include/lwip/err.h \ $(LWIPDIR)/include/lwip/api.h \ $(LWIPDIR)/include/lwip/api_msg.h \ $(LWIPDIR)/include/lwip/tcpip.h \ $(LWIPDIR)/include/lwip/sockets.h \ $(LWIPDIR)/include/lwip/netlink.h \ $(LWIPDIR)/include/lwip/netlinkdefs.h \ $(LWIPDIR)/include/lwip/if.h \ $(LWIPDIR)/include/lwip/native_syscalls.h \ $(LWIPDIR)/include/lwip/snmp.h \ $(LWIPDIR)/include/lwip/arphdr.h \ $(LWIPDIR)/include/lwip/stack.h \ $(LWIPDIR)/include/lwip/lwslirp.h \ $(LWIPDIR)/include/ipv6/lwip/ip.h \ $(LWIPDIR)/include/ipv6/lwip/ip_addr.h \ $(LWIPDIR)/include/ipv6/lwip/ip_autoconf.h \ $(LWIPDIR)/include/ipv6/lwip/ip_route.h \ $(LWIPDIR)/include/ipv6/lwip/ip_frag.h \ $(LWIPDIR)/include/ipv6/lwip/inet.h \ $(LWIPDIR)/include/ipv6/lwip/icmp.h \ $(LWIPDIR)/include/netif/etharp.h \ $(LWIPDIR)/include/netif/loopif.h \ $(LWIPDIR)/include/userfilter/lwip/userfilter.h \ $(LWIPARCH)/include/vde.h \ $(LWIPARCH)/include/netif/vdeif.h \ $(LWIPARCH)/include/netif/tunif.h \ $(LWIPARCH)/include/netif/tapif.h \ $(LWIPARCH)/include/netif/slirpif.h \ $(LWIPARCH)/include/arch/cc.h \ $(LWIPARCH)/include/arch/sys_arch.h \ $(LWIPARCH)/include/arch/perf.h \ lwipopts.h #============================================================================= # Stack Core Sources #============================================================================= # COREFILES, CORE4FILES: The minimum set of files needed for lwIP. # # Different implementations of memory manager # #COREFILES=$(LWIPDIR)/core/mem.c $(LWIPDIR)/core/memp.c #COREFILES=$(LWIPDIR)/core/mem_malloc.c $(LWIPDIR)/core/memp_dynmalloc.c # # Different implementation of 'pbuf' manager # #COREFILES:=$(COREFILES) $(LWIPDIR)/core/pbuf.c # # Stack Core files # COREFILES = $(LWIPDIR)/core/mem_malloc.c $(LWIPDIR)/core/memp_malloc.c \ $(LWIPDIR)/core/pbufnopool.c $(LWIPDIR)/core/netif.c \ $(LWIPDIR)/core/stats.c $(LWIPDIR)/core/sys.c \ $(LWIPDIR)/core/tcp.c $(LWIPDIR)/core/tcp_in.c \ $(LWIPDIR)/core/tcp_out.c $(LWIPDIR)/core/udp.c \ $(LWIPDIR)/core/raw.c $(LWIPDIR)/core/packet.c \ $(LWIPDIR)/core/dhcp.c $(LWIPDIR)/core/lwslirp.c CORE6FILES = $(LWIPDIR)/core/inet6.c \ $(LWIPDIR)/core/ipv6/icmp6.c \ $(LWIPDIR)/core/ipv6/ip6.c \ $(LWIPDIR)/core/ipv6/ip6_addr.c \ $(LWIPDIR)/core/ipv6/ip6_route.c \ $(LWIPDIR)/core/ipv6/ip6_frag.c \ $(LWIPDIR)/core/ipv6/ip6_autoconf.c \ $(LWIPDIR)/core/ipv6/ip6_radv.c # # APIFILES: The files which implement the sequential and socket APIs. # # # Different implementations of Socket API. # - renzosockets.c needs RD235LIB to be defined # #APIFILES:=$(APIFILES) $(LWIPDIR)/api/renzosockets.c APIFILES = $(LWIPDIR)/api/api_lib.c $(LWIPDIR)/api/api_msg.c \ $(LWIPDIR)/api/tcpip.c $(LWIPDIR)/api/err.c \ $(LWIPDIR)/api/netlink.c $(LWIPDIR)/api/sockets.c # # NETIFFILES: Files implementing various generic network interface functions.' # NETIFFILES = $(LWIPDIR)/netif/loopif.c \ $(LWIPDIR)/netif/etharp.c #============================================================================= # Architecture specific files #============================================================================= # ARCHFILES: Architecture specific files. #ARCHFILES=$(wildcard $(LWIPDIR)/arch/$(LWIPARCH)/*.c $(LWIPDIR)/arch/$(LWIPARCH)/netif/*.c) # # Different implementation of architecture backend # #ARCHFILES=$(LWIPARCH)/sys_arch.2sem.c #ARCHFILES = $(LWIPARCH)/sys_arch.c ARCHFILES = $(LWIPARCH)/sys_arch_pipe.c $(LWIPARCH)/netif/vdeif.c \ $(LWIPARCH)/netif/slirpif.c $(LWIPARCH)/netif/tapif.c \ $(LWIPARCH)/netif/tunif.c #============================================================================= # Add on #============================================================================= # RADVFILES: Router Advertisement configuration loader (IPv6_RADVCONF) RADVFILES = $(LWIPRADVDIR)/radvconf.c # File of Userfilter syb-sytem (LWIP_USERFILTER) # Files of the NAT sub-system (LWIP_NAT) LWIPFILTERFILES = $(LWIPFILTERDIR)/userfilter.c \ $(LWIPFILTERDIR)/nat/nat.c $(LWIPFILTERDIR)/nat/nat_rules.c \ $(LWIPFILTERDIR)/nat/nat_tables.c \ $(LWIPFILTERDIR)/nat/nat_track_proto_tcp.c \ $(LWIPFILTERDIR)/nat/nat_track_proto_udp.c \ $(LWIPFILTERDIR)/nat/nat_track_proto_icmp4.c \ $(LWIPFILTERDIR)/nat/nat_track_proto_generic.c #============================================================================= # Objects #============================================================================= # LWIPFILES: All the above. LWIPFILES = $(COREFILES) $(CORE6FILES) $(APIFILES) $(NETIFFILES) $(ARCHFILES) $(LWIPFILTERFILES) $(RADVFILES) #LWIPFILESW = $(wildcard $(LWIPFILES)) #LWIPOBJS = $(notdir $(LWIPFILESW:.c=.o)) #============================================================================= # Targets #============================================================================= lib_LTLIBRARIES = liblwipv6.la # NB: unixlib.o should not be included, it's used only by ViewOS # project. It's here only for debug. liblwipv6_la_SOURCES = $(LWIPFILES) $(LWIPHEADERS) sharedlib.c unixlib.c liblwipv6_la_LDFLAGS = -version-number 2:0:0 -Xcompiler -nostartfiles # liblwip_la_LIBADD = sharedlib.lo unixlib.lo include_HEADERS = $(LWIPARCH)/include/lwipv6.h all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign lwip-contrib/ports/unix/proj/lib/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign lwip-contrib/ports/unix/proj/lib/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)" @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ } uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done liblwipv6.la: $(liblwipv6_la_OBJECTS) $(liblwipv6_la_DEPENDENCIES) $(liblwipv6_la_LINK) -rpath $(libdir) $(liblwipv6_la_OBJECTS) $(liblwipv6_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/api_lib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/api_msg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dhcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etharp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icmp6.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/inet6.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip6.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip6_addr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip6_autoconf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip6_frag.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip6_radv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ip6_route.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loopif.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lwslirp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem_malloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/memp_malloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nat_rules.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nat_tables.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nat_track_proto_generic.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nat_track_proto_icmp4.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nat_track_proto_tcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nat_track_proto_udp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netif.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/netlink.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/packet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pbufnopool.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radvconf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sharedlib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/slirpif.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sockets.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stats.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sys.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sys_arch_pipe.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tapif.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcp_in.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcp_out.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcpip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tunif.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/udp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unixlib.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/userfilter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vdeif.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mem_malloc.lo: $(LWIPDIR)/core/mem_malloc.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT mem_malloc.lo -MD -MP -MF $(DEPDIR)/mem_malloc.Tpo -c -o mem_malloc.lo `test -f '$(LWIPDIR)/core/mem_malloc.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/mem_malloc.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/mem_malloc.Tpo $(DEPDIR)/mem_malloc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/mem_malloc.c' object='mem_malloc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o mem_malloc.lo `test -f '$(LWIPDIR)/core/mem_malloc.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/mem_malloc.c memp_malloc.lo: $(LWIPDIR)/core/memp_malloc.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT memp_malloc.lo -MD -MP -MF $(DEPDIR)/memp_malloc.Tpo -c -o memp_malloc.lo `test -f '$(LWIPDIR)/core/memp_malloc.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/memp_malloc.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/memp_malloc.Tpo $(DEPDIR)/memp_malloc.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/memp_malloc.c' object='memp_malloc.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o memp_malloc.lo `test -f '$(LWIPDIR)/core/memp_malloc.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/memp_malloc.c pbufnopool.lo: $(LWIPDIR)/core/pbufnopool.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT pbufnopool.lo -MD -MP -MF $(DEPDIR)/pbufnopool.Tpo -c -o pbufnopool.lo `test -f '$(LWIPDIR)/core/pbufnopool.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/pbufnopool.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/pbufnopool.Tpo $(DEPDIR)/pbufnopool.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/pbufnopool.c' object='pbufnopool.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o pbufnopool.lo `test -f '$(LWIPDIR)/core/pbufnopool.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/pbufnopool.c netif.lo: $(LWIPDIR)/core/netif.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netif.lo -MD -MP -MF $(DEPDIR)/netif.Tpo -c -o netif.lo `test -f '$(LWIPDIR)/core/netif.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/netif.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netif.Tpo $(DEPDIR)/netif.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/netif.c' object='netif.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netif.lo `test -f '$(LWIPDIR)/core/netif.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/netif.c stats.lo: $(LWIPDIR)/core/stats.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT stats.lo -MD -MP -MF $(DEPDIR)/stats.Tpo -c -o stats.lo `test -f '$(LWIPDIR)/core/stats.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/stats.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/stats.Tpo $(DEPDIR)/stats.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/stats.c' object='stats.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o stats.lo `test -f '$(LWIPDIR)/core/stats.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/stats.c sys.lo: $(LWIPDIR)/core/sys.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sys.lo -MD -MP -MF $(DEPDIR)/sys.Tpo -c -o sys.lo `test -f '$(LWIPDIR)/core/sys.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/sys.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sys.Tpo $(DEPDIR)/sys.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/sys.c' object='sys.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sys.lo `test -f '$(LWIPDIR)/core/sys.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/sys.c tcp.lo: $(LWIPDIR)/core/tcp.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tcp.lo -MD -MP -MF $(DEPDIR)/tcp.Tpo -c -o tcp.lo `test -f '$(LWIPDIR)/core/tcp.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/tcp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcp.Tpo $(DEPDIR)/tcp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/tcp.c' object='tcp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tcp.lo `test -f '$(LWIPDIR)/core/tcp.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/tcp.c tcp_in.lo: $(LWIPDIR)/core/tcp_in.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tcp_in.lo -MD -MP -MF $(DEPDIR)/tcp_in.Tpo -c -o tcp_in.lo `test -f '$(LWIPDIR)/core/tcp_in.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/tcp_in.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcp_in.Tpo $(DEPDIR)/tcp_in.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/tcp_in.c' object='tcp_in.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tcp_in.lo `test -f '$(LWIPDIR)/core/tcp_in.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/tcp_in.c tcp_out.lo: $(LWIPDIR)/core/tcp_out.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tcp_out.lo -MD -MP -MF $(DEPDIR)/tcp_out.Tpo -c -o tcp_out.lo `test -f '$(LWIPDIR)/core/tcp_out.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/tcp_out.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcp_out.Tpo $(DEPDIR)/tcp_out.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/tcp_out.c' object='tcp_out.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tcp_out.lo `test -f '$(LWIPDIR)/core/tcp_out.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/tcp_out.c udp.lo: $(LWIPDIR)/core/udp.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT udp.lo -MD -MP -MF $(DEPDIR)/udp.Tpo -c -o udp.lo `test -f '$(LWIPDIR)/core/udp.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/udp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/udp.Tpo $(DEPDIR)/udp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/udp.c' object='udp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o udp.lo `test -f '$(LWIPDIR)/core/udp.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/udp.c raw.lo: $(LWIPDIR)/core/raw.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT raw.lo -MD -MP -MF $(DEPDIR)/raw.Tpo -c -o raw.lo `test -f '$(LWIPDIR)/core/raw.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/raw.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/raw.Tpo $(DEPDIR)/raw.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/raw.c' object='raw.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o raw.lo `test -f '$(LWIPDIR)/core/raw.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/raw.c packet.lo: $(LWIPDIR)/core/packet.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT packet.lo -MD -MP -MF $(DEPDIR)/packet.Tpo -c -o packet.lo `test -f '$(LWIPDIR)/core/packet.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/packet.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/packet.Tpo $(DEPDIR)/packet.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/packet.c' object='packet.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o packet.lo `test -f '$(LWIPDIR)/core/packet.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/packet.c dhcp.lo: $(LWIPDIR)/core/dhcp.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT dhcp.lo -MD -MP -MF $(DEPDIR)/dhcp.Tpo -c -o dhcp.lo `test -f '$(LWIPDIR)/core/dhcp.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/dhcp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/dhcp.Tpo $(DEPDIR)/dhcp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/dhcp.c' object='dhcp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o dhcp.lo `test -f '$(LWIPDIR)/core/dhcp.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/dhcp.c lwslirp.lo: $(LWIPDIR)/core/lwslirp.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lwslirp.lo -MD -MP -MF $(DEPDIR)/lwslirp.Tpo -c -o lwslirp.lo `test -f '$(LWIPDIR)/core/lwslirp.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/lwslirp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/lwslirp.Tpo $(DEPDIR)/lwslirp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/lwslirp.c' object='lwslirp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lwslirp.lo `test -f '$(LWIPDIR)/core/lwslirp.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/lwslirp.c inet6.lo: $(LWIPDIR)/core/inet6.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT inet6.lo -MD -MP -MF $(DEPDIR)/inet6.Tpo -c -o inet6.lo `test -f '$(LWIPDIR)/core/inet6.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/inet6.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/inet6.Tpo $(DEPDIR)/inet6.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/inet6.c' object='inet6.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o inet6.lo `test -f '$(LWIPDIR)/core/inet6.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/inet6.c icmp6.lo: $(LWIPDIR)/core/ipv6/icmp6.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT icmp6.lo -MD -MP -MF $(DEPDIR)/icmp6.Tpo -c -o icmp6.lo `test -f '$(LWIPDIR)/core/ipv6/icmp6.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/icmp6.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/icmp6.Tpo $(DEPDIR)/icmp6.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/ipv6/icmp6.c' object='icmp6.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o icmp6.lo `test -f '$(LWIPDIR)/core/ipv6/icmp6.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/icmp6.c ip6.lo: $(LWIPDIR)/core/ipv6/ip6.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ip6.lo -MD -MP -MF $(DEPDIR)/ip6.Tpo -c -o ip6.lo `test -f '$(LWIPDIR)/core/ipv6/ip6.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ip6.Tpo $(DEPDIR)/ip6.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/ipv6/ip6.c' object='ip6.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ip6.lo `test -f '$(LWIPDIR)/core/ipv6/ip6.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6.c ip6_addr.lo: $(LWIPDIR)/core/ipv6/ip6_addr.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ip6_addr.lo -MD -MP -MF $(DEPDIR)/ip6_addr.Tpo -c -o ip6_addr.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_addr.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_addr.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ip6_addr.Tpo $(DEPDIR)/ip6_addr.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/ipv6/ip6_addr.c' object='ip6_addr.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ip6_addr.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_addr.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_addr.c ip6_route.lo: $(LWIPDIR)/core/ipv6/ip6_route.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ip6_route.lo -MD -MP -MF $(DEPDIR)/ip6_route.Tpo -c -o ip6_route.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_route.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_route.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ip6_route.Tpo $(DEPDIR)/ip6_route.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/ipv6/ip6_route.c' object='ip6_route.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ip6_route.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_route.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_route.c ip6_frag.lo: $(LWIPDIR)/core/ipv6/ip6_frag.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ip6_frag.lo -MD -MP -MF $(DEPDIR)/ip6_frag.Tpo -c -o ip6_frag.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_frag.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_frag.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ip6_frag.Tpo $(DEPDIR)/ip6_frag.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/ipv6/ip6_frag.c' object='ip6_frag.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ip6_frag.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_frag.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_frag.c ip6_autoconf.lo: $(LWIPDIR)/core/ipv6/ip6_autoconf.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ip6_autoconf.lo -MD -MP -MF $(DEPDIR)/ip6_autoconf.Tpo -c -o ip6_autoconf.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_autoconf.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_autoconf.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ip6_autoconf.Tpo $(DEPDIR)/ip6_autoconf.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/ipv6/ip6_autoconf.c' object='ip6_autoconf.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ip6_autoconf.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_autoconf.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_autoconf.c ip6_radv.lo: $(LWIPDIR)/core/ipv6/ip6_radv.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT ip6_radv.lo -MD -MP -MF $(DEPDIR)/ip6_radv.Tpo -c -o ip6_radv.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_radv.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_radv.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/ip6_radv.Tpo $(DEPDIR)/ip6_radv.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/core/ipv6/ip6_radv.c' object='ip6_radv.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o ip6_radv.lo `test -f '$(LWIPDIR)/core/ipv6/ip6_radv.c' || echo '$(srcdir)/'`$(LWIPDIR)/core/ipv6/ip6_radv.c api_lib.lo: $(LWIPDIR)/api/api_lib.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT api_lib.lo -MD -MP -MF $(DEPDIR)/api_lib.Tpo -c -o api_lib.lo `test -f '$(LWIPDIR)/api/api_lib.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/api_lib.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/api_lib.Tpo $(DEPDIR)/api_lib.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/api/api_lib.c' object='api_lib.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o api_lib.lo `test -f '$(LWIPDIR)/api/api_lib.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/api_lib.c api_msg.lo: $(LWIPDIR)/api/api_msg.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT api_msg.lo -MD -MP -MF $(DEPDIR)/api_msg.Tpo -c -o api_msg.lo `test -f '$(LWIPDIR)/api/api_msg.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/api_msg.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/api_msg.Tpo $(DEPDIR)/api_msg.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/api/api_msg.c' object='api_msg.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o api_msg.lo `test -f '$(LWIPDIR)/api/api_msg.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/api_msg.c tcpip.lo: $(LWIPDIR)/api/tcpip.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tcpip.lo -MD -MP -MF $(DEPDIR)/tcpip.Tpo -c -o tcpip.lo `test -f '$(LWIPDIR)/api/tcpip.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/tcpip.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tcpip.Tpo $(DEPDIR)/tcpip.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/api/tcpip.c' object='tcpip.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tcpip.lo `test -f '$(LWIPDIR)/api/tcpip.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/tcpip.c err.lo: $(LWIPDIR)/api/err.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT err.lo -MD -MP -MF $(DEPDIR)/err.Tpo -c -o err.lo `test -f '$(LWIPDIR)/api/err.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/err.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/err.Tpo $(DEPDIR)/err.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/api/err.c' object='err.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o err.lo `test -f '$(LWIPDIR)/api/err.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/err.c netlink.lo: $(LWIPDIR)/api/netlink.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT netlink.lo -MD -MP -MF $(DEPDIR)/netlink.Tpo -c -o netlink.lo `test -f '$(LWIPDIR)/api/netlink.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/netlink.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/netlink.Tpo $(DEPDIR)/netlink.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/api/netlink.c' object='netlink.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o netlink.lo `test -f '$(LWIPDIR)/api/netlink.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/netlink.c sockets.lo: $(LWIPDIR)/api/sockets.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sockets.lo -MD -MP -MF $(DEPDIR)/sockets.Tpo -c -o sockets.lo `test -f '$(LWIPDIR)/api/sockets.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/sockets.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sockets.Tpo $(DEPDIR)/sockets.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/api/sockets.c' object='sockets.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sockets.lo `test -f '$(LWIPDIR)/api/sockets.c' || echo '$(srcdir)/'`$(LWIPDIR)/api/sockets.c loopif.lo: $(LWIPDIR)/netif/loopif.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT loopif.lo -MD -MP -MF $(DEPDIR)/loopif.Tpo -c -o loopif.lo `test -f '$(LWIPDIR)/netif/loopif.c' || echo '$(srcdir)/'`$(LWIPDIR)/netif/loopif.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/loopif.Tpo $(DEPDIR)/loopif.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/netif/loopif.c' object='loopif.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o loopif.lo `test -f '$(LWIPDIR)/netif/loopif.c' || echo '$(srcdir)/'`$(LWIPDIR)/netif/loopif.c etharp.lo: $(LWIPDIR)/netif/etharp.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT etharp.lo -MD -MP -MF $(DEPDIR)/etharp.Tpo -c -o etharp.lo `test -f '$(LWIPDIR)/netif/etharp.c' || echo '$(srcdir)/'`$(LWIPDIR)/netif/etharp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/etharp.Tpo $(DEPDIR)/etharp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPDIR)/netif/etharp.c' object='etharp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o etharp.lo `test -f '$(LWIPDIR)/netif/etharp.c' || echo '$(srcdir)/'`$(LWIPDIR)/netif/etharp.c sys_arch_pipe.lo: $(LWIPARCH)/sys_arch_pipe.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT sys_arch_pipe.lo -MD -MP -MF $(DEPDIR)/sys_arch_pipe.Tpo -c -o sys_arch_pipe.lo `test -f '$(LWIPARCH)/sys_arch_pipe.c' || echo '$(srcdir)/'`$(LWIPARCH)/sys_arch_pipe.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/sys_arch_pipe.Tpo $(DEPDIR)/sys_arch_pipe.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPARCH)/sys_arch_pipe.c' object='sys_arch_pipe.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o sys_arch_pipe.lo `test -f '$(LWIPARCH)/sys_arch_pipe.c' || echo '$(srcdir)/'`$(LWIPARCH)/sys_arch_pipe.c vdeif.lo: $(LWIPARCH)/netif/vdeif.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT vdeif.lo -MD -MP -MF $(DEPDIR)/vdeif.Tpo -c -o vdeif.lo `test -f '$(LWIPARCH)/netif/vdeif.c' || echo '$(srcdir)/'`$(LWIPARCH)/netif/vdeif.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/vdeif.Tpo $(DEPDIR)/vdeif.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPARCH)/netif/vdeif.c' object='vdeif.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o vdeif.lo `test -f '$(LWIPARCH)/netif/vdeif.c' || echo '$(srcdir)/'`$(LWIPARCH)/netif/vdeif.c slirpif.lo: $(LWIPARCH)/netif/slirpif.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT slirpif.lo -MD -MP -MF $(DEPDIR)/slirpif.Tpo -c -o slirpif.lo `test -f '$(LWIPARCH)/netif/slirpif.c' || echo '$(srcdir)/'`$(LWIPARCH)/netif/slirpif.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/slirpif.Tpo $(DEPDIR)/slirpif.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPARCH)/netif/slirpif.c' object='slirpif.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o slirpif.lo `test -f '$(LWIPARCH)/netif/slirpif.c' || echo '$(srcdir)/'`$(LWIPARCH)/netif/slirpif.c tapif.lo: $(LWIPARCH)/netif/tapif.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tapif.lo -MD -MP -MF $(DEPDIR)/tapif.Tpo -c -o tapif.lo `test -f '$(LWIPARCH)/netif/tapif.c' || echo '$(srcdir)/'`$(LWIPARCH)/netif/tapif.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tapif.Tpo $(DEPDIR)/tapif.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPARCH)/netif/tapif.c' object='tapif.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tapif.lo `test -f '$(LWIPARCH)/netif/tapif.c' || echo '$(srcdir)/'`$(LWIPARCH)/netif/tapif.c tunif.lo: $(LWIPARCH)/netif/tunif.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tunif.lo -MD -MP -MF $(DEPDIR)/tunif.Tpo -c -o tunif.lo `test -f '$(LWIPARCH)/netif/tunif.c' || echo '$(srcdir)/'`$(LWIPARCH)/netif/tunif.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tunif.Tpo $(DEPDIR)/tunif.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPARCH)/netif/tunif.c' object='tunif.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tunif.lo `test -f '$(LWIPARCH)/netif/tunif.c' || echo '$(srcdir)/'`$(LWIPARCH)/netif/tunif.c userfilter.lo: $(LWIPFILTERDIR)/userfilter.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT userfilter.lo -MD -MP -MF $(DEPDIR)/userfilter.Tpo -c -o userfilter.lo `test -f '$(LWIPFILTERDIR)/userfilter.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/userfilter.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/userfilter.Tpo $(DEPDIR)/userfilter.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPFILTERDIR)/userfilter.c' object='userfilter.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o userfilter.lo `test -f '$(LWIPFILTERDIR)/userfilter.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/userfilter.c nat.lo: $(LWIPFILTERDIR)/nat/nat.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nat.lo -MD -MP -MF $(DEPDIR)/nat.Tpo -c -o nat.lo `test -f '$(LWIPFILTERDIR)/nat/nat.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nat.Tpo $(DEPDIR)/nat.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPFILTERDIR)/nat/nat.c' object='nat.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nat.lo `test -f '$(LWIPFILTERDIR)/nat/nat.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat.c nat_rules.lo: $(LWIPFILTERDIR)/nat/nat_rules.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nat_rules.lo -MD -MP -MF $(DEPDIR)/nat_rules.Tpo -c -o nat_rules.lo `test -f '$(LWIPFILTERDIR)/nat/nat_rules.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_rules.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nat_rules.Tpo $(DEPDIR)/nat_rules.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPFILTERDIR)/nat/nat_rules.c' object='nat_rules.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nat_rules.lo `test -f '$(LWIPFILTERDIR)/nat/nat_rules.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_rules.c nat_tables.lo: $(LWIPFILTERDIR)/nat/nat_tables.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nat_tables.lo -MD -MP -MF $(DEPDIR)/nat_tables.Tpo -c -o nat_tables.lo `test -f '$(LWIPFILTERDIR)/nat/nat_tables.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_tables.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nat_tables.Tpo $(DEPDIR)/nat_tables.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPFILTERDIR)/nat/nat_tables.c' object='nat_tables.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nat_tables.lo `test -f '$(LWIPFILTERDIR)/nat/nat_tables.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_tables.c nat_track_proto_tcp.lo: $(LWIPFILTERDIR)/nat/nat_track_proto_tcp.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nat_track_proto_tcp.lo -MD -MP -MF $(DEPDIR)/nat_track_proto_tcp.Tpo -c -o nat_track_proto_tcp.lo `test -f '$(LWIPFILTERDIR)/nat/nat_track_proto_tcp.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_track_proto_tcp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nat_track_proto_tcp.Tpo $(DEPDIR)/nat_track_proto_tcp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPFILTERDIR)/nat/nat_track_proto_tcp.c' object='nat_track_proto_tcp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nat_track_proto_tcp.lo `test -f '$(LWIPFILTERDIR)/nat/nat_track_proto_tcp.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_track_proto_tcp.c nat_track_proto_udp.lo: $(LWIPFILTERDIR)/nat/nat_track_proto_udp.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nat_track_proto_udp.lo -MD -MP -MF $(DEPDIR)/nat_track_proto_udp.Tpo -c -o nat_track_proto_udp.lo `test -f '$(LWIPFILTERDIR)/nat/nat_track_proto_udp.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_track_proto_udp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nat_track_proto_udp.Tpo $(DEPDIR)/nat_track_proto_udp.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPFILTERDIR)/nat/nat_track_proto_udp.c' object='nat_track_proto_udp.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nat_track_proto_udp.lo `test -f '$(LWIPFILTERDIR)/nat/nat_track_proto_udp.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_track_proto_udp.c nat_track_proto_icmp4.lo: $(LWIPFILTERDIR)/nat/nat_track_proto_icmp4.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nat_track_proto_icmp4.lo -MD -MP -MF $(DEPDIR)/nat_track_proto_icmp4.Tpo -c -o nat_track_proto_icmp4.lo `test -f '$(LWIPFILTERDIR)/nat/nat_track_proto_icmp4.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_track_proto_icmp4.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nat_track_proto_icmp4.Tpo $(DEPDIR)/nat_track_proto_icmp4.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPFILTERDIR)/nat/nat_track_proto_icmp4.c' object='nat_track_proto_icmp4.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nat_track_proto_icmp4.lo `test -f '$(LWIPFILTERDIR)/nat/nat_track_proto_icmp4.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_track_proto_icmp4.c nat_track_proto_generic.lo: $(LWIPFILTERDIR)/nat/nat_track_proto_generic.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT nat_track_proto_generic.lo -MD -MP -MF $(DEPDIR)/nat_track_proto_generic.Tpo -c -o nat_track_proto_generic.lo `test -f '$(LWIPFILTERDIR)/nat/nat_track_proto_generic.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_track_proto_generic.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/nat_track_proto_generic.Tpo $(DEPDIR)/nat_track_proto_generic.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPFILTERDIR)/nat/nat_track_proto_generic.c' object='nat_track_proto_generic.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o nat_track_proto_generic.lo `test -f '$(LWIPFILTERDIR)/nat/nat_track_proto_generic.c' || echo '$(srcdir)/'`$(LWIPFILTERDIR)/nat/nat_track_proto_generic.c radvconf.lo: $(LWIPRADVDIR)/radvconf.c @am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT radvconf.lo -MD -MP -MF $(DEPDIR)/radvconf.Tpo -c -o radvconf.lo `test -f '$(LWIPRADVDIR)/radvconf.c' || echo '$(srcdir)/'`$(LWIPRADVDIR)/radvconf.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/radvconf.Tpo $(DEPDIR)/radvconf.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(LWIPRADVDIR)/radvconf.c' object='radvconf.lo' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o radvconf.lo `test -f '$(LWIPRADVDIR)/radvconf.c' || echo '$(srcdir)/'`$(LWIPRADVDIR)/radvconf.c mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) test -z "$(includedir)" || $(MKDIR_P) "$(DESTDIR)$(includedir)" @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(includedir)'"; \ $(INSTALL_HEADER) $$files "$(DESTDIR)$(includedir)" || exit $$?; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; test -n "$(includedir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(includedir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(includedir)" && rm -f $$files ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-includeHEADERS install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-libLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-includeHEADERS install-info \ install-info-am install-libLTLIBRARIES install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-includeHEADERS \ uninstall-libLTLIBRARIES # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: lwipv6-1.5a/lwip-contrib/ports/unix/sys_arch.c0000644000175000017500000003367311671615010020557 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* * Wed Apr 17 16:05:29 EDT 2002 (James Roth) * * - Fixed an unlikely sys_thread_new() race condition. * * - Made current_thread() work with threads which where * not created with sys_thread_new(). This includes * the main thread and threads made with pthread_create(). * * - Catch overflows where more than SYS_MBOX_SIZE messages * are waiting to be read. The sys_mbox_post() routine * will block until there is more room instead of just * leaking messages. */ #include "lwip/debug.h" #include #include #include #include #include #include #include "lwip/sys.h" #include "lwip/opt.h" #include "lwip/stats.h" #define UMAX(a, b) ((a) > (b) ? (a) : (b)) static struct sys_thread *threads = NULL; static pthread_mutex_t threads_mutex = PTHREAD_MUTEX_INITIALIZER; struct sys_mbox_msg { struct sys_mbox_msg *next; void *msg; }; #define SYS_MBOX_SIZE 128 struct sys_mbox { int first, last; void *msgs[SYS_MBOX_SIZE]; struct sys_sem *mail; struct sys_sem *mutex; int wait_send; }; struct sys_sem { unsigned int c; pthread_cond_t cond; pthread_mutex_t mutex; }; struct sys_thread { struct sys_thread *next; struct sys_timeouts timeouts; pthread_t pthread; }; static struct timeval starttime; static pthread_mutex_t lwprot_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_t lwprot_thread = (pthread_t) 0xDEAD; static int lwprot_count = 0; static struct sys_sem *sys_sem_new_(u8_t count); static void sys_sem_free_(struct sys_sem *sem); static u32_t cond_wait(pthread_cond_t * cond, pthread_mutex_t * mutex, u32_t timeout); /*-----------------------------------------------------------------------------------*/ static struct sys_thread * introduce_thread(pthread_t id) { struct sys_thread *thread; thread = malloc(sizeof(struct sys_thread)); if (thread) { pthread_mutex_lock(&threads_mutex); thread->next = threads; thread->timeouts.next = NULL; thread->pthread = id; threads = thread; pthread_mutex_unlock(&threads_mutex); } return thread; } /*-----------------------------------------------------------------------------------*/ static struct sys_thread * current_thread(void) { struct sys_thread *st; pthread_t pt; pt = pthread_self(); pthread_mutex_lock(&threads_mutex); for(st = threads; st != NULL; st = st->next) { if (pthread_equal(st->pthread, pt)) { pthread_mutex_unlock(&threads_mutex); return st; } } pthread_mutex_unlock(&threads_mutex); st = introduce_thread(pt); if (!st) { printf("current_thread???\n"); abort(); } return st; } /*-----------------------------------------------------------------------------------*/ sys_thread_t sys_thread_new(void (*function)(void *arg), void *arg, int prio) { int code; pthread_t tmp; struct sys_thread *st = NULL; code = pthread_create(&tmp, NULL, (void *(*)(void *)) function, arg); if (0 == code) { st = introduce_thread(tmp); } if (NULL == st) { LWIP_DEBUGF(SYS_DEBUG, ("sys_thread_new: pthread_create %d, st = 0x%x", code, (int)st)); abort(); } return st; } /*-----------------------------------------------------------------------------------*/ struct sys_mbox * sys_mbox_new() { struct sys_mbox *mbox; mbox = malloc(sizeof(struct sys_mbox)); mbox->first = mbox->last = 0; mbox->mail = sys_sem_new_(0); mbox->mutex = sys_sem_new_(1); mbox->wait_send = 0; #if SYS_STATS lwip_stats.sys.mbox.used++; if (lwip_stats.sys.mbox.used > lwip_stats.sys.mbox.max) { lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used; } #endif /* SYS_STATS */ return mbox; } /*-----------------------------------------------------------------------------------*/ void sys_mbox_free(struct sys_mbox *mbox) { if (mbox != SYS_MBOX_NULL) { #if SYS_STATS lwip_stats.sys.mbox.used--; #endif /* SYS_STATS */ sys_sem_wait(mbox->mutex); sys_sem_free_(mbox->mail); sys_sem_free_(mbox->mutex); mbox->mail = mbox->mutex = NULL; /* LWIP_DEBUGF("sys_mbox_free: mbox 0x%lx\n", mbox); */ free(mbox); } } /*-----------------------------------------------------------------------------------*/ void sys_mbox_post(struct sys_mbox *mbox, void *msg) { u8_t first; sys_sem_wait(mbox->mutex); LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_post: mbox %p msg %p\n", (void *)mbox, (void *)msg)); while ((mbox->last + 1) >= (mbox->first + SYS_MBOX_SIZE)) { mbox->wait_send++; sys_sem_signal(mbox->mutex); sys_arch_sem_wait(mbox->mail, 0); sys_arch_sem_wait(mbox->mutex, 0); mbox->wait_send--; } mbox->msgs[mbox->last % SYS_MBOX_SIZE] = msg; if (mbox->last == mbox->first) { first = 1; } else { first = 0; } mbox->last++; if (first) { sys_sem_signal(mbox->mail); } sys_sem_signal(mbox->mutex); } /*-----------------------------------------------------------------------------------*/ u32_t sys_arch_mbox_fetch(struct sys_mbox *mbox, void **msg, u32_t timeout) { u32_t time = 0; /* The mutex lock is quick so we don't bother with the timeout stuff here. */ sys_arch_sem_wait(mbox->mutex, 0); while (mbox->first == mbox->last) { sys_sem_signal(mbox->mutex); /* We block while waiting for a mail to arrive in the mailbox. We must be prepared to timeout. */ if (timeout != 0) { time = sys_arch_sem_wait(mbox->mail, timeout); if (time == SYS_ARCH_TIMEOUT) { return SYS_ARCH_TIMEOUT; } } else { sys_arch_sem_wait(mbox->mail, 0); } sys_arch_sem_wait(mbox->mutex, 0); } if (msg != NULL) { LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p msg %p\n", (void *)mbox, *msg)); *msg = mbox->msgs[mbox->first % SYS_MBOX_SIZE]; } else{ LWIP_DEBUGF(SYS_DEBUG, ("sys_mbox_fetch: mbox %p, null msg\n", (void *)mbox)); } mbox->first++; if (mbox->wait_send) { sys_sem_signal(mbox->mail); } sys_sem_signal(mbox->mutex); return time; } /*-----------------------------------------------------------------------------------*/ struct sys_sem * sys_sem_new(u8_t count) { #if SYS_STATS lwip_stats.sys.sem.used++; if (lwip_stats.sys.sem.used > lwip_stats.sys.sem.max) { lwip_stats.sys.sem.max = lwip_stats.sys.sem.used; } #endif /* SYS_STATS */ return sys_sem_new_(count); } /*-----------------------------------------------------------------------------------*/ static struct sys_sem * sys_sem_new_(u8_t count) { struct sys_sem *sem; sem = malloc(sizeof(struct sys_sem)); sem->c = count; pthread_cond_init(&(sem->cond), NULL); pthread_mutex_init(&(sem->mutex), NULL); return sem; } /*-----------------------------------------------------------------------------------*/ static u32_t cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, u32_t timeout) { int tdiff; unsigned long sec, usec; struct timeval rtime1, rtime2; struct timespec ts; struct timezone tz; int retval; if (timeout > 0) { /* Get a timestamp and add the timeout value. */ gettimeofday(&rtime1, &tz); sec = rtime1.tv_sec; usec = rtime1.tv_usec; usec += timeout % 1000 * 1000; sec += (int)(timeout / 1000) + (int)(usec / 1000000); usec = usec % 1000000; ts.tv_nsec = usec * 1000; ts.tv_sec = sec; retval = pthread_cond_timedwait(cond, mutex, &ts); if (retval == ETIMEDOUT) { return SYS_ARCH_TIMEOUT; } else { /* Calculate for how long we waited for the cond. */ gettimeofday(&rtime2, &tz); tdiff = (rtime2.tv_sec - rtime1.tv_sec) * 1000 + (rtime2.tv_usec - rtime1.tv_usec) / 1000; if (tdiff <= 0) { return 0; } return tdiff; } } else { pthread_cond_wait(cond, mutex); return SYS_ARCH_TIMEOUT; } } /*-----------------------------------------------------------------------------------*/ u32_t sys_arch_sem_wait(struct sys_sem *sem, u32_t timeout) { u32_t time = 0; pthread_mutex_lock(&(sem->mutex)); while (sem->c <= 0) { if (timeout > 0) { time = cond_wait(&(sem->cond), &(sem->mutex), timeout); if (time == SYS_ARCH_TIMEOUT) { pthread_mutex_unlock(&(sem->mutex)); return SYS_ARCH_TIMEOUT; } /* pthread_mutex_unlock(&(sem->mutex)); return time; */ } else { cond_wait(&(sem->cond), &(sem->mutex), 0); } } sem->c--; pthread_mutex_unlock(&(sem->mutex)); return time; } /*-----------------------------------------------------------------------------------*/ void sys_sem_signal(struct sys_sem *sem) { pthread_mutex_lock(&(sem->mutex)); sem->c++; if (sem->c > 1) { sem->c = 1; } pthread_cond_broadcast(&(sem->cond)); pthread_mutex_unlock(&(sem->mutex)); } /*-----------------------------------------------------------------------------------*/ void sys_sem_free(struct sys_sem *sem) { if (sem != SYS_SEM_NULL) { #if SYS_STATS lwip_stats.sys.sem.used--; #endif /* SYS_STATS */ sys_sem_free_(sem); } } /*-----------------------------------------------------------------------------------*/ static void sys_sem_free_(struct sys_sem *sem) { pthread_cond_destroy(&(sem->cond)); pthread_mutex_destroy(&(sem->mutex)); free(sem); } /*-----------------------------------------------------------------------------------*/ void sys_init() { struct timezone tz; gettimeofday(&starttime, &tz); } /*-----------------------------------------------------------------------------------*/ struct sys_timeouts * sys_arch_timeouts(void) { struct sys_thread *thread; thread = current_thread(); return &thread->timeouts; } /*-----------------------------------------------------------------------------------*/ /** sys_prot_t sys_arch_protect(void) This optional function does a "fast" critical region protection and returns the previous protection level. This function is only called during very short critical regions. An embedded system which supports ISR-based drivers might want to implement this function by disabling interrupts. Task-based systems might want to implement this by using a mutex or disabling tasking. This function should support recursive calls from the same task or interrupt. In other words, sys_arch_protect() could be called while already protected. In that case the return value indicates that it is already protected. sys_arch_protect() is only required if your port is supporting an operating system. */ sys_prot_t sys_arch_protect(void) { /* Note that for the UNIX port, we are using a lightweight mutex, and our * own counter (which is locked by the mutex). The return code is not actually * used. */ if (lwprot_thread != pthread_self()) { /* We are locking the mutex where it has not been locked before * * or is being locked by another thread */ pthread_mutex_lock(&lwprot_mutex); lwprot_thread = pthread_self(); lwprot_count = 1; } else /* It is already locked by THIS thread */ lwprot_count++; return 0; } /*-----------------------------------------------------------------------------------*/ /** void sys_arch_unprotect(sys_prot_t pval) This optional function does a "fast" set of critical region protection to the value specified by pval. See the documentation for sys_arch_protect() for more information. This function is only required if your port is supporting an operating system. */ void sys_arch_unprotect(sys_prot_t pval) { if (lwprot_thread == pthread_self()) { if (--lwprot_count == 0) { lwprot_thread = (pthread_t) 0xDEAD; pthread_mutex_unlock(&lwprot_mutex); } } } /*-----------------------------------------------------------------------------------*/ #ifndef MAX_JIFFY_OFFSET #define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) #endif #ifndef HZ #define HZ 100 #endif unsigned long sys_jiffies(void) { struct timeval tv; unsigned long sec = tv.tv_sec; long usec = tv.tv_usec; gettimeofday(&tv,NULL); if (sec >= (MAX_JIFFY_OFFSET / HZ)) return MAX_JIFFY_OFFSET; usec += 1000000L / HZ - 1; usec /= 1000000L / HZ; return HZ * sec + usec; } #if PPP_DEBUG #include void ppp_trace(int level, const char *format, ...) { va_list args; (void)level; va_start(args, format); vprintf(format, args); va_end(args); } #endif lwipv6-1.5a/ltmain.sh0000644000175000017500000105202211671615046013654 0ustar renzorenzo # libtool (GNU libtool) 2.4.2 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [OPTION]... [MODE-ARG]... # # Provide generalized library-building support services. # # --config show all configuration variables # --debug enable verbose shell tracing # -n, --dry-run display commands without modifying any files # --features display basic configuration information and exit # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --no-warn don't display warning messages # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # MODE must be one of the following: # # clean remove files from the build directory # compile compile a source file into a libtool object # execute automatically set library path, then run a program # finish complete the installation of libtool libraries # install install libraries or executables # link create a library or an executable # uninstall remove libraries from an installed directory # # MODE-ARGS vary depending on the MODE. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4.2 Debian-2.4.2-1" TIMESTAMP="" package_revision=1.3337 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=${PATH_SEPARATOR-:} for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_features () { echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_warning=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-warning|--no-warn) opt_warning=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then $ECHO "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' if test "$need_locks" = warn && test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then $ECHO "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $ECHO \ "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $ECHO \ "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $ECHO \ "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $ECHO \ "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $ECHO \ "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append staticlibs " $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $tool_oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { case \" \$* \" in *\\ --lt-*) for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done ;; esac func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 sed $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${1+\"\$@\"} fi else # The program doesn't exist. \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -n -e ' s/^\(.\{79\}\)\(..*\)/\1\ \2/ h s/\([\\"]\)/\\\1/g s/$/\\n/ s/\([^\n]*\).*/ fputs ("\1", f);/p g D' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invocation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args=$nonopt base_compile="$nonopt $@" compile_command=$nonopt finalize_command=$nonopt compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test "$#" -gt 0; do arg="$1" shift func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append finalize_command " @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; esac fi # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$absdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in # correct linux to gnu/linux during the next big refactor darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) # correct to gnu/linux during the next big refactor func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` #done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null | $GREP " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then # Remove ${wl} instances when linking with ld. # FIXME: should test the right _cmds variable. case $archive_cmds in *\$LD\ *) wl= ;; esac if test "$hardcode_into_libs" = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_run || $RM $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. # $show "echo timestamp > $libobj" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append finalize_perm_rpath " $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append rpath "$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 tool_oldlib=$func_to_tool_file_result eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) func_basename "$deplib" name="$func_basename_result" func_resolve_sysroot "$deplib" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 lwipv6-1.5a/COPYING0000644000175000017500000003543711671615010013070 0ustar renzorenzo GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS lwipv6-1.5a/lwip-v6/0000755000175000017500000000000011671615111013327 5ustar renzorenzolwipv6-1.5a/lwip-v6/README0000644000175000017500000000712311671615010014210 0ustar renzorenzoINTRODUCTION lwIP is a small independent implementation of the TCP/IP protocol suite that has been developed by Adam Dunkels at the Computer and Networks Architectures (CNA) lab at the Swedish Institute of Computer Science (SICS). The focus of the lwIP TCP/IP implementation is to reduce the RAM usage while still having a full scale TCP. This making lwIP suitable for use in embedded systems with tenths of kilobytes of free RAM and room for around 40 kilobytes of code ROM. FEATURES * IP (Internet Protocol) including packet forwarding over multiple network interfaces * ICMP (Internet Control Message Protocol) for network maintenance and debugging * UDP (User Datagram Protocol) including experimental UDP-lite extensions * TCP (Transmission Control Protocol) with congestion control, RTT estimation and fast recovery/fast retransmit * Specialized API for enhanced performance * Optional Berkeley socket API LICENSE lwIP is freely available under a BSD license. DEVELOPMENT lwIP has grown into an excellent TCP/IP stack for embedded devices, and developers using the stack often submit bug fixes, improvements, and additions to the stack to further increase its usefulness. Development of lwIP is hosted on Savannah, a central point for software development, maintenance and distribution. Everyone can help improve lwIP by use of Savannah's interface, CVS and the mailing list. A core team of developers will commit changes to the CVS source tree. The lwIP TCP/IP stack is maintained in the 'lwip' CVS module and contributions (such as platform ports) are in the 'contrib' module. The CVS main trunk is the stable branch, which contains bug fixes and tested features. The latest stable branch can be checked out by doing: cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip co lwip The 'STABLE' tag in the stable branch will represent the most stable revision (which may be somewhat older to protect us from errors introduced by merges). This 'STABLE' tagged version can be checked out by doing: cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip co -r STABLE lwip The 'DEVEL' branch is the active development branch, which contains bleeding edge changes, and may be instable. It can be checkout by doing: cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip co -r DEVEL lwip The current contrib CVS tree can be checked out by doing: cvs -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip login cvs -z3 -d:pserver:anoncvs@subversions.gnu.org:/cvsroot/lwip co contrib Last night's CVS tar ball can be downloaded from: http://savannah.gnu.org/cvs.backups/lwip.tar.gz The current CVS trees are web-browsable: http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/lwip/ http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/contrib/ Submit patches and bugs via the lwIP project page: http://savannah.nongnu.org/projects/lwip/ DOCUMENTATION The original out-dated homepage of lwIP and Adam Dunkels' papers on lwIP are at the official lwIP home page: http://www.sics.se/~adam/lwip/ Self documentation of the source code is regularly extracted from the current CVS sources and is available from this web page: http://www.nongnu.org/lwip/ Reading Adam's papers, the files in docs/, browsing the source code documentation and browsing the mailing list archives is a good way to become familiar with the design of lwIP. Adam Dunkels Leon Woestenberg lwipv6-1.5a/lwip-v6/doc/0000755000175000017500000000000011671615111014074 5ustar renzorenzolwipv6-1.5a/lwip-v6/doc/rawapi.txt0000644000175000017500000003001011671615003016112 0ustar renzorenzoRaw TCP/IP interface for lwIP Authors: Adam Dunkels, Leon Woestenberg lwIP provides two Application Program's Interfaces (APIs) for programs to use for communication with the TCP/IP code: * low-level "core" / "callback" or "raw" API. * higher-level "sequential" API. The sequential API provides a way for ordinary, sequential, programs to use the lwIP stack. It is quite similar to the BSD socket API. The model of execution is based on the blocking open-read-write-close paradigm. Since the TCP/IP stack is event based by nature, the TCP/IP code and the application program must reside in different execution contexts (threads). ** The remainder of this document discusses the "raw" API. ** The raw TCP/IP interface allows the application program to integrate better with the TCP/IP code. Program execution is event based by having callback functions being called from within the TCP/IP code. The TCP/IP code and the application program both run in the same thread. The sequential API has a much higher overhead and is not very well suited for small systems since it forces a multithreaded paradigm on the application. The raw TCP/IP interface is not only faster in terms of code execution time but is also less memory intensive. The drawback is that program development is somewhat harder and application programs written for the raw TCP/IP interface are more difficult to understand. Still, this is the preferred way of writing applications that should be small in code size and memory usage. Both APIs can be used simultaneously by different application programs. In fact, the sequential API is implemented as an application program using the raw TCP/IP interface. --- Callbacks Program execution is driven by callbacks. Each callback is an ordinary C function that is called from within the TCP/IP code. Every callback function is passed the current TCP or UDP connection state as an argument. Also, in order to be able to keep program specific state, the callback functions are called with a program specified argument that is independent of the TCP/IP state. The function for setting the application connection state is: - void tcp_arg(struct tcp_pcb *pcb, void *arg) Specifies the program specific state that should be passed to all other callback functions. The "pcb" argument is the current TCP connection control block, and the "arg" argument is the argument that will be passed to the callbacks. --- TCP connection setup The functions used for setting up connections is similar to that of the sequential API and of the BSD socket API. A new TCP connection identifier (i.e., a protocol control block - PCB) is created with the tcp_new() function. This PCB can then be either set to listen for new incoming connections or be explicitly connected to another host. - struct tcp_pcb *tcp_new(void) Creates a new connection identifier (PCB). If memory is not available for creating the new pcb, NULL is returned. - err_t tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) Binds the pcb to a local IP address and port number. The IP address can be specified as IP_ADDR_ANY in order to bind the connection to all local IP addresses. If another connection is bound to the same port, the function will return ERR_USE, otherwise ERR_OK is returned. - struct tcp_pcb *tcp_listen(struct tcp_pcb *pcb) Commands a pcb to start listening for incoming connections. When an incoming connection is accepted, the function specified with the tcp_accept() function will be called. The pcb will have to be bound to a local port with the tcp_bind() function. The tcp_listen() function returns a new connection identifier, and the one passed as an argument to the function will be deallocated. The reason for this behavior is that less memory is needed for a connection that is listening, so tcp_listen() will reclaim the memory needed for the original connection and allocate a new smaller memory block for the listening connection. tcp_listen() may return NULL if no memory was available for the listening connection. If so, the memory associated with the pcb passed as an argument to tcp_listen() will not be deallocated. - void tcp_accept(struct tcp_pcb *pcb, err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err)) Specified the callback function that should be called when a new connection arrives on a listening connection. - err_t tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port, err_t (* connected)(void *arg, struct tcp_pcb *tpcb, err_t err)); Sets up the pcb to connect to the remote host and sends the initial SYN segment which opens the connection. The tcp_connect() function returns immediately; it does not wait for the connection to be properly setup. Instead, it will call the function specified as the fourth argument (the "connected" argument) when the connection is established. If the connection could not be properly established, either because the other host refused the connection or because the other host didn't answer, the "connected" function will be called with an the "err" argument set accordingly. The tcp_connect() function can return ERR_MEM if no memory is available for enqueueing the SYN segment. If the SYN indeed was enqueued successfully, the tcp_connect() function returns ERR_OK. --- Sending TCP data TCP data is sent by enqueueing the data with a call to tcp_write(). When the data is successfully transmitted to the remote host, the application will be notified with a call to a specified callback function. - err_t tcp_write(struct tcp_pcb *pcb, void *dataptr, u16_t len, u8_t copy) Enqueues the data pointed to by the argument dataptr. The length of the data is passed as the len parameter. The copy argument is either 0 or 1 and indicates whether the new memory should be allocated for the data to be copied into. If the argument is 0, no new memory should be allocated and the data should only be referenced by pointer. The tcp_write() function will fail and return ERR_MEM if the length of the data exceeds the current send buffer size or if the length of the queue of outgoing segment is larger than the upper limit defined in lwipopts.h. The number of bytes available in the output queue can be retrieved with the tcp_sndbuf() function. The proper way to use this function is to call the function with at most tcp_sndbuf() bytes of data. If the function returns ERR_MEM, the application should wait until some of the currently enqueued data has been successfully received by the other host and try again. - void tcp_sent(struct tcp_pcb *pcb, err_t (* sent)(void *arg, struct tcp_pcb *tpcb, u16_t len)) Specifies the callback function that should be called when data has successfully been received (i.e., acknowledged) by the remote host. The len argument passed to the callback function gives the amount bytes that was acknowledged by the last acknowledgment. --- Receiving TCP data TCP data reception is callback based - an application specified callback function is called when new data arrives. When the application has taken the data, it has to call the tcp_recved() function to indicate that TCP can advertise increase the receive window. - void tcp_recv(struct tcp_pcb *pcb, err_t (* recv)(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)) Sets the callback function that will be called when new data arrives. The callback function will be passed a NULL pbuf to indicate that the remote host has closed the connection. - void tcp_recved(struct tcp_pcb *pcb, u16_t len) Must be called when the application has received the data. The len argument indicates the length of the received data. --- Application polling When a connection is idle (i.e., no data is either transmitted or received), lwIP will repeatedly poll the application by calling a specified callback function. This can be used either as a watchdog timer for killing connections that have stayed idle for too long, or as a method of waiting for memory to become available. For instance, if a call to tcp_write() has failed because memory wasn't available, the application may use the polling functionality to call tcp_write() again when the connection has been idle for a while. - void tcp_poll(struct tcp_pcb *pcb, u8_t interval, err_t (* poll)(void *arg, struct tcp_pcb *tpcb)) Specifies the polling interval and the callback function that should be called to poll the application. The interval is specified in number of TCP coarse grained timer shots, which typically occurs twice a second. An interval of 10 means that the application would be polled every 5 seconds. --- Closing and aborting connections - err_t tcp_close(struct tcp_pcb *pcb) Closes the connection. The function may return ERR_MEM if no memory was available for closing the connection. If so, the application should wait and try again either by using the acknowledgment callback or the polling functionality. If the close succeeds, the function returns ERR_OK. The pcb is deallocated by the TCP code after a call to tcp_close(). - void tcp_abort(struct tcp_pcb *pcb) Aborts the connection by sending a RST (reset) segment to the remote host. The pcb is deallocated. This function never fails. If a connection is aborted because of an error, the application is alerted of this event by the err callback. Errors that might abort a connection are when there is a shortage of memory. The callback function to be called is set using the tcp_err() function. - void tcp_err(struct tcp_pcb *pcb, void (* err)(void *arg, err_t err)) The error callback function does not get the pcb passed to it as a parameter since the pcb may already have been deallocated. --- Lower layer TCP interface TCP provides a simple interface to the lower layers of the system. During system initialization, the function tcp_init() has to be called before any other TCP function is called. When the system is running, the two timer functions tcp_fasttmr() and tcp_slowtmr() must be called with regular intervals. The tcp_fasttmr() should be called every TCP_FAST_INTERVAL milliseconds (defined in tcp.h) and tcp_slowtmr() should be called every TCP_SLOW_INTERVAL milliseconds. --- UDP interface The UDP interface is similar to that of TCP, but due to the lower level of complexity of UDP, the interface is significantly simpler. - struct udp_pcb *udp_new(void) Creates a new UDP pcb which can be used for UDP communication. The pcb is not active until it has either been bound to a local address or connected to a remote address. - void udp_remove(struct udp_pcb *pcb) Removes and deallocates the pcb. - err_t udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) Binds the pcb to a local address. The IP-address argument "ipaddr" can be IP_ADDR_ANY to indicate that it should listen to any local IP address. The function currently always return ERR_OK. - err_t udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) Sets the remote end of the pcb. This function does not generate any network traffic, but only set the remote address of the pcb. - err_t udp_disconnect(struct udp_pcb *pcb) Remove the remote end of the pcb. This function does not generate any network traffic, but only removes the remote address of the pcb. - err_t udp_send(struct udp_pcb *pcb, struct pbuf *p) Sends the pbuf p. The pbuf is not deallocated. - void udp_recv(struct udp_pcb *pcb, void (* recv)(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port), void *recv_arg) Specifies a callback function that should be called when a UDP datagram is received.lwipv6-1.5a/lwip-v6/doc/sys_arch.txt0000644000175000017500000001742511671615003016461 0ustar renzorenzosys_arch interface for lwIP 0.6++ Author: Adam Dunkels The operating system emulation layer provides a common interface between the lwIP code and the underlying operating system kernel. The general idea is that porting lwIP to new architectures requires only small changes to a few header files and a new sys_arch implementation. It is also possible to do a sys_arch implementation that does not rely on any underlying operating system. The sys_arch provides semaphores and mailboxes to lwIP. For the full lwIP functionality, multiple threads support can be implemented in the sys_arch, but this is not required for the basic lwIP functionality. Previous versions of lwIP required the sys_arch to implement timer scheduling as well but as of lwIP 0.5 this is implemented in a higher layer. In addition to the source file providing the functionality of sys_arch, the OS emulation layer must provide several header files defining macros used throughout lwip. The files required and the macros they must define are listed below the sys_arch description. Semaphores can be either counting or binary - lwIP works with both kinds. Mailboxes are used for message passing and can be implemented either as a queue which allows multiple messages to be posted to a mailbox, or as a rendez-vous point where only one message can be posted at a time. lwIP works with both kinds, but the former type will be more efficient. A message in a mailbox is just a pointer, nothing more. Semaphores are represented by the type "sys_sem_t" which is typedef'd in the sys_arch.h file. Mailboxes are equivalently represented by the type "sys_mbox_t". lwIP does not place any restrictions on how sys_sem_t or sys_mbox_t are represented internally. The following functions must be implemented by the sys_arch: - void sys_init(void) Is called to initialize the sys_arch layer. - sys_sem_t sys_sem_new(u8_t count) Creates and returns a new semaphore. The "count" argument specifies the initial state of the semaphore. - void sys_sem_free(sys_sem_t sem) Deallocates a semaphore. - void sys_sem_signal(sys_sem_t sem) Signals a semaphore. - u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout) Blocks the thread while waiting for the semaphore to be signaled. If the "timeout" argument is non-zero, the thread should only be blocked for the specified time (measured in milliseconds). If the timeout argument is non-zero, the return value is the number of milliseconds spent waiting for the semaphore to be signaled. If the semaphore wasn't signaled within the specified time, the return value is SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore (i.e., it was already signaled), the function may return zero. Notice that lwIP implements a function with a similar name, sys_sem_wait(), that uses the sys_arch_sem_wait() function. - sys_mbox_t sys_mbox_new(void) Creates an empty mailbox. - void sys_mbox_free(sys_mbox_t mbox) Deallocates a mailbox. If there are messages still present in the mailbox when the mailbox is deallocated, it is an indication of a programming error in lwIP and the developer should be notified. - void sys_mbox_post(sys_mbox_t mbox, void *msg) Posts the "msg" to the mailbox. - u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout) Blocks the thread until a message arrives in the mailbox, but does not block the thread longer than "timeout" milliseconds (similar to the sys_arch_sem_wait() function). The "msg" argument is a result parameter that is set by the function (i.e., by doing "*msg = ptr"). The "msg" parameter maybe NULL to indicate that the message should be dropped. The return values are the same as for the sys_arch_sem_wait() function: Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a timeout. Note that a function with a similar name, sys_mbox_fetch(), is implemented by lwIP. - struct sys_timeouts *sys_arch_timeouts(void) Returns a pointer to the per-thread sys_timeouts structure. In lwIP, each thread has a list of timeouts which is repressented as a linked list of sys_timeout structures. The sys_timeouts structure holds a pointer to a linked list of timeouts. This function is called by the lwIP timeout scheduler and must not return a NULL value. In a single threadd sys_arch implementation, this function will simply return a pointer to a global sys_timeouts variable stored in the sys_arch module. If threads are supported by the underlying operating system and if such functionality is needed in lwIP, the following function will have to be implemented as well: - sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio) Starts a new thread with priority "prio" that will begin its execution in the function "thread()". The "arg" argument will be passed as an argument to the thread() function. The id of the new thread is returned. Both the id and the priority are system dependent. - sys_prot_t sys_arch_protect(void) This optional function does a "fast" critical region protection and returns the previous protection level. This function is only called during very short critical regions. An embedded system which supports ISR-based drivers might want to implement this function by disabling interrupts. Task-based systems might want to implement this by using a mutex or disabling tasking. This function should support recursive calls from the same task or interrupt. In other words, sys_arch_protect() could be called while already protected. In that case the return value indicates that it is already protected. sys_arch_protect() is only required if your port is supporting an operating system. - void sys_arch_unprotect(sys_prot_t pval) This optional function does a "fast" set of critical region protection to the value specified by pval. See the documentation for sys_arch_protect() for more information. This function is only required if your port is supporting an operating system. ------------------------------------------------------------------------------- Additional files required for the "OS support" emulation layer: ------------------------------------------------------------------------------- cc.h - Architecture environment, some compiler specific, some environment specific (probably should move env stuff to sys_arch.h.) Typedefs for the types used by lwip - u8_t, s8_t, u16_t, s16_t, u32_t, s32_t, mem_ptr_t Compiler hints for packing lwip's structures - PACK_STRUCT_FIELD(x) PACK_STRUCT_STRUCT PACK_STRUCT_BEGIN PACK_STRUCT_END Platform specific diagnostic output - LWIP_PLATFORM_DIAG(x) - non-fatal, print a message. LWIP_PLATFORM_ASSERT(x) - fatal, print message and abandon execution. "lightweight" synchronization mechanisms - SYS_ARCH_DECL_PROTECT(x) - declare a protection state variable. SYS_ARCH_PROTECT(x) - enter protection mode. SYS_ARCH_UNPROTECT(x) - leave protection mode. If the compiler does not provide memset() this file must include a definition of it, or include a file which defines it. This file must either include a system-local which defines the standard *nix error codes, or it should #define LWIP_PROVIDE_ERRNO to make lwip/arch.h define the codes which are used throughout. perf.h - Architecture specific performance measurement. Measurement calls made throughout lwip, these can be defined to nothing. PERF_START - start measuring something. PERF_STOP(x) - stop measuring something, and record the result. sys_arch.h - Tied to sys_arch.c Arch dependent types for the following objects: sys_sem_t, sys_mbox_t, sys_thread_t, And, optionally: sys_prot_t Defines to set vars of sys_mbox_t and sys_sem_t to NULL. SYS_MBOX_NULL NULL SYS_SEM_NULL NULL lwipv6-1.5a/lwip-v6/doc/lwip_radv.conf0000644000175000017500000000025011671615003016727 0ustar renzorenzo[vd0] AdvSendAdvert = on AdvLinkMTU = 1321 MinRtrAdvInterval = 5 MaxRtrAdvInterval = 20 AddPrefix = 2001:1234:5678::0/64 , AdvOnLinkFlag = on , AdvAutonomousFlag = on lwipv6-1.5a/lwip-v6/doc/savannah.txt0000644000175000017500000001136511671615003016442 0ustar renzorenzoDaily Use Guide for using Savannah for lwIP Table of Contents: 1 - Obtaining lwIP from the CVS repository 2 - Committers/developers CVS access using SSH (to be written) 3 - Merging from DEVEL branch to main trunk (stable branch) 4 - How to release lwIP 1 Obtaining lwIP from the CVS repository ---------------------------------------- To perform an anonymous CVS checkout of the main trunk (this is where bug fixes and incremental enhancements occur), do this: export CVS_RSH=ssh cvs -d:ext:anoncvs@subversions.gnu.org:/cvsroot/lwip checkout lwip (If SSH asks about authenticity of the host, you can check the key fingerprint against http://savannah.nongnu.org/cvs/?group=lwip) Or, obtain a stable branch (updated with bug fixes only) as follows: cvs -d:ext:anoncvs@subversions.gnu.org:/cvsroot/lwip checkout -r STABLE-0_7 -d lwip-0.7 lwip Or, obtain a specific (fixed) release as follows: cvs -d:ext:anoncvs@subversions.gnu.org:/cvsroot/lwip checkout -r STABLE-0_7_0 -d lwip-0.7.0 lwip Or, obtain a development branch (considered unstable!) as follows: cvs -d:ext:anoncvs@subversions.gnu.org:/cvsroot/lwip checkout -r DEVEL -d lwip-DEVEL lwip 3 Committers/developers CVS access using SSH -------------------------------------------- The Savannah server uses SSH (Secure Shell) protocol 2 authentication and encryption. As such, CVS commits to the server occur through a SSH tunnel for project members. To create a SSH2 key pair in UNIX-like environments, do this: ssh-keygen -t dsa Under Windows, a recommended SSH client is "PuTTY", freely available with good documentation and a graphic user interface. Use its key generator. Now paste the id_dsa.pub contents into your Savannah account public key list. Wait a while so that Savannah can update its configuration (This can take minutes). Try to login using SSH: ssh -v your_login@subversions.gnu.org If it tells you: Authenticating with public key "your_key_name"... Server refused to allocate pty then you could login; Savannah refuses to give you a shell - which is OK, as we are allowed to use SSH for CVS only. Now, you should be able to do this: export CVS_RSH=ssh cvs -d:ext:your_login@subversions.gnu.org:/cvsroot/lwip checkout lwip after which you can edit your local files with bug fixes or new features and commit them. Make sure you know what you are doing when using CVS to make changes on the repository. If in doubt, ask on the lwip-members mailing list. 3 Merging from DEVEL branch to main trunk (stable) -------------------------------------------------- Merging is a delicate process in CVS and requires the following disciplined steps in order to prevent conflicts in the future. Conflicts can be hard to solve! Merging from branch A to branch B requires that the A branch has a tag indicating the previous merger. This tag is called 'merged_from_A_to_B'. After merging, the tag is moved in the A branch to remember this merger for future merge actions. IMPORTANT: AFTER COMMITTING A SUCCESFUL MERGE IN THE REPOSITORY, THE TAG MUST BE SET ON THE SOURCE BRANCH OF THE MERGE ACTION (REPLACING EXISTING TAGS WITH THE SAME NAME). Merge all changes in DEVEL since our last merge to main: In the working copy of the main trunk: cvs update -P -jmerged_from_DEVEL_to_main -jDEVEL (This will apply the changes between 'merged_from_DEVEL_to_main' and 'DEVEL' to your work set of files) We can now commit the merge result. cvs commit -R -m "Merged from DEVEL to main." If this worked out OK, we now move the tag in the DEVEL branch to this merge point, so we can use this point for future merges: cvs rtag -F -r DEVEL merged_from_DEVEL_to_main lwip 4 How to release lwIP --------------------- First, checkout a clean copy of the branch to be released. Tag this set with tag name "STABLE-0_6_3". (I use release number 0.6.3 throughout this example). Login CVS using pserver authentication, then export a clean copy of the tagged tree. Export is similar to a checkout, except that the CVS metadata is not created locally. export CVS_RSH=ssh cvs -d:ext:anoncvs@subversions.gnu.org:/cvsroot/lwip export -r STABLE-0_6_3 -d lwip-0.6.3 lwip Archive this directory using tar, gzip'd, bzip2'd and zip'd. tar czvf lwip-0.6.3.tar.gz lwip-0.6.3 tar cjvf lwip-0.6.3.tar.bz2 lwip-0.6.3 zip -r lwip-0.6.3.zip lwip-0.6.3 Now, sign the archives with a detached GPG binary signature as follows: gpg -b lwip-0.6.3.tar.gz gpg -b lwip-0.6.3.tar.bz2 gpg -b lwip-0.6.3.zip Upload these files using anonymous FTP: ncftp ftp://savannah.gnu.org/incoming/savannah/lwip ncftp>mput *0.6.3.* Additionally, you may post a news item on Savannah, like this: A new 0.6.3 release is now available here: http://savannah.nongnu.org/files/?group=lwip&highlight=0.6.3 You will have to submit this via the user News interface, then approve this via the Administrator News interface.lwipv6-1.5a/lwip-v6/doc/contrib.txt0000644000175000017500000000631611671615003016303 0ustar renzorenzo1 Introduction This document describes some guidelines for people participating in lwIP development. 2 How to contribute to lwIP Here is a short list of suggestions to anybody working with lwIP and trying to contribute bug reports, fixes, enhancements, platform ports etc. First of all as you may already know lwIP is a volunteer project so feedback to fixes or questions might often come late. Hopefully the bug and patch tracking features of Savannah help us not lose users' input. 2.1 Source code style: 1. do not use tabs. 2. indentation is two spaces per level (i.e. per tab). 3. end debug messages with a trailing newline (\n). 4. one space between keyword and opening bracket. 5. no space between function and opening bracket. 6. one space and no newline before opening curly braces of a block. 7. closing curly brace on a single line. 8. spaces surrounding assignment and comparisons. 9. use current source code style as further reference. 2.2 Source code documentation style: 1. JavaDoc compliant and Doxygen compatible. 2. Function documentation above functions in .c files, not .h files. (This forces you to synchronize documentation and implementation.) 3. Use current documentation style as further reference. 2.3 Bug reports and patches: 1. Make sure you are reporting bugs or send patches against the latest sources. (From the latest release and/or the current CVS sources.) 2. If you think you found a bug make sure it's not already filed in the bugtracker at Savannah. 3. If you have a fix put the patch on Savannah. If it is a patch that affects both core and arch specific stuff please separate them so that the core can be applied separately while leaving the other patch 'open'. The prefered way is to NOT touch archs you can't test and let maintainers take care of them. This is a good way to see if they are used at all - the same goes for unix netifs except tapif. 4. Do not file a bug and post a fix to it to the patch area. Either a bug report or a patch will be enough. If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area. 5. Trivial patches (compiler warning, indentation and spelling fixes or anything obvious which takes a line or two) can go to the lwip-users list. This is still the fastest way of interaction and the list is not so crowded as to allow for loss of fixes. Putting bugs on Savannah and subsequently closing them is too much an overhead for reporting a compiler warning fix. 6. Patches should be specific to a single change or to related changes.Do not mix bugfixes with spelling and other trivial fixes unless the bugfix is trivial too.Do not reorganize code and rename identifiers in the same patch you change behaviour if not necessary.A patch is easier to read and understand if it's to the point and short than if it's not to the point and long :) so the chances for it to be applied are greater. 2.4 Platform porters: 1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and you think it could benefit others[1] you might want discuss this on the mailing list. You can also ask for CVS access to submit and maintain your port in the contrib CVS module. lwipv6-1.5a/lwip-v6/COPYING0000644000175000017500000000311311671615010014356 0ustar renzorenzo/* * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ lwipv6-1.5a/lwip-v6/src/0000755000175000017500000000000011671615111014116 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/radv/0000755000175000017500000000000011671615111015052 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/radv/radvconf.c0000644000175000017500000003025411671615010017022 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if IPv6_RADVCONF #include #include #include #include #include #include "lwip/debug.h" #include "lwip/stats.h" #include "lwip/sys.h" #include "lwip/netif.h" #include "lwip/ip.h" #include "lwip/ip_addr.h" #include "lwip/icmp.h" #include "lwip/inet.h" #ifndef AF_INET6 #define AF_INET6 10 #endif #include "lwip/ip_radv.h" #include "lwip/radvconf.h" #ifndef IP_RADVCONF_DEBUG #define IP_RADVCONF_DEBUG DBG_ON #endif #define ASCIILINESZ 1024 char * strlwc(char * s) { static char l[ASCIILINESZ+1]; int i ; if (s==NULL) return NULL ; memset(l, 0, ASCIILINESZ+1); i=0 ; while (s[i] && i l) { if (!isspace((int)*(last-1))) break ; last -- ; } *last = (char)0; return l ; } char * strstrip(char * s) { static char l[ASCIILINESZ+1]; char * last ; if (s==NULL) return NULL ; while (isspace((int)*s) && *s) s++; memset(l, 0, ASCIILINESZ+1); strcpy(l, s); last = l + strlen(l); while (last > l) { if (!isspace((int)*(last-1))) break ; last -- ; } *last = (char)0; return (char*)l ; } /*--------------------------------------------------------------------------*/ char * str_strip(char *str) { char * last; if (str==NULL) return NULL ; while (isspace((int)*str) && *str) str++; last = str + strlen(str); while (last > str) { if (!isspace((int)*(last-1))) break ; last -- ; } *last = (char)0; return (char*)str ; } int str_to_bool(u8_t *bool, char *str) { if (strcmp(str, "true") == 0) { *bool=1; return 1; } if (strcmp(str, "TRUE") == 0) { *bool=1; return 1; } if (strcmp(str, "on") == 0) { *bool=1; return 1; } if (strcmp(str, "ON") == 0) { *bool=1; return 1; } if (strcmp(str, "false") == 0) { *bool=0; return 1; } if (strcmp(str, "FALSE") == 0) { *bool=0; return 1; } if (strcmp(str, "off") == 0) { *bool=0; return 1; } if (strcmp(str, "OFF") == 0) { *bool=0; return 1; } return 0; } int str_to_int(u32_t *val, char *str) { unsigned int integer; char *ptr = NULL; integer = strtol(str, &ptr, 10); if (errno == ERANGE || *ptr != '\0') return 0; else { *val = integer; return 1; } } int str_to_int_or_infinity(u32_t *val, char *str) { if (strcmp(str, "infinity") == 0 || strcmp(str, "INFINITY") == 0) { *val = 0xffffffff; return 1; } else return str_to_int(val, str); } int str_to_short(u16_t *val, char *str) { unsigned int integer; char *ptr = NULL; integer = strtol(str, &ptr, 10); if (errno == ERANGE || *ptr != '\0') return 0; else { * val = (u16_t) integer; return 1; } } int str_to_char(u8_t *val, char *str) { unsigned int integer; char *ptr = NULL; integer = strtol(str, &ptr, 10); if (errno == ERANGE || *ptr != '\0') return 0; else { * val = (char) integer; return 1; } } static char *GETTOK(int argc, char *argv[], int pos) { if (pos >= 0 && pos < argc) return argv[pos]; else return NULL; } static int tokenize(char *str, char **tokens, int max, char sep) { char inside_token; int ntok; if (str == NULL || max == 0 || tokens == NULL) return 0; inside_token = 0; ntok = 0; while (*str) { if ((*str) == sep) { * str = '\0'; if (inside_token) { inside_token = 0; tokens[ntok+1] = NULL; if (ntok == max) // add NULL token to the end break; } } else // new token if (! inside_token) { tokens[ntok] = str; inside_token = 1; ntok++; } str++; } tokens[ntok+1] = NULL; return ntok; } /*--------------------------------------------------------------------------*/ int set_prefix_ip_len(struct radv_prefix *prefix, char *str_ip, char *str_len, int lineno) { if (inet_pton(AF_INET6, str_ip, &prefix->Prefix) < 0) { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("Invalid prefix %s/%s at line: %d\n", str_ip, str_len, lineno) ); return 0; } if (str_to_char( (u8_t *) & prefix->PrefixLen, str_len) == 0) { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("Invalid prefix %s/%s at line: %d\n", str_ip, str_len, lineno) ); return 0; } return 1; } int set_prefix_option(struct radv_prefix *prefix, char *option, char *val, int lineno) { if (strcmp(option, "AdvOnLinkFlag") == 0) { if (str_to_bool( & prefix->AdvOnLinkFlag, val) == 1) return 1; } else if (strcmp(option, "AdvAutonomousFlag") == 0) { if (str_to_bool( & prefix->AdvAutonomousFlag, val) == 1) return 1; } else if (strcmp(option, "AdvValidLifetime") == 0) { if (str_to_int_or_infinity( & prefix->AdvValidLifetime, val) == 1) return 1; } else if (strcmp(option, "AdvPreferredLifetime") == 0) { if (str_to_int_or_infinity( & prefix->AdvPreferredLifetime, val) == 1) return 1; } else { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("Unknown option '%s' \n", option) ); } LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("Wrong value '%s' for '%s' at line '%d'\n", val, option, lineno) ); return 0; } int set_netif_prefix(struct netif *netif, char *val, int lineno) { char *tokens[31]; int num, i, err; struct radv_prefix *prefix; if(netif->radv == NULL) return 0; prefix = radv_prefix_list_alloc(); if (prefix == NULL) return 0; /* * 2001:1234:5678::/64 , Option1 = val, Option2 = val, .... * token 0 token 0 token 0 */ err = 0; if ((num=tokenize(val, tokens, 30, ',')) >= 1 ) { for (i=0; i '/' */ if (i==0) { char *pref_tok[3]; if (tokenize(GETTOK(num, tokens, i), pref_tok, 2, '/') != 2) { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("Error while parsing '%s' at line: %d\n", GETTOK(num, tokens, i), lineno)); err = 1; break; } if (set_prefix_ip_len(prefix, str_strip(pref_tok[0]), str_strip(pref_tok[1]), lineno) == 0) err = 1; } /* * Option '=' */ else { char *opt_tok[3]; if (tokenize(GETTOK(num, tokens, i), opt_tok, 2, '=') != 2) { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("Error while parsing '%s' at line: %d\n", GETTOK(num, tokens, i), lineno) ); err = 1; break; } if (set_prefix_option(prefix, str_strip(opt_tok[0]), str_strip(opt_tok[1]), lineno) == 0) err = 1; } } } else { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("Error while parsing line: %d\n", lineno) ); err = 1; } if (err) { radv_prefix_list_free(prefix); return 0; } ip_addr_debug_print(IP_RADVCONF_DEBUG, &prefix->Prefix); prefix->next = netif->radv->prefix_list; netif->radv->prefix_list = prefix; return 1; } int set_netif_parameter(struct netif *netif, char *parameter, char *val, int lineno) { struct radv *rinfo = netif->radv; if (rinfo == NULL) { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("%s: invalid interface '%c%c%d' at line: %d\n", __func__, netif->name[0], netif->name[1], netif->num, lineno)); return 0; } if (strcmp(parameter, "AdvSendAdvert") == 0) { if (str_to_bool( &rinfo->AdvSendAdvert , val) == 1) return 1; } else if (strcmp(parameter, "MaxRtrAdvInterval") == 0) { if (str_to_int( &rinfo->MaxRtrAdvInterval , val) == 1) return 1; } else if (strcmp(parameter, "MinRtrAdvInterval") == 0) { if (str_to_int( &rinfo->MinRtrAdvInterval , val) == 1) return 1; } else if (strcmp(parameter, "MinDelayBetweenRAs") == 0) { if (str_to_int( &rinfo->MinDelayBetweenRAs , val) == 1) return 1; } else if (strcmp(parameter, "AdvManagedFlag") == 0) { if (str_to_bool( &rinfo->AdvManagedFlag , val) == 0) return 1; } else if (strcmp(parameter, "AdvOtherConfigFlag") == 0) { if (str_to_bool( &rinfo->AdvOtherConfigFlag , val) == 1) return 1; } else if (strcmp(parameter, "AdvLinkMTU") == 0) { if (str_to_int( &rinfo->AdvLinkMTU , val) == 1) return 1; } else if (strcmp(parameter, "AdvReachableTime") == 0) { if (str_to_int( &rinfo->AdvReachableTime , val) == 1) return 1; } else if (strcmp(parameter, "AdvRetransTimer") == 0) { if (str_to_int( &rinfo->AdvRetransTimer , val) == 1) return 1; } else if (strcmp(parameter, "AdvCurHopLimit") == 0) { if (str_to_char( &rinfo->AdvCurHopLimit , val) == 1) return 1; } else if (strcmp(parameter, "AdvDefaultLifetime") == 0) { if (str_to_short( &rinfo->AdvDefaultLifetime , val) == 1) return 1; } else if (strcmp(parameter, "AdvSourceLLAddress") == 0) { if (str_to_bool( &rinfo->AdvSourceLLAddress , val) == 1) return 1; } else if (strcmp(parameter, "UnicastOnly") == 0) { if (str_to_bool( &rinfo->UnicastOnly , val) == 1) return 1; } else /* * Prefix options */ if (strcmp(parameter, "AddPrefix") == 0) { return set_netif_prefix(netif, val, lineno); } else /* * Others */ { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("%s: unknown option '%s' at line: %d\n", __func__, parameter, lineno)); return 0; } LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("%s: invalid value '%s' for '%s' at line: %d\n", __func__, val, parameter, lineno)); return 0; } /*--------------------------------------------------------------------------*/ void radv_load_config(struct stack *stack, FILE *filein) { char lin[ASCIILINESZ+1]; char sec[ASCIILINESZ+1]; char key[ASCIILINESZ+1]; char val[ASCIILINESZ+1]; char * where ; int lineno ; struct netif * curr_netif; sec[0]=0; /* * Initialize a new dictionary entry */ lineno = 0 ; curr_netif = NULL; while (fgets(lin, ASCIILINESZ, filein) != NULL) { lineno++ ; where = strskp(lin); /* Skip leading spaces */ /* * # Comment. */ if (*where==';' || *where=='#' || *where==0) continue ; /* Comment lines */ else /* * [vd0] */ if (sscanf(where, "[%[^]]", sec) == 1) { /* Valid section name */ strcpy(sec, strlwc(sec)); if (curr_netif != NULL) { ip_radv_check_options(curr_netif); // FIX: check values } curr_netif = netif_find(stack, sec); if (curr_netif == NULL) { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("%s: netif '%s' not found! (line %d)\n", __func__, sec, lineno)); } } /* * Parameter = Value */ else if (sscanf (where, "%[^=] = %[^;#]", key, val) == 2) { if (curr_netif == NULL) { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("%s: interface not specified!\n", __func__)); continue; } strcpy(key, strcrop(key)); strcpy(val, strcrop(val)); set_netif_parameter(curr_netif, key, val, lineno); } } if (curr_netif != NULL) { ip_radv_check_options(curr_netif); // FIX: check values } } int radv_load_configfile(struct stack *stack, char *path) { FILE * filein ; if ((filein=fopen(path, "r"))==NULL) { LWIP_DEBUGF(IP_RADVCONF_DEBUG, ("%s: file '%s' not found!\n", __func__, path)); return 0; } radv_load_config(stack, filein); fclose(filein); return 1 ; } #endif lwipv6-1.5a/lwip-v6/src/netif/0000755000175000017500000000000011671615111015223 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/netif/ppp/0000755000175000017500000000000011671615111016022 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/netif/ppp/vjbsdhdr.h0000644000175000017500000000401211671615006020001 0ustar renzorenzo#ifndef VJBSDHDR_H #define VJBSDHDR_H #include "lwip/tcp.h" /* * Structure of an internet header, naked of options. * * We declare ip_len and ip_off to be short, rather than u_short * pragmatically since otherwise unsigned comparisons can result * against negative integers quite easily, and fail in subtle ways. */ PACK_STRUCT_BEGIN struct ip { #if defined(NO_CHAR_BITFIELDS) u_char ip_hl_v; /* bug in GCC for mips means the bitfield stuff will sometimes break - so we use a char for both and get round it with macro's instead... */ #else #if BYTE_ORDER == LITTLE_ENDIAN unsigned ip_hl:4, /* header length */ ip_v:4; /* version */ #elif BYTE_ORDER == BIG_ENDIAN unsigned ip_v:4, /* version */ ip_hl:4; /* header length */ #else COMPLAIN - NO BYTE ORDER SELECTED! #endif #endif u_char ip_tos; /* type of service */ u_short ip_len; /* total length */ u_short ip_id; /* identification */ u_short ip_off; /* fragment offset field */ #define IP_DF 0x4000 /* dont fragment flag */ #define IP_MF 0x2000 /* more fragments flag */ #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ u_char ip_ttl; /* time to live */ u_char ip_p; /* protocol */ u_short ip_sum; /* checksum */ struct in_addr ip_src,ip_dst; /* source and dest address */ }; PACK_STRUCT_END typedef u32_t tcp_seq; /* * TCP header. * Per RFC 793, September, 1981. */ PACK_STRUCT_BEGIN struct tcphdr { u_short th_sport; /* source port */ u_short th_dport; /* destination port */ tcp_seq th_seq; /* sequence number */ tcp_seq th_ack; /* acknowledgement number */ #if defined(NO_CHAR_BITFIELDS) u_char th_x2_off; #else #if BYTE_ORDER == LITTLE_ENDIAN unsigned th_x2:4, /* (unused) */ th_off:4; /* data offset */ #endif #if BYTE_ORDER == BIG_ENDIAN unsigned th_off:4, /* data offset */ th_x2:4; /* (unused) */ #endif #endif u_char th_flags; u_short th_win; /* window */ u_short th_sum; /* checksum */ u_short th_urp; /* urgent pointer */ }; PACK_STRUCT_END #endif /* VJBSDHDR_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/chap.c0000644000175000017500000005555611671615006017124 0ustar renzorenzo/*** WARNING - THIS HAS NEVER BEEN FINISHED ***/ /***************************************************************************** * chap.c - Network Challenge Handshake Authentication Protocol program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 by Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-04 Guy Lancaster , Global Election Systems Inc. * Original based on BSD chap.c. *****************************************************************************/ /* * chap.c - Challenge Handshake Authentication Protocol. * * Copyright (c) 1993 The Australian National University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the Australian National University. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Copyright (c) 1991 Gregory M. Christy. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Gregory M. Christy. The name of the author may not be used to * endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include "ppp.h" #if PPP_SUPPORT > 0 #include "magic.h" #if CHAP_SUPPORT > 0 #include "randm.h" #include "auth.h" #include "md5.h" #include "chap.h" #include "chpms.h" #include "pppdebug.h" /*************************/ /*** LOCAL DEFINITIONS ***/ /*************************/ /************************/ /*** LOCAL DATA TYPES ***/ /************************/ /***********************************/ /*** LOCAL FUNCTION DECLARATIONS ***/ /***********************************/ /* * Protocol entry points. */ static void ChapInit (int); static void ChapLowerUp (int); static void ChapLowerDown (int); static void ChapInput (int, u_char *, int); static void ChapProtocolReject (int); static int ChapPrintPkt (u_char *, int, void (*) (void *, char *, ...), void *); static void ChapChallengeTimeout (void *); static void ChapResponseTimeout (void *); static void ChapReceiveChallenge (chap_state *, u_char *, int, int); static void ChapRechallenge (void *); static void ChapReceiveResponse (chap_state *, u_char *, int, int); static void ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len); static void ChapReceiveFailure(chap_state *cstate, u_char *inp, u_char id, int len); static void ChapSendStatus (chap_state *, int); static void ChapSendChallenge (chap_state *); static void ChapSendResponse (chap_state *); static void ChapGenChallenge (chap_state *); /******************************/ /*** PUBLIC DATA STRUCTURES ***/ /******************************/ chap_state chap[NUM_PPP]; /* CHAP state; one for each unit */ struct protent chap_protent = { PPP_CHAP, ChapInit, ChapInput, ChapProtocolReject, ChapLowerUp, ChapLowerDown, NULL, NULL, #if 0 ChapPrintPkt, NULL, #endif 1, "CHAP", #if 0 NULL, NULL, NULL #endif }; /*****************************/ /*** LOCAL DATA STRUCTURES ***/ /*****************************/ static char *ChapCodenames[] = { "Challenge", "Response", "Success", "Failure" }; /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* * ChapAuthWithPeer - Authenticate us with our peer (start client). * */ void ChapAuthWithPeer(int unit, char *our_name, int digest) { chap_state *cstate = &chap[unit]; cstate->resp_name = our_name; cstate->resp_type = digest; if (cstate->clientstate == CHAPCS_INITIAL || cstate->clientstate == CHAPCS_PENDING) { /* lower layer isn't up - wait until later */ cstate->clientstate = CHAPCS_PENDING; return; } /* * We get here as a result of LCP coming up. * So even if CHAP was open before, we will * have to re-authenticate ourselves. */ cstate->clientstate = CHAPCS_LISTEN; } /* * ChapAuthPeer - Authenticate our peer (start server). */ void ChapAuthPeer(int unit, char *our_name, int digest) { chap_state *cstate = &chap[unit]; cstate->chal_name = our_name; cstate->chal_type = digest; if (cstate->serverstate == CHAPSS_INITIAL || cstate->serverstate == CHAPSS_PENDING) { /* lower layer isn't up - wait until later */ cstate->serverstate = CHAPSS_PENDING; return; } ChapGenChallenge(cstate); ChapSendChallenge(cstate); /* crank it up dude! */ cstate->serverstate = CHAPSS_INITIAL_CHAL; } /**********************************/ /*** LOCAL FUNCTION DEFINITIONS ***/ /**********************************/ /* * ChapInit - Initialize a CHAP unit. */ static void ChapInit(int unit) { chap_state *cstate = &chap[unit]; BZERO(cstate, sizeof(*cstate)); cstate->unit = unit; cstate->clientstate = CHAPCS_INITIAL; cstate->serverstate = CHAPSS_INITIAL; cstate->timeouttime = CHAP_DEFTIMEOUT; cstate->max_transmits = CHAP_DEFTRANSMITS; /* random number generator is initialized in magic_init */ } /* * ChapChallengeTimeout - Timeout expired on sending challenge. */ static void ChapChallengeTimeout(void *arg) { chap_state *cstate = (chap_state *) arg; /* if we aren't sending challenges, don't worry. then again we */ /* probably shouldn't be here either */ if (cstate->serverstate != CHAPSS_INITIAL_CHAL && cstate->serverstate != CHAPSS_RECHALLENGE) return; if (cstate->chal_transmits >= cstate->max_transmits) { /* give up on peer */ CHAPDEBUG((LOG_ERR, "Peer failed to respond to CHAP challenge\n")); cstate->serverstate = CHAPSS_BADAUTH; auth_peer_fail(cstate->unit, PPP_CHAP); return; } ChapSendChallenge(cstate); /* Re-send challenge */ } /* * ChapResponseTimeout - Timeout expired on sending response. */ static void ChapResponseTimeout(void *arg) { chap_state *cstate = (chap_state *) arg; /* if we aren't sending a response, don't worry. */ if (cstate->clientstate != CHAPCS_RESPONSE) return; ChapSendResponse(cstate); /* re-send response */ } /* * ChapRechallenge - Time to challenge the peer again. */ static void ChapRechallenge(void *arg) { chap_state *cstate = (chap_state *) arg; /* if we aren't sending a response, don't worry. */ if (cstate->serverstate != CHAPSS_OPEN) return; ChapGenChallenge(cstate); ChapSendChallenge(cstate); cstate->serverstate = CHAPSS_RECHALLENGE; } /* * ChapLowerUp - The lower layer is up. * * Start up if we have pending requests. */ static void ChapLowerUp(int unit) { chap_state *cstate = &chap[unit]; if (cstate->clientstate == CHAPCS_INITIAL) cstate->clientstate = CHAPCS_CLOSED; else if (cstate->clientstate == CHAPCS_PENDING) cstate->clientstate = CHAPCS_LISTEN; if (cstate->serverstate == CHAPSS_INITIAL) cstate->serverstate = CHAPSS_CLOSED; else if (cstate->serverstate == CHAPSS_PENDING) { ChapGenChallenge(cstate); ChapSendChallenge(cstate); cstate->serverstate = CHAPSS_INITIAL_CHAL; } } /* * ChapLowerDown - The lower layer is down. * * Cancel all timeouts. */ static void ChapLowerDown(int unit) { chap_state *cstate = &chap[unit]; /* Timeout(s) pending? Cancel if so. */ if (cstate->serverstate == CHAPSS_INITIAL_CHAL || cstate->serverstate == CHAPSS_RECHALLENGE) UNTIMEOUT(ChapChallengeTimeout, cstate); else if (cstate->serverstate == CHAPSS_OPEN && cstate->chal_interval != 0) UNTIMEOUT(ChapRechallenge, cstate); if (cstate->clientstate == CHAPCS_RESPONSE) UNTIMEOUT(ChapResponseTimeout, cstate); cstate->clientstate = CHAPCS_INITIAL; cstate->serverstate = CHAPSS_INITIAL; } /* * ChapProtocolReject - Peer doesn't grok CHAP. */ static void ChapProtocolReject(int unit) { chap_state *cstate = &chap[unit]; if (cstate->serverstate != CHAPSS_INITIAL && cstate->serverstate != CHAPSS_CLOSED) auth_peer_fail(unit, PPP_CHAP); if (cstate->clientstate != CHAPCS_INITIAL && cstate->clientstate != CHAPCS_CLOSED) auth_withpeer_fail(unit, PPP_CHAP); ChapLowerDown(unit); /* shutdown chap */ } /* * ChapInput - Input CHAP packet. */ static void ChapInput(int unit, u_char *inpacket, int packet_len) { chap_state *cstate = &chap[unit]; u_char *inp; u_char code, id; int len; /* * Parse header (code, id and length). * If packet too short, drop it. */ inp = inpacket; if (packet_len < CHAP_HEADERLEN) { CHAPDEBUG((LOG_INFO, "ChapInput: rcvd short header.\n")); return; } GETCHAR(code, inp); GETCHAR(id, inp); GETSHORT(len, inp); if (len < CHAP_HEADERLEN) { CHAPDEBUG((LOG_INFO, "ChapInput: rcvd illegal length.\n")); return; } if (len > packet_len) { CHAPDEBUG((LOG_INFO, "ChapInput: rcvd short packet.\n")); return; } len -= CHAP_HEADERLEN; /* * Action depends on code (as in fact it usually does :-). */ switch (code) { case CHAP_CHALLENGE: ChapReceiveChallenge(cstate, inp, id, len); break; case CHAP_RESPONSE: ChapReceiveResponse(cstate, inp, id, len); break; case CHAP_FAILURE: ChapReceiveFailure(cstate, inp, id, len); break; case CHAP_SUCCESS: ChapReceiveSuccess(cstate, inp, id, len); break; default: /* Need code reject? */ CHAPDEBUG((LOG_WARNING, "Unknown CHAP code (%d) received.\n", code)); break; } } /* * ChapReceiveChallenge - Receive Challenge and send Response. */ static void ChapReceiveChallenge(chap_state *cstate, u_char *inp, int id, int len) { int rchallenge_len; u_char *rchallenge; int secret_len; char secret[MAXSECRETLEN]; char rhostname[256]; MD5_CTX mdContext; u_char hash[MD5_SIGNATURE_SIZE]; CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: Rcvd id %d.\n", id)); if (cstate->clientstate == CHAPCS_CLOSED || cstate->clientstate == CHAPCS_PENDING) { CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: in state %d\n", cstate->clientstate)); return; } if (len < 2) { CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: rcvd short packet.\n")); return; } GETCHAR(rchallenge_len, inp); len -= sizeof (u_char) + rchallenge_len; /* now name field length */ if (len < 0) { CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: rcvd short packet.\n")); return; } rchallenge = inp; INCPTR(rchallenge_len, inp); if (len >= sizeof(rhostname)) len = sizeof(rhostname) - 1; BCOPY(inp, rhostname, len); rhostname[len] = '\000'; CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: received name field '%s'\n", rhostname)); /* Microsoft doesn't send their name back in the PPP packet */ if (ppp_settings.remote_name[0] != 0 && (ppp_settings.explicit_remote || rhostname[0] == 0)) { strncpy(rhostname, ppp_settings.remote_name, sizeof(rhostname)); rhostname[sizeof(rhostname) - 1] = 0; CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: using '%s' as remote name\n", rhostname)); } /* get secret for authenticating ourselves with the specified host */ if (!get_secret(cstate->unit, cstate->resp_name, rhostname, secret, &secret_len, 0)) { secret_len = 0; /* assume null secret if can't find one */ CHAPDEBUG((LOG_WARNING, "No CHAP secret found for authenticating us to %s\n", rhostname)); } /* cancel response send timeout if necessary */ if (cstate->clientstate == CHAPCS_RESPONSE) UNTIMEOUT(ChapResponseTimeout, cstate); cstate->resp_id = id; cstate->resp_transmits = 0; /* generate MD based on negotiated type */ switch (cstate->resp_type) { case CHAP_DIGEST_MD5: MD5Init(&mdContext); MD5Update(&mdContext, &cstate->resp_id, 1); MD5Update(&mdContext, (u_char*)secret, secret_len); MD5Update(&mdContext, rchallenge, rchallenge_len); MD5Final(hash, &mdContext); BCOPY(hash, cstate->response, MD5_SIGNATURE_SIZE); cstate->resp_length = MD5_SIGNATURE_SIZE; break; #ifdef CHAPMS case CHAP_MICROSOFT: ChapMS(cstate, rchallenge, rchallenge_len, secret, secret_len); break; #endif default: CHAPDEBUG((LOG_INFO, "unknown digest type %d\n", cstate->resp_type)); return; } BZERO(secret, sizeof(secret)); ChapSendResponse(cstate); } /* * ChapReceiveResponse - Receive and process response. */ static void ChapReceiveResponse(chap_state *cstate, u_char *inp, int id, int len) { u_char *remmd, remmd_len; int secret_len, old_state; int code; char rhostname[256]; MD5_CTX mdContext; char secret[MAXSECRETLEN]; u_char hash[MD5_SIGNATURE_SIZE]; CHAPDEBUG((LOG_INFO, "ChapReceiveResponse: Rcvd id %d.\n", id)); if (cstate->serverstate == CHAPSS_CLOSED || cstate->serverstate == CHAPSS_PENDING) { CHAPDEBUG((LOG_INFO, "ChapReceiveResponse: in state %d\n", cstate->serverstate)); return; } if (id != cstate->chal_id) return; /* doesn't match ID of last challenge */ /* * If we have received a duplicate or bogus Response, * we have to send the same answer (Success/Failure) * as we did for the first Response we saw. */ if (cstate->serverstate == CHAPSS_OPEN) { ChapSendStatus(cstate, CHAP_SUCCESS); return; } if (cstate->serverstate == CHAPSS_BADAUTH) { ChapSendStatus(cstate, CHAP_FAILURE); return; } if (len < 2) { CHAPDEBUG((LOG_INFO, "ChapReceiveResponse: rcvd short packet.\n")); return; } GETCHAR(remmd_len, inp); /* get length of MD */ remmd = inp; /* get pointer to MD */ INCPTR(remmd_len, inp); len -= sizeof (u_char) + remmd_len; if (len < 0) { CHAPDEBUG((LOG_INFO, "ChapReceiveResponse: rcvd short packet.\n")); return; } UNTIMEOUT(ChapChallengeTimeout, cstate); if (len >= sizeof(rhostname)) len = sizeof(rhostname) - 1; BCOPY(inp, rhostname, len); rhostname[len] = '\000'; CHAPDEBUG((LOG_INFO, "ChapReceiveResponse: received name field: %s\n", rhostname)); /* * Get secret for authenticating them with us, * do the hash ourselves, and compare the result. */ code = CHAP_FAILURE; if (!get_secret(cstate->unit, rhostname, cstate->chal_name, secret, &secret_len, 1)) { /* CHAPDEBUG((LOG_WARNING, TL_CHAP, "No CHAP secret found for authenticating %s\n", rhostname)); */ CHAPDEBUG((LOG_WARNING, "No CHAP secret found for authenticating %s\n", rhostname)); } else { /* generate MD based on negotiated type */ switch (cstate->chal_type) { case CHAP_DIGEST_MD5: /* only MD5 is defined for now */ if (remmd_len != MD5_SIGNATURE_SIZE) break; /* it's not even the right length */ MD5Init(&mdContext); MD5Update(&mdContext, &cstate->chal_id, 1); MD5Update(&mdContext, (u_char*)secret, secret_len); MD5Update(&mdContext, cstate->challenge, cstate->chal_len); MD5Final(hash, &mdContext); /* compare local and remote MDs and send the appropriate status */ if (memcmp (hash, remmd, MD5_SIGNATURE_SIZE) == 0) code = CHAP_SUCCESS; /* they are the same! */ break; default: CHAPDEBUG((LOG_INFO, "unknown digest type %d\n", cstate->chal_type)); } } BZERO(secret, sizeof(secret)); ChapSendStatus(cstate, code); if (code == CHAP_SUCCESS) { old_state = cstate->serverstate; cstate->serverstate = CHAPSS_OPEN; if (old_state == CHAPSS_INITIAL_CHAL) { auth_peer_success(cstate->unit, PPP_CHAP, rhostname, len); } if (cstate->chal_interval != 0) TIMEOUT(ChapRechallenge, cstate, cstate->chal_interval); } else { CHAPDEBUG((LOG_ERR, "CHAP peer authentication failed\n")); cstate->serverstate = CHAPSS_BADAUTH; auth_peer_fail(cstate->unit, PPP_CHAP); } } /* * ChapReceiveSuccess - Receive Success */ static void ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len) { CHAPDEBUG((LOG_INFO, "ChapReceiveSuccess: Rcvd id %d.\n", id)); if (cstate->clientstate == CHAPCS_OPEN) /* presumably an answer to a duplicate response */ return; if (cstate->clientstate != CHAPCS_RESPONSE) { /* don't know what this is */ CHAPDEBUG((LOG_INFO, "ChapReceiveSuccess: in state %d\n", cstate->clientstate)); return; } UNTIMEOUT(ChapResponseTimeout, cstate); /* * Print message. */ if (len > 0) PRINTMSG(inp, len); cstate->clientstate = CHAPCS_OPEN; auth_withpeer_success(cstate->unit, PPP_CHAP); } /* * ChapReceiveFailure - Receive failure. */ static void ChapReceiveFailure(chap_state *cstate, u_char *inp, u_char id, int len) { CHAPDEBUG((LOG_INFO, "ChapReceiveFailure: Rcvd id %d.\n", id)); if (cstate->clientstate != CHAPCS_RESPONSE) { /* don't know what this is */ CHAPDEBUG((LOG_INFO, "ChapReceiveFailure: in state %d\n", cstate->clientstate)); return; } UNTIMEOUT(ChapResponseTimeout, cstate); /* * Print message. */ if (len > 0) PRINTMSG(inp, len); CHAPDEBUG((LOG_ERR, "CHAP authentication failed\n")); auth_withpeer_fail(cstate->unit, PPP_CHAP); } /* * ChapSendChallenge - Send an Authenticate challenge. */ static void ChapSendChallenge(chap_state *cstate) { u_char *outp; int chal_len, name_len; int outlen; chal_len = cstate->chal_len; name_len = strlen(cstate->chal_name); outlen = CHAP_HEADERLEN + sizeof (u_char) + chal_len + name_len; outp = outpacket_buf[cstate->unit]; MAKEHEADER(outp, PPP_CHAP); /* paste in a CHAP header */ PUTCHAR(CHAP_CHALLENGE, outp); PUTCHAR(cstate->chal_id, outp); PUTSHORT(outlen, outp); PUTCHAR(chal_len, outp); /* put length of challenge */ BCOPY(cstate->challenge, outp, chal_len); INCPTR(chal_len, outp); BCOPY(cstate->chal_name, outp, name_len); /* append hostname */ pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); CHAPDEBUG((LOG_INFO, "ChapSendChallenge: Sent id %d.\n", cstate->chal_id)); TIMEOUT(ChapChallengeTimeout, cstate, cstate->timeouttime); ++cstate->chal_transmits; } /* * ChapSendStatus - Send a status response (ack or nak). */ static void ChapSendStatus(chap_state *cstate, int code) { u_char *outp; int outlen, msglen; char msg[256]; if (code == CHAP_SUCCESS) strcpy(msg, "Welcome!"); else strcpy(msg, "I don't like you. Go 'way."); msglen = strlen(msg); outlen = CHAP_HEADERLEN + msglen; outp = outpacket_buf[cstate->unit]; MAKEHEADER(outp, PPP_CHAP); /* paste in a header */ PUTCHAR(code, outp); PUTCHAR(cstate->chal_id, outp); PUTSHORT(outlen, outp); BCOPY(msg, outp, msglen); pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); CHAPDEBUG((LOG_INFO, "ChapSendStatus: Sent code %d, id %d.\n", code, cstate->chal_id)); } /* * ChapGenChallenge is used to generate a pseudo-random challenge string of * a pseudo-random length between min_len and max_len. The challenge * string and its length are stored in *cstate, and various other fields of * *cstate are initialized. */ static void ChapGenChallenge(chap_state *cstate) { int chal_len; u_char *ptr = cstate->challenge; int i; /* pick a random challenge length between MIN_CHALLENGE_LENGTH and MAX_CHALLENGE_LENGTH */ chal_len = (unsigned) ((((magic() >> 16) * (MAX_CHALLENGE_LENGTH - MIN_CHALLENGE_LENGTH)) >> 16) + MIN_CHALLENGE_LENGTH); cstate->chal_len = chal_len; cstate->chal_id = ++cstate->id; cstate->chal_transmits = 0; /* generate a random string */ for (i = 0; i < chal_len; i++ ) *ptr++ = (char) (magic() & 0xff); } /* * ChapSendResponse - send a response packet with values as specified * in *cstate. */ /* ARGSUSED */ static void ChapSendResponse(chap_state *cstate) { u_char *outp; int outlen, md_len, name_len; md_len = cstate->resp_length; name_len = strlen(cstate->resp_name); outlen = CHAP_HEADERLEN + sizeof (u_char) + md_len + name_len; outp = outpacket_buf[cstate->unit]; MAKEHEADER(outp, PPP_CHAP); PUTCHAR(CHAP_RESPONSE, outp); /* we are a response */ PUTCHAR(cstate->resp_id, outp); /* copy id from challenge packet */ PUTSHORT(outlen, outp); /* packet length */ PUTCHAR(md_len, outp); /* length of MD */ BCOPY(cstate->response, outp, md_len); /* copy MD to buffer */ INCPTR(md_len, outp); BCOPY(cstate->resp_name, outp, name_len); /* append our name */ /* send the packet */ pppWrite(cstate->unit, outpacket_buf[cstate->unit], outlen + PPP_HDRLEN); cstate->clientstate = CHAPCS_RESPONSE; TIMEOUT(ChapResponseTimeout, cstate, cstate->timeouttime); ++cstate->resp_transmits; } /* * ChapPrintPkt - print the contents of a CHAP packet. */ static int ChapPrintPkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg ) { int code, id, len; int clen, nlen; u_char x; if (plen < CHAP_HEADERLEN) return 0; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < CHAP_HEADERLEN || len > plen) return 0; if (code >= 1 && code <= sizeof(ChapCodenames) / sizeof(char *)) printer(arg, " %s", ChapCodenames[code-1]); else printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= CHAP_HEADERLEN; switch (code) { case CHAP_CHALLENGE: case CHAP_RESPONSE: if (len < 1) break; clen = p[0]; if (len < clen + 1) break; ++p; nlen = len - clen - 1; printer(arg, " <"); for (; clen > 0; --clen) { GETCHAR(x, p); printer(arg, "%.2x", x); } printer(arg, ">, name = %.*Z", nlen, p); break; case CHAP_FAILURE: case CHAP_SUCCESS: printer(arg, " %.*Z", len, p); break; default: for (clen = len; clen > 0; --clen) { GETCHAR(x, p); printer(arg, " %.2x", x); } } return len + CHAP_HEADERLEN; } #endif #endif /* PPP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/md5.h0000644000175000017500000000571511671615006016673 0ustar renzorenzo/* *********************************************************************** ** md5.h -- header file for implementation of MD5 ** ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** ** Created: 2/17/90 RLR ** ** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version ** ** Revised (for MD5): RLR 4/27/91 ** ** -- G modified to have y&~z instead of y&z ** ** -- FF, GG, HH modified to add in last register done ** ** -- Access pattern: round 2 works mod 5, round 3 works mod 3 ** ** -- distinct additive constant for each step ** ** -- round 4 added, working mod 7 ** *********************************************************************** */ /* *********************************************************************** ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** ** ** ** License to copy and use this software is granted provided that ** ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** ** Digest Algorithm" in all material mentioning or referencing this ** ** software or this function. ** ** ** ** License is also granted to make and use derivative works ** ** provided that such works are identified as "derived from the RSA ** ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** ** material mentioning or referencing the derived work. ** ** ** ** RSA Data Security, Inc. makes no representations concerning ** ** either the merchantability of this software or the suitability ** ** of this software for any particular purpose. It is provided "as ** ** is" without express or implied warranty of any kind. ** ** ** ** These notices must be retained in any copies of any part of this ** ** documentation and/or software. ** *********************************************************************** */ #ifndef MD5_H #define MD5_H /* Data structure for MD5 (Message-Digest) computation */ typedef struct { u32_t i[2]; /* number of _bits_ handled mod 2^64 */ u32_t buf[4]; /* scratch buffer */ unsigned char in[64]; /* input buffer */ unsigned char digest[16]; /* actual digest after MD5Final call */ } MD5_CTX; void MD5Init (MD5_CTX *mdContext); void MD5Update (MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen); void MD5Final (unsigned char hash[], MD5_CTX *mdContext); #endif /* MD5_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/randm.h0000644000175000017500000000602311671615006017300 0ustar renzorenzo/***************************************************************************** * randm.h - Random number generator header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * Copyright (c) 1998 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 98-05-29 Guy Lancaster , Global Election Systems Inc. * Extracted from avos. *****************************************************************************/ #ifndef RANDM_H #define RANDM_H /*********************** *** PUBLIC FUNCTIONS *** ***********************/ /* * Initialize the random number generator. */ void avRandomInit(void); /* * Churn the randomness pool on a random event. Call this early and often * on random and semi-random system events to build randomness in time for * usage. For randomly timed events, pass a null pointer and a zero length * and this will use the system timer and other sources to add randomness. * If new random data is available, pass a pointer to that and it will be * included. */ void avChurnRand(char *randData, u32_t randLen); /* * Randomize our random seed value. To be called for truely random events * such as user operations and network traffic. */ #if MD5_SUPPORT #define avRandomize() avChurnRand(NULL, 0) #else void avRandomize(void); #endif /* * Use the random pool to generate random data. This degrades to pseudo * random when used faster than randomness is supplied using churnRand(). * Thus it's important to make sure that the results of this are not * published directly because one could predict the next result to at * least some degree. Also, it's important to get a good seed before * the first use. */ void avGenRand(char *buf, u32_t bufLen); /* * Return a new random number. */ u32_t avRandom(void); #endif /* RANDM_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/magic.c0000644000175000017500000000577011671615006017262 0ustar renzorenzo/***************************************************************************** * magic.c - Network Random Number Generator program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 by Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-04 Guy Lancaster , Global Election Systems Inc. * Original based on BSD magic.c. *****************************************************************************/ /* * magic.c - PPP Magic Number routines. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include "ppp.h" #include "randm.h" #include "magic.h" /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* * magicInit - Initialize the magic number generator. * * Since we use another random number generator that has its own * initialization, we do nothing here. */ void magicInit() { return; } /* * magic - Returns the next magic number. */ u32_t magic() { return avRandom(); } lwipv6-1.5a/lwip-v6/src/netif/ppp/lcp.h0000644000175000017500000001424711671615006016764 0ustar renzorenzo/***************************************************************************** * lcp.h - Network Link Control Protocol header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-11-05 Guy Lancaster , Global Election Systems Inc. * Original derived from BSD codes. *****************************************************************************/ /* * lcp.h - Link Control Protocol definitions. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * $Id: lcp.h 26 2005-08-10 18:50:38Z rd235 $ */ #ifndef LCP_H #define LCP_H /************************* *** PUBLIC DEFINITIONS *** *************************/ /* * Options. */ #define CI_MRU 1 /* Maximum Receive Unit */ #define CI_ASYNCMAP 2 /* Async Control Character Map */ #define CI_AUTHTYPE 3 /* Authentication Type */ #define CI_QUALITY 4 /* Quality Protocol */ #define CI_MAGICNUMBER 5 /* Magic Number */ #define CI_PCOMPRESSION 7 /* Protocol Field Compression */ #define CI_ACCOMPRESSION 8 /* Address/Control Field Compression */ #define CI_CALLBACK 13 /* callback */ #define CI_MRRU 17 /* max reconstructed receive unit; multilink */ #define CI_SSNHF 18 /* short sequence numbers for multilink */ #define CI_EPDISC 19 /* endpoint discriminator */ /* * LCP-specific packet types. */ #define PROTREJ 8 /* Protocol Reject */ #define ECHOREQ 9 /* Echo Request */ #define ECHOREP 10 /* Echo Reply */ #define DISCREQ 11 /* Discard Request */ #define CBCP_OPT 6 /* Use callback control protocol */ /************************ *** PUBLIC DATA TYPES *** ************************/ /* * The state of options is described by an lcp_options structure. */ typedef struct lcp_options { u_int passive : 1; /* Don't die if we don't get a response */ u_int silent : 1; /* Wait for the other end to start first */ u_int restart : 1; /* Restart vs. exit after close */ u_int neg_mru : 1; /* Negotiate the MRU? */ u_int neg_asyncmap : 1; /* Negotiate the async map? */ u_int neg_upap : 1; /* Ask for UPAP authentication? */ u_int neg_chap : 1; /* Ask for CHAP authentication? */ u_int neg_magicnumber : 1; /* Ask for magic number? */ u_int neg_pcompression : 1; /* HDLC Protocol Field Compression? */ u_int neg_accompression : 1; /* HDLC Address/Control Field Compression? */ u_int neg_lqr : 1; /* Negotiate use of Link Quality Reports */ u_int neg_cbcp : 1; /* Negotiate use of CBCP */ #ifdef PPP_MULTILINK u_int neg_mrru : 1; /* Negotiate multilink MRRU */ u_int neg_ssnhf : 1; /* Negotiate short sequence numbers */ u_int neg_endpoint : 1; /* Negotiate endpoint discriminator */ #endif u_short mru; /* Value of MRU */ #ifdef PPP_MULTILINK u_short mrru; /* Value of MRRU, and multilink enable */ #endif u_char chap_mdtype; /* which MD type (hashing algorithm) */ u32_t asyncmap; /* Value of async map */ u32_t magicnumber; int numloops; /* Number of loops during magic number neg. */ u32_t lqr_period; /* Reporting period for LQR 1/100ths second */ #ifdef PPP_MULTILINK struct epdisc endpoint; /* endpoint discriminator */ #endif } lcp_options; /* * Values for phase from BSD pppd.h based on RFC 1661. */ typedef enum { PHASE_DEAD = 0, PHASE_INITIALIZE, PHASE_ESTABLISH, PHASE_AUTHENTICATE, PHASE_CALLBACK, PHASE_NETWORK, PHASE_TERMINATE } LinkPhase; /***************************** *** PUBLIC DATA STRUCTURES *** *****************************/ extern LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */ extern lcp_options lcp_wantoptions[]; extern lcp_options lcp_gotoptions[]; extern lcp_options lcp_allowoptions[]; extern lcp_options lcp_hisoptions[]; extern ext_accm xmit_accm[]; /*********************** *** PUBLIC FUNCTIONS *** ***********************/ void lcp_init (int); void lcp_open (int); void lcp_close (int, char *); void lcp_lowerup (int); void lcp_lowerdown (int); void lcp_sprotrej (int, u_char *, int); /* send protocol reject */ extern struct protent lcp_protent; /* Default number of times we receive our magic number from the peer before deciding the link is looped-back. */ #define DEFLOOPBACKFAIL 10 #endif /* LCP_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/pap.c0000644000175000017500000003406711671615006016763 0ustar renzorenzo/***************************************************************************** * pap.c - Network Password Authentication Protocol program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 by Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-12 Guy Lancaster , Global Election Systems Inc. * Original. *****************************************************************************/ /* * upap.c - User/Password Authentication Protocol. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include "ppp.h" #include "auth.h" #include "pap.h" #include "pppdebug.h" #if PAP_SUPPORT > 0 /***********************************/ /*** LOCAL FUNCTION DECLARATIONS ***/ /***********************************/ /* * Protocol entry points. */ static void upap_init (int); static void upap_lowerup (int); static void upap_lowerdown (int); static void upap_input (int, u_char *, int); static void upap_protrej (int); static void upap_timeout (void *); static void upap_reqtimeout (void *); static void upap_rauthreq (upap_state *, u_char *, int, int); static void upap_rauthack (upap_state *, u_char *, int, int); static void upap_rauthnak (upap_state *, u_char *, int, int); static void upap_sauthreq (upap_state *); static void upap_sresp (upap_state *, u_char, u_char, char *, int); /******************************/ /*** PUBLIC DATA STRUCTURES ***/ /******************************/ struct protent pap_protent = { PPP_PAP, upap_init, upap_input, upap_protrej, upap_lowerup, upap_lowerdown, NULL, NULL, #if 0 upap_printpkt, NULL, #endif 1, "PAP", #if 0 NULL, NULL, NULL #endif }; upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */ /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* * Set the default login name and password for the pap sessions */ void upap_setloginpasswd(int unit, const char *luser, const char *lpassword) { upap_state *u = &upap[unit]; /* Save the username and password we're given */ u->us_user = luser; u->us_userlen = strlen(luser); u->us_passwd = lpassword; u->us_passwdlen = strlen(lpassword); } /* * upap_authwithpeer - Authenticate us with our peer (start client). * * Set new state and send authenticate's. */ void upap_authwithpeer(int unit, char *user, char *password) { upap_state *u = &upap[unit]; UPAPDEBUG((LOG_INFO, "upap_authwithpeer: %d user=%s password=%s s=%d\n", unit, user, password, u->us_clientstate)); upap_setloginpasswd(unit, user, password); u->us_transmits = 0; /* Lower layer up yet? */ if (u->us_clientstate == UPAPCS_INITIAL || u->us_clientstate == UPAPCS_PENDING) { u->us_clientstate = UPAPCS_PENDING; return; } upap_sauthreq(u); /* Start protocol */ } /* * upap_authpeer - Authenticate our peer (start server). * * Set new state. */ void upap_authpeer(int unit) { upap_state *u = &upap[unit]; /* Lower layer up yet? */ if (u->us_serverstate == UPAPSS_INITIAL || u->us_serverstate == UPAPSS_PENDING) { u->us_serverstate = UPAPSS_PENDING; return; } u->us_serverstate = UPAPSS_LISTEN; if (u->us_reqtimeout > 0) TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); } /**********************************/ /*** LOCAL FUNCTION DEFINITIONS ***/ /**********************************/ /* * upap_init - Initialize a UPAP unit. */ static void upap_init(int unit) { upap_state *u = &upap[unit]; UPAPDEBUG((LOG_INFO, "upap_init: %d\n", unit)); u->us_unit = unit; u->us_user = NULL; u->us_userlen = 0; u->us_passwd = NULL; u->us_passwdlen = 0; u->us_clientstate = UPAPCS_INITIAL; u->us_serverstate = UPAPSS_INITIAL; u->us_id = 0; u->us_timeouttime = UPAP_DEFTIMEOUT; u->us_maxtransmits = 10; u->us_reqtimeout = UPAP_DEFREQTIME; } /* * upap_timeout - Retransmission timer for sending auth-reqs expired. */ static void upap_timeout(void *arg) { upap_state *u = (upap_state *) arg; UPAPDEBUG((LOG_INFO, "upap_timeout: %d timeout %d expired s=%d\n", u->us_unit, u->us_timeouttime, u->us_clientstate)); if (u->us_clientstate != UPAPCS_AUTHREQ) return; if (u->us_transmits >= u->us_maxtransmits) { /* give up in disgust */ UPAPDEBUG((LOG_ERR, "No response to PAP authenticate-requests\n")); u->us_clientstate = UPAPCS_BADAUTH; auth_withpeer_fail(u->us_unit, PPP_PAP); return; } upap_sauthreq(u); /* Send Authenticate-Request */ } /* * upap_reqtimeout - Give up waiting for the peer to send an auth-req. */ static void upap_reqtimeout(void *arg) { upap_state *u = (upap_state *) arg; if (u->us_serverstate != UPAPSS_LISTEN) return; /* huh?? */ auth_peer_fail(u->us_unit, PPP_PAP); u->us_serverstate = UPAPSS_BADAUTH; } /* * upap_lowerup - The lower layer is up. * * Start authenticating if pending. */ static void upap_lowerup(int unit) { upap_state *u = &upap[unit]; UPAPDEBUG((LOG_INFO, "upap_lowerup: %d s=%d\n", unit, u->us_clientstate)); if (u->us_clientstate == UPAPCS_INITIAL) u->us_clientstate = UPAPCS_CLOSED; else if (u->us_clientstate == UPAPCS_PENDING) { upap_sauthreq(u); /* send an auth-request */ } if (u->us_serverstate == UPAPSS_INITIAL) u->us_serverstate = UPAPSS_CLOSED; else if (u->us_serverstate == UPAPSS_PENDING) { u->us_serverstate = UPAPSS_LISTEN; if (u->us_reqtimeout > 0) TIMEOUT(upap_reqtimeout, u, u->us_reqtimeout); } } /* * upap_lowerdown - The lower layer is down. * * Cancel all timeouts. */ static void upap_lowerdown(int unit) { upap_state *u = &upap[unit]; UPAPDEBUG((LOG_INFO, "upap_lowerdown: %d s=%d\n", unit, u->us_clientstate)); if (u->us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */ UNTIMEOUT(upap_timeout, u); /* Cancel timeout */ if (u->us_serverstate == UPAPSS_LISTEN && u->us_reqtimeout > 0) UNTIMEOUT(upap_reqtimeout, u); u->us_clientstate = UPAPCS_INITIAL; u->us_serverstate = UPAPSS_INITIAL; } /* * upap_protrej - Peer doesn't speak this protocol. * * This shouldn't happen. In any case, pretend lower layer went down. */ static void upap_protrej(int unit) { upap_state *u = &upap[unit]; if (u->us_clientstate == UPAPCS_AUTHREQ) { UPAPDEBUG((LOG_ERR, "PAP authentication failed due to protocol-reject\n")); auth_withpeer_fail(unit, PPP_PAP); } if (u->us_serverstate == UPAPSS_LISTEN) { UPAPDEBUG((LOG_ERR, "PAP authentication of peer failed (protocol-reject)\n")); auth_peer_fail(unit, PPP_PAP); } upap_lowerdown(unit); } /* * upap_input - Input UPAP packet. */ static void upap_input(int unit, u_char *inpacket, int l) { upap_state *u = &upap[unit]; u_char *inp; u_char code, id; int len; /* * Parse header (code, id and length). * If packet too short, drop it. */ inp = inpacket; if (l < UPAP_HEADERLEN) { UPAPDEBUG((LOG_INFO, "pap_input: rcvd short header.\n")); return; } GETCHAR(code, inp); GETCHAR(id, inp); GETSHORT(len, inp); if (len < UPAP_HEADERLEN) { UPAPDEBUG((LOG_INFO, "pap_input: rcvd illegal length.\n")); return; } if (len > l) { UPAPDEBUG((LOG_INFO, "pap_input: rcvd short packet.\n")); return; } len -= UPAP_HEADERLEN; /* * Action depends on code. */ switch (code) { case UPAP_AUTHREQ: upap_rauthreq(u, inp, id, len); break; case UPAP_AUTHACK: upap_rauthack(u, inp, id, len); break; case UPAP_AUTHNAK: upap_rauthnak(u, inp, id, len); break; default: /* XXX Need code reject */ break; } } /* * upap_rauth - Receive Authenticate. */ static void upap_rauthreq( upap_state *u, u_char *inp, int id, int len ) { u_char ruserlen, rpasswdlen; char *ruser, *rpasswd; int retcode; char *msg; int msglen; UPAPDEBUG((LOG_INFO, "pap_rauth: Rcvd id %d.\n", id)); if (u->us_serverstate < UPAPSS_LISTEN) return; /* * If we receive a duplicate authenticate-request, we are * supposed to return the same status as for the first request. */ if (u->us_serverstate == UPAPSS_OPEN) { upap_sresp(u, UPAP_AUTHACK, id, "", 0); /* return auth-ack */ return; } if (u->us_serverstate == UPAPSS_BADAUTH) { upap_sresp(u, UPAP_AUTHNAK, id, "", 0); /* return auth-nak */ return; } /* * Parse user/passwd. */ if (len < sizeof (u_char)) { UPAPDEBUG((LOG_INFO, "pap_rauth: rcvd short packet.\n")); return; } GETCHAR(ruserlen, inp); len -= sizeof (u_char) + ruserlen + sizeof (u_char); if (len < 0) { UPAPDEBUG((LOG_INFO, "pap_rauth: rcvd short packet.\n")); return; } ruser = (char *) inp; INCPTR(ruserlen, inp); GETCHAR(rpasswdlen, inp); if (len < rpasswdlen) { UPAPDEBUG((LOG_INFO, "pap_rauth: rcvd short packet.\n")); return; } rpasswd = (char *) inp; /* * Check the username and password given. */ retcode = check_passwd(u->us_unit, ruser, ruserlen, rpasswd, rpasswdlen, &msg, &msglen); BZERO(rpasswd, rpasswdlen); upap_sresp(u, retcode, id, msg, msglen); if (retcode == UPAP_AUTHACK) { u->us_serverstate = UPAPSS_OPEN; auth_peer_success(u->us_unit, PPP_PAP, ruser, ruserlen); } else { u->us_serverstate = UPAPSS_BADAUTH; auth_peer_fail(u->us_unit, PPP_PAP); } if (u->us_reqtimeout > 0) UNTIMEOUT(upap_reqtimeout, u); } /* * upap_rauthack - Receive Authenticate-Ack. */ static void upap_rauthack( upap_state *u, u_char *inp, int id, int len ) { u_char msglen; char *msg; UPAPDEBUG((LOG_INFO, "pap_rauthack: Rcvd id %d s=%d\n", id, u->us_clientstate)); if (u->us_clientstate != UPAPCS_AUTHREQ) /* XXX */ return; /* * Parse message. */ if (len < sizeof (u_char)) { UPAPDEBUG((LOG_INFO, "pap_rauthack: rcvd short packet.\n")); return; } GETCHAR(msglen, inp); len -= sizeof (u_char); if (len < msglen) { UPAPDEBUG((LOG_INFO, "pap_rauthack: rcvd short packet.\n")); return; } msg = (char *) inp; PRINTMSG(msg, msglen); u->us_clientstate = UPAPCS_OPEN; auth_withpeer_success(u->us_unit, PPP_PAP); } /* * upap_rauthnak - Receive Authenticate-Nakk. */ static void upap_rauthnak( upap_state *u, u_char *inp, int id, int len ) { u_char msglen; char *msg; UPAPDEBUG((LOG_INFO, "pap_rauthnak: Rcvd id %d s=%d\n", id, u->us_clientstate)); if (u->us_clientstate != UPAPCS_AUTHREQ) /* XXX */ return; /* * Parse message. */ if (len < sizeof (u_char)) { UPAPDEBUG((LOG_INFO, "pap_rauthnak: rcvd short packet.\n")); return; } GETCHAR(msglen, inp); len -= sizeof (u_char); if (len < msglen) { UPAPDEBUG((LOG_INFO, "pap_rauthnak: rcvd short packet.\n")); return; } msg = (char *) inp; PRINTMSG(msg, msglen); u->us_clientstate = UPAPCS_BADAUTH; UPAPDEBUG((LOG_ERR, "PAP authentication failed\n")); auth_withpeer_fail(u->us_unit, PPP_PAP); } /* * upap_sauthreq - Send an Authenticate-Request. */ static void upap_sauthreq(upap_state *u) { u_char *outp; int outlen; outlen = UPAP_HEADERLEN + 2 * sizeof (u_char) + u->us_userlen + u->us_passwdlen; outp = outpacket_buf[u->us_unit]; MAKEHEADER(outp, PPP_PAP); PUTCHAR(UPAP_AUTHREQ, outp); PUTCHAR(++u->us_id, outp); PUTSHORT(outlen, outp); PUTCHAR(u->us_userlen, outp); BCOPY(u->us_user, outp, u->us_userlen); INCPTR(u->us_userlen, outp); PUTCHAR(u->us_passwdlen, outp); BCOPY(u->us_passwd, outp, u->us_passwdlen); pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); UPAPDEBUG((LOG_INFO, "pap_sauth: Sent id %d\n", u->us_id)); TIMEOUT(upap_timeout, u, u->us_timeouttime); ++u->us_transmits; u->us_clientstate = UPAPCS_AUTHREQ; } /* * upap_sresp - Send a response (ack or nak). */ static void upap_sresp( upap_state *u, u_char code, u_char id, char *msg, int msglen ) { u_char *outp; int outlen; outlen = UPAP_HEADERLEN + sizeof (u_char) + msglen; outp = outpacket_buf[u->us_unit]; MAKEHEADER(outp, PPP_PAP); PUTCHAR(code, outp); PUTCHAR(id, outp); PUTSHORT(outlen, outp); PUTCHAR(msglen, outp); BCOPY(msg, outp, msglen); pppWrite(u->us_unit, outpacket_buf[u->us_unit], outlen + PPP_HDRLEN); UPAPDEBUG((LOG_INFO, "pap_sresp: Sent code %d, id %d s=%d\n", code, id, u->us_clientstate)); } #if 0 /* * upap_printpkt - print the contents of a PAP packet. */ static int upap_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg ) { (void)p; (void)plen; (void)printer; (void)arg; return 0; } #endif #endif /* PAP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/lcp.c0000644000175000017500000014366611671615006016767 0ustar renzorenzo/***************************************************************************** * lcp.c - Network Link Control Protocol program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 by Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-01 Guy Lancaster , Global Election Systems Inc. * Original. *****************************************************************************/ /* * lcp.c - PPP Link Control Protocol. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include "ppp.h" #if PPP_SUPPORT > 0 #include "fsm.h" #include "chap.h" #include "magic.h" #include "auth.h" #include "lcp.h" #include "pppdebug.h" /*************************/ /*** LOCAL DEFINITIONS ***/ /*************************/ /* * Length of each type of configuration option (in octets) */ #define CILEN_VOID 2 #define CILEN_CHAR 3 #define CILEN_SHORT 4 /* CILEN_VOID + sizeof(short) */ #define CILEN_CHAP 5 /* CILEN_VOID + sizeof(short) + 1 */ #define CILEN_LONG 6 /* CILEN_VOID + sizeof(long) */ #define CILEN_LQR 8 /* CILEN_VOID + sizeof(short) + sizeof(long) */ #define CILEN_CBCP 3 /***********************************/ /*** LOCAL FUNCTION DECLARATIONS ***/ /***********************************/ /* * Callbacks for fsm code. (CI = Configuration Information) */ static void lcp_resetci (fsm*); /* Reset our CI */ static int lcp_cilen (fsm*); /* Return length of our CI */ static void lcp_addci (fsm*, u_char*, int*); /* Add our CI to pkt */ static int lcp_ackci (fsm*, u_char*, int);/* Peer ack'd our CI */ static int lcp_nakci (fsm*, u_char*, int);/* Peer nak'd our CI */ static int lcp_rejci (fsm*, u_char*, int);/* Peer rej'd our CI */ static int lcp_reqci (fsm*, u_char*, int*, int); /* Rcv peer CI */ static void lcp_up (fsm*); /* We're UP */ static void lcp_down (fsm*); /* We're DOWN */ static void lcp_starting (fsm*); /* We need lower layer up */ static void lcp_finished (fsm*); /* We need lower layer down */ static int lcp_extcode (fsm*, int, u_char, u_char*, int); static void lcp_rprotrej (fsm*, u_char*, int); /* * routines to send LCP echos to peer */ static void lcp_echo_lowerup (int); static void lcp_echo_lowerdown (int); static void LcpEchoTimeout (void*); static void lcp_received_echo_reply (fsm*, int, u_char*, int); static void LcpSendEchoRequest (fsm*); static void LcpLinkFailure (fsm*); static void LcpEchoCheck (fsm*); /* * Protocol entry points. * Some of these are called directly. */ static void lcp_input (int, u_char *, int); static void lcp_protrej (int); #define CODENAME(x) ((x) == CONFACK ? "ACK" : \ (x) == CONFNAK ? "NAK" : "REJ") /******************************/ /*** PUBLIC DATA STRUCTURES ***/ /******************************/ /* global vars */ LinkPhase lcp_phase[NUM_PPP]; /* Phase of link session (RFC 1661) */ lcp_options lcp_wantoptions[NUM_PPP]; /* Options that we want to request */ lcp_options lcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */ lcp_options lcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ ext_accm xmit_accm[NUM_PPP]; /* extended transmit ACCM */ /*****************************/ /*** LOCAL DATA STRUCTURES ***/ /*****************************/ static fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/ static u_int lcp_echo_interval = LCP_ECHOINTERVAL; /* Interval between LCP echo-requests */ static u_int lcp_echo_fails = LCP_MAXECHOFAILS; /* Tolerance to unanswered echo-requests */ static u32_t lcp_echos_pending = 0; /* Number of outstanding echo msgs */ static u32_t lcp_echo_number = 0; /* ID number of next echo frame */ static u32_t lcp_echo_timer_running = 0; /* TRUE if a timer is running */ static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */ static fsm_callbacks lcp_callbacks = { /* LCP callback routines */ lcp_resetci, /* Reset our Configuration Information */ lcp_cilen, /* Length of our Configuration Information */ lcp_addci, /* Add our Configuration Information */ lcp_ackci, /* ACK our Configuration Information */ lcp_nakci, /* NAK our Configuration Information */ lcp_rejci, /* Reject our Configuration Information */ lcp_reqci, /* Request peer's Configuration Information */ lcp_up, /* Called when fsm reaches OPENED state */ lcp_down, /* Called when fsm leaves OPENED state */ lcp_starting, /* Called when we want the lower layer up */ lcp_finished, /* Called when we want the lower layer down */ NULL, /* Called when Protocol-Reject received */ NULL, /* Retransmission is necessary */ lcp_extcode, /* Called to handle LCP-specific codes */ "LCP" /* String name of protocol */ }; struct protent lcp_protent = { PPP_LCP, lcp_init, lcp_input, lcp_protrej, lcp_lowerup, lcp_lowerdown, lcp_open, lcp_close, #if 0 lcp_printpkt, NULL, #endif 1, "LCP", #if 0 NULL, NULL, NULL #endif }; int lcp_loopbackfail = DEFLOOPBACKFAIL; /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* * lcp_init - Initialize LCP. */ void lcp_init(int unit) { fsm *f = &lcp_fsm[unit]; lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *ao = &lcp_allowoptions[unit]; f->unit = unit; f->protocol = PPP_LCP; f->callbacks = &lcp_callbacks; fsm_init(f); wo->passive = 0; wo->silent = 0; wo->restart = 0; /* Set to 1 in kernels or multi-line * implementations */ wo->neg_mru = 1; wo->mru = PPP_DEFMRU; wo->neg_asyncmap = 1; wo->asyncmap = 0x00000000l; /* Assume don't need to escape any ctl chars. */ wo->neg_chap = 0; /* Set to 1 on server */ wo->neg_upap = 0; /* Set to 1 on server */ wo->chap_mdtype = CHAP_DIGEST_MD5; wo->neg_magicnumber = 1; wo->neg_pcompression = 1; wo->neg_accompression = 1; wo->neg_lqr = 0; /* no LQR implementation yet */ wo->neg_cbcp = 0; ao->neg_mru = 1; ao->mru = PPP_MAXMRU; ao->neg_asyncmap = 1; ao->asyncmap = 0x00000000l; /* Assume don't need to escape any ctl chars. */ ao->neg_chap = (CHAP_SUPPORT != 0); ao->chap_mdtype = CHAP_DIGEST_MD5; ao->neg_upap = (PAP_SUPPORT != 0); ao->neg_magicnumber = 1; ao->neg_pcompression = 1; ao->neg_accompression = 1; ao->neg_lqr = 0; /* no LQR implementation yet */ ao->neg_cbcp = (CBCP_SUPPORT != 0); /* * Set transmit escape for the flag and escape characters plus anything * set for the allowable options. */ memset(xmit_accm[unit], 0, sizeof(xmit_accm[0])); xmit_accm[unit][15] = 0x60; xmit_accm[unit][0] = (u_char)(ao->asyncmap & 0xFF); xmit_accm[unit][1] = (u_char)((ao->asyncmap >> 8) & 0xFF); xmit_accm[unit][2] = (u_char)((ao->asyncmap >> 16) & 0xFF); xmit_accm[unit][3] = (u_char)((ao->asyncmap >> 24) & 0xFF); LCPDEBUG((LOG_INFO, "lcp_init: xmit_accm=%X %X %X %X\n", xmit_accm[unit][0], xmit_accm[unit][1], xmit_accm[unit][2], xmit_accm[unit][3])); lcp_phase[unit] = PHASE_INITIALIZE; } /* * lcp_open - LCP is allowed to come up. */ void lcp_open(int unit) { fsm *f = &lcp_fsm[unit]; lcp_options *wo = &lcp_wantoptions[unit]; f->flags = 0; if (wo->passive) f->flags |= OPT_PASSIVE; if (wo->silent) f->flags |= OPT_SILENT; fsm_open(f); lcp_phase[unit] = PHASE_ESTABLISH; } /* * lcp_close - Take LCP down. */ void lcp_close(int unit, char *reason) { fsm *f = &lcp_fsm[unit]; if (lcp_phase[unit] != PHASE_DEAD) lcp_phase[unit] = PHASE_TERMINATE; if (f->state == STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) { /* * This action is not strictly according to the FSM in RFC1548, * but it does mean that the program terminates if you do an * lcp_close() in passive/silent mode when a connection hasn't * been established. */ f->state = CLOSED; lcp_finished(f); } else fsm_close(&lcp_fsm[unit], reason); } /* * lcp_lowerup - The lower layer is up. */ void lcp_lowerup(int unit) { lcp_options *wo = &lcp_wantoptions[unit]; /* * Don't use A/C or protocol compression on transmission, * but accept A/C and protocol compressed packets * if we are going to ask for A/C and protocol compression. */ ppp_set_xaccm(unit, &xmit_accm[unit]); ppp_send_config(unit, PPP_MRU, 0xffffffffl, 0, 0); ppp_recv_config(unit, PPP_MRU, 0x00000000l, wo->neg_pcompression, wo->neg_accompression); peer_mru[unit] = PPP_MRU; lcp_allowoptions[unit].asyncmap = (u_long)xmit_accm[unit][0] | ((u_long)xmit_accm[unit][1] << 8) | ((u_long)xmit_accm[unit][2] << 16) | ((u_long)xmit_accm[unit][3] << 24); LCPDEBUG((LOG_INFO, "lcp_lowerup: asyncmap=%X %X %X %X\n", xmit_accm[unit][3], xmit_accm[unit][2], xmit_accm[unit][1], xmit_accm[unit][0])); fsm_lowerup(&lcp_fsm[unit]); } /* * lcp_lowerdown - The lower layer is down. */ void lcp_lowerdown(int unit) { fsm_lowerdown(&lcp_fsm[unit]); } /* * lcp_sprotrej - Send a Protocol-Reject for some protocol. */ void lcp_sprotrej(int unit, u_char *p, int len) { /* * Send back the protocol and the information field of the * rejected packet. We only get here if LCP is in the OPENED state. */ fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id, p, len); } /**********************************/ /*** LOCAL FUNCTION DEFINITIONS ***/ /**********************************/ /* * lcp_input - Input LCP packet. */ static void lcp_input(int unit, u_char *p, int len) { fsm *f = &lcp_fsm[unit]; fsm_input(f, p, len); } /* * lcp_extcode - Handle a LCP-specific code. */ static int lcp_extcode(fsm *f, int code, u_char id, u_char *inp, int len) { u_char *magp; switch( code ){ case PROTREJ: lcp_rprotrej(f, inp, len); break; case ECHOREQ: if (f->state != OPENED) break; LCPDEBUG((LOG_INFO, "lcp: Echo-Request, Rcvd id %d\n", id)); magp = inp; PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp); fsm_sdata(f, ECHOREP, id, inp, len); break; case ECHOREP: lcp_received_echo_reply(f, id, inp, len); break; case DISCREQ: break; default: return 0; } return 1; } /* * lcp_rprotrej - Receive an Protocol-Reject. * * Figure out which protocol is rejected and inform it. */ static void lcp_rprotrej(fsm *f, u_char *inp, int len) { int i; struct protent *protp; u_short prot; if (len < sizeof (u_short)) { LCPDEBUG((LOG_INFO, "lcp_rprotrej: Rcvd short Protocol-Reject packet!\n")); return; } GETSHORT(prot, inp); LCPDEBUG((LOG_INFO, "lcp_rprotrej: Rcvd Protocol-Reject packet for %x!\n", prot)); /* * Protocol-Reject packets received in any state other than the LCP * OPENED state SHOULD be silently discarded. */ if( f->state != OPENED ){ LCPDEBUG((LOG_INFO, "Protocol-Reject discarded: LCP in state %d\n", f->state)); return; } /* * Upcall the proper Protocol-Reject routine. */ for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) if (protp->protocol == prot && protp->enabled_flag) { (*protp->protrej)(f->unit); return; } LCPDEBUG((LOG_WARNING, "Protocol-Reject for unsupported protocol 0x%x\n", prot)); } /* * lcp_protrej - A Protocol-Reject was received. */ static void lcp_protrej(int unit) { (void)unit; /* * Can't reject LCP! */ LCPDEBUG((LOG_WARNING, "lcp_protrej: Received Protocol-Reject for LCP!\n")); fsm_protreject(&lcp_fsm[unit]); } /* * lcp_resetci - Reset our CI. */ static void lcp_resetci(fsm *f) { lcp_wantoptions[f->unit].magicnumber = magic(); lcp_wantoptions[f->unit].numloops = 0; lcp_gotoptions[f->unit] = lcp_wantoptions[f->unit]; peer_mru[f->unit] = PPP_MRU; auth_reset(f->unit); } /* * lcp_cilen - Return length of our CI. */ static int lcp_cilen(fsm *f) { lcp_options *go = &lcp_gotoptions[f->unit]; #define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0) #define LENCICHAP(neg) ((neg) ? CILEN_CHAP : 0) #define LENCISHORT(neg) ((neg) ? CILEN_SHORT : 0) #define LENCILONG(neg) ((neg) ? CILEN_LONG : 0) #define LENCILQR(neg) ((neg) ? CILEN_LQR: 0) #define LENCICBCP(neg) ((neg) ? CILEN_CBCP: 0) /* * NB: we only ask for one of CHAP and UPAP, even if we will * accept either. */ return (LENCISHORT(go->neg_mru && go->mru != PPP_DEFMRU) + LENCILONG(go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) + LENCICHAP(go->neg_chap) + LENCISHORT(!go->neg_chap && go->neg_upap) + LENCILQR(go->neg_lqr) + LENCICBCP(go->neg_cbcp) + LENCILONG(go->neg_magicnumber) + LENCIVOID(go->neg_pcompression) + LENCIVOID(go->neg_accompression)); } /* * lcp_addci - Add our desired CIs to a packet. */ static void lcp_addci(fsm *f, u_char *ucp, int *lenp) { lcp_options *go = &lcp_gotoptions[f->unit]; u_char *start_ucp = ucp; #define ADDCIVOID(opt, neg) \ if (neg) { \ LCPDEBUG((LOG_INFO, "lcp_addci: opt=%d\n", opt)); \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_VOID, ucp); \ } #define ADDCISHORT(opt, neg, val) \ if (neg) { \ LCPDEBUG((LOG_INFO, "lcp_addci: INT opt=%d %X\n", opt, val)); \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_SHORT, ucp); \ PUTSHORT(val, ucp); \ } #define ADDCICHAP(opt, neg, val, digest) \ if (neg) { \ LCPDEBUG((LOG_INFO, "lcp_addci: CHAP opt=%d %X\n", opt, val)); \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_CHAP, ucp); \ PUTSHORT(val, ucp); \ PUTCHAR(digest, ucp); \ } #define ADDCILONG(opt, neg, val) \ if (neg) { \ LCPDEBUG((LOG_INFO, "lcp_addci: L opt=%d %lX\n", opt, val)); \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_LONG, ucp); \ PUTLONG(val, ucp); \ } #define ADDCILQR(opt, neg, val) \ if (neg) { \ LCPDEBUG((LOG_INFO, "lcp_addci: LQR opt=%d %lX\n", opt, val)); \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_LQR, ucp); \ PUTSHORT(PPP_LQR, ucp); \ PUTLONG(val, ucp); \ } #define ADDCICHAR(opt, neg, val) \ if (neg) { \ LCPDEBUG((LOG_INFO, "lcp_addci: CHAR opt=%d %X '%z'\n", opt, val, val)); \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_CHAR, ucp); \ PUTCHAR(val, ucp); \ } ADDCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); ADDCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap); ADDCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype); ADDCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP); ADDCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period); ADDCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT); ADDCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber); ADDCIVOID(CI_PCOMPRESSION, go->neg_pcompression); ADDCIVOID(CI_ACCOMPRESSION, go->neg_accompression); if (ucp - start_ucp != *lenp) { /* this should never happen, because peer_mtu should be 1500 */ LCPDEBUG((LOG_ERR, "Bug in lcp_addci: wrong length\n")); } } /* * lcp_ackci - Ack our CIs. * This should not modify any state if the Ack is bad. * * Returns: * 0 - Ack was bad. * 1 - Ack was good. */ static int lcp_ackci(fsm *f, u_char *p, int len) { lcp_options *go = &lcp_gotoptions[f->unit]; u_char cilen, citype, cichar; u_short cishort; u32_t cilong; /* * CIs must be in exactly the same order that we sent. * Check packet length and CI length at each step. * If we find any deviations, then this packet is bad. */ #define ACKCIVOID(opt, neg) \ if (neg) { \ if ((len -= CILEN_VOID) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != CILEN_VOID || \ citype != opt) \ goto bad; \ } #define ACKCISHORT(opt, neg, val) \ if (neg) { \ if ((len -= CILEN_SHORT) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != CILEN_SHORT || \ citype != opt) \ goto bad; \ GETSHORT(cishort, p); \ if (cishort != val) \ goto bad; \ } #define ACKCICHAR(opt, neg, val) \ if (neg) { \ if ((len -= CILEN_CHAR) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != CILEN_CHAR || \ citype != opt) \ goto bad; \ GETCHAR(cichar, p); \ if (cichar != val) \ goto bad; \ } #define ACKCICHAP(opt, neg, val, digest) \ if (neg) { \ if ((len -= CILEN_CHAP) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != CILEN_CHAP || \ citype != opt) \ goto bad; \ GETSHORT(cishort, p); \ if (cishort != val) \ goto bad; \ GETCHAR(cichar, p); \ if (cichar != digest) \ goto bad; \ } #define ACKCILONG(opt, neg, val) \ if (neg) { \ if ((len -= CILEN_LONG) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != CILEN_LONG || \ citype != opt) \ goto bad; \ GETLONG(cilong, p); \ if (cilong != val) \ goto bad; \ } #define ACKCILQR(opt, neg, val) \ if (neg) { \ if ((len -= CILEN_LQR) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != CILEN_LQR || \ citype != opt) \ goto bad; \ GETSHORT(cishort, p); \ if (cishort != PPP_LQR) \ goto bad; \ GETLONG(cilong, p); \ if (cilong != val) \ goto bad; \ } ACKCISHORT(CI_MRU, go->neg_mru && go->mru != PPP_DEFMRU, go->mru); ACKCILONG(CI_ASYNCMAP, go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl, go->asyncmap); ACKCICHAP(CI_AUTHTYPE, go->neg_chap, PPP_CHAP, go->chap_mdtype); ACKCISHORT(CI_AUTHTYPE, !go->neg_chap && go->neg_upap, PPP_PAP); ACKCILQR(CI_QUALITY, go->neg_lqr, go->lqr_period); ACKCICHAR(CI_CALLBACK, go->neg_cbcp, CBCP_OPT); ACKCILONG(CI_MAGICNUMBER, go->neg_magicnumber, go->magicnumber); ACKCIVOID(CI_PCOMPRESSION, go->neg_pcompression); ACKCIVOID(CI_ACCOMPRESSION, go->neg_accompression); /* * If there are any remaining CIs, then this packet is bad. */ if (len != 0) goto bad; LCPDEBUG((LOG_INFO, "lcp_acki: Ack\n")); return (1); bad: LCPDEBUG((LOG_WARNING, "lcp_acki: received bad Ack!\n")); return (0); } /* * lcp_nakci - Peer has sent a NAK for some of our CIs. * This should not modify any state if the Nak is bad * or if LCP is in the OPENED state. * * Returns: * 0 - Nak was bad. * 1 - Nak was good. */ static int lcp_nakci(fsm *f, u_char *p, int len) { lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *wo = &lcp_wantoptions[f->unit]; u_char citype, cichar, *next; u_short cishort; u32_t cilong; lcp_options no; /* options we've seen Naks for */ lcp_options try; /* options to request next time */ int looped_back = 0; int cilen; BZERO(&no, sizeof(no)); try = *go; /* * Any Nak'd CIs must be in exactly the same order that we sent. * Check packet length and CI length at each step. * If we find any deviations, then this packet is bad. */ #define NAKCIVOID(opt, neg, code) \ if (go->neg && \ len >= CILEN_VOID && \ p[1] == CILEN_VOID && \ p[0] == opt) { \ len -= CILEN_VOID; \ INCPTR(CILEN_VOID, p); \ no.neg = 1; \ code \ } #define NAKCICHAP(opt, neg, code) \ if (go->neg && \ len >= CILEN_CHAP && \ p[1] == CILEN_CHAP && \ p[0] == opt) { \ len -= CILEN_CHAP; \ INCPTR(2, p); \ GETSHORT(cishort, p); \ GETCHAR(cichar, p); \ no.neg = 1; \ code \ } #define NAKCICHAR(opt, neg, code) \ if (go->neg && \ len >= CILEN_CHAR && \ p[1] == CILEN_CHAR && \ p[0] == opt) { \ len -= CILEN_CHAR; \ INCPTR(2, p); \ GETCHAR(cichar, p); \ no.neg = 1; \ code \ } #define NAKCISHORT(opt, neg, code) \ if (go->neg && \ len >= CILEN_SHORT && \ p[1] == CILEN_SHORT && \ p[0] == opt) { \ len -= CILEN_SHORT; \ INCPTR(2, p); \ GETSHORT(cishort, p); \ no.neg = 1; \ code \ } #define NAKCILONG(opt, neg, code) \ if (go->neg && \ len >= CILEN_LONG && \ p[1] == CILEN_LONG && \ p[0] == opt) { \ len -= CILEN_LONG; \ INCPTR(2, p); \ GETLONG(cilong, p); \ no.neg = 1; \ code \ } #define NAKCILQR(opt, neg, code) \ if (go->neg && \ len >= CILEN_LQR && \ p[1] == CILEN_LQR && \ p[0] == opt) { \ len -= CILEN_LQR; \ INCPTR(2, p); \ GETSHORT(cishort, p); \ GETLONG(cilong, p); \ no.neg = 1; \ code \ } /* * We don't care if they want to send us smaller packets than * we want. Therefore, accept any MRU less than what we asked for, * but then ignore the new value when setting the MRU in the kernel. * If they send us a bigger MRU than what we asked, accept it, up to * the limit of the default MRU we'd get if we didn't negotiate. */ if (go->neg_mru && go->mru != PPP_DEFMRU) { NAKCISHORT(CI_MRU, neg_mru, if (cishort <= wo->mru || cishort < PPP_DEFMRU) try.mru = cishort; ); } /* * Add any characters they want to our (receive-side) asyncmap. */ if (go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) { NAKCILONG(CI_ASYNCMAP, neg_asyncmap, try.asyncmap = go->asyncmap | cilong; ); } /* * If they've nak'd our authentication-protocol, check whether * they are proposing a different protocol, or a different * hash algorithm for CHAP. */ if ((go->neg_chap || go->neg_upap) && len >= CILEN_SHORT && p[0] == CI_AUTHTYPE && p[1] >= CILEN_SHORT && p[1] <= len) { cilen = p[1]; len -= cilen; no.neg_chap = go->neg_chap; no.neg_upap = go->neg_upap; INCPTR(2, p); GETSHORT(cishort, p); if (cishort == PPP_PAP && cilen == CILEN_SHORT) { /* * If we were asking for CHAP, they obviously don't want to do it. * If we weren't asking for CHAP, then we were asking for PAP, * in which case this Nak is bad. */ if (!go->neg_chap) goto bad; try.neg_chap = 0; } else if (cishort == PPP_CHAP && cilen == CILEN_CHAP) { GETCHAR(cichar, p); if (go->neg_chap) { /* * We were asking for CHAP/MD5; they must want a different * algorithm. If they can't do MD5, we'll have to stop * asking for CHAP. */ if (cichar != go->chap_mdtype) try.neg_chap = 0; } else { /* * Stop asking for PAP if we were asking for it. */ try.neg_upap = 0; } } else { /* * We don't recognize what they're suggesting. * Stop asking for what we were asking for. */ if (go->neg_chap) try.neg_chap = 0; else try.neg_upap = 0; p += cilen - CILEN_SHORT; } } /* * If they can't cope with our link quality protocol, we'll have * to stop asking for LQR. We haven't got any other protocol. * If they Nak the reporting period, take their value XXX ? */ NAKCILQR(CI_QUALITY, neg_lqr, if (cishort != PPP_LQR) try.neg_lqr = 0; else try.lqr_period = cilong; ); /* * Only implementing CBCP...not the rest of the callback options */ NAKCICHAR(CI_CALLBACK, neg_cbcp, try.neg_cbcp = 0; ); /* * Check for a looped-back line. */ NAKCILONG(CI_MAGICNUMBER, neg_magicnumber, try.magicnumber = magic(); looped_back = 1; ); /* * Peer shouldn't send Nak for protocol compression or * address/control compression requests; they should send * a Reject instead. If they send a Nak, treat it as a Reject. */ NAKCIVOID(CI_PCOMPRESSION, neg_pcompression, try.neg_pcompression = 0; ); NAKCIVOID(CI_ACCOMPRESSION, neg_accompression, try.neg_accompression = 0; ); /* * There may be remaining CIs, if the peer is requesting negotiation * on an option that we didn't include in our request packet. * If we see an option that we requested, or one we've already seen * in this packet, then this packet is bad. * If we wanted to respond by starting to negotiate on the requested * option(s), we could, but we don't, because except for the * authentication type and quality protocol, if we are not negotiating * an option, it is because we were told not to. * For the authentication type, the Nak from the peer means * `let me authenticate myself with you' which is a bit pointless. * For the quality protocol, the Nak means `ask me to send you quality * reports', but if we didn't ask for them, we don't want them. * An option we don't recognize represents the peer asking to * negotiate some option we don't support, so ignore it. */ while (len > CILEN_VOID) { GETCHAR(citype, p); GETCHAR(cilen, p); if (cilen < CILEN_VOID || (len -= cilen) < 0) goto bad; next = p + cilen - 2; switch (citype) { case CI_MRU: if ((go->neg_mru && go->mru != PPP_DEFMRU) || no.neg_mru || cilen != CILEN_SHORT) goto bad; GETSHORT(cishort, p); if (cishort < PPP_DEFMRU) try.mru = cishort; break; case CI_ASYNCMAP: if ((go->neg_asyncmap && go->asyncmap != 0xFFFFFFFFl) || no.neg_asyncmap || cilen != CILEN_LONG) goto bad; break; case CI_AUTHTYPE: if (go->neg_chap || no.neg_chap || go->neg_upap || no.neg_upap) goto bad; break; case CI_MAGICNUMBER: if (go->neg_magicnumber || no.neg_magicnumber || cilen != CILEN_LONG) goto bad; break; case CI_PCOMPRESSION: if (go->neg_pcompression || no.neg_pcompression || cilen != CILEN_VOID) goto bad; break; case CI_ACCOMPRESSION: if (go->neg_accompression || no.neg_accompression || cilen != CILEN_VOID) goto bad; break; case CI_QUALITY: if (go->neg_lqr || no.neg_lqr || cilen != CILEN_LQR) goto bad; break; } p = next; } /* If there is still anything left, this packet is bad. */ if (len != 0) goto bad; /* * OK, the Nak is good. Now we can update state. */ if (f->state != OPENED) { if (looped_back) { if (++try.numloops >= lcp_loopbackfail) { LCPDEBUG((LOG_NOTICE, "Serial line is looped back.\n")); lcp_close(f->unit, "Loopback detected"); } } else try.numloops = 0; *go = try; } return 1; bad: LCPDEBUG((LOG_WARNING, "lcp_nakci: received bad Nak!\n")); return 0; } /* * lcp_rejci - Peer has Rejected some of our CIs. * This should not modify any state if the Reject is bad * or if LCP is in the OPENED state. * * Returns: * 0 - Reject was bad. * 1 - Reject was good. */ static int lcp_rejci(fsm *f, u_char *p, int len) { lcp_options *go = &lcp_gotoptions[f->unit]; u_char cichar; u_short cishort; u32_t cilong; lcp_options try; /* options to request next time */ try = *go; /* * Any Rejected CIs must be in exactly the same order that we sent. * Check packet length and CI length at each step. * If we find any deviations, then this packet is bad. */ #define REJCIVOID(opt, neg) \ if (go->neg && \ len >= CILEN_VOID && \ p[1] == CILEN_VOID && \ p[0] == opt) { \ len -= CILEN_VOID; \ INCPTR(CILEN_VOID, p); \ try.neg = 0; \ LCPDEBUG((LOG_INFO, "lcp_rejci: void opt %d rejected\n", opt)); \ } #define REJCISHORT(opt, neg, val) \ if (go->neg && \ len >= CILEN_SHORT && \ p[1] == CILEN_SHORT && \ p[0] == opt) { \ len -= CILEN_SHORT; \ INCPTR(2, p); \ GETSHORT(cishort, p); \ /* Check rejected value. */ \ if (cishort != val) \ goto bad; \ try.neg = 0; \ LCPDEBUG((LOG_INFO,"lcp_rejci: short opt %d rejected\n", opt)); \ } #define REJCICHAP(opt, neg, val, digest) \ if (go->neg && \ len >= CILEN_CHAP && \ p[1] == CILEN_CHAP && \ p[0] == opt) { \ len -= CILEN_CHAP; \ INCPTR(2, p); \ GETSHORT(cishort, p); \ GETCHAR(cichar, p); \ /* Check rejected value. */ \ if (cishort != val || cichar != digest) \ goto bad; \ try.neg = 0; \ try.neg_upap = 0; \ LCPDEBUG((LOG_INFO,"lcp_rejci: chap opt %d rejected\n", opt)); \ } #define REJCILONG(opt, neg, val) \ if (go->neg && \ len >= CILEN_LONG && \ p[1] == CILEN_LONG && \ p[0] == opt) { \ len -= CILEN_LONG; \ INCPTR(2, p); \ GETLONG(cilong, p); \ /* Check rejected value. */ \ if (cilong != val) \ goto bad; \ try.neg = 0; \ LCPDEBUG((LOG_INFO,"lcp_rejci: long opt %d rejected\n", opt)); \ } #define REJCILQR(opt, neg, val) \ if (go->neg && \ len >= CILEN_LQR && \ p[1] == CILEN_LQR && \ p[0] == opt) { \ len -= CILEN_LQR; \ INCPTR(2, p); \ GETSHORT(cishort, p); \ GETLONG(cilong, p); \ /* Check rejected value. */ \ if (cishort != PPP_LQR || cilong != val) \ goto bad; \ try.neg = 0; \ LCPDEBUG((LOG_INFO,"lcp_rejci: LQR opt %d rejected\n", opt)); \ } #define REJCICBCP(opt, neg, val) \ if (go->neg && \ len >= CILEN_CBCP && \ p[1] == CILEN_CBCP && \ p[0] == opt) { \ len -= CILEN_CBCP; \ INCPTR(2, p); \ GETCHAR(cichar, p); \ /* Check rejected value. */ \ if (cichar != val) \ goto bad; \ try.neg = 0; \ LCPDEBUG((LOG_INFO,"lcp_rejci: Callback opt %d rejected\n", opt)); \ } REJCISHORT(CI_MRU, neg_mru, go->mru); REJCILONG(CI_ASYNCMAP, neg_asyncmap, go->asyncmap); REJCICHAP(CI_AUTHTYPE, neg_chap, PPP_CHAP, go->chap_mdtype); if (!go->neg_chap) { REJCISHORT(CI_AUTHTYPE, neg_upap, PPP_PAP); } REJCILQR(CI_QUALITY, neg_lqr, go->lqr_period); REJCICBCP(CI_CALLBACK, neg_cbcp, CBCP_OPT); REJCILONG(CI_MAGICNUMBER, neg_magicnumber, go->magicnumber); REJCIVOID(CI_PCOMPRESSION, neg_pcompression); REJCIVOID(CI_ACCOMPRESSION, neg_accompression); /* * If there are any remaining CIs, then this packet is bad. */ if (len != 0) goto bad; /* * Now we can update state. */ if (f->state != OPENED) *go = try; return 1; bad: LCPDEBUG((LOG_WARNING, "lcp_rejci: received bad Reject!\n")); return 0; } /* * lcp_reqci - Check the peer's requested CIs and send appropriate response. * * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified * appropriately. If reject_if_disagree is non-zero, doesn't return * CONFNAK; returns CONFREJ if it can't return CONFACK. */ static int lcp_reqci(fsm *f, u_char *inp, /* Requested CIs */ int *lenp, /* Length of requested CIs */ int reject_if_disagree) { lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *ho = &lcp_hisoptions[f->unit]; lcp_options *ao = &lcp_allowoptions[f->unit]; u_char *cip, *next; /* Pointer to current and next CIs */ int cilen, citype, cichar; /* Parsed len, type, char value */ u_short cishort; /* Parsed short value */ u32_t cilong; /* Parse long value */ int rc = CONFACK; /* Final packet return code */ int orc; /* Individual option return code */ u_char *p; /* Pointer to next char to parse */ u_char *rejp; /* Pointer to next char in reject frame */ u_char *nakp; /* Pointer to next char in Nak frame */ int l = *lenp; /* Length left */ #if TRACELCP > 0 char traceBuf[80]; int traceNdx = 0; #endif /* * Reset all his options. */ BZERO(ho, sizeof(*ho)); /* * Process all his options. */ next = inp; nakp = nak_buffer; rejp = inp; while (l) { orc = CONFACK; /* Assume success */ cip = p = next; /* Remember begining of CI */ if (l < 2 || /* Not enough data for CI header or */ p[1] < 2 || /* CI length too small or */ p[1] > l) { /* CI length too big? */ LCPDEBUG((LOG_WARNING, "lcp_reqci: bad CI length!\n")); orc = CONFREJ; /* Reject bad CI */ cilen = l; /* Reject till end of packet */ l = 0; /* Don't loop again */ citype = 0; goto endswitch; } GETCHAR(citype, p); /* Parse CI type */ GETCHAR(cilen, p); /* Parse CI length */ l -= cilen; /* Adjust remaining length */ next += cilen; /* Step to next CI */ switch (citype) { /* Check CI type */ case CI_MRU: if (!ao->neg_mru) { /* Allow option? */ LCPDEBUG((LOG_INFO, "lcp_reqci: Reject MRU - not allowed\n")); orc = CONFREJ; /* Reject CI */ break; } else if (cilen != CILEN_SHORT) { /* Check CI length */ LCPDEBUG((LOG_INFO, "lcp_reqci: Reject MRU - bad length\n")); orc = CONFREJ; /* Reject CI */ break; } GETSHORT(cishort, p); /* Parse MRU */ /* * He must be able to receive at least our minimum. * No need to check a maximum. If he sends a large number, * we'll just ignore it. */ if (cishort < PPP_MINMRU) { LCPDEBUG((LOG_INFO, "lcp_reqci: Nak - MRU too small\n")); orc = CONFNAK; /* Nak CI */ PUTCHAR(CI_MRU, nakp); PUTCHAR(CILEN_SHORT, nakp); PUTSHORT(PPP_MINMRU, nakp); /* Give him a hint */ break; } ho->neg_mru = 1; /* Remember he sent MRU */ ho->mru = cishort; /* And remember value */ #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " MRU %d", cishort); traceNdx = strlen(traceBuf); #endif break; case CI_ASYNCMAP: if (!ao->neg_asyncmap) { LCPDEBUG((LOG_INFO, "lcp_reqci: Reject ASYNCMAP not allowed\n")); orc = CONFREJ; break; } else if (cilen != CILEN_LONG) { LCPDEBUG((LOG_INFO, "lcp_reqci: Reject ASYNCMAP bad length\n")); orc = CONFREJ; break; } GETLONG(cilong, p); /* * Asyncmap must have set at least the bits * which are set in lcp_allowoptions[unit].asyncmap. */ if ((ao->asyncmap & ~cilong) != 0) { LCPDEBUG((LOG_INFO, "lcp_reqci: Nak ASYNCMAP %lX missing %lX\n", cilong, ao->asyncmap)); orc = CONFNAK; PUTCHAR(CI_ASYNCMAP, nakp); PUTCHAR(CILEN_LONG, nakp); PUTLONG(ao->asyncmap | cilong, nakp); break; } ho->neg_asyncmap = 1; ho->asyncmap = cilong; #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " ASYNCMAP=%lX", cilong); traceNdx = strlen(traceBuf); #endif break; case CI_AUTHTYPE: if (cilen < CILEN_SHORT) { LCPDEBUG((LOG_INFO, "lcp_reqci: Reject AUTHTYPE missing arg\n")); orc = CONFREJ; break; } else if (!(ao->neg_upap || ao->neg_chap)) { /* * Reject the option if we're not willing to authenticate. */ LCPDEBUG((LOG_INFO, "lcp_reqci: Reject AUTHTYPE not allowed\n")); orc = CONFREJ; break; } GETSHORT(cishort, p); /* * Authtype must be UPAP or CHAP. * * Note: if both ao->neg_upap and ao->neg_chap are set, * and the peer sends a Configure-Request with two * authenticate-protocol requests, one for CHAP and one * for UPAP, then we will reject the second request. * Whether we end up doing CHAP or UPAP depends then on * the ordering of the CIs in the peer's Configure-Request. */ if (cishort == PPP_PAP) { if (ho->neg_chap) { /* we've already accepted CHAP */ LCPDEBUG((LOG_WARNING, "lcp_reqci: Reject AUTHTYPE PAP already accepted\n")); orc = CONFREJ; break; } else if (cilen != CILEN_SHORT) { LCPDEBUG((LOG_WARNING, "lcp_reqci: Reject AUTHTYPE PAP bad len\n")); orc = CONFREJ; break; } if (!ao->neg_upap) { /* we don't want to do PAP */ LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE PAP not allowed\n")); orc = CONFNAK; /* NAK it and suggest CHAP */ PUTCHAR(CI_AUTHTYPE, nakp); PUTCHAR(CILEN_CHAP, nakp); PUTSHORT(PPP_CHAP, nakp); PUTCHAR(ao->chap_mdtype, nakp); break; } ho->neg_upap = 1; #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " PAP (%X)", cishort); traceNdx = strlen(traceBuf); #endif break; } if (cishort == PPP_CHAP) { if (ho->neg_upap) { /* we've already accepted PAP */ LCPDEBUG((LOG_WARNING, "lcp_reqci: Reject AUTHTYPE CHAP accepted PAP\n")); orc = CONFREJ; break; } else if (cilen != CILEN_CHAP) { LCPDEBUG((LOG_WARNING, "lcp_reqci: Reject AUTHTYPE CHAP bad len\n")); orc = CONFREJ; break; } if (!ao->neg_chap) { /* we don't want to do CHAP */ LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE CHAP not allowed\n")); orc = CONFNAK; /* NAK it and suggest PAP */ PUTCHAR(CI_AUTHTYPE, nakp); PUTCHAR(CILEN_SHORT, nakp); PUTSHORT(PPP_PAP, nakp); break; } GETCHAR(cichar, p); /* get digest type*/ if (cichar != CHAP_DIGEST_MD5 #ifdef CHAPMS && cichar != CHAP_MICROSOFT #endif ) { LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE CHAP digest=%d\n", cichar)); orc = CONFNAK; PUTCHAR(CI_AUTHTYPE, nakp); PUTCHAR(CILEN_CHAP, nakp); PUTSHORT(PPP_CHAP, nakp); PUTCHAR(ao->chap_mdtype, nakp); break; } #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " CHAP %X,%d", cishort, cichar); traceNdx = strlen(traceBuf); #endif ho->chap_mdtype = cichar; /* save md type */ ho->neg_chap = 1; break; } /* * We don't recognize the protocol they're asking for. * Nak it with something we're willing to do. * (At this point we know ao->neg_upap || ao->neg_chap.) */ orc = CONFNAK; PUTCHAR(CI_AUTHTYPE, nakp); if (ao->neg_chap) { LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE %d req CHAP\n", cishort)); PUTCHAR(CILEN_CHAP, nakp); PUTSHORT(PPP_CHAP, nakp); PUTCHAR(ao->chap_mdtype, nakp); } else { LCPDEBUG((LOG_WARNING, "lcp_reqci: Nak AUTHTYPE %d req PAP\n", cishort)); PUTCHAR(CILEN_SHORT, nakp); PUTSHORT(PPP_PAP, nakp); } break; case CI_QUALITY: GETSHORT(cishort, p); GETLONG(cilong, p); #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " QUALITY (%x %x)", cishort, (unsigned int) cilong); traceNdx = strlen(traceBuf); #endif if (!ao->neg_lqr || cilen != CILEN_LQR) { orc = CONFREJ; break; } /* * Check the protocol and the reporting period. * XXX When should we Nak this, and what with? */ if (cishort != PPP_LQR) { orc = CONFNAK; PUTCHAR(CI_QUALITY, nakp); PUTCHAR(CILEN_LQR, nakp); PUTSHORT(PPP_LQR, nakp); PUTLONG(ao->lqr_period, nakp); break; } break; case CI_MAGICNUMBER: if (!(ao->neg_magicnumber || go->neg_magicnumber) || cilen != CILEN_LONG) { orc = CONFREJ; break; } GETLONG(cilong, p); #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " MAGICNUMBER (%lX)", cilong); traceNdx = strlen(traceBuf); #endif /* * He must have a different magic number. */ if (go->neg_magicnumber && cilong == go->magicnumber) { cilong = magic(); /* Don't put magic() inside macro! */ orc = CONFNAK; PUTCHAR(CI_MAGICNUMBER, nakp); PUTCHAR(CILEN_LONG, nakp); PUTLONG(cilong, nakp); break; } ho->neg_magicnumber = 1; ho->magicnumber = cilong; break; case CI_PCOMPRESSION: #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " PCOMPRESSION"); traceNdx = strlen(traceBuf); #endif if (!ao->neg_pcompression || cilen != CILEN_VOID) { orc = CONFREJ; break; } ho->neg_pcompression = 1; break; case CI_ACCOMPRESSION: #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " ACCOMPRESSION"); traceNdx = strlen(traceBuf); #endif if (!ao->neg_accompression || cilen != CILEN_VOID) { orc = CONFREJ; break; } ho->neg_accompression = 1; break; case CI_MRRU: #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " CI_MRRU"); traceNdx = strlen(traceBuf); #endif orc = CONFREJ; break; case CI_SSNHF: #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " CI_SSNHF"); traceNdx = strlen(traceBuf); #endif orc = CONFREJ; break; case CI_EPDISC: #if TRACELCP > 0 sprintf(&traceBuf[traceNdx], " CI_EPDISC"); traceNdx = strlen(traceBuf); #endif orc = CONFREJ; break; default: #if TRACELCP sprintf(&traceBuf[traceNdx], " unknown %d", citype); traceNdx = strlen(traceBuf); #endif orc = CONFREJ; break; } endswitch: #if TRACELCP if (traceNdx >= 80 - 32) { LCPDEBUG((LOG_INFO, "lcp_reqci: rcvd%s\n", traceBuf)); traceNdx = 0; } #endif if (orc == CONFACK && /* Good CI */ rc != CONFACK) /* but prior CI wasnt? */ continue; /* Don't send this one */ if (orc == CONFNAK) { /* Nak this CI? */ if (reject_if_disagree /* Getting fed up with sending NAKs? */ && citype != CI_MAGICNUMBER) { orc = CONFREJ; /* Get tough if so */ } else { if (rc == CONFREJ) /* Rejecting prior CI? */ continue; /* Don't send this one */ rc = CONFNAK; } } if (orc == CONFREJ) { /* Reject this CI */ rc = CONFREJ; if (cip != rejp) /* Need to move rejected CI? */ BCOPY(cip, rejp, cilen); /* Move it */ INCPTR(cilen, rejp); /* Update output pointer */ } } /* * If we wanted to send additional NAKs (for unsent CIs), the * code would go here. The extra NAKs would go at *nakp. * At present there are no cases where we want to ask the * peer to negotiate an option. */ switch (rc) { case CONFACK: *lenp = (int)(next - inp); break; case CONFNAK: /* * Copy the Nak'd options from the nak_buffer to the caller's buffer. */ *lenp = (int)(nakp - nak_buffer); BCOPY(nak_buffer, inp, *lenp); break; case CONFREJ: *lenp = (int)(rejp - inp); break; } #if TRACELCP > 0 if (traceNdx > 0) { LCPDEBUG((LOG_INFO, "lcp_reqci: %s\n", traceBuf)); } #endif LCPDEBUG((LOG_INFO, "lcp_reqci: returning CONF%s.\n", CODENAME(rc))); return (rc); /* Return final code */ } /* * lcp_up - LCP has come UP. */ static void lcp_up(fsm *f) { lcp_options *wo = &lcp_wantoptions[f->unit]; lcp_options *ho = &lcp_hisoptions[f->unit]; lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *ao = &lcp_allowoptions[f->unit]; if (!go->neg_magicnumber) go->magicnumber = 0; if (!ho->neg_magicnumber) ho->magicnumber = 0; /* * Set our MTU to the smaller of the MTU we wanted and * the MRU our peer wanted. If we negotiated an MRU, * set our MRU to the larger of value we wanted and * the value we got in the negotiation. */ ppp_send_config(f->unit, LWIP_MIN(ao->mru, (ho->neg_mru? ho->mru: PPP_MRU)), (ho->neg_asyncmap? ho->asyncmap: 0xffffffffl), ho->neg_pcompression, ho->neg_accompression); /* * If the asyncmap hasn't been negotiated, we really should * set the receive asyncmap to ffffffff, but we set it to 0 * for backwards contemptibility. */ ppp_recv_config(f->unit, (go->neg_mru? LWIP_MAX(wo->mru, go->mru): PPP_MRU), (go->neg_asyncmap? go->asyncmap: 0x00000000), go->neg_pcompression, go->neg_accompression); if (ho->neg_mru) peer_mru[f->unit] = ho->mru; lcp_echo_lowerup(f->unit); /* Enable echo messages */ link_established(f->unit); } /* * lcp_down - LCP has gone DOWN. * * Alert other protocols. */ static void lcp_down(fsm *f) { lcp_options *go = &lcp_gotoptions[f->unit]; lcp_echo_lowerdown(f->unit); link_down(f->unit); ppp_send_config(f->unit, PPP_MRU, 0xffffffffl, 0, 0); ppp_recv_config(f->unit, PPP_MRU, (go->neg_asyncmap? go->asyncmap: 0x00000000), go->neg_pcompression, go->neg_accompression); peer_mru[f->unit] = PPP_MRU; } /* * lcp_starting - LCP needs the lower layer up. */ static void lcp_starting(fsm *f) { link_required(f->unit); } /* * lcp_finished - LCP has finished with the lower layer. */ static void lcp_finished(fsm *f) { link_terminated(f->unit); } #if 0 /* * print_string - print a readable representation of a string using * printer. */ static void print_string( char *p, int len, void (*printer) (void *, char *, ...), void *arg ) { int c; printer(arg, "\""); for (; len > 0; --len) { c = *p++; if (' ' <= c && c <= '~') { if (c == '\\' || c == '"') printer(arg, "\\"); printer(arg, "%c", c); } else { switch (c) { case '\n': printer(arg, "\\n"); break; case '\r': printer(arg, "\\r"); break; case '\t': printer(arg, "\\t"); break; default: printer(arg, "\\%.3o", c); } } } printer(arg, "\""); } /* * lcp_printpkt - print the contents of an LCP packet. */ static char *lcp_codenames[] = { "ConfReq", "ConfAck", "ConfNak", "ConfRej", "TermReq", "TermAck", "CodeRej", "ProtRej", "EchoReq", "EchoRep", "DiscReq" }; static int lcp_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg ) { int code, id, len, olen; u_char *pstart, *optend; u_short cishort; u32_t cilong; if (plen < HEADERLEN) return 0; pstart = p; GETCHAR(code, p); GETCHAR(id, p); GETSHORT(len, p); if (len < HEADERLEN || len > plen) return 0; if (code >= 1 && code <= sizeof(lcp_codenames) / sizeof(char *)) printer(arg, " %s", lcp_codenames[code-1]); else printer(arg, " code=0x%x", code); printer(arg, " id=0x%x", id); len -= HEADERLEN; switch (code) { case CONFREQ: case CONFACK: case CONFNAK: case CONFREJ: /* print option list */ while (len >= 2) { GETCHAR(code, p); GETCHAR(olen, p); p -= 2; if (olen < 2 || olen > len) { break; } printer(arg, " <"); len -= olen; optend = p + olen; switch (code) { case CI_MRU: if (olen == CILEN_SHORT) { p += 2; GETSHORT(cishort, p); printer(arg, "mru %d", cishort); } break; case CI_ASYNCMAP: if (olen == CILEN_LONG) { p += 2; GETLONG(cilong, p); printer(arg, "asyncmap 0x%lx", cilong); } break; case CI_AUTHTYPE: if (olen >= CILEN_SHORT) { p += 2; printer(arg, "auth "); GETSHORT(cishort, p); switch (cishort) { case PPP_PAP: printer(arg, "pap"); break; case PPP_CHAP: printer(arg, "chap"); break; default: printer(arg, "0x%x", cishort); } } break; case CI_QUALITY: if (olen >= CILEN_SHORT) { p += 2; printer(arg, "quality "); GETSHORT(cishort, p); switch (cishort) { case PPP_LQR: printer(arg, "lqr"); break; default: printer(arg, "0x%x", cishort); } } break; case CI_CALLBACK: if (olen >= CILEN_CHAR) { p += 2; printer(arg, "callback "); GETSHORT(cishort, p); switch (cishort) { case CBCP_OPT: printer(arg, "CBCP"); break; default: printer(arg, "0x%x", cishort); } } break; case CI_MAGICNUMBER: if (olen == CILEN_LONG) { p += 2; GETLONG(cilong, p); printer(arg, "magic 0x%x", cilong); } break; case CI_PCOMPRESSION: if (olen == CILEN_VOID) { p += 2; printer(arg, "pcomp"); } break; case CI_ACCOMPRESSION: if (olen == CILEN_VOID) { p += 2; printer(arg, "accomp"); } break; } while (p < optend) { GETCHAR(code, p); printer(arg, " %.2x", code); } printer(arg, ">"); } break; case TERMACK: case TERMREQ: if (len > 0 && *p >= ' ' && *p < 0x7f) { printer(arg, " "); print_string((char*)p, len, printer, arg); p += len; len = 0; } break; case ECHOREQ: case ECHOREP: case DISCREQ: if (len >= 4) { GETLONG(cilong, p); printer(arg, " magic=0x%x", cilong); p += 4; len -= 4; } break; } /* print the rest of the bytes in the packet */ for (; len > 0; --len) { GETCHAR(code, p); printer(arg, " %.2x", code); } return (int)(p - pstart); } #endif /* * Time to shut down the link because there is nothing out there. */ static void LcpLinkFailure (fsm *f) { if (f->state == OPENED) { LCPDEBUG((LOG_INFO, "No response to %d echo-requests\n", lcp_echos_pending)); LCPDEBUG((LOG_NOTICE, "Serial link appears to be disconnected.\n")); lcp_close(f->unit, "Peer not responding"); } } /* * Timer expired for the LCP echo requests from this process. */ static void LcpEchoCheck (fsm *f) { LcpSendEchoRequest (f); /* * Start the timer for the next interval. */ LWIP_ASSERT("lcp_echo_timer_running == 0", lcp_echo_timer_running == 0); TIMEOUT (LcpEchoTimeout, f, lcp_echo_interval); lcp_echo_timer_running = 1; } /* * LcpEchoTimeout - Timer expired on the LCP echo */ static void LcpEchoTimeout (void *arg) { if (lcp_echo_timer_running != 0) { lcp_echo_timer_running = 0; LcpEchoCheck ((fsm *) arg); } } /* * LcpEchoReply - LCP has received a reply to the echo */ static void lcp_received_echo_reply (fsm *f, int id, u_char *inp, int len) { u32_t magic; (void)id; /* Check the magic number - don't count replies from ourselves. */ if (len < 4) { LCPDEBUG((LOG_WARNING, "lcp: received short Echo-Reply, length %d\n", len)); return; } GETLONG(magic, inp); if (lcp_gotoptions[f->unit].neg_magicnumber && magic == lcp_gotoptions[f->unit].magicnumber) { LCPDEBUG((LOG_WARNING, "appear to have received our own echo-reply!\n")); return; } /* Reset the number of outstanding echo frames */ lcp_echos_pending = 0; } /* * LcpSendEchoRequest - Send an echo request frame to the peer */ static void LcpSendEchoRequest (fsm *f) { u32_t lcp_magic; u_char pkt[4], *pktp; /* * Detect the failure of the peer at this point. */ if (lcp_echo_fails != 0) { if (lcp_echos_pending++ >= lcp_echo_fails) { LcpLinkFailure(f); lcp_echos_pending = 0; } } /* * Make and send the echo request frame. */ if (f->state == OPENED) { lcp_magic = lcp_gotoptions[f->unit].magicnumber; pktp = pkt; PUTLONG(lcp_magic, pktp); fsm_sdata(f, ECHOREQ, (u_char)(lcp_echo_number++ & 0xFF), pkt, (int)(pktp - pkt)); } } /* * lcp_echo_lowerup - Start the timer for the LCP frame */ static void lcp_echo_lowerup (int unit) { fsm *f = &lcp_fsm[unit]; /* Clear the parameters for generating echo frames */ lcp_echos_pending = 0; lcp_echo_number = 0; lcp_echo_timer_running = 0; /* If a timeout interval is specified then start the timer */ if (lcp_echo_interval != 0) LcpEchoCheck (f); } /* * lcp_echo_lowerdown - Stop the timer for the LCP frame */ static void lcp_echo_lowerdown (int unit) { fsm *f = &lcp_fsm[unit]; if (lcp_echo_timer_running != 0) { UNTIMEOUT (LcpEchoTimeout, f); lcp_echo_timer_running = 0; } } #endif /* PPP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/ipcp.c0000644000175000017500000010617411671615006017135 0ustar renzorenzo/***************************************************************************** * ipcp.c - Network PPP IP Control Protocol program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 by Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-08 Guy Lancaster , Global Election Systems Inc. * Original. *****************************************************************************/ /* * ipcp.c - PPP IP Control Protocol. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include "ppp.h" #if PPP_SUPPORT > 0 #include "auth.h" #include "fsm.h" #include "vj.h" #include "ipcp.h" #include "pppdebug.h" /*************************/ /*** LOCAL DEFINITIONS ***/ /*************************/ /* #define OLD_CI_ADDRS 1 */ /* Support deprecated address negotiation. */ /* * Lengths of configuration options. */ #define CILEN_VOID 2 #define CILEN_COMPRESS 4 /* min length for compression protocol opt. */ #define CILEN_VJ 6 /* length for RFC1332 Van-Jacobson opt. */ #define CILEN_ADDR 6 /* new-style single address option */ #define CILEN_ADDRS 10 /* old-style dual address option */ /***********************************/ /*** LOCAL FUNCTION DECLARATIONS ***/ /***********************************/ /* * Callbacks for fsm code. (CI = Configuration Information) */ static void ipcp_resetci (fsm *); /* Reset our CI */ static int ipcp_cilen (fsm *); /* Return length of our CI */ static void ipcp_addci (fsm *, u_char *, int *); /* Add our CI */ static int ipcp_ackci (fsm *, u_char *, int); /* Peer ack'd our CI */ static int ipcp_nakci (fsm *, u_char *, int); /* Peer nak'd our CI */ static int ipcp_rejci (fsm *, u_char *, int); /* Peer rej'd our CI */ static int ipcp_reqci (fsm *, u_char *, int *, int); /* Rcv CI */ static void ipcp_up (fsm *); /* We're UP */ static void ipcp_down (fsm *); /* We're DOWN */ #if 0 static void ipcp_script (fsm *, char *); /* Run an up/down script */ #endif static void ipcp_finished (fsm *); /* Don't need lower layer */ /* * Protocol entry points from main code. */ static void ipcp_init (int); static void ipcp_open (int); static void ipcp_close (int, char *); static void ipcp_lowerup (int); static void ipcp_lowerdown (int); static void ipcp_input (int, u_char *, int); static void ipcp_protrej (int); static void ipcp_clear_addrs (int); #define CODENAME(x) ((x) == CONFACK ? "ACK" : \ (x) == CONFNAK ? "NAK" : "REJ") /******************************/ /*** PUBLIC DATA STRUCTURES ***/ /******************************/ /* global vars */ ipcp_options ipcp_wantoptions[NUM_PPP]; /* Options that we want to request */ ipcp_options ipcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */ ipcp_options ipcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */ ipcp_options ipcp_hisoptions[NUM_PPP]; /* Options that we ack'd */ fsm ipcp_fsm[NUM_PPP]; /* IPCP fsm structure */ struct protent ipcp_protent = { PPP_IPCP, ipcp_init, ipcp_input, ipcp_protrej, ipcp_lowerup, ipcp_lowerdown, ipcp_open, ipcp_close, #if 0 ipcp_printpkt, NULL, #endif 1, "IPCP", #if 0 ip_check_options, NULL, ip_active_pkt #endif }; /*****************************/ /*** LOCAL DATA STRUCTURES ***/ /*****************************/ /* local vars */ static int cis_received[NUM_PPP]; /* # Conf-Reqs received */ static int default_route_set[NUM_PPP]; /* Have set up a default route */ static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */ ipcp_resetci, /* Reset our Configuration Information */ ipcp_cilen, /* Length of our Configuration Information */ ipcp_addci, /* Add our Configuration Information */ ipcp_ackci, /* ACK our Configuration Information */ ipcp_nakci, /* NAK our Configuration Information */ ipcp_rejci, /* Reject our Configuration Information */ ipcp_reqci, /* Request peer's Configuration Information */ ipcp_up, /* Called when fsm reaches OPENED state */ ipcp_down, /* Called when fsm leaves OPENED state */ NULL, /* Called when we want the lower layer up */ ipcp_finished, /* Called when we want the lower layer down */ NULL, /* Called when Protocol-Reject received */ NULL, /* Retransmission is necessary */ NULL, /* Called to handle protocol-specific codes */ "IPCP" /* String name of protocol */ }; /**********************************/ /*** LOCAL FUNCTION DEFINITIONS ***/ /**********************************/ /* * Non-standard inet_ntoa left here for compat with original ppp * sources. Assumes u32_t instead of struct in_addr. */ char * _inet_ntoa(u32_t n) { struct in_addr ia; ia.s_addr = n; return inet_ntoa(ia); } #define inet_ntoa _inet_ntoa /* * ipcp_init - Initialize IPCP. */ static void ipcp_init(int unit) { fsm *f = &ipcp_fsm[unit]; ipcp_options *wo = &ipcp_wantoptions[unit]; ipcp_options *ao = &ipcp_allowoptions[unit]; f->unit = unit; f->protocol = PPP_IPCP; f->callbacks = &ipcp_callbacks; fsm_init(&ipcp_fsm[unit]); memset(wo, 0, sizeof(*wo)); memset(ao, 0, sizeof(*ao)); wo->neg_addr = 1; wo->ouraddr = 0; #if VJ_SUPPORT > 0 wo->neg_vj = 1; #else wo->neg_vj = 0; #endif wo->vj_protocol = IPCP_VJ_COMP; wo->maxslotindex = MAX_SLOTS - 1; wo->cflag = 0; wo->default_route = 1; ao->neg_addr = 1; #if VJ_SUPPORT > 0 ao->neg_vj = 1; #else ao->neg_vj = 0; #endif ao->maxslotindex = MAX_SLOTS - 1; ao->cflag = 1; ao->default_route = 1; } /* * ipcp_open - IPCP is allowed to come up. */ static void ipcp_open(int unit) { fsm_open(&ipcp_fsm[unit]); } /* * ipcp_close - Take IPCP down. */ static void ipcp_close(int unit, char *reason) { fsm_close(&ipcp_fsm[unit], reason); } /* * ipcp_lowerup - The lower layer is up. */ static void ipcp_lowerup(int unit) { fsm_lowerup(&ipcp_fsm[unit]); } /* * ipcp_lowerdown - The lower layer is down. */ static void ipcp_lowerdown(int unit) { fsm_lowerdown(&ipcp_fsm[unit]); } /* * ipcp_input - Input IPCP packet. */ static void ipcp_input(int unit, u_char *p, int len) { fsm_input(&ipcp_fsm[unit], p, len); } /* * ipcp_protrej - A Protocol-Reject was received for IPCP. * * Pretend the lower layer went down, so we shut up. */ static void ipcp_protrej(int unit) { fsm_lowerdown(&ipcp_fsm[unit]); } /* * ipcp_resetci - Reset our CI. */ static void ipcp_resetci(fsm *f) { ipcp_options *wo = &ipcp_wantoptions[f->unit]; wo->req_addr = wo->neg_addr && ipcp_allowoptions[f->unit].neg_addr; if (wo->ouraddr == 0) wo->accept_local = 1; if (wo->hisaddr == 0) wo->accept_remote = 1; /* Request DNS addresses from the peer */ wo->req_dns1 = ppp_settings.usepeerdns; wo->req_dns2 = ppp_settings.usepeerdns; ipcp_gotoptions[f->unit] = *wo; cis_received[f->unit] = 0; } /* * ipcp_cilen - Return length of our CI. */ static int ipcp_cilen(fsm *f) { ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *wo = &ipcp_wantoptions[f->unit]; ipcp_options *ho = &ipcp_hisoptions[f->unit]; #define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0) #define LENCIADDR(neg, old) (neg ? (old? CILEN_ADDRS : CILEN_ADDR) : 0) #define LENCIDNS(neg) (neg ? (CILEN_ADDR) : 0) /* * First see if we want to change our options to the old * forms because we have received old forms from the peer. */ if (wo->neg_addr && !go->neg_addr && !go->old_addrs) { /* use the old style of address negotiation */ go->neg_addr = 1; go->old_addrs = 1; } if (wo->neg_vj && !go->neg_vj && !go->old_vj) { /* try an older style of VJ negotiation */ if (cis_received[f->unit] == 0) { /* keep trying the new style until we see some CI from the peer */ go->neg_vj = 1; } else { /* use the old style only if the peer did */ if (ho->neg_vj && ho->old_vj) { go->neg_vj = 1; go->old_vj = 1; go->vj_protocol = ho->vj_protocol; } } } return (LENCIADDR(go->neg_addr, go->old_addrs) + LENCIVJ(go->neg_vj, go->old_vj) + LENCIDNS(go->req_dns1) + LENCIDNS(go->req_dns2)); } /* * ipcp_addci - Add our desired CIs to a packet. */ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) { ipcp_options *go = &ipcp_gotoptions[f->unit]; int len = *lenp; #define ADDCIVJ(opt, neg, val, old, maxslotindex, cflag) \ if (neg) { \ int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ if (len >= vjlen) { \ PUTCHAR(opt, ucp); \ PUTCHAR(vjlen, ucp); \ PUTSHORT(val, ucp); \ if (!old) { \ PUTCHAR(maxslotindex, ucp); \ PUTCHAR(cflag, ucp); \ } \ len -= vjlen; \ } else \ neg = 0; \ } #define ADDCIADDR(opt, neg, old, val1, val2) \ if (neg) { \ int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \ if (len >= addrlen) { \ u32_t l; \ PUTCHAR(opt, ucp); \ PUTCHAR(addrlen, ucp); \ l = ntohl(val1); \ PUTLONG(l, ucp); \ if (old) { \ l = ntohl(val2); \ PUTLONG(l, ucp); \ } \ len -= addrlen; \ } else \ neg = 0; \ } #define ADDCIDNS(opt, neg, addr) \ if (neg) { \ if (len >= CILEN_ADDR) { \ u32_t l; \ PUTCHAR(opt, ucp); \ PUTCHAR(CILEN_ADDR, ucp); \ l = ntohl(addr); \ PUTLONG(l, ucp); \ len -= CILEN_ADDR; \ } else \ neg = 0; \ } ADDCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, go->old_addrs, go->ouraddr, go->hisaddr); ADDCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); ADDCIDNS(CI_MS_DNS1, go->req_dns1, go->dnsaddr[0]); ADDCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]); *lenp -= len; } /* * ipcp_ackci - Ack our CIs. * * Returns: * 0 - Ack was bad. * 1 - Ack was good. */ static int ipcp_ackci(fsm *f, u_char *p, int len) { ipcp_options *go = &ipcp_gotoptions[f->unit]; u_short cilen, citype, cishort; u32_t cilong; u_char cimaxslotindex, cicflag; /* * CIs must be in exactly the same order that we sent... * Check packet length and CI length at each step. * If we find any deviations, then this packet is bad. */ #define ACKCIVJ(opt, neg, val, old, maxslotindex, cflag) \ if (neg) { \ int vjlen = old? CILEN_COMPRESS : CILEN_VJ; \ if ((len -= vjlen) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != vjlen || \ citype != opt) \ goto bad; \ GETSHORT(cishort, p); \ if (cishort != val) \ goto bad; \ if (!old) { \ GETCHAR(cimaxslotindex, p); \ if (cimaxslotindex != maxslotindex) \ goto bad; \ GETCHAR(cicflag, p); \ if (cicflag != cflag) \ goto bad; \ } \ } #define ACKCIADDR(opt, neg, old, val1, val2) \ if (neg) { \ int addrlen = (old? CILEN_ADDRS: CILEN_ADDR); \ u32_t l; \ if ((len -= addrlen) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != addrlen || \ citype != opt) \ goto bad; \ GETLONG(l, p); \ cilong = htonl(l); \ if (val1 != cilong) \ goto bad; \ if (old) { \ GETLONG(l, p); \ cilong = htonl(l); \ if (val2 != cilong) \ goto bad; \ } \ } #define ACKCIDNS(opt, neg, addr) \ if (neg) { \ u32_t l; \ if ((len -= CILEN_ADDR) < 0) \ goto bad; \ GETCHAR(citype, p); \ GETCHAR(cilen, p); \ if (cilen != CILEN_ADDR || \ citype != opt) \ goto bad; \ GETLONG(l, p); \ cilong = htonl(l); \ if (addr != cilong) \ goto bad; \ } ACKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), go->neg_addr, go->old_addrs, go->ouraddr, go->hisaddr); ACKCIVJ(CI_COMPRESSTYPE, go->neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); ACKCIDNS(CI_MS_DNS1, go->req_dns1, go->dnsaddr[0]); ACKCIDNS(CI_MS_DNS2, go->req_dns2, go->dnsaddr[1]); /* * If there are any remaining CIs, then this packet is bad. */ if (len != 0) goto bad; return (1); bad: IPCPDEBUG((LOG_INFO, "ipcp_ackci: received bad Ack!\n")); return (0); } /* * ipcp_nakci - Peer has sent a NAK for some of our CIs. * This should not modify any state if the Nak is bad * or if IPCP is in the OPENED state. * * Returns: * 0 - Nak was bad. * 1 - Nak was good. */ static int ipcp_nakci(fsm *f, u_char *p, int len) { ipcp_options *go = &ipcp_gotoptions[f->unit]; u_char cimaxslotindex, cicflag; u_char citype, cilen, *next; u_short cishort; u32_t ciaddr1, ciaddr2, l, cidnsaddr; ipcp_options no; /* options we've seen Naks for */ ipcp_options try; /* options to request next time */ BZERO(&no, sizeof(no)); try = *go; /* * Any Nak'd CIs must be in exactly the same order that we sent. * Check packet length and CI length at each step. * If we find any deviations, then this packet is bad. */ #define NAKCIADDR(opt, neg, old, code) \ if (go->neg && \ len >= (cilen = (old? CILEN_ADDRS: CILEN_ADDR)) && \ p[1] == cilen && \ p[0] == opt) { \ len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ ciaddr1 = htonl(l); \ if (old) { \ GETLONG(l, p); \ ciaddr2 = htonl(l); \ no.old_addrs = 1; \ } else \ ciaddr2 = 0; \ no.neg = 1; \ code \ } #define NAKCIVJ(opt, neg, code) \ if (go->neg && \ ((cilen = p[1]) == CILEN_COMPRESS || cilen == CILEN_VJ) && \ len >= cilen && \ p[0] == opt) { \ len -= cilen; \ INCPTR(2, p); \ GETSHORT(cishort, p); \ no.neg = 1; \ code \ } #define NAKCIDNS(opt, neg, code) \ if (go->neg && \ ((cilen = p[1]) == CILEN_ADDR) && \ len >= cilen && \ p[0] == opt) { \ len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ cidnsaddr = htonl(l); \ no.neg = 1; \ code \ } /* * Accept the peer's idea of {our,his} address, if different * from our idea, only if the accept_{local,remote} flag is set. */ NAKCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), neg_addr, go->old_addrs, if (go->accept_local && ciaddr1) { /* Do we know our address? */ try.ouraddr = ciaddr1; IPCPDEBUG((LOG_INFO, "local IP address %s\n", inet_ntoa(ciaddr1))); } if (go->accept_remote && ciaddr2) { /* Does he know his? */ try.hisaddr = ciaddr2; IPCPDEBUG((LOG_INFO, "remote IP address %s\n", inet_ntoa(ciaddr2))); } ); /* * Accept the peer's value of maxslotindex provided that it * is less than what we asked for. Turn off slot-ID compression * if the peer wants. Send old-style compress-type option if * the peer wants. */ NAKCIVJ(CI_COMPRESSTYPE, neg_vj, if (cilen == CILEN_VJ) { GETCHAR(cimaxslotindex, p); GETCHAR(cicflag, p); if (cishort == IPCP_VJ_COMP) { try.old_vj = 0; if (cimaxslotindex < go->maxslotindex) try.maxslotindex = cimaxslotindex; if (!cicflag) try.cflag = 0; } else { try.neg_vj = 0; } } else { if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) { try.old_vj = 1; try.vj_protocol = cishort; } else { try.neg_vj = 0; } } ); NAKCIDNS(CI_MS_DNS1, req_dns1, try.dnsaddr[0] = cidnsaddr; IPCPDEBUG((LOG_INFO, "primary DNS address %s\n", inet_ntoa(cidnsaddr))); ); NAKCIDNS(CI_MS_DNS2, req_dns2, try.dnsaddr[1] = cidnsaddr; IPCPDEBUG((LOG_INFO, "secondary DNS address %s\n", inet_ntoa(cidnsaddr))); ); /* * There may be remaining CIs, if the peer is requesting negotiation * on an option that we didn't include in our request packet. * If they want to negotiate about IP addresses, we comply. * If they want us to ask for compression, we refuse. */ while (len > CILEN_VOID) { GETCHAR(citype, p); GETCHAR(cilen, p); if( (len -= cilen) < 0 ) goto bad; next = p + cilen - 2; switch (citype) { case CI_COMPRESSTYPE: if (go->neg_vj || no.neg_vj || (cilen != CILEN_VJ && cilen != CILEN_COMPRESS)) goto bad; no.neg_vj = 1; break; case CI_ADDRS: if ((go->neg_addr && go->old_addrs) || no.old_addrs || cilen != CILEN_ADDRS) goto bad; try.neg_addr = 1; try.old_addrs = 1; GETLONG(l, p); ciaddr1 = htonl(l); if (ciaddr1 && go->accept_local) try.ouraddr = ciaddr1; GETLONG(l, p); ciaddr2 = htonl(l); if (ciaddr2 && go->accept_remote) try.hisaddr = ciaddr2; no.old_addrs = 1; break; case CI_ADDR: if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) goto bad; try.old_addrs = 0; GETLONG(l, p); ciaddr1 = htonl(l); if (ciaddr1 && go->accept_local) try.ouraddr = ciaddr1; if (try.ouraddr != 0) try.neg_addr = 1; no.neg_addr = 1; break; } p = next; } /* If there is still anything left, this packet is bad. */ if (len != 0) goto bad; /* * OK, the Nak is good. Now we can update state. */ if (f->state != OPENED) *go = try; return 1; bad: IPCPDEBUG((LOG_INFO, "ipcp_nakci: received bad Nak!\n")); return 0; } /* * ipcp_rejci - Reject some of our CIs. */ static int ipcp_rejci(fsm *f, u_char *p, int len) { ipcp_options *go = &ipcp_gotoptions[f->unit]; u_char cimaxslotindex, ciflag, cilen; u_short cishort; u32_t cilong; ipcp_options try; /* options to request next time */ try = *go; /* * Any Rejected CIs must be in exactly the same order that we sent. * Check packet length and CI length at each step. * If we find any deviations, then this packet is bad. */ #define REJCIADDR(opt, neg, old, val1, val2) \ if (go->neg && \ len >= (cilen = old? CILEN_ADDRS: CILEN_ADDR) && \ p[1] == cilen && \ p[0] == opt) { \ u32_t l; \ len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ cilong = htonl(l); \ /* Check rejected value. */ \ if (cilong != val1) \ goto bad; \ if (old) { \ GETLONG(l, p); \ cilong = htonl(l); \ /* Check rejected value. */ \ if (cilong != val2) \ goto bad; \ } \ try.neg = 0; \ } #define REJCIVJ(opt, neg, val, old, maxslot, cflag) \ if (go->neg && \ p[1] == (old? CILEN_COMPRESS : CILEN_VJ) && \ len >= p[1] && \ p[0] == opt) { \ len -= p[1]; \ INCPTR(2, p); \ GETSHORT(cishort, p); \ /* Check rejected value. */ \ if (cishort != val) \ goto bad; \ if (!old) { \ GETCHAR(cimaxslotindex, p); \ if (cimaxslotindex != maxslot) \ goto bad; \ GETCHAR(ciflag, p); \ if (ciflag != cflag) \ goto bad; \ } \ try.neg = 0; \ } #define REJCIDNS(opt, neg, dnsaddr) \ if (go->neg && \ ((cilen = p[1]) == CILEN_ADDR) && \ len >= cilen && \ p[0] == opt) { \ u32_t l; \ len -= cilen; \ INCPTR(2, p); \ GETLONG(l, p); \ cilong = htonl(l); \ /* Check rejected value. */ \ if (cilong != dnsaddr) \ goto bad; \ try.neg = 0; \ } REJCIADDR((go->old_addrs? CI_ADDRS: CI_ADDR), neg_addr, go->old_addrs, go->ouraddr, go->hisaddr); REJCIVJ(CI_COMPRESSTYPE, neg_vj, go->vj_protocol, go->old_vj, go->maxslotindex, go->cflag); REJCIDNS(CI_MS_DNS1, req_dns1, go->dnsaddr[0]); REJCIDNS(CI_MS_DNS2, req_dns2, go->dnsaddr[1]); /* * If there are any remaining CIs, then this packet is bad. */ if (len != 0) goto bad; /* * Now we can update state. */ if (f->state != OPENED) *go = try; return 1; bad: IPCPDEBUG((LOG_INFO, "ipcp_rejci: received bad Reject!\n")); return 0; } /* * ipcp_reqci - Check the peer's requested CIs and send appropriate response. * * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified * appropriately. If reject_if_disagree is non-zero, doesn't return * CONFNAK; returns CONFREJ if it can't return CONFACK. */ static int ipcp_reqci( fsm *f, u_char *inp, /* Requested CIs */ int *len, /* Length of requested CIs */ int reject_if_disagree ) { ipcp_options *wo = &ipcp_wantoptions[f->unit]; ipcp_options *ho = &ipcp_hisoptions[f->unit]; ipcp_options *ao = &ipcp_allowoptions[f->unit]; #ifdef OLD_CI_ADDRS ipcp_options *go = &ipcp_gotoptions[f->unit]; #endif u_char *cip, *next; /* Pointer to current and next CIs */ u_short cilen, citype; /* Parsed len, type */ u_short cishort; /* Parsed short value */ u32_t tl, ciaddr1; /* Parsed address values */ #ifdef OLD_CI_ADDRS u32_t ciaddr2; /* Parsed address values */ #endif int rc = CONFACK; /* Final packet return code */ int orc; /* Individual option return code */ u_char *p; /* Pointer to next char to parse */ u_char *ucp = inp; /* Pointer to current output char */ int l = *len; /* Length left */ u_char maxslotindex, cflag; int d; cis_received[f->unit] = 1; /* * Reset all his options. */ BZERO(ho, sizeof(*ho)); /* * Process all his options. */ next = inp; while (l) { orc = CONFACK; /* Assume success */ cip = p = next; /* Remember begining of CI */ if (l < 2 || /* Not enough data for CI header or */ p[1] < 2 || /* CI length too small or */ p[1] > l) { /* CI length too big? */ IPCPDEBUG((LOG_INFO, "ipcp_reqci: bad CI length!\n")); orc = CONFREJ; /* Reject bad CI */ cilen = l; /* Reject till end of packet */ l = 0; /* Don't loop again */ goto endswitch; } GETCHAR(citype, p); /* Parse CI type */ GETCHAR(cilen, p); /* Parse CI length */ l -= cilen; /* Adjust remaining length */ next += cilen; /* Step to next CI */ switch (citype) { /* Check CI type */ #ifdef OLD_CI_ADDRS /* Need to save space... */ case CI_ADDRS: IPCPDEBUG((LOG_INFO, "ipcp_reqci: received ADDRS\n")); if (!ao->neg_addr || cilen != CILEN_ADDRS) { /* Check CI length */ orc = CONFREJ; /* Reject CI */ break; } /* * If he has no address, or if we both have his address but * disagree about it, then NAK it with our idea. * In particular, if we don't know his address, but he does, * then accept it. */ GETLONG(tl, p); /* Parse source address (his) */ ciaddr1 = htonl(tl); IPCPDEBUG((LOG_INFO, "his addr %s\n", inet_ntoa(ciaddr1))); if (ciaddr1 != wo->hisaddr && (ciaddr1 == 0 || !wo->accept_remote)) { orc = CONFNAK; if (!reject_if_disagree) { DECPTR(sizeof(u32_t), p); tl = ntohl(wo->hisaddr); PUTLONG(tl, p); } } else if (ciaddr1 == 0 && wo->hisaddr == 0) { /* * If neither we nor he knows his address, reject the option. */ orc = CONFREJ; wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ break; } /* * If he doesn't know our address, or if we both have our address * but disagree about it, then NAK it with our idea. */ GETLONG(tl, p); /* Parse desination address (ours) */ ciaddr2 = htonl(tl); IPCPDEBUG((LOG_INFO, "our addr %s\n", inet_ntoa(ciaddr2))); if (ciaddr2 != wo->ouraddr) { if (ciaddr2 == 0 || !wo->accept_local) { orc = CONFNAK; if (!reject_if_disagree) { DECPTR(sizeof(u32_t), p); tl = ntohl(wo->ouraddr); PUTLONG(tl, p); } } else { go->ouraddr = ciaddr2; /* accept peer's idea */ } } ho->neg_addr = 1; ho->old_addrs = 1; ho->hisaddr = ciaddr1; ho->ouraddr = ciaddr2; break; #endif case CI_ADDR: if (!ao->neg_addr) { IPCPDEBUG((LOG_INFO, "ipcp_reqci: Reject ADDR not allowed\n")); orc = CONFREJ; /* Reject CI */ break; } else if (cilen != CILEN_ADDR) { /* Check CI length */ IPCPDEBUG((LOG_INFO, "ipcp_reqci: Reject ADDR bad len\n")); orc = CONFREJ; /* Reject CI */ break; } /* * If he has no address, or if we both have his address but * disagree about it, then NAK it with our idea. * In particular, if we don't know his address, but he does, * then accept it. */ GETLONG(tl, p); /* Parse source address (his) */ ciaddr1 = htonl(tl); if (ciaddr1 != wo->hisaddr && (ciaddr1 == 0 || !wo->accept_remote)) { orc = CONFNAK; if (!reject_if_disagree) { DECPTR(sizeof(u32_t), p); tl = ntohl(wo->hisaddr); PUTLONG(tl, p); } IPCPDEBUG((LOG_INFO, "ipcp_reqci: Nak ADDR %s\n", inet_ntoa(ciaddr1))); } else if (ciaddr1 == 0 && wo->hisaddr == 0) { /* * Don't ACK an address of 0.0.0.0 - reject it instead. */ IPCPDEBUG((LOG_INFO, "ipcp_reqci: Reject ADDR %s\n", inet_ntoa(ciaddr1))); orc = CONFREJ; wo->req_addr = 0; /* don't NAK with 0.0.0.0 later */ break; } ho->neg_addr = 1; ho->hisaddr = ciaddr1; IPCPDEBUG((LOG_INFO, "ipcp_reqci: ADDR %s\n", inet_ntoa(ciaddr1))); break; case CI_MS_DNS1: case CI_MS_DNS2: /* Microsoft primary or secondary DNS request */ d = citype == CI_MS_DNS2; /* If we do not have a DNS address then we cannot send it */ if (ao->dnsaddr[d] == 0 || cilen != CILEN_ADDR) { /* Check CI length */ IPCPDEBUG((LOG_INFO, "ipcp_reqci: Rejecting DNS%d Request\n", d+1)); orc = CONFREJ; /* Reject CI */ break; } GETLONG(tl, p); if (htonl(tl) != ao->dnsaddr[d]) { IPCPDEBUG((LOG_INFO, "ipcp_reqci: Naking DNS%d Request %d\n", d+1, inet_ntoa(tl))); DECPTR(sizeof(u32_t), p); tl = ntohl(ao->dnsaddr[d]); PUTLONG(tl, p); orc = CONFNAK; } IPCPDEBUG((LOG_INFO, "ipcp_reqci: received DNS%d Request\n", d+1)); break; case CI_MS_WINS1: case CI_MS_WINS2: /* Microsoft primary or secondary WINS request */ d = citype == CI_MS_WINS2; IPCPDEBUG((LOG_INFO, "ipcp_reqci: received WINS%d Request\n", d+1)); /* If we do not have a DNS address then we cannot send it */ if (ao->winsaddr[d] == 0 || cilen != CILEN_ADDR) { /* Check CI length */ orc = CONFREJ; /* Reject CI */ break; } GETLONG(tl, p); if (htonl(tl) != ao->winsaddr[d]) { DECPTR(sizeof(u32_t), p); tl = ntohl(ao->winsaddr[d]); PUTLONG(tl, p); orc = CONFNAK; } break; case CI_COMPRESSTYPE: if (!ao->neg_vj) { IPCPDEBUG((LOG_INFO, "ipcp_reqci: Rejecting COMPRESSTYPE not allowed\n")); orc = CONFREJ; break; } else if (cilen != CILEN_VJ && cilen != CILEN_COMPRESS) { IPCPDEBUG((LOG_INFO, "ipcp_reqci: Rejecting COMPRESSTYPE len=%d\n", cilen)); orc = CONFREJ; break; } GETSHORT(cishort, p); if (!(cishort == IPCP_VJ_COMP || (cishort == IPCP_VJ_COMP_OLD && cilen == CILEN_COMPRESS))) { IPCPDEBUG((LOG_INFO, "ipcp_reqci: Rejecting COMPRESSTYPE %d\n", cishort)); orc = CONFREJ; break; } ho->neg_vj = 1; ho->vj_protocol = cishort; if (cilen == CILEN_VJ) { GETCHAR(maxslotindex, p); if (maxslotindex > ao->maxslotindex) { IPCPDEBUG((LOG_INFO, "ipcp_reqci: Naking VJ max slot %d\n", maxslotindex)); orc = CONFNAK; if (!reject_if_disagree){ DECPTR(1, p); PUTCHAR(ao->maxslotindex, p); } } GETCHAR(cflag, p); if (cflag && !ao->cflag) { IPCPDEBUG((LOG_INFO, "ipcp_reqci: Naking VJ cflag %d\n", cflag)); orc = CONFNAK; if (!reject_if_disagree){ DECPTR(1, p); PUTCHAR(wo->cflag, p); } } ho->maxslotindex = maxslotindex; ho->cflag = cflag; } else { ho->old_vj = 1; ho->maxslotindex = MAX_SLOTS - 1; ho->cflag = 1; } IPCPDEBUG((LOG_INFO, "ipcp_reqci: received COMPRESSTYPE p=%d old=%d maxslot=%d cflag=%d\n", ho->vj_protocol, ho->old_vj, ho->maxslotindex, ho->cflag)); break; default: IPCPDEBUG((LOG_INFO, "ipcp_reqci: Rejecting unknown CI type %d\n", citype)); orc = CONFREJ; break; } endswitch: if (orc == CONFACK && /* Good CI */ rc != CONFACK) /* but prior CI wasnt? */ continue; /* Don't send this one */ if (orc == CONFNAK) { /* Nak this CI? */ if (reject_if_disagree) { /* Getting fed up with sending NAKs? */ IPCPDEBUG((LOG_INFO, "ipcp_reqci: Rejecting too many naks\n")); orc = CONFREJ; /* Get tough if so */ } else { if (rc == CONFREJ) /* Rejecting prior CI? */ continue; /* Don't send this one */ if (rc == CONFACK) { /* Ack'd all prior CIs? */ rc = CONFNAK; /* Not anymore... */ ucp = inp; /* Backup */ } } } if (orc == CONFREJ && /* Reject this CI */ rc != CONFREJ) { /* but no prior ones? */ rc = CONFREJ; ucp = inp; /* Backup */ } /* Need to move CI? */ if (ucp != cip) BCOPY(cip, ucp, cilen); /* Move it */ /* Update output pointer */ INCPTR(cilen, ucp); } /* * If we aren't rejecting this packet, and we want to negotiate * their address, and they didn't send their address, then we * send a NAK with a CI_ADDR option appended. We assume the * input buffer is long enough that we can append the extra * option safely. */ if (rc != CONFREJ && !ho->neg_addr && wo->req_addr && !reject_if_disagree) { IPCPDEBUG((LOG_INFO, "ipcp_reqci: Requesting peer address\n")); if (rc == CONFACK) { rc = CONFNAK; ucp = inp; /* reset pointer */ wo->req_addr = 0; /* don't ask again */ } PUTCHAR(CI_ADDR, ucp); PUTCHAR(CILEN_ADDR, ucp); tl = ntohl(wo->hisaddr); PUTLONG(tl, ucp); } *len = (int)(ucp - inp); /* Compute output length */ IPCPDEBUG((LOG_INFO, "ipcp_reqci: returning Configure-%s\n", CODENAME(rc))); return (rc); /* Return final code */ } #if 0 /* * ip_check_options - check that any IP-related options are OK, * and assign appropriate defaults. */ static void ip_check_options(u_long localAddr) { ipcp_options *wo = &ipcp_wantoptions[0]; /* * Load our default IP address but allow the remote host to give us * a new address. */ if (wo->ouraddr == 0 && !ppp_settings.disable_defaultip) { wo->accept_local = 1; /* don't insist on this default value */ wo->ouraddr = htonl(localAddr); } } #endif /* * ipcp_up - IPCP has come UP. * * Configure the IP network interface appropriately and bring it up. */ static void ipcp_up(fsm *f) { u32_t mask; ipcp_options *ho = &ipcp_hisoptions[f->unit]; ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *wo = &ipcp_wantoptions[f->unit]; np_up(f->unit, PPP_IP); IPCPDEBUG((LOG_INFO, "ipcp: up\n")); /* * We must have a non-zero IP address for both ends of the link. */ if (!ho->neg_addr) ho->hisaddr = wo->hisaddr; if (ho->hisaddr == 0) { IPCPDEBUG((LOG_ERR, "Could not determine remote IP address\n")); ipcp_close(f->unit, "Could not determine remote IP address"); return; } if (go->ouraddr == 0) { IPCPDEBUG((LOG_ERR, "Could not determine local IP address\n")); ipcp_close(f->unit, "Could not determine local IP address"); return; } if (ppp_settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { /*pppGotDNSAddrs(go->dnsaddr[0], go->dnsaddr[1]);*/ } /* * Check that the peer is allowed to use the IP address it wants. */ if (!auth_ip_addr(f->unit, ho->hisaddr)) { IPCPDEBUG((LOG_ERR, "Peer is not authorized to use remote address %s\n", inet_ntoa(ho->hisaddr))); ipcp_close(f->unit, "Unauthorized remote IP address"); return; } /* set tcp compression */ sifvjcomp(f->unit, ho->neg_vj, ho->cflag, ho->maxslotindex); /* * Set IP addresses and (if specified) netmask. */ mask = GetMask(go->ouraddr); if (!sifaddr(f->unit, go->ouraddr, ho->hisaddr, mask, go->dnsaddr[0], go->dnsaddr[1])) { IPCPDEBUG((LOG_WARNING, "sifaddr failed\n")); ipcp_close(f->unit, "Interface configuration failed"); return; } /* bring the interface up for IP */ if (!sifup(f->unit)) { IPCPDEBUG((LOG_WARNING, "sifup failed\n")); ipcp_close(f->unit, "Interface configuration failed"); return; } sifnpmode(f->unit, PPP_IP, NPMODE_PASS); /* assign a default route through the interface if required */ if (ipcp_wantoptions[f->unit].default_route) if (sifdefaultroute(f->unit, go->ouraddr, ho->hisaddr)) default_route_set[f->unit] = 1; IPCPDEBUG((LOG_NOTICE, "local IP address %s\n", inet_ntoa(go->ouraddr))); IPCPDEBUG((LOG_NOTICE, "remote IP address %s\n", inet_ntoa(ho->hisaddr))); if (go->dnsaddr[0]) { IPCPDEBUG((LOG_NOTICE, "primary DNS address %s\n", inet_ntoa(go->dnsaddr[0]))); } if (go->dnsaddr[1]) { IPCPDEBUG((LOG_NOTICE, "secondary DNS address %s\n", inet_ntoa(go->dnsaddr[1]))); } } /* * ipcp_down - IPCP has gone DOWN. * * Take the IP network interface down, clear its addresses * and delete routes through it. */ static void ipcp_down(fsm *f) { IPCPDEBUG((LOG_INFO, "ipcp: down\n")); np_down(f->unit, PPP_IP); sifvjcomp(f->unit, 0, 0, 0); sifdown(f->unit); ipcp_clear_addrs(f->unit); } /* * ipcp_clear_addrs() - clear the interface addresses, routes, etc. */ static void ipcp_clear_addrs(int unit) { u32_t ouraddr, hisaddr; ouraddr = ipcp_gotoptions[unit].ouraddr; hisaddr = ipcp_hisoptions[unit].hisaddr; if (default_route_set[unit]) { cifdefaultroute(unit, ouraddr, hisaddr); default_route_set[unit] = 0; } cifaddr(unit, ouraddr, hisaddr); } /* * ipcp_finished - possibly shut down the lower layers. */ static void ipcp_finished(fsm *f) { np_finished(f->unit, PPP_IP); } #if 0 static int ipcp_printpkt( u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg ) { (void)p; (void)plen; (void)printer; (void)arg; return 0; } /* * ip_active_pkt - see if this IP packet is worth bringing the link up for. * We don't bring the link up for IP fragments or for TCP FIN packets * with no data. */ #define IP_HDRLEN 20 /* bytes */ #define IP_OFFMASK 0x1fff #define IPPROTO_TCP 6 #define TCP_HDRLEN 20 #define TH_FIN 0x01 /* * We use these macros because the IP header may be at an odd address, * and some compilers might use word loads to get th_off or ip_hl. */ #define net_short(x) (((x)[0] << 8) + (x)[1]) #define get_iphl(x) (((unsigned char *)(x))[0] & 0xF) #define get_ipoff(x) net_short((unsigned char *)(x) + 6) #define get_ipproto(x) (((unsigned char *)(x))[9]) #define get_tcpoff(x) (((unsigned char *)(x))[12] >> 4) #define get_tcpflags(x) (((unsigned char *)(x))[13]) static int ip_active_pkt(u_char *pkt, int len) { u_char *tcp; int hlen; len -= PPP_HDRLEN; pkt += PPP_HDRLEN; if (len < IP_HDRLEN) return 0; if ((get_ipoff(pkt) & IP_OFFMASK) != 0) return 0; if (get_ipproto(pkt) != IPPROTO_TCP) return 1; hlen = get_iphl(pkt) * 4; if (len < hlen + TCP_HDRLEN) return 0; tcp = pkt + hlen; if ((get_tcpflags(tcp) & TH_FIN) != 0 && len == hlen + get_tcpoff(tcp) * 4) return 0; return 1; } #endif #endif /* PPP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/pppdebug.h0000644000175000017500000000531211671615006020005 0ustar renzorenzo/***************************************************************************** * pppdebug.h - System debugging utilities. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1998 Global Election Systems Inc. * portions Copyright (c) 2001 by Cognizant Pty Ltd. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY (please don't use tabs!) * * 03-01-01 Marc Boucher * Ported to lwIP. * 98-07-29 Guy Lancaster , Global Election Systems Inc. * Original. * ***************************************************************************** */ #ifndef PPPDEBUG_H #define PPPDEBUG_H /************************ *** PUBLIC DATA TYPES *** ************************/ /* Trace levels. */ typedef enum { LOG_CRITICAL = 0, LOG_ERR = 1, LOG_NOTICE = 2, LOG_WARNING = 3, LOG_INFO = 5, LOG_DETAIL = 6, LOG_DEBUG = 7 } LogCodes; /*********************** *** PUBLIC FUNCTIONS *** ***********************/ /* * ppp_trace - a form of printf to send tracing information to stderr */ void ppp_trace(int level, const char *format,...); #if PPP_DEBUG > 0 #define AUTHDEBUG(a) ppp_trace a #define IPCPDEBUG(a) ppp_trace a #define UPAPDEBUG(a) ppp_trace a #define LCPDEBUG(a) ppp_trace a #define FSMDEBUG(a) ppp_trace a #define CHAPDEBUG(a) ppp_trace a #define PPPDEBUG(a) ppp_trace a #define TRACELCP 1 #else #define AUTHDEBUG(a) #define IPCPDEBUG(a) #define UPAPDEBUG(a) #define LCPDEBUG(a) #define FSMDEBUG(a) #define CHAPDEBUG(a) #define PPPDEBUG(a) #define TRACELCP 0 #endif #endif /* PPPDEBUG_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/chpms.c0000644000175000017500000002546711671615006017321 0ustar renzorenzo/*** WARNING - THIS CODE HAS NOT BEEN FINISHED! ***/ /***************************************************************************** * chpms.c - Network MicroSoft Challenge Handshake Authentication Protocol program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * Copyright (c) 1997 by Global Election Systems Inc. All rights reserved. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-08 Guy Lancaster , Global Election Systems Inc. * Original based on BSD chap_ms.c. *****************************************************************************/ /* * chap_ms.c - Microsoft MS-CHAP compatible implementation. * * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. * http://www.strataware.com/ * * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Eric Rosenquist. The name of the author may not be used to * endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* * Modifications by Lauri Pesonen / lpesonen@clinet.fi, april 1997 * * Implemented LANManager type password response to MS-CHAP challenges. * Now pppd provides both NT style and LANMan style blocks, and the * prefered is set by option "ms-lanman". Default is to use NT. * The hash text (StdText) was taken from Win95 RASAPI32.DLL. * * You should also use DOMAIN\\USERNAME as described in README.MSCHAP80 */ #define USE_CRYPT #include "ppp.h" #if MSCHAP_SUPPORT > 0 #include "md4.h" #ifndef USE_CRYPT #include "des.h" #endif #include "chap.h" #include "chpms.h" #include "pppdebug.h" /*************************/ /*** LOCAL DEFINITIONS ***/ /*************************/ /************************/ /*** LOCAL DATA TYPES ***/ /************************/ typedef struct { u_char LANManResp[24]; u_char NTResp[24]; u_char UseNT; /* If 1, ignore the LANMan response field */ } MS_ChapResponse; /* We use MS_CHAP_RESPONSE_LEN, rather than sizeof(MS_ChapResponse), in case this struct gets padded. */ /***********************************/ /*** LOCAL FUNCTION DECLARATIONS ***/ /***********************************/ /* XXX Don't know what to do with these. */ extern void setkey(const char *); extern void encrypt(char *, int); static void DesEncrypt (u_char *, u_char *, u_char *); static void MakeKey (u_char *, u_char *); #ifdef USE_CRYPT static void Expand (u_char *, u_char *); static void Collapse (u_char *, u_char *); #endif static void ChallengeResponse( u_char *challenge, /* IN 8 octets */ u_char *pwHash, /* IN 16 octets */ u_char *response /* OUT 24 octets */ ); static void ChapMS_NT( char *rchallenge, int rchallenge_len, char *secret, int secret_len, MS_ChapResponse *response ); static u_char Get7Bits( u_char *input, int startBit ); /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ void ChapMS( chap_state *cstate, char *rchallenge, int rchallenge_len, char *secret, int secret_len ) { MS_ChapResponse response; #ifdef MSLANMAN extern int ms_lanman; #endif #if 0 CHAPDEBUG((LOG_INFO, "ChapMS: secret is '%.*s'\n", secret_len, secret)); #endif BZERO(&response, sizeof(response)); /* Calculate both always */ ChapMS_NT(rchallenge, rchallenge_len, secret, secret_len, &response); #ifdef MSLANMAN ChapMS_LANMan(rchallenge, rchallenge_len, secret, secret_len, &response); /* prefered method is set by option */ response.UseNT = !ms_lanman; #else response.UseNT = 1; #endif BCOPY(&response, cstate->response, MS_CHAP_RESPONSE_LEN); cstate->resp_length = MS_CHAP_RESPONSE_LEN; } /**********************************/ /*** LOCAL FUNCTION DEFINITIONS ***/ /**********************************/ static void ChallengeResponse( u_char *challenge, /* IN 8 octets */ u_char *pwHash, /* IN 16 octets */ u_char *response /* OUT 24 octets */ ) { char ZPasswordHash[21]; BZERO(ZPasswordHash, sizeof(ZPasswordHash)); BCOPY(pwHash, ZPasswordHash, 16); #if 0 log_packet(ZPasswordHash, sizeof(ZPasswordHash), "ChallengeResponse - ZPasswordHash", LOG_DEBUG); #endif DesEncrypt(challenge, ZPasswordHash + 0, response + 0); DesEncrypt(challenge, ZPasswordHash + 7, response + 8); DesEncrypt(challenge, ZPasswordHash + 14, response + 16); #if 0 log_packet(response, 24, "ChallengeResponse - response", LOG_DEBUG); #endif } #ifdef USE_CRYPT static void DesEncrypt( u_char *clear, /* IN 8 octets */ u_char *key, /* IN 7 octets */ u_char *cipher /* OUT 8 octets */ ) { u_char des_key[8]; u_char crypt_key[66]; u_char des_input[66]; MakeKey(key, des_key); Expand(des_key, crypt_key); setkey(crypt_key); #if 0 CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet input : %02X%02X%02X%02X%02X%02X%02X%02X\n", clear[0], clear[1], clear[2], clear[3], clear[4], clear[5], clear[6], clear[7])); #endif Expand(clear, des_input); encrypt(des_input, 0); Collapse(des_input, cipher); #if 0 CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet output: %02X%02X%02X%02X%02X%02X%02X%02X\n", cipher[0], cipher[1], cipher[2], cipher[3], cipher[4], cipher[5], cipher[6], cipher[7])); #endif } #else /* USE_CRYPT */ static void DesEncrypt( u_char *clear, /* IN 8 octets */ u_char *key, /* IN 7 octets */ u_char *cipher /* OUT 8 octets */ ) { des_cblock des_key; des_key_schedule key_schedule; MakeKey(key, des_key); des_set_key(&des_key, key_schedule); #if 0 CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet input : %02X%02X%02X%02X%02X%02X%02X%02X\n", clear[0], clear[1], clear[2], clear[3], clear[4], clear[5], clear[6], clear[7])); #endif des_ecb_encrypt((des_cblock *)clear, (des_cblock *)cipher, key_schedule, 1); #if 0 CHAPDEBUG((LOG_INFO, "DesEncrypt: 8 octet output: %02X%02X%02X%02X%02X%02X%02X%02X\n", cipher[0], cipher[1], cipher[2], cipher[3], cipher[4], cipher[5], cipher[6], cipher[7])); #endif } #endif /* USE_CRYPT */ static u_char Get7Bits( u_char *input, int startBit ) { register unsigned int word; word = (unsigned)input[startBit / 8] << 8; word |= (unsigned)input[startBit / 8 + 1]; word >>= 15 - (startBit % 8 + 7); return word & 0xFE; } #ifdef USE_CRYPT /* in == 8-byte string (expanded version of the 56-bit key) * out == 64-byte string where each byte is either 1 or 0 * Note that the low-order "bit" is always ignored by by setkey() */ static void Expand(u_char *in, u_char *out) { int j, c; int i; for(i = 0; i < 64; in++){ c = *in; for(j = 7; j >= 0; j--) *out++ = (c >> j) & 01; i += 8; } } /* The inverse of Expand */ static void Collapse(u_char *in, u_char *out) { int j; int i; unsigned int c; for (i = 0; i < 64; i += 8, out++) { c = 0; for (j = 7; j >= 0; j--, in++) c |= *in << j; *out = c & 0xff; } } #endif static void MakeKey( u_char *key, /* IN 56 bit DES key missing parity bits */ u_char *des_key /* OUT 64 bit DES key with parity bits added */ ) { des_key[0] = Get7Bits(key, 0); des_key[1] = Get7Bits(key, 7); des_key[2] = Get7Bits(key, 14); des_key[3] = Get7Bits(key, 21); des_key[4] = Get7Bits(key, 28); des_key[5] = Get7Bits(key, 35); des_key[6] = Get7Bits(key, 42); des_key[7] = Get7Bits(key, 49); #ifndef USE_CRYPT des_set_odd_parity((des_cblock *)des_key); #endif #if 0 CHAPDEBUG((LOG_INFO, "MakeKey: 56-bit input : %02X%02X%02X%02X%02X%02X%02X\n", key[0], key[1], key[2], key[3], key[4], key[5], key[6])); CHAPDEBUG((LOG_INFO, "MakeKey: 64-bit output: %02X%02X%02X%02X%02X%02X%02X%02X\n", des_key[0], des_key[1], des_key[2], des_key[3], des_key[4], des_key[5], des_key[6], des_key[7])); #endif } static void ChapMS_NT( char *rchallenge, int rchallenge_len, char *secret, int secret_len, MS_ChapResponse *response ) { int i; MDstruct md4Context; u_char unicodePassword[MAX_NT_PASSWORD * 2]; static int low_byte_first = -1; /* Initialize the Unicode version of the secret (== password). */ /* This implicitly supports 8-bit ISO8859/1 characters. */ BZERO(unicodePassword, sizeof(unicodePassword)); for (i = 0; i < secret_len; i++) unicodePassword[i * 2] = (u_char)secret[i]; MDbegin(&md4Context); MDupdate(&md4Context, unicodePassword, secret_len * 2 * 8); /* Unicode is 2 bytes/char, *8 for bit count */ if (low_byte_first == -1) low_byte_first = (htons((unsigned short int)1) != 1); if (low_byte_first == 0) MDreverse((u_long *)&md4Context); /* sfb 961105 */ MDupdate(&md4Context, NULL, 0); /* Tell MD4 we're done */ ChallengeResponse(rchallenge, (char *)md4Context.buffer, response->NTResp); } #ifdef MSLANMAN static u_char *StdText = (u_char *)"KGS!@#$%"; /* key from rasapi32.dll */ static ChapMS_LANMan( char *rchallenge, int rchallenge_len, char *secret, int secret_len, MS_ChapResponse *response ) { int i; u_char UcasePassword[MAX_NT_PASSWORD]; /* max is actually 14 */ u_char PasswordHash[16]; /* LANMan password is case insensitive */ BZERO(UcasePassword, sizeof(UcasePassword)); for (i = 0; i < secret_len; i++) UcasePassword[i] = (u_char)toupper(secret[i]); DesEncrypt( StdText, UcasePassword + 0, PasswordHash + 0 ); DesEncrypt( StdText, UcasePassword + 7, PasswordHash + 8 ); ChallengeResponse(rchallenge, PasswordHash, response->LANManResp); } #endif #endif /* MSCHAP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/fsm.h0000644000175000017500000001655011671615006016772 0ustar renzorenzo/***************************************************************************** * fsm.h - Network Control Protocol Finite State Machine header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * Copyright (c) 1997 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-11-05 Guy Lancaster , Global Election Systems Inc. * Original based on BSD code. *****************************************************************************/ /* * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * $Id: fsm.h 26 2005-08-10 18:50:38Z rd235 $ */ #ifndef FSM_H #define FSM_H /***************************************************************************** ************************* PUBLIC DEFINITIONS ********************************* *****************************************************************************/ /* * LCP Packet header = Code, id, length. */ #define HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short)) /* * CP (LCP, IPCP, etc.) codes. */ #define CONFREQ 1 /* Configuration Request */ #define CONFACK 2 /* Configuration Ack */ #define CONFNAK 3 /* Configuration Nak */ #define CONFREJ 4 /* Configuration Reject */ #define TERMREQ 5 /* Termination Request */ #define TERMACK 6 /* Termination Ack */ #define CODEREJ 7 /* Code Reject */ /* * Link states. */ #define INITIAL 0 /* Down, hasn't been opened */ #define STARTING 1 /* Down, been opened */ #define CLOSED 2 /* Up, hasn't been opened */ #define STOPPED 3 /* Open, waiting for down event */ #define CLOSING 4 /* Terminating the connection, not open */ #define STOPPING 5 /* Terminating, but open */ #define REQSENT 6 /* We've sent a Config Request */ #define ACKRCVD 7 /* We've received a Config Ack */ #define ACKSENT 8 /* We've sent a Config Ack */ #define OPENED 9 /* Connection available */ /* * Flags - indicate options controlling FSM operation */ #define OPT_PASSIVE 1 /* Don't die if we don't get a response */ #define OPT_RESTART 2 /* Treat 2nd OPEN as DOWN, UP */ #define OPT_SILENT 4 /* Wait for peer to speak first */ /***************************************************************************** ************************* PUBLIC DATA TYPES ********************************** *****************************************************************************/ /* * Each FSM is described by an fsm structure and fsm callbacks. */ typedef struct fsm { int unit; /* Interface unit number */ u_short protocol; /* Data Link Layer Protocol field value */ int state; /* State */ int flags; /* Contains option bits */ u_char id; /* Current id */ u_char reqid; /* Current request id */ u_char seen_ack; /* Have received valid Ack/Nak/Rej to Req */ int timeouttime; /* Timeout time in milliseconds */ int maxconfreqtransmits;/* Maximum Configure-Request transmissions */ int retransmits; /* Number of retransmissions left */ int maxtermtransmits; /* Maximum Terminate-Request transmissions */ int nakloops; /* Number of nak loops since last ack */ int maxnakloops; /* Maximum number of nak loops tolerated */ struct fsm_callbacks* callbacks;/* Callback routines */ char* term_reason; /* Reason for closing protocol */ int term_reason_len; /* Length of term_reason */ } fsm; typedef struct fsm_callbacks { void (*resetci) /* Reset our Configuration Information */ (fsm*); int (*cilen) /* Length of our Configuration Information */ (fsm*); void (*addci) /* Add our Configuration Information */ (fsm*, u_char*, int*); int (*ackci) /* ACK our Configuration Information */ (fsm*, u_char*, int); int (*nakci) /* NAK our Configuration Information */ (fsm*, u_char*, int); int (*rejci) /* Reject our Configuration Information */ (fsm*, u_char*, int); int (*reqci) /* Request peer's Configuration Information */ (fsm*, u_char*, int*, int); void (*up) /* Called when fsm reaches OPENED state */ (fsm*); void (*down) /* Called when fsm leaves OPENED state */ (fsm*); void (*starting) /* Called when we want the lower layer */ (fsm*); void (*finished) /* Called when we don't want the lower layer */ (fsm*); void (*protreject) /* Called when Protocol-Reject received */ (int); void (*retransmit) /* Retransmission is necessary */ (fsm*); int (*extcode) /* Called when unknown code received */ (fsm*, int, u_char, u_char*, int); char *proto_name; /* String name for protocol (for messages) */ } fsm_callbacks; /***************************************************************************** *********************** PUBLIC DATA STRUCTURES ******************************* *****************************************************************************/ /* * Variables */ extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */ /***************************************************************************** ************************** PUBLIC FUNCTIONS ********************************** *****************************************************************************/ /* * Prototypes */ void fsm_init (fsm*); void fsm_lowerup (fsm*); void fsm_lowerdown (fsm*); void fsm_open (fsm*); void fsm_close (fsm*, char*); void fsm_input (fsm*, u_char*, int); void fsm_protreject (fsm*); void fsm_sdata (fsm*, u_char, u_char, u_char*, int); #endif /* FSM_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/chpms.h0000644000175000017500000000556411671615006017322 0ustar renzorenzo/***************************************************************************** * chpms.h - Network Microsoft Challenge Handshake Protocol header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1998 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 98-01-30 Guy Lancaster , Global Election Systems Inc. * Original built from BSD network code. ******************************************************************************/ /* * chap.h - Challenge Handshake Authentication Protocol definitions. * * Copyright (c) 1995 Eric Rosenquist, Strata Software Limited. * http://www.strataware.com/ * * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Eric Rosenquist. The name of the author may not be used to * endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * $Id: chpms.h 26 2005-08-10 18:50:38Z rd235 $ */ #ifndef CHPMS_H #define CHPMS_H #define MAX_NT_PASSWORD 256 /* Maximum number of (Unicode) chars in an NT password */ void ChapMS (chap_state *, char *, int, char *, int); #endif /* CHPMS_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/randm.c0000644000175000017500000001761511671615006017304 0ustar renzorenzo/***************************************************************************** * randm.c - Random number generator program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * Copyright (c) 1998 by Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 98-06-03 Guy Lancaster , Global Election Systems Inc. * Extracted from avos. *****************************************************************************/ #include "ppp.h" #if PPP_SUPPORT > 0 #include "md5.h" #include "randm.h" #include "pppdebug.h" #if MD5_SUPPORT>0 /* this module depends on MD5 */ #define RANDPOOLSZ 16 /* Bytes stored in the pool of randomness. */ /*****************************/ /*** LOCAL DATA STRUCTURES ***/ /*****************************/ static char randPool[RANDPOOLSZ]; /* Pool of randomness. */ static long randCount = 0; /* Pseudo-random incrementer */ /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* * Initialize the random number generator. * * Since this is to be called on power up, we don't have much * system randomess to work with. Here all we use is the * real-time clock. We'll accumulate more randomness as soon * as things start happening. */ void avRandomInit() { avChurnRand(NULL, 0); } /* * Churn the randomness pool on a random event. Call this early and often * on random and semi-random system events to build randomness in time for * usage. For randomly timed events, pass a null pointer and a zero length * and this will use the system timer and other sources to add randomness. * If new random data is available, pass a pointer to that and it will be * included. * * Ref: Applied Cryptography 2nd Ed. by Bruce Schneier p. 427 */ void avChurnRand(char *randData, u32_t randLen) { MD5_CTX md5; /* ppp_trace(LOG_INFO, "churnRand: %u@%P\n", randLen, randData); */ MD5Init(&md5); MD5Update(&md5, (u_char *)randPool, sizeof(randPool)); if (randData) MD5Update(&md5, (u_char *)randData, randLen); else { struct { /* INCLUDE fields for any system sources of randomness */ char foobar; } sysData; /* Load sysData fields here. */ ; MD5Update(&md5, (u_char *)&sysData, sizeof(sysData)); } MD5Final((u_char *)randPool, &md5); /* ppp_trace(LOG_INFO, "churnRand: -> 0\n"); */ } /* * Use the random pool to generate random data. This degrades to pseudo * random when used faster than randomness is supplied using churnRand(). * Note: It's important that there be sufficient randomness in randPool * before this is called for otherwise the range of the result may be * narrow enough to make a search feasible. * * Ref: Applied Cryptography 2nd Ed. by Bruce Schneier p. 427 * * XXX Why does he not just call churnRand() for each block? Probably * so that you don't ever publish the seed which could possibly help * predict future values. * XXX Why don't we preserve md5 between blocks and just update it with * randCount each time? Probably there is a weakness but I wish that * it was documented. */ void avGenRand(char *buf, u32_t bufLen) { MD5_CTX md5; u_char tmp[16]; u32_t n; while (bufLen > 0) { n = LWIP_MIN(bufLen, RANDPOOLSZ); MD5Init(&md5); MD5Update(&md5, (u_char *)randPool, sizeof(randPool)); MD5Update(&md5, (u_char *)&randCount, sizeof(randCount)); MD5Final(tmp, &md5); randCount++; memcpy(buf, tmp, n); buf += n; bufLen -= n; } } /* * Return a new random number. */ u32_t avRandom() { u32_t newRand; avGenRand((char *)&newRand, sizeof(newRand)); return newRand; } #else /* MD5_SUPPORT */ /*****************************/ /*** LOCAL DATA STRUCTURES ***/ /*****************************/ static int avRandomized = 0; /* Set when truely randomized. */ static u32_t avRandomSeed = 0; /* Seed used for random number generation. */ /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* * Initialize the random number generator. * * Here we attempt to compute a random number seed but even if * it isn't random, we'll randomize it later. * * The current method uses the fields from the real time clock, * the idle process counter, the millisecond counter, and the * hardware timer tick counter. When this is invoked * in startup(), then the idle counter and timer values may * repeat after each boot and the real time clock may not be * operational. Thus we call it again on the first random * event. */ void avRandomInit() { #if 0 /* Get a pointer into the last 4 bytes of clockBuf. */ u32_t *lptr1 = (u32_t *)((char *)&clockBuf[3]); /* * Initialize our seed using the real-time clock, the idle * counter, the millisecond timer, and the hardware timer * tick counter. The real-time clock and the hardware * tick counter are the best sources of randomness but * since the tick counter is only 16 bit (and truncated * at that), the idle counter and millisecond timer * (which may be small values) are added to help * randomize the lower 16 bits of the seed. */ readClk(); avRandomSeed += *(u32_t *)clockBuf + *lptr1 + OSIdleCtr + ppp_mtime() + ((u32_t)TM1 << 16) + TM1; #else avRandomSeed += sys_jiffies(); /* XXX */ #endif /* Initialize the Borland random number generator. */ srand((unsigned)avRandomSeed); } /* * Randomize our random seed value. Here we use the fact that * this function is called at *truely random* times by the polling * and network functions. Here we only get 16 bits of new random * value but we use the previous value to randomize the other 16 * bits. */ void avRandomize(void) { static u32_t last_jiffies; if (!avRandomized) { avRandomized = !0; avRandomInit(); /* The initialization function also updates the seed. */ } else { /* avRandomSeed += (avRandomSeed << 16) + TM1; */ avRandomSeed += (sys_jiffies() - last_jiffies); /* XXX */ } last_jiffies = sys_jiffies(); } /* * Return a new random number. * Here we use the Borland rand() function to supply a pseudo random * number which we make truely random by combining it with our own * seed which is randomized by truely random events. * Thus the numbers will be truely random unless there have been no * operator or network events in which case it will be pseudo random * seeded by the real time clock. */ u32_t avRandom() { return ((((u32_t)rand() << 16) + rand()) + avRandomSeed); } #endif /* MD5_SUPPORT */ #endif /* PPP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/ppp.c0000644000175000017500000013641411671615006017001 0ustar renzorenzo/***************************************************************************** * ppp.c - Network Point to Point Protocol program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 by Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-11-05 Guy Lancaster , Global Election Systems Inc. * Original. *****************************************************************************/ /* * ppp_defs.h - PPP definitions. * * if_pppvar.h - private structures and declarations for PPP. * * Copyright (c) 1994 The Australian National University. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation is hereby granted, provided that the above copyright * notice appears in all copies. This software is provided without any * warranty, express or implied. The Australian National University * makes no representations about the suitability of this software for * any purpose. * * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, * OR MODIFICATIONS. */ /* * if_ppp.h - Point-to-Point Protocol definitions. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include #include "ppp.h" #if PPP_SUPPORT > 0 #include "randm.h" #include "fsm.h" #if PAP_SUPPORT > 0 #include "pap.h" #endif #if CHAP_SUPPORT > 0 #include "chap.h" #endif #include "ipcp.h" #include "lcp.h" #include "magic.h" #include "auth.h" #if VJ_SUPPORT > 0 #include "vj.h" #endif #include "pppdebug.h" /*************************/ /*** LOCAL DEFINITIONS ***/ /*************************/ /* * The basic PPP frame. */ #define PPP_ADDRESS(p) (((u_char *)(p))[0]) #define PPP_CONTROL(p) (((u_char *)(p))[1]) #define PPP_PROTOCOL(p) ((((u_char *)(p))[2] << 8) + ((u_char *)(p))[3]) /* PPP packet parser states. Current state indicates operation yet to be * completed. */ typedef enum { PDIDLE = 0, /* Idle state - waiting. */ PDSTART, /* Process start flag. */ PDADDRESS, /* Process address field. */ PDCONTROL, /* Process control field. */ PDPROTOCOL1, /* Process protocol field 1. */ PDPROTOCOL2, /* Process protocol field 2. */ PDDATA /* Process data byte. */ } PPPDevStates; #define ESCAPE_P(accm, c) ((accm)[(c) >> 3] & pppACCMMask[c & 0x07]) /************************/ /*** LOCAL DATA TYPES ***/ /************************/ /* * PPP interface control block. */ typedef struct PPPControl_s { char openFlag; /* True when in use. */ char oldFrame; /* Old framing character for fd. */ sio_fd_t fd; /* File device ID of port. */ int kill_link; /* Shut the link down. */ int sig_hup; /* Carrier lost. */ int if_up; /* True when the interface is up. */ int errCode; /* Code indicating why interface is down. */ struct pbuf *inHead, *inTail; /* The input packet. */ PPPDevStates inState; /* The input process state. */ char inEscaped; /* Escape next character. */ u16_t inProtocol; /* The input protocol code. */ u16_t inFCS; /* Input Frame Check Sequence value. */ int mtu; /* Peer's mru */ int pcomp; /* Does peer accept protocol compression? */ int accomp; /* Does peer accept addr/ctl compression? */ u_long lastXMit; /* Time of last transmission. */ ext_accm inACCM; /* Async-Ctl-Char-Map for input. */ ext_accm outACCM; /* Async-Ctl-Char-Map for output. */ #if VJ_SUPPORT > 0 int vjEnabled; /* Flag indicating VJ compression enabled. */ struct vjcompress vjComp; /* Van Jabobsen compression header. */ #endif struct netif netif; struct ppp_addrs addrs; void (*linkStatusCB)(void *ctx, int errCode, void *arg); void *linkStatusCtx; } PPPControl; /* * Ioctl definitions. */ struct npioctl { int protocol; /* PPP procotol, e.g. PPP_IP */ enum NPmode mode; }; /***********************************/ /*** LOCAL FUNCTION DECLARATIONS ***/ /***********************************/ static void pppMain(void *pd); static void pppDrop(PPPControl *pc); static void pppInProc(int pd, u_char *s, int l); /******************************/ /*** PUBLIC DATA STRUCTURES ***/ /******************************/ u_long subnetMask; static PPPControl pppControl[NUM_PPP]; /* The PPP interface control blocks. */ /* * PPP Data Link Layer "protocol" table. * One entry per supported protocol. * The last entry must be NULL. */ struct protent *ppp_protocols[] = { &lcp_protent, #if PAP_SUPPORT > 0 &pap_protent, #endif #if CHAP_SUPPORT > 0 &chap_protent, #endif #if CBCP_SUPPORT > 0 &cbcp_protent, #endif &ipcp_protent, #if CCP_SUPPORT > 0 &ccp_protent, #endif NULL }; /* * Buffers for outgoing packets. This must be accessed only from the appropriate * PPP task so that it doesn't need to be protected to avoid collisions. */ u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN]; /*****************************/ /*** LOCAL DATA STRUCTURES ***/ /*****************************/ /* * FCS lookup table as calculated by genfcstab. */ static const u_short fcstab[256] = { 0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78 }; /* PPP's Asynchronous-Control-Character-Map. The mask array is used * to select the specific bit for a character. */ static u_char pppACCMMask[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* Initialize the PPP subsystem. */ struct ppp_settings ppp_settings; void pppInit(void) { struct protent *protp; int i, j; memset(&ppp_settings, 0, sizeof(ppp_settings)); ppp_settings.usepeerdns = 1; pppSetAuth(PPPAUTHTYPE_NONE, NULL, NULL); magicInit(); for (i = 0; i < NUM_PPP; i++) { pppControl[i].openFlag = 0; subnetMask = htonl(0xffffff00); /* * Initialize to the standard option set. */ for (j = 0; (protp = ppp_protocols[j]) != NULL; ++j) (*protp->init)(i); } #if LINK_STATS /* Clear the statistics. */ memset(&lwip_stats.link, 0, sizeof(lwip_stats.link)); #endif } void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd) { switch(authType) { case PPPAUTHTYPE_NONE: default: #ifdef LWIP_PPP_STRICT_PAP_REJECT ppp_settings.refuse_pap = 1; #else /* some providers request pap and accept an empty login/pw */ ppp_settings.refuse_pap = 0; #endif ppp_settings.refuse_chap = 1; break; case PPPAUTHTYPE_ANY: /* Warning: Using PPPAUTHTYPE_ANY might have security consequences. * RFC 1994 says: * * In practice, within or associated with each PPP server, there is a * database which associates "user" names with authentication * information ("secrets"). It is not anticipated that a particular * named user would be authenticated by multiple methods. This would * make the user vulnerable to attacks which negotiate the least secure * method from among a set (such as PAP rather than CHAP). If the same * secret was used, PAP would reveal the secret to be used later with * CHAP. * * Instead, for each user name there should be an indication of exactly * one method used to authenticate that user name. If a user needs to * make use of different authentication methods under different * circumstances, then distinct user names SHOULD be employed, each of * which identifies exactly one authentication method. * */ ppp_settings.refuse_pap = 0; ppp_settings.refuse_chap = 0; break; case PPPAUTHTYPE_PAP: ppp_settings.refuse_pap = 0; ppp_settings.refuse_chap = 1; break; case PPPAUTHTYPE_CHAP: ppp_settings.refuse_pap = 1; ppp_settings.refuse_chap = 0; break; } if(user) { strncpy(ppp_settings.user, user, sizeof(ppp_settings.user)-1); ppp_settings.user[sizeof(ppp_settings.user)-1] = '\0'; } else ppp_settings.user[0] = '\0'; if(passwd) { strncpy(ppp_settings.passwd, passwd, sizeof(ppp_settings.passwd)-1); ppp_settings.passwd[sizeof(ppp_settings.passwd)-1] = '\0'; } else ppp_settings.passwd[0] = '\0'; } /* Open a new PPP connection using the given I/O device. * This initializes the PPP control block but does not * attempt to negotiate the LCP session. If this port * connects to a modem, the modem connection must be * established before calling this. * Return a new PPP connection descriptor on success or * an error code (negative) on failure. */ int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *ctx, int errCode, void *arg), void *linkStatusCtx) { PPPControl *pc; int pd; /* Find a free PPP session descriptor. Critical region? */ for (pd = 0; pd < NUM_PPP && pppControl[pd].openFlag != 0; pd++); if (pd >= NUM_PPP) pd = PPPERR_OPEN; else pppControl[pd].openFlag = !0; /* Launch a deamon thread. */ if (pd >= 0) { pppControl[pd].openFlag = 1; lcp_init(pd); pc = &pppControl[pd]; pc->fd = fd; pc->kill_link = 0; pc->sig_hup = 0; pc->if_up = 0; pc->errCode = 0; pc->inState = PDIDLE; pc->inHead = NULL; pc->inTail = NULL; pc->inEscaped = 0; pc->lastXMit = 0; #if VJ_SUPPORT > 0 pc->vjEnabled = 0; vj_compress_init(&pc->vjComp); #endif /* * Default the in and out accm so that escape and flag characters * are always escaped. */ memset(pc->inACCM, 0, sizeof(ext_accm)); pc->inACCM[15] = 0x60; memset(pc->outACCM, 0, sizeof(ext_accm)); pc->outACCM[15] = 0x60; pc->linkStatusCB = linkStatusCB; pc->linkStatusCtx = linkStatusCtx; sys_thread_new(pppMain, (void*)pd, PPP_THREAD_PRIO); if(!linkStatusCB) { while(pd >= 0 && !pc->if_up) { sys_msleep(500); if (lcp_phase[pd] == PHASE_DEAD) { pppClose(pd); if (pc->errCode) pd = pc->errCode; else pd = PPPERR_CONNECT; } } } } return pd; } /* Close a PPP connection and release the descriptor. * Any outstanding packets in the queues are dropped. * Return 0 on success, an error code on failure. */ int pppClose(int pd) { PPPControl *pc = &pppControl[pd]; int st = 0; /* Disconnect */ pc->kill_link = !0; pppMainWakeup(pd); if(!pc->linkStatusCB) { while(st >= 0 && lcp_phase[pd] != PHASE_DEAD) { sys_msleep(500); break; } } return st; } /* This function is called when carrier is lost on the PPP channel. */ void pppSigHUP(int pd) { PPPControl *pc = &pppControl[pd]; pc->sig_hup = 1; pppMainWakeup(pd); } static void nPut(PPPControl *pc, struct pbuf *nb) { struct pbuf *b; int c; for(b = nb; b != NULL; b = b->next) { if((c = sio_write(pc->fd, b->payload, b->len)) != b->len) { PPPDEBUG((LOG_WARNING, "PPP nPut: incomplete sio_write(%d,, %u) = %d\n", pc->fd, b->len, c)); #if LINK_STATS lwip_stats.link.err++; #endif /* LINK_STATS */ pc->lastXMit = 0; /* prepend PPP_FLAG to next packet */ break; } } pbuf_free(nb); #if LINK_STATS lwip_stats.link.xmit++; #endif /* LINK_STATS */ } /* * pppAppend - append given character to end of given pbuf. If outACCM * is not NULL and the character needs to be escaped, do so. * If pbuf is full, append another. * Return the current pbuf. */ static struct pbuf *pppAppend(u_char c, struct pbuf *nb, ext_accm *outACCM) { struct pbuf *tb = nb; /* Make sure there is room for the character and an escape code. * Sure we don't quite fill the buffer if the character doesn't * get escaped but is one character worth complicating this? */ /* Note: We assume no packet header. */ if (nb && (PBUF_POOL_BUFSIZE - nb->len) < 2) { tb = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); if (tb) { nb->next = tb; } #if LINK_STATS else { lwip_stats.link.memerr++; } #endif /* LINK_STATS */ nb = tb; } if (nb) { if (outACCM && ESCAPE_P(*outACCM, c)) { *((u_char*)nb->payload + nb->len++) = PPP_ESCAPE; *((u_char*)nb->payload + nb->len++) = c ^ PPP_TRANS; } else *((u_char*)nb->payload + nb->len++) = c; } return tb; } /* Send a packet on the given connection. */ static err_t pppifOutput(struct netif *netif, struct pbuf *pb, struct ip_addr *ipaddr) { int pd = (int)netif->state; u_short protocol = PPP_IP; PPPControl *pc = &pppControl[pd]; u_int fcsOut = PPP_INITFCS; struct pbuf *headMB = NULL, *tailMB = NULL, *p; u_char c; (void)ipaddr; /* Validate parameters. */ /* We let any protocol value go through - it can't hurt us * and the peer will just drop it if it's not accepting it. */ if (pd < 0 || pd >= NUM_PPP || !pc->openFlag || !pb) { PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: bad parms prot=%d pb=%p\n", pd, protocol, pb)); #if LINK_STATS lwip_stats.link.opterr++; lwip_stats.link.drop++; #endif return ERR_ARG; } /* Check that the link is up. */ if (lcp_phase[pd] == PHASE_DEAD) { PPPDEBUG((LOG_ERR, "pppifOutput[%d]: link not up\n", pd)); #if LINK_STATS lwip_stats.link.rterr++; lwip_stats.link.drop++; #endif return ERR_RTE; } /* Grab an output buffer. */ headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); if (headMB == NULL) { PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: first alloc fail\n", pd)); #if LINK_STATS lwip_stats.link.memerr++; lwip_stats.link.drop++; #endif /* LINK_STATS */ return ERR_MEM; } #if VJ_SUPPORT > 0 /* * Attempt Van Jacobson header compression if VJ is configured and * this is an IP packet. */ if (protocol == PPP_IP && pc->vjEnabled) { switch (vj_compress_tcp(&pc->vjComp, pb)) { case TYPE_IP: /* No change... protocol = PPP_IP_PROTOCOL; */ break; case TYPE_COMPRESSED_TCP: protocol = PPP_VJC_COMP; break; case TYPE_UNCOMPRESSED_TCP: protocol = PPP_VJC_UNCOMP; break; default: PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: bad IP packet\n", pd)); #if LINK_STATS lwip_stats.link.proterr++; lwip_stats.link.drop++; #endif pbuf_free(headMB); return ERR_VAL; } } #endif tailMB = headMB; /* Build the PPP header. */ if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG) tailMB = pppAppend(PPP_FLAG, tailMB, NULL); pc->lastXMit = sys_jiffies(); if (!pc->accomp) { fcsOut = PPP_FCS(fcsOut, PPP_ALLSTATIONS); tailMB = pppAppend(PPP_ALLSTATIONS, tailMB, &pc->outACCM); fcsOut = PPP_FCS(fcsOut, PPP_UI); tailMB = pppAppend(PPP_UI, tailMB, &pc->outACCM); } if (!pc->pcomp || protocol > 0xFF) { c = (protocol >> 8) & 0xFF; fcsOut = PPP_FCS(fcsOut, c); tailMB = pppAppend(c, tailMB, &pc->outACCM); } c = protocol & 0xFF; fcsOut = PPP_FCS(fcsOut, c); tailMB = pppAppend(c, tailMB, &pc->outACCM); /* Load packet. */ for(p = pb; p; p = p->next) { int n; u_char *sPtr; sPtr = (u_char*)p->payload; n = p->len; while (n-- > 0) { c = *sPtr++; /* Update FCS before checking for special characters. */ fcsOut = PPP_FCS(fcsOut, c); /* Copy to output buffer escaping special characters. */ tailMB = pppAppend(c, tailMB, &pc->outACCM); } } /* Add FCS and trailing flag. */ c = ~fcsOut & 0xFF; tailMB = pppAppend(c, tailMB, &pc->outACCM); c = (~fcsOut >> 8) & 0xFF; tailMB = pppAppend(c, tailMB, &pc->outACCM); tailMB = pppAppend(PPP_FLAG, tailMB, NULL); /* If we failed to complete the packet, throw it away. */ if (!tailMB) { PPPDEBUG((LOG_WARNING, "pppifOutput[%d]: Alloc err - dropping proto=%d\n", pd, protocol)); pbuf_free(headMB); #if LINK_STATS lwip_stats.link.memerr++; lwip_stats.link.drop++; #endif return ERR_MEM; } /* Send it. */ PPPDEBUG((LOG_INFO, "pppifOutput[%d]: proto=0x%04X\n", pd, protocol)); nPut(pc, headMB); return ERR_OK; } /* Get and set parameters for the given connection. * Return 0 on success, an error code on failure. */ int pppIOCtl(int pd, int cmd, void *arg) { PPPControl *pc = &pppControl[pd]; int st = 0; if (pd < 0 || pd >= NUM_PPP) st = PPPERR_PARAM; else { switch(cmd) { case PPPCTLG_UPSTATUS: /* Get the PPP up status. */ if (arg) *(int *)arg = (int)(pc->if_up); else st = PPPERR_PARAM; break; case PPPCTLS_ERRCODE: /* Set the PPP error code. */ if (arg) pc->errCode = *(int *)arg; else st = PPPERR_PARAM; break; case PPPCTLG_ERRCODE: /* Get the PPP error code. */ if (arg) *(int *)arg = (int)(pc->errCode); else st = PPPERR_PARAM; break; case PPPCTLG_FD: if (arg) *(sio_fd_t *)arg = pc->fd; else st = PPPERR_PARAM; break; default: st = PPPERR_PARAM; break; } } return st; } /* * Return the Maximum Transmission Unit for the given PPP connection. */ u_int pppMTU(int pd) { PPPControl *pc = &pppControl[pd]; u_int st; /* Validate parameters. */ if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) st = 0; else st = pc->mtu; return st; } /* * Write n characters to a ppp link. * RETURN: >= 0 Number of characters written * -1 Failed to write to device */ int pppWrite(int pd, const u_char *s, int n) { PPPControl *pc = &pppControl[pd]; u_char c; u_int fcsOut = PPP_INITFCS; struct pbuf *headMB = NULL, *tailMB; headMB = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); if (headMB == NULL) { #if LINK_STATS lwip_stats.link.memerr++; lwip_stats.link.proterr++; #endif /* LINK_STATS */ return PPPERR_ALLOC; } tailMB = headMB; /* If the link has been idle, we'll send a fresh flag character to * flush any noise. */ if ((sys_jiffies() - pc->lastXMit) >= PPP_MAXIDLEFLAG) tailMB = pppAppend(PPP_FLAG, tailMB, NULL); pc->lastXMit = sys_jiffies(); /* Load output buffer. */ while (n-- > 0) { c = *s++; /* Update FCS before checking for special characters. */ fcsOut = PPP_FCS(fcsOut, c); /* Copy to output buffer escaping special characters. */ tailMB = pppAppend(c, tailMB, &pc->outACCM); } /* Add FCS and trailing flag. */ c = ~fcsOut & 0xFF; tailMB = pppAppend(c, tailMB, &pc->outACCM); c = (~fcsOut >> 8) & 0xFF; tailMB = pppAppend(c, tailMB, &pc->outACCM); tailMB = pppAppend(PPP_FLAG, tailMB, NULL); /* If we failed to complete the packet, throw it away. * Otherwise send it. */ if (!tailMB) { PPPDEBUG((LOG_WARNING, "pppWrite[%d]: Alloc err - dropping pbuf len=%d\n", pd, headMB->len)); /* "pppWrite[%d]: Alloc err - dropping %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */ pbuf_free(headMB); #if LINK_STATS lwip_stats.link.memerr++; lwip_stats.link.proterr++; #endif /* LINK_STATS */ return PPPERR_ALLOC; } PPPDEBUG((LOG_INFO, "pppWrite[%d]: len=%d\n", pd, headMB->len)); /* "pppWrite[%d]: %d:%.*H", pd, headMB->len, LWIP_MIN(headMB->len * 2, 40), headMB->payload)); */ nPut(pc, headMB); return PPPERR_NONE; } /* * ppp_send_config - configure the transmit characteristics of * the ppp interface. */ void ppp_send_config( int unit, int mtu, u32_t asyncmap, int pcomp, int accomp ) { PPPControl *pc = &pppControl[unit]; int i; pc->mtu = mtu; pc->pcomp = pcomp; pc->accomp = accomp; /* Load the ACCM bits for the 32 control codes. */ for (i = 0; i < 32/8; i++) pc->outACCM[i] = (u_char)((asyncmap >> (8 * i)) & 0xFF); PPPDEBUG((LOG_INFO, "ppp_send_config[%d]: outACCM=%X %X %X %X\n", unit, pc->outACCM[0], pc->outACCM[1], pc->outACCM[2], pc->outACCM[3])); } /* * ppp_set_xaccm - set the extended transmit ACCM for the interface. */ void ppp_set_xaccm(int unit, ext_accm *accm) { memcpy(pppControl[unit].outACCM, accm, sizeof(ext_accm)); PPPDEBUG((LOG_INFO, "ppp_set_xaccm[%d]: outACCM=%X %X %X %X\n", unit, pppControl[unit].outACCM[0], pppControl[unit].outACCM[1], pppControl[unit].outACCM[2], pppControl[unit].outACCM[3])); } /* * ppp_recv_config - configure the receive-side characteristics of * the ppp interface. */ void ppp_recv_config( int unit, int mru, u32_t asyncmap, int pcomp, int accomp ) { PPPControl *pc = &pppControl[unit]; int i; (void)accomp; (void)pcomp; (void)mru; /* Load the ACCM bits for the 32 control codes. */ for (i = 0; i < 32 / 8; i++) pc->inACCM[i] = (u_char)(asyncmap >> (i * 8)); PPPDEBUG((LOG_INFO, "ppp_recv_config[%d]: inACCM=%X %X %X %X\n", unit, pc->inACCM[0], pc->inACCM[1], pc->inACCM[2], pc->inACCM[3])); } #if 0 /* * ccp_test - ask kernel whether a given compression method * is acceptable for use. Returns 1 if the method and parameters * are OK, 0 if the method is known but the parameters are not OK * (e.g. code size should be reduced), or -1 if the method is unknown. */ int ccp_test( int unit, int opt_len, int for_transmit, u_char *opt_ptr ) { return 0; /* XXX Currently no compression. */ } /* * ccp_flags_set - inform kernel about the current state of CCP. */ void ccp_flags_set(int unit, int isopen, int isup) { /* XXX */ } /* * ccp_fatal_error - returns 1 if decompression was disabled as a * result of an error detected after decompression of a packet, * 0 otherwise. This is necessary because of patent nonsense. */ int ccp_fatal_error(int unit) { /* XXX */ return 0; } #endif /* * get_idle_time - return how long the link has been idle. */ int get_idle_time(int u, struct ppp_idle *ip) { /* XXX */ (void)u; (void)ip; return 0; } /* * Return user specified netmask, modified by any mask we might determine * for address `addr' (in network byte order). * Here we scan through the system's list of interfaces, looking for * any non-point-to-point interfaces which might appear to be on the same * network as `addr'. If we find any, we OR in their netmask to the * user-specified netmask. */ u32_t GetMask(u32_t addr) { u32_t mask, nmask; htonl(addr); if (IN_CLASSA(addr)) /* determine network mask for address class */ nmask = IN_CLASSA_NET; else if (IN_CLASSB(addr)) nmask = IN_CLASSB_NET; else nmask = IN_CLASSC_NET; /* class D nets are disallowed by bad_ip_adrs */ mask = subnetMask | htonl(nmask); /* XXX * Scan through the system's network interfaces. * Get each netmask and OR them into our mask. */ return mask; } /* * sifvjcomp - config tcp header compression */ int sifvjcomp( int pd, int vjcomp, int cidcomp, int maxcid ) { #if VJ_SUPPORT > 0 PPPControl *pc = &pppControl[pd]; pc->vjEnabled = vjcomp; pc->vjComp.compressSlot = cidcomp; pc->vjComp.maxSlotIndex = maxcid; PPPDEBUG((LOG_INFO, "sifvjcomp: VJ compress enable=%d slot=%d max slot=%d\n", vjcomp, cidcomp, maxcid)); #endif return 0; } /* * pppifNetifInit - netif init callback */ static err_t pppifNetifInit(struct netif *netif) { netif->name[0] = 'p'; netif->name[1] = 'p'; netif->output = pppifOutput; netif->mtu = pppMTU((int)netif->state); return ERR_OK; } /* * sifup - Config the interface up and enable IP packets to pass. */ int sifup(int pd) { PPPControl *pc = &pppControl[pd]; int st = 1; if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); } else { netif_remove(&pc->netif); if (netif_add(&pc->netif, &pc->addrs.our_ipaddr, &pc->addrs.netmask, &pc->addrs.his_ipaddr, (void *)pd, pppifNetifInit, ip_input)) { pc->if_up = 1; pc->errCode = PPPERR_NONE; PPPDEBUG((LOG_DEBUG, "sifup: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); if(pc->linkStatusCB) pc->linkStatusCB(pc->linkStatusCtx, pc->errCode, &pc->addrs); } else { st = 0; PPPDEBUG((LOG_ERR, "sifup[%d]: netif_add failed\n", pd)); } } return st; } /* * sifnpmode - Set the mode for handling packets for a given NP. */ int sifnpmode(int u, int proto, enum NPmode mode) { (void)u; (void)proto; (void)mode; return 0; } /* * sifdown - Config the interface down and disable IP. */ int sifdown(int pd) { PPPControl *pc = &pppControl[pd]; int st = 1; if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG((LOG_WARNING, "sifdown[%d]: bad parms\n", pd)); } else { pc->if_up = 0; netif_remove(&pc->netif); PPPDEBUG((LOG_DEBUG, "sifdown: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); if(pc->linkStatusCB) pc->linkStatusCB(pc->linkStatusCtx, PPPERR_CONNECT, NULL); } return st; } /* * sifaddr - Config the interface IP addresses and netmask. */ int sifaddr( int pd, /* Interface unit ??? */ u32_t o, /* Our IP address ??? */ u32_t h, /* His IP address ??? */ u32_t m, /* IP subnet mask ??? */ u32_t ns1, /* Primary DNS */ u32_t ns2 /* Secondary DNS */ ) { PPPControl *pc = &pppControl[pd]; int st = 1; if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); } else { memcpy(&pc->addrs.our_ipaddr, &o, sizeof(o)); memcpy(&pc->addrs.his_ipaddr, &h, sizeof(h)); memcpy(&pc->addrs.netmask, &m, sizeof(m)); memcpy(&pc->addrs.dns1, &ns1, sizeof(ns1)); memcpy(&pc->addrs.dns2, &ns2, sizeof(ns2)); } return st; } /* * cifaddr - Clear the interface IP addresses, and delete routes * through the interface if possible. */ int cifaddr( int pd, /* Interface unit ??? */ u32_t o, /* Our IP address ??? */ u32_t h /* IP broadcast address ??? */ ) { PPPControl *pc = &pppControl[pd]; int st = 1; (void)o; (void)h; if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); } else { IP4_ADDR(&pc->addrs.our_ipaddr, 0,0,0,0); IP4_ADDR(&pc->addrs.his_ipaddr, 0,0,0,0); IP4_ADDR(&pc->addrs.netmask, 255,255,255,0); IP4_ADDR(&pc->addrs.dns1, 0,0,0,0); IP4_ADDR(&pc->addrs.dns2, 0,0,0,0); } return st; } /* * sifdefaultroute - assign a default route through the address given. */ int sifdefaultroute(int pd, u32_t l, u32_t g) { PPPControl *pc = &pppControl[pd]; int st = 1; (void)l; (void)g; if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); } else { netif_set_default(&pc->netif); } /* TODO: check how PPP handled the netMask, previously not set by ipSetDefault */ return st; } /* * cifdefaultroute - delete a default route through the address given. */ int cifdefaultroute(int pd, u32_t l, u32_t g) { PPPControl *pc = &pppControl[pd]; int st = 1; (void)l; (void)g; if (pd < 0 || pd >= NUM_PPP || !pc->openFlag) { st = 0; PPPDEBUG((LOG_WARNING, "sifup[%d]: bad parms\n", pd)); } else { netif_set_default(NULL); } return st; } void pppMainWakeup(int pd) { PPPDEBUG((LOG_DEBUG, "pppMainWakeup: unit %d\n", pd)); sio_read_abort(pppControl[pd].fd); } /* these callbacks are necessary because lcp_* functions must be called in the same context as pppInput(), namely the tcpip_thread(), essentially because they manipulate timeouts which are thread-private */ static void pppStartCB(void *arg) { int pd = (int)arg; PPPDEBUG((LOG_DEBUG, "pppStartCB: unit %d\n", pd)); lcp_lowerup(pd); lcp_open(pd); /* Start protocol */ } static void pppStopCB(void *arg) { int pd = (int)arg; PPPDEBUG((LOG_DEBUG, "pppStopCB: unit %d\n", pd)); lcp_close(pd, "User request"); } static void pppHupCB(void *arg) { int pd = (int)arg; PPPDEBUG((LOG_DEBUG, "pppHupCB: unit %d\n", pd)); lcp_lowerdown(pd); link_terminated(pd); } /**********************************/ /*** LOCAL FUNCTION DEFINITIONS ***/ /**********************************/ /* The main PPP process function. This implements the state machine according * to section 4 of RFC 1661: The Point-To-Point Protocol. */ static void pppMain(void *arg) { int pd = (int)arg; struct pbuf *p; PPPControl* pc; pc = &pppControl[pd]; p = pbuf_alloc(PBUF_RAW, PPP_MRU+PPP_HDRLEN, PBUF_RAM); if(!p) { LWIP_ASSERT("p != NULL", p); pc->errCode = PPPERR_ALLOC; goto out; } /* * Start the connection and handle incoming events (packet or timeout). */ PPPDEBUG((LOG_INFO, "pppMain: unit %d: Connecting\n", pd)); tcpip_callback(pppStartCB, arg); while (lcp_phase[pd] != PHASE_DEAD) { if (pc->kill_link) { PPPDEBUG((LOG_DEBUG, "pppMainWakeup: unit %d kill_link -> pppStopCB\n", pd)); pc->errCode = PPPERR_USER; /* This will leave us at PHASE_DEAD. */ tcpip_callback(pppStopCB, arg); pc->kill_link = 0; } else if (pc->sig_hup) { PPPDEBUG((LOG_DEBUG, "pppMainWakeup: unit %d sig_hup -> pppHupCB\n", pd)); pc->sig_hup = 0; tcpip_callback(pppHupCB, arg); } else { int c = sio_read(pc->fd, p->payload, p->len); if(c > 0) { pppInProc(pd, p->payload, c); } else { PPPDEBUG((LOG_DEBUG, "pppMainWakeup: unit %d sio_read len=%d returned %d\n", pd, p->len, c)); sys_msleep(1); /* give other tasks a chance to run */ } } } PPPDEBUG((LOG_INFO, "pppMain: unit %d: PHASE_DEAD\n", pd)); pbuf_free(p); out: PPPDEBUG((LOG_DEBUG, "pppMain: unit %d: linkStatusCB=%lx errCode=%d\n", pd, pc->linkStatusCB, pc->errCode)); if(pc->linkStatusCB) pc->linkStatusCB(pc->linkStatusCtx, pc->errCode ? pc->errCode : PPPERR_PROTOCOL, NULL); pc->openFlag = 0; } static struct pbuf *pppSingleBuf(struct pbuf *p) { struct pbuf *q, *b; u_char *pl; if(p->tot_len == p->len) return p; q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); if(!q) { PPPDEBUG((LOG_ERR, "pppSingleBuf: unable to alloc new buf (%d)\n", p->tot_len)); return p; /* live dangerously */ } for(b = p, pl = q->payload; b != NULL; b = b->next) { memcpy(pl, b->payload, b->len); pl += b->len; } pbuf_free(p); return q; } struct pppInputHeader { int unit; u16_t proto; }; /* * Pass the processed input packet to the appropriate handler. * This function and all handlers run in the context of the tcpip_thread */ static void pppInput(void *arg) { struct pbuf *nb = (struct pbuf *)arg; u16_t protocol; int pd; pd = ((struct pppInputHeader *)nb->payload)->unit; protocol = ((struct pppInputHeader *)nb->payload)->proto; pbuf_header(nb, -(int)sizeof(struct pppInputHeader)); #if LINK_STATS lwip_stats.link.recv++; #endif /* LINK_STATS */ /* * Toss all non-LCP packets unless LCP is OPEN. * Until we get past the authentication phase, toss all packets * except LCP, LQR and authentication packets. */ if((lcp_phase[pd] <= PHASE_AUTHENTICATE) && (protocol != PPP_LCP)) { if(!((protocol == PPP_LQR) || (protocol == PPP_PAP) || (protocol == PPP_CHAP)) || (lcp_phase[pd] != PHASE_AUTHENTICATE)) { PPPDEBUG((LOG_INFO, "pppInput: discarding proto 0x%04X in phase %d\n", protocol, lcp_phase[pd])); goto drop; } } switch(protocol) { case PPP_VJC_COMP: /* VJ compressed TCP */ #if VJ_SUPPORT > 0 PPPDEBUG((LOG_INFO, "pppInput[%d]: vj_comp in pbuf len=%d\n", pd, nb->len)); /* * Clip off the VJ header and prepend the rebuilt TCP/IP header and * pass the result to IP. */ if (vj_uncompress_tcp(&nb, &pppControl[pd].vjComp) >= 0) { pppControl[pd].netif.input(nb, &pppControl[pd].netif); return; } /* Something's wrong so drop it. */ PPPDEBUG((LOG_WARNING, "pppInput[%d]: Dropping VJ compressed\n", pd)); #else /* No handler for this protocol so drop the packet. */ PPPDEBUG((LOG_INFO, "pppInput[%d]: drop VJ Comp in %d:%s\n", pd, nb->len, nb->payload)); #endif /* VJ_SUPPORT > 0 */ break; case PPP_VJC_UNCOMP: /* VJ uncompressed TCP */ #if VJ_SUPPORT > 0 PPPDEBUG((LOG_INFO, "pppInput[%d]: vj_un in pbuf len=%d\n", pd, nb->len)); /* * Process the TCP/IP header for VJ header compression and then pass * the packet to IP. */ if (vj_uncompress_uncomp(nb, &pppControl[pd].vjComp) >= 0) { pppControl[pd].netif.input(nb, &pppControl[pd].netif); return; } /* Something's wrong so drop it. */ PPPDEBUG((LOG_WARNING, "pppInput[%d]: Dropping VJ uncompressed\n", pd)); #else /* No handler for this protocol so drop the packet. */ PPPDEBUG((LOG_INFO, "pppInput[%d]: drop VJ UnComp in %d:.*H\n", pd, nb->len, LWIP_MIN(nb->len * 2, 40), nb->payload)); #endif /* VJ_SUPPORT > 0 */ break; case PPP_IP: /* Internet Protocol */ PPPDEBUG((LOG_INFO, "pppInput[%d]: ip in pbuf len=%d\n", pd, nb->len)); pppControl[pd].netif.input(nb, &pppControl[pd].netif); return; default: { struct protent *protp; int i; /* * Upcall the proper protocol input routine. */ for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { if (protp->protocol == protocol && protp->enabled_flag) { PPPDEBUG((LOG_INFO, "pppInput[%d]: %s len=%d\n", pd, protp->name, nb->len)); nb = pppSingleBuf(nb); (*protp->input)(pd, nb->payload, nb->len); goto out; } } /* No handler for this protocol so reject the packet. */ PPPDEBUG((LOG_INFO, "pppInput[%d]: rejecting unsupported proto 0x%04X len=%d\n", pd, protocol, nb->len)); pbuf_header(nb, sizeof(protocol)); #if BYTE_ORDER == LITTLE_ENDIAN protocol = htons(protocol); memcpy(nb->payload, &protocol, sizeof(protocol)); #endif lcp_sprotrej(pd, nb->payload, nb->len); } break; } drop: #if LINK_STATS lwip_stats.link.drop++; #endif out: pbuf_free(nb); return; } /* * Drop the input packet. */ static void pppDrop(PPPControl *pc) { if (pc->inHead != NULL) { #if 0 PPPDEBUG((LOG_INFO, "pppDrop: %d:%.*H\n", pc->inHead->len, min(60, pc->inHead->len * 2), pc->inHead->payload)); #endif PPPDEBUG((LOG_INFO, "pppDrop: pbuf len=%d\n", pc->inHead->len)); if (pc->inTail && (pc->inTail != pc->inHead)) pbuf_free(pc->inTail); pbuf_free(pc->inHead); pc->inHead = NULL; pc->inTail = NULL; } #if VJ_SUPPORT > 0 vj_uncompress_err(&pc->vjComp); #endif #if LINK_STATS lwip_stats.link.drop++; #endif /* LINK_STATS */ } /* * Process a received octet string. */ static void pppInProc(int pd, u_char *s, int l) { PPPControl *pc = &pppControl[pd]; struct pbuf *nextNBuf; u_char curChar; PPPDEBUG((LOG_DEBUG, "pppInProc[%d]: got %d bytes\n", pd, l)); while (l-- > 0) { curChar = *s++; /* Handle special characters. */ if (ESCAPE_P(pc->inACCM, curChar)) { /* Check for escape sequences. */ /* XXX Note that this does not handle an escaped 0x5d character which * would appear as an escape character. Since this is an ASCII ']' * and there is no reason that I know of to escape it, I won't complicate * the code to handle this case. GLL */ if (curChar == PPP_ESCAPE) pc->inEscaped = 1; /* Check for the flag character. */ else if (curChar == PPP_FLAG) { /* If this is just an extra flag character, ignore it. */ if (pc->inState <= PDADDRESS) ; /* If we haven't received the packet header, drop what has come in. */ else if (pc->inState < PDDATA) { PPPDEBUG((LOG_WARNING, "pppInProc[%d]: Dropping incomplete packet %d\n", pd, pc->inState)); #if LINK_STATS lwip_stats.link.lenerr++; #endif pppDrop(pc); } /* If the fcs is invalid, drop the packet. */ else if (pc->inFCS != PPP_GOODFCS) { PPPDEBUG((LOG_INFO, "pppInProc[%d]: Dropping bad fcs 0x%04X proto=0x%04X\n", pd, pc->inFCS, pc->inProtocol)); #if LINK_STATS lwip_stats.link.chkerr++; #endif pppDrop(pc); } /* Otherwise it's a good packet so pass it on. */ else { /* Trim off the checksum. */ if(pc->inTail->len >= 2) { pc->inTail->len -= 2; pc->inTail->tot_len = pc->inTail->len; if (pc->inTail != pc->inHead) { pbuf_cat(pc->inHead, pc->inTail); } } else { pc->inTail->tot_len = pc->inTail->len; if (pc->inTail != pc->inHead) { pbuf_cat(pc->inHead, pc->inTail); } pbuf_realloc(pc->inHead, pc->inHead->tot_len - 2); } /* Dispatch the packet thereby consuming it. */ if(tcpip_callback(pppInput, pc->inHead) != ERR_OK) { PPPDEBUG((LOG_ERR, "pppInProc[%d]: tcpip_callback() failed, dropping packet\n", pd)); pbuf_free(pc->inHead); #if LINK_STATS lwip_stats.link.drop++; #endif } pc->inHead = NULL; pc->inTail = NULL; } /* Prepare for a new packet. */ pc->inFCS = PPP_INITFCS; pc->inState = PDADDRESS; pc->inEscaped = 0; } /* Other characters are usually control characters that may have * been inserted by the physical layer so here we just drop them. */ else { PPPDEBUG((LOG_WARNING, "pppInProc[%d]: Dropping ACCM char <%d>\n", pd, curChar)); } } /* Process other characters. */ else { /* Unencode escaped characters. */ if (pc->inEscaped) { pc->inEscaped = 0; curChar ^= PPP_TRANS; } /* Process character relative to current state. */ switch(pc->inState) { case PDIDLE: /* Idle state - waiting. */ /* Drop the character if it's not 0xff * we would have processed a flag character above. */ if (curChar != PPP_ALLSTATIONS) { break; } /* Fall through */ case PDSTART: /* Process start flag. */ /* Prepare for a new packet. */ pc->inFCS = PPP_INITFCS; /* Fall through */ case PDADDRESS: /* Process address field. */ if (curChar == PPP_ALLSTATIONS) { pc->inState = PDCONTROL; break; } /* Else assume compressed address and control fields so * fall through to get the protocol... */ case PDCONTROL: /* Process control field. */ /* If we don't get a valid control code, restart. */ if (curChar == PPP_UI) { pc->inState = PDPROTOCOL1; break; } #if 0 else { PPPDEBUG((LOG_WARNING, "pppInProc[%d]: Invalid control <%d>\n", pd, curChar)); pc->inState = PDSTART; } #endif case PDPROTOCOL1: /* Process protocol field 1. */ /* If the lower bit is set, this is the end of the protocol * field. */ if (curChar & 1) { pc->inProtocol = curChar; pc->inState = PDDATA; } else { pc->inProtocol = (u_int)curChar << 8; pc->inState = PDPROTOCOL2; } break; case PDPROTOCOL2: /* Process protocol field 2. */ pc->inProtocol |= curChar; pc->inState = PDDATA; break; case PDDATA: /* Process data byte. */ /* Make space to receive processed data. */ if (pc->inTail == NULL || pc->inTail->len == PBUF_POOL_BUFSIZE) { if(pc->inTail) { pc->inTail->tot_len = pc->inTail->len; if (pc->inTail != pc->inHead) { pbuf_cat(pc->inHead, pc->inTail); } } /* If we haven't started a packet, we need a packet header. */ nextNBuf = pbuf_alloc(PBUF_RAW, 0, PBUF_POOL); if (nextNBuf == NULL) { /* No free buffers. Drop the input packet and let the * higher layers deal with it. Continue processing * the received pbuf chain in case a new packet starts. */ PPPDEBUG((LOG_ERR, "pppInProc[%d]: NO FREE MBUFS!\n", pd)); #if LINK_STATS lwip_stats.link.memerr++; #endif /* LINK_STATS */ pppDrop(pc); pc->inState = PDSTART; /* Wait for flag sequence. */ break; } if (pc->inHead == NULL) { struct pppInputHeader *pih = nextNBuf->payload; pih->unit = pd; pih->proto = pc->inProtocol; nextNBuf->len += sizeof(*pih); pc->inHead = nextNBuf; } pc->inTail = nextNBuf; } /* Load character into buffer. */ ((u_char*)pc->inTail->payload)[pc->inTail->len++] = curChar; break; } /* update the frame check sequence number. */ pc->inFCS = PPP_FCS(pc->inFCS, curChar); } } avRandomize(); } #endif /* PPP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/vj.c0000644000175000017500000004152111671615006016613 0ustar renzorenzo/* * Routines to compress and uncompess tcp packets (for transmission * over low speed serial lines. * * Copyright (c) 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: * - Initial distribution. * * Modified June 1993 by Paul Mackerras, paulus@cs.anu.edu.au, * so that the entire packet being decompressed doesn't have * to be in contiguous memory (just the compressed header). * * Modified March 1998 by Guy Lancaster, glanca@gesn.com, * for a 16 bit processor. */ #include #include "ppp.h" #include "vj.h" #include "pppdebug.h" #if VJ_SUPPORT > 0 #if LINK_STATS #define INCR(counter) ++comp->stats.counter #else #define INCR(counter) #endif #if defined(NO_CHAR_BITFIELDS) #define getip_hl(base) ((base).ip_hl_v&0xf) #define getth_off(base) (((base).th_x2_off&0xf0)>>4) #else #define getip_hl(base) ((base).ip_hl) #define getth_off(base) ((base).th_off) #endif void vj_compress_init(struct vjcompress *comp) { register u_int i; register struct cstate *tstate = comp->tstate; #if MAX_SLOTS == 0 memset((char *)comp, 0, sizeof(*comp)); #endif comp->maxSlotIndex = MAX_SLOTS - 1; comp->compressSlot = 0; /* Disable slot ID compression by default. */ for (i = MAX_SLOTS - 1; i > 0; --i) { tstate[i].cs_id = i; tstate[i].cs_next = &tstate[i - 1]; } tstate[0].cs_next = &tstate[MAX_SLOTS - 1]; tstate[0].cs_id = 0; comp->last_cs = &tstate[0]; comp->last_recv = 255; comp->last_xmit = 255; comp->flags = VJF_TOSS; } /* ENCODE encodes a number that is known to be non-zero. ENCODEZ * checks for zero (since zero has to be encoded in the long, 3 byte * form). */ #define ENCODE(n) { \ if ((u_short)(n) >= 256) { \ *cp++ = 0; \ cp[1] = (n); \ cp[0] = (n) >> 8; \ cp += 2; \ } else { \ *cp++ = (n); \ } \ } #define ENCODEZ(n) { \ if ((u_short)(n) >= 256 || (u_short)(n) == 0) { \ *cp++ = 0; \ cp[1] = (n); \ cp[0] = (n) >> 8; \ cp += 2; \ } else { \ *cp++ = (n); \ } \ } #define DECODEL(f) { \ if (*cp == 0) {\ u32_t tmp = ntohl(f) + ((cp[1] << 8) | cp[2]); \ (f) = htonl(tmp); \ cp += 3; \ } else { \ u32_t tmp = ntohl(f) + (u32_t)*cp++; \ (f) = htonl(tmp); \ } \ } #define DECODES(f) { \ if (*cp == 0) {\ u_short tmp = ntohs(f) + (((u_short)cp[1] << 8) | cp[2]); \ (f) = htons(tmp); \ cp += 3; \ } else { \ u_short tmp = ntohs(f) + (u_short)*cp++; \ (f) = htons(tmp); \ } \ } #define DECODEU(f) { \ if (*cp == 0) {\ (f) = htons(((u_short)cp[1] << 8) | cp[2]); \ cp += 3; \ } else { \ (f) = htons((u_short)*cp++); \ } \ } /* * vj_compress_tcp - Attempt to do Van Jacobsen header compression on a * packet. This assumes that nb and comp are not null and that the first * buffer of the chain contains a valid IP header. * Return the VJ type code indicating whether or not the packet was * compressed. */ u_int vj_compress_tcp( struct vjcompress *comp, struct pbuf *pb ) { register struct ip *ip = (struct ip *)pb->payload; register struct cstate *cs = comp->last_cs->cs_next; register u_short hlen = getip_hl(*ip); register struct tcphdr *oth; register struct tcphdr *th; register u_short deltaS, deltaA; register u_long deltaL; register u_int changes = 0; u_char new_seq[16]; register u_char *cp = new_seq; /* * Check that the packet is IP proto TCP. */ if (ip->ip_p != IPPROTO_TCP) return (TYPE_IP); /* * Bail if this is an IP fragment or if the TCP packet isn't * `compressible' (i.e., ACK isn't set or some other control bit is * set). */ if ((ip->ip_off & htons(0x3fff)) || pb->tot_len < 40) return (TYPE_IP); th = (struct tcphdr *)&((long *)ip)[hlen]; if ((th->th_flags & (TCP_SYN|TCP_FIN|TCP_RST|TCP_ACK)) != TCP_ACK) return (TYPE_IP); /* * Packet is compressible -- we're going to send either a * COMPRESSED_TCP or UNCOMPRESSED_TCP packet. Either way we need * to locate (or create) the connection state. Special case the * most recently used connection since it's most likely to be used * again & we don't have to do any reordering if it's used. */ INCR(vjs_packets); if (ip->ip_src.s_addr != cs->cs_ip.ip_src.s_addr || ip->ip_dst.s_addr != cs->cs_ip.ip_dst.s_addr || *(long *)th != ((long *)&cs->cs_ip)[getip_hl(cs->cs_ip)]) { /* * Wasn't the first -- search for it. * * States are kept in a circularly linked list with * last_cs pointing to the end of the list. The * list is kept in lru order by moving a state to the * head of the list whenever it is referenced. Since * the list is short and, empirically, the connection * we want is almost always near the front, we locate * states via linear search. If we don't find a state * for the datagram, the oldest state is (re-)used. */ register struct cstate *lcs; register struct cstate *lastcs = comp->last_cs; do { lcs = cs; cs = cs->cs_next; INCR(vjs_searches); if (ip->ip_src.s_addr == cs->cs_ip.ip_src.s_addr && ip->ip_dst.s_addr == cs->cs_ip.ip_dst.s_addr && *(long *)th == ((long *)&cs->cs_ip)[getip_hl(cs->cs_ip)]) goto found; } while (cs != lastcs); /* * Didn't find it -- re-use oldest cstate. Send an * uncompressed packet that tells the other side what * connection number we're using for this conversation. * Note that since the state list is circular, the oldest * state points to the newest and we only need to set * last_cs to update the lru linkage. */ INCR(vjs_misses); comp->last_cs = lcs; hlen += getth_off(*th); hlen <<= 2; /* Check that the IP/TCP headers are contained in the first buffer. */ if (hlen > pb->len) return (TYPE_IP); goto uncompressed; found: /* * Found it -- move to the front on the connection list. */ if (cs == lastcs) comp->last_cs = lcs; else { lcs->cs_next = cs->cs_next; cs->cs_next = lastcs->cs_next; lastcs->cs_next = cs; } } oth = (struct tcphdr *)&((long *)&cs->cs_ip)[hlen]; deltaS = hlen; hlen += getth_off(*th); hlen <<= 2; /* Check that the IP/TCP headers are contained in the first buffer. */ if (hlen > pb->len) { PPPDEBUG((LOG_INFO, "vj_compress_tcp: header len %d spans buffers\n", hlen)); return (TYPE_IP); } /* * Make sure that only what we expect to change changed. The first * line of the `if' checks the IP protocol version, header length & * type of service. The 2nd line checks the "Don't fragment" bit. * The 3rd line checks the time-to-live and protocol (the protocol * check is unnecessary but costless). The 4th line checks the TCP * header length. The 5th line checks IP options, if any. The 6th * line checks TCP options, if any. If any of these things are * different between the previous & current datagram, we send the * current datagram `uncompressed'. */ if (((u_short *)ip)[0] != ((u_short *)&cs->cs_ip)[0] || ((u_short *)ip)[3] != ((u_short *)&cs->cs_ip)[3] || ((u_short *)ip)[4] != ((u_short *)&cs->cs_ip)[4] || getth_off(*th) != getth_off(*oth) || (deltaS > 5 && BCMP(ip + 1, &cs->cs_ip + 1, (deltaS - 5) << 2)) || (getth_off(*th) > 5 && BCMP(th + 1, oth + 1, (getth_off(*th) - 5) << 2))) goto uncompressed; /* * Figure out which of the changing fields changed. The * receiver expects changes in the order: urgent, window, * ack, seq (the order minimizes the number of temporaries * needed in this section of code). */ if (th->th_flags & TCP_URG) { deltaS = ntohs(th->th_urp); ENCODEZ(deltaS); changes |= NEW_U; } else if (th->th_urp != oth->th_urp) /* argh! URG not set but urp changed -- a sensible * implementation should never do this but RFC793 * doesn't prohibit the change so we have to deal * with it. */ goto uncompressed; if ((deltaS = (u_short)(ntohs(th->th_win) - ntohs(oth->th_win))) != 0) { ENCODE(deltaS); changes |= NEW_W; } if ((deltaL = ntohl(th->th_ack) - ntohl(oth->th_ack)) != 0) { if (deltaL > 0xffff) goto uncompressed; deltaA = (u_short)deltaL; ENCODE(deltaA); changes |= NEW_A; } if ((deltaL = ntohl(th->th_seq) - ntohl(oth->th_seq)) != 0) { if (deltaL > 0xffff) goto uncompressed; deltaS = (u_short)deltaL; ENCODE(deltaS); changes |= NEW_S; } switch(changes) { case 0: /* * Nothing changed. If this packet contains data and the * last one didn't, this is probably a data packet following * an ack (normal on an interactive connection) and we send * it compressed. Otherwise it's probably a retransmit, * retransmitted ack or window probe. Send it uncompressed * in case the other side missed the compressed version. */ if (ip->ip_len != cs->cs_ip.ip_len && ntohs(cs->cs_ip.ip_len) == hlen) break; /* (fall through) */ case SPECIAL_I: case SPECIAL_D: /* * actual changes match one of our special case encodings -- * send packet uncompressed. */ goto uncompressed; case NEW_S|NEW_A: if (deltaS == deltaA && deltaS == ntohs(cs->cs_ip.ip_len) - hlen) { /* special case for echoed terminal traffic */ changes = SPECIAL_I; cp = new_seq; } break; case NEW_S: if (deltaS == ntohs(cs->cs_ip.ip_len) - hlen) { /* special case for data xfer */ changes = SPECIAL_D; cp = new_seq; } break; } deltaS = (u_short)(ntohs(ip->ip_id) - ntohs(cs->cs_ip.ip_id)); if (deltaS != 1) { ENCODEZ(deltaS); changes |= NEW_I; } if (th->th_flags & TCP_PSH) changes |= TCP_PUSH_BIT; /* * Grab the cksum before we overwrite it below. Then update our * state with this packet's header. */ deltaA = ntohs(th->th_sum); BCOPY(ip, &cs->cs_ip, hlen); /* * We want to use the original packet as our compressed packet. * (cp - new_seq) is the number of bytes we need for compressed * sequence numbers. In addition we need one byte for the change * mask, one for the connection id and two for the tcp checksum. * So, (cp - new_seq) + 4 bytes of header are needed. hlen is how * many bytes of the original packet to toss so subtract the two to * get the new packet size. */ deltaS = (u_short)(cp - new_seq); if (!comp->compressSlot || comp->last_xmit != cs->cs_id) { comp->last_xmit = cs->cs_id; hlen -= deltaS + 4; pbuf_header(pb, -hlen); cp = (u_char *)pb->payload; *cp++ = changes | NEW_C; *cp++ = cs->cs_id; } else { hlen -= deltaS + 3; pbuf_header(pb, -hlen); cp = (u_char *)pb->payload; *cp++ = changes; } *cp++ = deltaA >> 8; *cp++ = deltaA; BCOPY(new_seq, cp, deltaS); INCR(vjs_compressed); return (TYPE_COMPRESSED_TCP); /* * Update connection state cs & send uncompressed packet (that is, * a regular ip/tcp packet but with the 'conversation id' we hope * to use on future compressed packets in the protocol field). */ uncompressed: BCOPY(ip, &cs->cs_ip, hlen); ip->ip_p = cs->cs_id; comp->last_xmit = cs->cs_id; return (TYPE_UNCOMPRESSED_TCP); } /* * Called when we may have missed a packet. */ void vj_uncompress_err(struct vjcompress *comp) { comp->flags |= VJF_TOSS; INCR(vjs_errorin); } /* * "Uncompress" a packet of type TYPE_UNCOMPRESSED_TCP. * Return 0 on success, -1 on failure. */ int vj_uncompress_uncomp( struct pbuf *nb, struct vjcompress *comp ) { register u_int hlen; register struct cstate *cs; register struct ip *ip; ip = (struct ip *)nb->payload; hlen = getip_hl(*ip) << 2; if (ip->ip_p >= MAX_SLOTS || hlen + sizeof(struct tcphdr) > nb->len || (hlen += getth_off(*((struct tcphdr *)&((char *)ip)[hlen])) << 2) > nb->len || hlen > MAX_HDR) { PPPDEBUG((LOG_INFO, "vj_uncompress_uncomp: bad cid=%d, hlen=%d buflen=%d\n", ip->ip_p, hlen, nb->len)); comp->flags |= VJF_TOSS; INCR(vjs_errorin); return -1; } cs = &comp->rstate[comp->last_recv = ip->ip_p]; comp->flags &=~ VJF_TOSS; ip->ip_p = IPPROTO_TCP; BCOPY(ip, &cs->cs_ip, hlen); cs->cs_hlen = hlen; INCR(vjs_uncompressedin); return 0; } /* * Uncompress a packet of type TYPE_COMPRESSED_TCP. * The packet is composed of a buffer chain and the first buffer * must contain an accurate chain length. * The first buffer must include the entire compressed TCP/IP header. * This procedure replaces the compressed header with the uncompressed * header and returns the length of the VJ header. */ int vj_uncompress_tcp( struct pbuf **nb, struct vjcompress *comp ) { u_char *cp; struct tcphdr *th; struct cstate *cs; u_short *bp; struct pbuf *n0 = *nb; u32_t tmp; u_int vjlen, hlen, changes; INCR(vjs_compressedin); cp = (u_char *)n0->payload; changes = *cp++; if (changes & NEW_C) { /* * Make sure the state index is in range, then grab the state. * If we have a good state index, clear the 'discard' flag. */ if (*cp >= MAX_SLOTS) { PPPDEBUG((LOG_INFO, "vj_uncompress_tcp: bad cid=%d\n", *cp)); goto bad; } comp->flags &=~ VJF_TOSS; comp->last_recv = *cp++; } else { /* * this packet has an implicit state index. If we've * had a line error since the last time we got an * explicit state index, we have to toss the packet. */ if (comp->flags & VJF_TOSS) { PPPDEBUG((LOG_INFO, "vj_uncompress_tcp: tossing\n")); INCR(vjs_tossed); return (-1); } } cs = &comp->rstate[comp->last_recv]; hlen = getip_hl(cs->cs_ip) << 2; th = (struct tcphdr *)&((u_char *)&cs->cs_ip)[hlen]; th->th_sum = htons((*cp << 8) | cp[1]); cp += 2; if (changes & TCP_PUSH_BIT) th->th_flags |= TCP_PSH; else th->th_flags &=~ TCP_PSH; switch (changes & SPECIALS_MASK) { case SPECIAL_I: { register u32_t i = ntohs(cs->cs_ip.ip_len) - cs->cs_hlen; /* some compilers can't nest inline assembler.. */ tmp = ntohl(th->th_ack) + i; th->th_ack = htonl(tmp); tmp = ntohl(th->th_seq) + i; th->th_seq = htonl(tmp); } break; case SPECIAL_D: /* some compilers can't nest inline assembler.. */ tmp = ntohl(th->th_seq) + ntohs(cs->cs_ip.ip_len) - cs->cs_hlen; th->th_seq = htonl(tmp); break; default: if (changes & NEW_U) { th->th_flags |= TCP_URG; DECODEU(th->th_urp); } else th->th_flags &=~ TCP_URG; if (changes & NEW_W) DECODES(th->th_win); if (changes & NEW_A) DECODEL(th->th_ack); if (changes & NEW_S) DECODEL(th->th_seq); break; } if (changes & NEW_I) { DECODES(cs->cs_ip.ip_id); } else { cs->cs_ip.ip_id = ntohs(cs->cs_ip.ip_id) + 1; cs->cs_ip.ip_id = htons(cs->cs_ip.ip_id); } /* * At this point, cp points to the first byte of data in the * packet. Fill in the IP total length and update the IP * header checksum. */ vjlen = (u_short)(cp - (u_char*)n0->payload); if (n0->len < vjlen) { /* * We must have dropped some characters (crc should detect * this but the old slip framing won't) */ PPPDEBUG((LOG_INFO, "vj_uncompress_tcp: head buffer %d too short %d\n", n0->len, vjlen)); goto bad; } #if BYTE_ORDER == LITTLE_ENDIAN tmp = n0->tot_len - vjlen + cs->cs_hlen; cs->cs_ip.ip_len = htons(tmp); #else cs->cs_ip.ip_len = htons(n0->tot_len - vjlen + cs->cs_hlen); #endif /* recompute the ip header checksum */ bp = (u_short *) &cs->cs_ip; cs->cs_ip.ip_sum = 0; for (tmp = 0; hlen > 0; hlen -= 2) tmp += *bp++; tmp = (tmp & 0xffff) + (tmp >> 16); tmp = (tmp & 0xffff) + (tmp >> 16); cs->cs_ip.ip_sum = (u_short)(~tmp); /* Remove the compressed header and prepend the uncompressed header. */ pbuf_header(n0, -vjlen); if(MEM_ALIGN(n0->payload) != n0->payload) { struct pbuf *np, *q; u8_t *bufptr; np = pbuf_alloc(PBUF_RAW, n0->len + cs->cs_hlen, PBUF_POOL); if(!np) { PPPDEBUG((LOG_WARNING, "vj_uncompress_tcp: realign failed\n")); *nb = NULL; goto bad; } pbuf_header(np, -cs->cs_hlen); bufptr = n0->payload; for(q = np; q != NULL; q = q->next) { memcpy(q->payload, bufptr, q->len); bufptr += q->len; } if(n0->next) { pbuf_chain(np, n0->next); pbuf_dechain(n0); } pbuf_free(n0); n0 = np; } if(pbuf_header(n0, cs->cs_hlen)) { struct pbuf *np; LWIP_ASSERT("vj_uncompress_tcp: cs->cs_hlen <= PBUF_POOL_BUFSIZE", cs->cs_hlen <= PBUF_POOL_BUFSIZE); np = pbuf_alloc(PBUF_RAW, cs->cs_hlen, PBUF_POOL); if(!np) { PPPDEBUG((LOG_WARNING, "vj_uncompress_tcp: prepend failed\n")); *nb = NULL; goto bad; } pbuf_cat(np, n0); n0 = np; } LWIP_ASSERT("n0->len >= cs->cs_hlen", n0->len >= cs->cs_hlen); memcpy(n0->payload, &cs->cs_ip, cs->cs_hlen); *nb = n0; return vjlen; bad: comp->flags |= VJF_TOSS; INCR(vjs_errorin); return (-1); } #endif lwipv6-1.5a/lwip-v6/src/netif/ppp/md5.c0000644000175000017500000002643511671615006016670 0ustar renzorenzo/* *********************************************************************** ** md5.c -- the source code for MD5 routines ** ** RSA Data Security, Inc. MD5 Message-Digest Algorithm ** ** Created: 2/17/90 RLR ** ** Revised: 1/91 SRD,AJ,BSK,JT Reference C ver., 7/10 constant corr. ** *********************************************************************** */ /* *********************************************************************** ** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. ** ** ** ** License to copy and use this software is granted provided that ** ** it is identified as the "RSA Data Security, Inc. MD5 Message- ** ** Digest Algorithm" in all material mentioning or referencing this ** ** software or this function. ** ** ** ** License is also granted to make and use derivative works ** ** provided that such works are identified as "derived from the RSA ** ** Data Security, Inc. MD5 Message-Digest Algorithm" in all ** ** material mentioning or referencing the derived work. ** ** ** ** RSA Data Security, Inc. makes no representations concerning ** ** either the merchantability of this software or the suitability ** ** of this software for any particular purpose. It is provided "as ** ** is" without express or implied warranty of any kind. ** ** ** ** These notices must be retained in any copies of any part of this ** ** documentation and/or software. ** *********************************************************************** */ #include "ppp.h" #include "md5.h" #include "pppdebug.h" #if CHAP_SUPPORT > 0 || MD5_SUPPORT > 0 /* *********************************************************************** ** Message-digest routines: ** ** To form the message digest for a message M ** ** (1) Initialize a context buffer mdContext using MD5Init ** ** (2) Call MD5Update on mdContext and M ** ** (3) Call MD5Final on mdContext ** ** The message digest is now in mdContext->digest[0...15] ** *********************************************************************** */ /* forward declaration */ static void Transform (u32_t *buf, u32_t *in); static unsigned char PADDING[64] = { 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; /* F, G, H and I are basic MD5 functions */ #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) #define H(x, y, z) ((x) ^ (y) ^ (z)) #define I(x, y, z) ((y) ^ ((x) | (~z))) /* ROTATE_LEFT rotates x left n bits */ #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) /* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */ /* Rotation is separate from addition to prevent recomputation */ #define FF(a, b, c, d, x, s, ac) \ {(a) += F ((b), (c), (d)) + (x) + (u32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define GG(a, b, c, d, x, s, ac) \ {(a) += G ((b), (c), (d)) + (x) + (u32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define HH(a, b, c, d, x, s, ac) \ {(a) += H ((b), (c), (d)) + (x) + (u32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #define II(a, b, c, d, x, s, ac) \ {(a) += I ((b), (c), (d)) + (x) + (u32_t)(ac); \ (a) = ROTATE_LEFT ((a), (s)); \ (a) += (b); \ } #ifdef __STDC__ #define UL(x) x##UL #else #ifdef WIN32 #define UL(x) x##UL #else #define UL(x) x #endif #endif /* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */ void MD5Init (MD5_CTX *mdContext) { mdContext->i[0] = mdContext->i[1] = (u32_t)0; /* Load magic initialization constants. */ mdContext->buf[0] = (u32_t)0x67452301UL; mdContext->buf[1] = (u32_t)0xefcdab89UL; mdContext->buf[2] = (u32_t)0x98badcfeUL; mdContext->buf[3] = (u32_t)0x10325476UL; } /* The routine MD5Update updates the message-digest context to account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed. */ void MD5Update(MD5_CTX *mdContext, unsigned char *inBuf, unsigned int inLen) { u32_t in[16]; int mdi; unsigned int i, ii; #if 0 ppp_trace(LOG_INFO, "MD5Update: %u:%.*H\n", inLen, MIN(inLen, 20) * 2, inBuf); ppp_trace(LOG_INFO, "MD5Update: %u:%s\n", inLen, inBuf); #endif /* compute number of bytes mod 64 */ mdi = (int)((mdContext->i[0] >> 3) & 0x3F); /* update number of bits */ if ((mdContext->i[0] + ((u32_t)inLen << 3)) < mdContext->i[0]) mdContext->i[1]++; mdContext->i[0] += ((u32_t)inLen << 3); mdContext->i[1] += ((u32_t)inLen >> 29); while (inLen--) { /* add new character to buffer, increment mdi */ mdContext->in[mdi++] = *inBuf++; /* transform if necessary */ if (mdi == 0x40) { for (i = 0, ii = 0; i < 16; i++, ii += 4) in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | (((u32_t)mdContext->in[ii+2]) << 16) | (((u32_t)mdContext->in[ii+1]) << 8) | ((u32_t)mdContext->in[ii]); Transform (mdContext->buf, in); mdi = 0; } } } /* The routine MD5Final terminates the message-digest computation and ends with the desired message digest in mdContext->digest[0...15]. */ void MD5Final (unsigned char hash[], MD5_CTX *mdContext) { u32_t in[16]; int mdi; unsigned int i, ii; unsigned int padLen; /* save number of bits */ in[14] = mdContext->i[0]; in[15] = mdContext->i[1]; /* compute number of bytes mod 64 */ mdi = (int)((mdContext->i[0] >> 3) & 0x3F); /* pad out to 56 mod 64 */ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); MD5Update (mdContext, PADDING, padLen); /* append length in bits and transform */ for (i = 0, ii = 0; i < 14; i++, ii += 4) in[i] = (((u32_t)mdContext->in[ii+3]) << 24) | (((u32_t)mdContext->in[ii+2]) << 16) | (((u32_t)mdContext->in[ii+1]) << 8) | ((u32_t)mdContext->in[ii]); Transform (mdContext->buf, in); /* store buffer in digest */ for (i = 0, ii = 0; i < 4; i++, ii += 4) { mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF); mdContext->digest[ii+1] = (unsigned char)((mdContext->buf[i] >> 8) & 0xFF); mdContext->digest[ii+2] = (unsigned char)((mdContext->buf[i] >> 16) & 0xFF); mdContext->digest[ii+3] = (unsigned char)((mdContext->buf[i] >> 24) & 0xFF); } memcpy(hash, mdContext->digest, 16); } /* Basic MD5 step. Transforms buf based on in. */ static void Transform (u32_t *buf, u32_t *in) { u32_t a = buf[0], b = buf[1], c = buf[2], d = buf[3]; /* Round 1 */ #define S11 7 #define S12 12 #define S13 17 #define S14 22 FF ( a, b, c, d, in[ 0], S11, UL(3614090360)); /* 1 */ FF ( d, a, b, c, in[ 1], S12, UL(3905402710)); /* 2 */ FF ( c, d, a, b, in[ 2], S13, UL( 606105819)); /* 3 */ FF ( b, c, d, a, in[ 3], S14, UL(3250441966)); /* 4 */ FF ( a, b, c, d, in[ 4], S11, UL(4118548399)); /* 5 */ FF ( d, a, b, c, in[ 5], S12, UL(1200080426)); /* 6 */ FF ( c, d, a, b, in[ 6], S13, UL(2821735955)); /* 7 */ FF ( b, c, d, a, in[ 7], S14, UL(4249261313)); /* 8 */ FF ( a, b, c, d, in[ 8], S11, UL(1770035416)); /* 9 */ FF ( d, a, b, c, in[ 9], S12, UL(2336552879)); /* 10 */ FF ( c, d, a, b, in[10], S13, UL(4294925233)); /* 11 */ FF ( b, c, d, a, in[11], S14, UL(2304563134)); /* 12 */ FF ( a, b, c, d, in[12], S11, UL(1804603682)); /* 13 */ FF ( d, a, b, c, in[13], S12, UL(4254626195)); /* 14 */ FF ( c, d, a, b, in[14], S13, UL(2792965006)); /* 15 */ FF ( b, c, d, a, in[15], S14, UL(1236535329)); /* 16 */ /* Round 2 */ #define S21 5 #define S22 9 #define S23 14 #define S24 20 GG ( a, b, c, d, in[ 1], S21, UL(4129170786)); /* 17 */ GG ( d, a, b, c, in[ 6], S22, UL(3225465664)); /* 18 */ GG ( c, d, a, b, in[11], S23, UL( 643717713)); /* 19 */ GG ( b, c, d, a, in[ 0], S24, UL(3921069994)); /* 20 */ GG ( a, b, c, d, in[ 5], S21, UL(3593408605)); /* 21 */ GG ( d, a, b, c, in[10], S22, UL( 38016083)); /* 22 */ GG ( c, d, a, b, in[15], S23, UL(3634488961)); /* 23 */ GG ( b, c, d, a, in[ 4], S24, UL(3889429448)); /* 24 */ GG ( a, b, c, d, in[ 9], S21, UL( 568446438)); /* 25 */ GG ( d, a, b, c, in[14], S22, UL(3275163606)); /* 26 */ GG ( c, d, a, b, in[ 3], S23, UL(4107603335)); /* 27 */ GG ( b, c, d, a, in[ 8], S24, UL(1163531501)); /* 28 */ GG ( a, b, c, d, in[13], S21, UL(2850285829)); /* 29 */ GG ( d, a, b, c, in[ 2], S22, UL(4243563512)); /* 30 */ GG ( c, d, a, b, in[ 7], S23, UL(1735328473)); /* 31 */ GG ( b, c, d, a, in[12], S24, UL(2368359562)); /* 32 */ /* Round 3 */ #define S31 4 #define S32 11 #define S33 16 #define S34 23 HH ( a, b, c, d, in[ 5], S31, UL(4294588738)); /* 33 */ HH ( d, a, b, c, in[ 8], S32, UL(2272392833)); /* 34 */ HH ( c, d, a, b, in[11], S33, UL(1839030562)); /* 35 */ HH ( b, c, d, a, in[14], S34, UL(4259657740)); /* 36 */ HH ( a, b, c, d, in[ 1], S31, UL(2763975236)); /* 37 */ HH ( d, a, b, c, in[ 4], S32, UL(1272893353)); /* 38 */ HH ( c, d, a, b, in[ 7], S33, UL(4139469664)); /* 39 */ HH ( b, c, d, a, in[10], S34, UL(3200236656)); /* 40 */ HH ( a, b, c, d, in[13], S31, UL( 681279174)); /* 41 */ HH ( d, a, b, c, in[ 0], S32, UL(3936430074)); /* 42 */ HH ( c, d, a, b, in[ 3], S33, UL(3572445317)); /* 43 */ HH ( b, c, d, a, in[ 6], S34, UL( 76029189)); /* 44 */ HH ( a, b, c, d, in[ 9], S31, UL(3654602809)); /* 45 */ HH ( d, a, b, c, in[12], S32, UL(3873151461)); /* 46 */ HH ( c, d, a, b, in[15], S33, UL( 530742520)); /* 47 */ HH ( b, c, d, a, in[ 2], S34, UL(3299628645)); /* 48 */ /* Round 4 */ #define S41 6 #define S42 10 #define S43 15 #define S44 21 II ( a, b, c, d, in[ 0], S41, UL(4096336452)); /* 49 */ II ( d, a, b, c, in[ 7], S42, UL(1126891415)); /* 50 */ II ( c, d, a, b, in[14], S43, UL(2878612391)); /* 51 */ II ( b, c, d, a, in[ 5], S44, UL(4237533241)); /* 52 */ II ( a, b, c, d, in[12], S41, UL(1700485571)); /* 53 */ II ( d, a, b, c, in[ 3], S42, UL(2399980690)); /* 54 */ II ( c, d, a, b, in[10], S43, UL(4293915773)); /* 55 */ II ( b, c, d, a, in[ 1], S44, UL(2240044497)); /* 56 */ II ( a, b, c, d, in[ 8], S41, UL(1873313359)); /* 57 */ II ( d, a, b, c, in[15], S42, UL(4264355552)); /* 58 */ II ( c, d, a, b, in[ 6], S43, UL(2734768916)); /* 59 */ II ( b, c, d, a, in[13], S44, UL(1309151649)); /* 60 */ II ( a, b, c, d, in[ 4], S41, UL(4149444226)); /* 61 */ II ( d, a, b, c, in[11], S42, UL(3174756917)); /* 62 */ II ( c, d, a, b, in[ 2], S43, UL( 718787259)); /* 63 */ II ( b, c, d, a, in[ 9], S44, UL(3951481745)); /* 64 */ buf[0] += a; buf[1] += b; buf[2] += c; buf[3] += d; } #endif lwipv6-1.5a/lwip-v6/src/netif/ppp/fsm.c0000644000175000017500000004736611671615006016776 0ustar renzorenzo/***************************************************************************** * fsm.c - Network Control Protocol Finite State Machine program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 by Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-01 Guy Lancaster , Global Election Systems Inc. * Original based on BSD fsm.c. *****************************************************************************/ /* * fsm.c - {Link, IP} Control Protocol Finite State Machine. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* * TODO: * Randomize fsm id on link/init. * Deal with variable outgoing MTU. */ #include "ppp.h" #if PPP_SUPPORT > 0 #include "fsm.h" #include "pppdebug.h" /*************************/ /*** LOCAL DEFINITIONS ***/ /*************************/ /************************/ /*** LOCAL DATA TYPES ***/ /************************/ /***********************************/ /*** LOCAL FUNCTION DECLARATIONS ***/ /***********************************/ static void fsm_timeout (void *); static void fsm_rconfreq (fsm *, u_char, u_char *, int); static void fsm_rconfack (fsm *, int, u_char *, int); static void fsm_rconfnakrej (fsm *, int, int, u_char *, int); static void fsm_rtermreq (fsm *, int, u_char *, int); static void fsm_rtermack (fsm *); static void fsm_rcoderej (fsm *, u_char *, int); static void fsm_sconfreq (fsm *, int); #define PROTO_NAME(f) ((f)->callbacks->proto_name) /******************************/ /*** PUBLIC DATA STRUCTURES ***/ /******************************/ /*****************************/ /*** LOCAL DATA STRUCTURES ***/ /*****************************/ int peer_mru[NUM_PPP]; /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* * fsm_init - Initialize fsm. * * Initialize fsm state. */ void fsm_init(fsm *f) { f->state = INITIAL; f->flags = 0; f->id = 0; /* XXX Start with random id? */ f->timeouttime = FSM_DEFTIMEOUT; f->maxconfreqtransmits = FSM_DEFMAXCONFREQS; f->maxtermtransmits = FSM_DEFMAXTERMREQS; f->maxnakloops = FSM_DEFMAXNAKLOOPS; f->term_reason_len = 0; } /* * fsm_lowerup - The lower layer is up. */ void fsm_lowerup(fsm *f) { int oldState = f->state; switch( f->state ){ case INITIAL: f->state = CLOSED; break; case STARTING: if( f->flags & OPT_SILENT ) f->state = STOPPED; else { /* Send an initial configure-request */ fsm_sconfreq(f, 0); f->state = REQSENT; } break; default: FSMDEBUG((LOG_INFO, "%s: Up event in state %d!\n", PROTO_NAME(f), f->state)); } FSMDEBUG((LOG_INFO, "%s: lowerup state %d -> %d\n", PROTO_NAME(f), oldState, f->state)); } /* * fsm_lowerdown - The lower layer is down. * * Cancel all timeouts and inform upper layers. */ void fsm_lowerdown(fsm *f) { int oldState = f->state; switch( f->state ){ case CLOSED: f->state = INITIAL; break; case STOPPED: f->state = STARTING; if( f->callbacks->starting ) (*f->callbacks->starting)(f); break; case CLOSING: f->state = INITIAL; UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ break; case STOPPING: case REQSENT: case ACKRCVD: case ACKSENT: f->state = STARTING; UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ break; case OPENED: if( f->callbacks->down ) (*f->callbacks->down)(f); f->state = STARTING; break; default: FSMDEBUG((LOG_INFO, "%s: Down event in state %d!\n", PROTO_NAME(f), f->state)); } FSMDEBUG((LOG_INFO, "%s: lowerdown state %d -> %d\n", PROTO_NAME(f), oldState, f->state)); } /* * fsm_open - Link is allowed to come up. */ void fsm_open(fsm *f) { int oldState = f->state; switch( f->state ){ case INITIAL: f->state = STARTING; if( f->callbacks->starting ) (*f->callbacks->starting)(f); break; case CLOSED: if( f->flags & OPT_SILENT ) f->state = STOPPED; else { /* Send an initial configure-request */ fsm_sconfreq(f, 0); f->state = REQSENT; } break; case CLOSING: f->state = STOPPING; /* fall through */ case STOPPED: case OPENED: if( f->flags & OPT_RESTART ){ fsm_lowerdown(f); fsm_lowerup(f); } break; } FSMDEBUG((LOG_INFO, "%s: open state %d -> %d\n", PROTO_NAME(f), oldState, f->state)); } /* * fsm_close - Start closing connection. * * Cancel timeouts and either initiate close or possibly go directly to * the CLOSED state. */ void fsm_close(fsm *f, char *reason) { int oldState = f->state; f->term_reason = reason; f->term_reason_len = (reason == NULL? 0: strlen(reason)); switch( f->state ){ case STARTING: f->state = INITIAL; break; case STOPPED: f->state = CLOSED; break; case STOPPING: f->state = CLOSING; break; case REQSENT: case ACKRCVD: case ACKSENT: case OPENED: if( f->state != OPENED ) UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ else if( f->callbacks->down ) (*f->callbacks->down)(f); /* Inform upper layers we're down */ /* Init restart counter, send Terminate-Request */ f->retransmits = f->maxtermtransmits; fsm_sdata(f, TERMREQ, f->reqid = ++f->id, (u_char *) f->term_reason, f->term_reason_len); TIMEOUT(fsm_timeout, f, f->timeouttime); --f->retransmits; f->state = CLOSING; break; } FSMDEBUG((LOG_INFO, "%s: close reason=%s state %d -> %d\n", PROTO_NAME(f), reason, oldState, f->state)); } /* * fsm_sdata - Send some data. * * Used for all packets sent to our peer by this module. */ void fsm_sdata( fsm *f, u_char code, u_char id, u_char *data, int datalen ) { u_char *outp; int outlen; /* Adjust length to be smaller than MTU */ outp = outpacket_buf[f->unit]; if (datalen > peer_mru[f->unit] - (int)HEADERLEN) datalen = peer_mru[f->unit] - HEADERLEN; if (datalen && data != outp + PPP_HDRLEN + HEADERLEN) BCOPY(data, outp + PPP_HDRLEN + HEADERLEN, datalen); outlen = datalen + HEADERLEN; MAKEHEADER(outp, f->protocol); PUTCHAR(code, outp); PUTCHAR(id, outp); PUTSHORT(outlen, outp); pppWrite(f->unit, outpacket_buf[f->unit], outlen + PPP_HDRLEN); FSMDEBUG((LOG_INFO, "fsm_sdata(%s): Sent code %d,%d,%d.\n", PROTO_NAME(f), code, id, outlen)); } /* * fsm_input - Input packet. */ void fsm_input(fsm *f, u_char *inpacket, int l) { u_char *inp = inpacket; u_char code, id; int len; /* * Parse header (code, id and length). * If packet too short, drop it. */ if (l < HEADERLEN) { FSMDEBUG((LOG_WARNING, "fsm_input(%x): Rcvd short header.\n", f->protocol)); return; } GETCHAR(code, inp); GETCHAR(id, inp); GETSHORT(len, inp); if (len < HEADERLEN) { FSMDEBUG((LOG_INFO, "fsm_input(%x): Rcvd illegal length.\n", f->protocol)); return; } if (len > l) { FSMDEBUG((LOG_INFO, "fsm_input(%x): Rcvd short packet.\n", f->protocol)); return; } len -= HEADERLEN; /* subtract header length */ if( f->state == INITIAL || f->state == STARTING ){ FSMDEBUG((LOG_INFO, "fsm_input(%x): Rcvd packet in state %d.\n", f->protocol, f->state)); return; } FSMDEBUG((LOG_INFO, "fsm_input(%s):%d,%d,%d\n", PROTO_NAME(f), code, id, l)); /* * Action depends on code. */ switch (code) { case CONFREQ: fsm_rconfreq(f, id, inp, len); break; case CONFACK: fsm_rconfack(f, id, inp, len); break; case CONFNAK: case CONFREJ: fsm_rconfnakrej(f, code, id, inp, len); break; case TERMREQ: fsm_rtermreq(f, id, inp, len); break; case TERMACK: fsm_rtermack(f); break; case CODEREJ: fsm_rcoderej(f, inp, len); break; default: if( !f->callbacks->extcode || !(*f->callbacks->extcode)(f, code, id, inp, len) ) fsm_sdata(f, CODEREJ, ++f->id, inpacket, len + HEADERLEN); break; } } /* * fsm_protreject - Peer doesn't speak this protocol. * * Treat this as a catastrophic error (RXJ-). */ void fsm_protreject(fsm *f) { switch( f->state ){ case CLOSING: UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ /* fall through */ case CLOSED: f->state = CLOSED; if( f->callbacks->finished ) (*f->callbacks->finished)(f); break; case STOPPING: case REQSENT: case ACKRCVD: case ACKSENT: UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ /* fall through */ case STOPPED: f->state = STOPPED; if( f->callbacks->finished ) (*f->callbacks->finished)(f); break; case OPENED: if( f->callbacks->down ) (*f->callbacks->down)(f); /* Init restart counter, send Terminate-Request */ f->retransmits = f->maxtermtransmits; fsm_sdata(f, TERMREQ, f->reqid = ++f->id, (u_char *) f->term_reason, f->term_reason_len); TIMEOUT(fsm_timeout, f, f->timeouttime); --f->retransmits; f->state = STOPPING; break; default: FSMDEBUG((LOG_INFO, "%s: Protocol-reject event in state %d!\n", PROTO_NAME(f), f->state)); } } /**********************************/ /*** LOCAL FUNCTION DEFINITIONS ***/ /**********************************/ /* * fsm_timeout - Timeout expired. */ static void fsm_timeout(void *arg) { fsm *f = (fsm *) arg; switch (f->state) { case CLOSING: case STOPPING: if( f->retransmits <= 0 ){ FSMDEBUG((LOG_WARNING, "%s: timeout sending Terminate-Request state=%d\n", PROTO_NAME(f), f->state)); /* * We've waited for an ack long enough. Peer probably heard us. */ f->state = (f->state == CLOSING)? CLOSED: STOPPED; if( f->callbacks->finished ) (*f->callbacks->finished)(f); } else { FSMDEBUG((LOG_WARNING, "%s: timeout resending Terminate-Requests state=%d\n", PROTO_NAME(f), f->state)); /* Send Terminate-Request */ fsm_sdata(f, TERMREQ, f->reqid = ++f->id, (u_char *) f->term_reason, f->term_reason_len); TIMEOUT(fsm_timeout, f, f->timeouttime); --f->retransmits; } break; case REQSENT: case ACKRCVD: case ACKSENT: if (f->retransmits <= 0) { FSMDEBUG((LOG_WARNING, "%s: timeout sending Config-Requests state=%d\n", PROTO_NAME(f), f->state)); f->state = STOPPED; if( (f->flags & OPT_PASSIVE) == 0 && f->callbacks->finished ) (*f->callbacks->finished)(f); } else { FSMDEBUG((LOG_WARNING, "%s: timeout resending Config-Request state=%d\n", PROTO_NAME(f), f->state)); /* Retransmit the configure-request */ if (f->callbacks->retransmit) (*f->callbacks->retransmit)(f); fsm_sconfreq(f, 1); /* Re-send Configure-Request */ if( f->state == ACKRCVD ) f->state = REQSENT; } break; default: FSMDEBUG((LOG_INFO, "%s: Timeout event in state %d!\n", PROTO_NAME(f), f->state)); } } /* * fsm_rconfreq - Receive Configure-Request. */ static void fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) { int code, reject_if_disagree; FSMDEBUG((LOG_INFO, "fsm_rconfreq(%s): Rcvd id %d state=%d\n", PROTO_NAME(f), id, f->state)); switch( f->state ){ case CLOSED: /* Go away, we're closed */ fsm_sdata(f, TERMACK, id, NULL, 0); return; case CLOSING: case STOPPING: return; case OPENED: /* Go down and restart negotiation */ if( f->callbacks->down ) (*f->callbacks->down)(f); /* Inform upper layers */ fsm_sconfreq(f, 0); /* Send initial Configure-Request */ break; case STOPPED: /* Negotiation started by our peer */ fsm_sconfreq(f, 0); /* Send initial Configure-Request */ f->state = REQSENT; break; } /* * Pass the requested configuration options * to protocol-specific code for checking. */ if (f->callbacks->reqci){ /* Check CI */ reject_if_disagree = (f->nakloops >= f->maxnakloops); code = (*f->callbacks->reqci)(f, inp, &len, reject_if_disagree); } else if (len) code = CONFREJ; /* Reject all CI */ else code = CONFACK; /* send the Ack, Nak or Rej to the peer */ fsm_sdata(f, (u_char)code, id, inp, len); if (code == CONFACK) { if (f->state == ACKRCVD) { UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ f->state = OPENED; if (f->callbacks->up) (*f->callbacks->up)(f); /* Inform upper layers */ } else f->state = ACKSENT; f->nakloops = 0; } else { /* we sent CONFACK or CONFREJ */ if (f->state != ACKRCVD) f->state = REQSENT; if( code == CONFNAK ) ++f->nakloops; } } /* * fsm_rconfack - Receive Configure-Ack. */ static void fsm_rconfack(fsm *f, int id, u_char *inp, int len) { FSMDEBUG((LOG_INFO, "fsm_rconfack(%s): Rcvd id %d state=%d\n", PROTO_NAME(f), id, f->state)); if (id != f->reqid || f->seen_ack) /* Expected id? */ return; /* Nope, toss... */ if( !(f->callbacks->ackci? (*f->callbacks->ackci)(f, inp, len): (len == 0)) ){ /* Ack is bad - ignore it */ FSMDEBUG((LOG_INFO, "%s: received bad Ack (length %d)\n", PROTO_NAME(f), len)); return; } f->seen_ack = 1; switch (f->state) { case CLOSED: case STOPPED: fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); break; case REQSENT: f->state = ACKRCVD; f->retransmits = f->maxconfreqtransmits; break; case ACKRCVD: /* Huh? an extra valid Ack? oh well... */ UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ fsm_sconfreq(f, 0); f->state = REQSENT; break; case ACKSENT: UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ f->state = OPENED; f->retransmits = f->maxconfreqtransmits; if (f->callbacks->up) (*f->callbacks->up)(f); /* Inform upper layers */ break; case OPENED: /* Go down and restart negotiation */ if (f->callbacks->down) (*f->callbacks->down)(f); /* Inform upper layers */ fsm_sconfreq(f, 0); /* Send initial Configure-Request */ f->state = REQSENT; break; } } /* * fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject. */ static void fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) { int (*proc) (fsm *, u_char *, int); int ret; FSMDEBUG((LOG_INFO, "fsm_rconfnakrej(%s): Rcvd id %d state=%d\n", PROTO_NAME(f), id, f->state)); if (id != f->reqid || f->seen_ack) /* Expected id? */ return; /* Nope, toss... */ proc = (code == CONFNAK)? f->callbacks->nakci: f->callbacks->rejci; if (!proc || !(ret = proc(f, inp, len))) { /* Nak/reject is bad - ignore it */ FSMDEBUG((LOG_INFO, "%s: received bad %s (length %d)\n", PROTO_NAME(f), (code==CONFNAK? "Nak": "reject"), len)); return; } f->seen_ack = 1; switch (f->state) { case CLOSED: case STOPPED: fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); break; case REQSENT: case ACKSENT: /* They didn't agree to what we wanted - try another request */ UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ if (ret < 0) f->state = STOPPED; /* kludge for stopping CCP */ else fsm_sconfreq(f, 0); /* Send Configure-Request */ break; case ACKRCVD: /* Got a Nak/reject when we had already had an Ack?? oh well... */ UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */ fsm_sconfreq(f, 0); f->state = REQSENT; break; case OPENED: /* Go down and restart negotiation */ if (f->callbacks->down) (*f->callbacks->down)(f); /* Inform upper layers */ fsm_sconfreq(f, 0); /* Send initial Configure-Request */ f->state = REQSENT; break; } } /* * fsm_rtermreq - Receive Terminate-Req. */ static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) { FSMDEBUG((LOG_INFO, "fsm_rtermreq(%s): Rcvd id %d state=%d\n", PROTO_NAME(f), id, f->state)); switch (f->state) { case ACKRCVD: case ACKSENT: f->state = REQSENT; /* Start over but keep trying */ break; case OPENED: if (len > 0) { FSMDEBUG((LOG_INFO, "%s terminated by peer (%x)\n", PROTO_NAME(f), p)); } else { FSMDEBUG((LOG_INFO, "%s terminated by peer\n", PROTO_NAME(f))); } if (f->callbacks->down) (*f->callbacks->down)(f); /* Inform upper layers */ f->retransmits = 0; f->state = STOPPING; TIMEOUT(fsm_timeout, f, f->timeouttime); break; } fsm_sdata(f, TERMACK, (u_char)id, NULL, 0); } /* * fsm_rtermack - Receive Terminate-Ack. */ static void fsm_rtermack(fsm *f) { FSMDEBUG((LOG_INFO, "fsm_rtermack(%s): state=%d\n", PROTO_NAME(f), f->state)); switch (f->state) { case CLOSING: UNTIMEOUT(fsm_timeout, f); f->state = CLOSED; if( f->callbacks->finished ) (*f->callbacks->finished)(f); break; case STOPPING: UNTIMEOUT(fsm_timeout, f); f->state = STOPPED; if( f->callbacks->finished ) (*f->callbacks->finished)(f); break; case ACKRCVD: f->state = REQSENT; break; case OPENED: if (f->callbacks->down) (*f->callbacks->down)(f); /* Inform upper layers */ fsm_sconfreq(f, 0); break; } } /* * fsm_rcoderej - Receive an Code-Reject. */ static void fsm_rcoderej(fsm *f, u_char *inp, int len) { u_char code, id; FSMDEBUG((LOG_INFO, "fsm_rcoderej(%s): state=%d\n", PROTO_NAME(f), f->state)); if (len < HEADERLEN) { FSMDEBUG((LOG_INFO, "fsm_rcoderej: Rcvd short Code-Reject packet!\n")); return; } GETCHAR(code, inp); GETCHAR(id, inp); FSMDEBUG((LOG_WARNING, "%s: Rcvd Code-Reject for code %d, id %d\n", PROTO_NAME(f), code, id)); if( f->state == ACKRCVD ) f->state = REQSENT; } /* * fsm_sconfreq - Send a Configure-Request. */ static void fsm_sconfreq(fsm *f, int retransmit) { u_char *outp; int cilen; if( f->state != REQSENT && f->state != ACKRCVD && f->state != ACKSENT ){ /* Not currently negotiating - reset options */ if( f->callbacks->resetci ) (*f->callbacks->resetci)(f); f->nakloops = 0; } if( !retransmit ){ /* New request - reset retransmission counter, use new ID */ f->retransmits = f->maxconfreqtransmits; f->reqid = ++f->id; } f->seen_ack = 0; /* * Make up the request packet */ outp = outpacket_buf[f->unit] + PPP_HDRLEN + HEADERLEN; if( f->callbacks->cilen && f->callbacks->addci ){ cilen = (*f->callbacks->cilen)(f); if( cilen > peer_mru[f->unit] - (int)HEADERLEN ) cilen = peer_mru[f->unit] - HEADERLEN; if (f->callbacks->addci) (*f->callbacks->addci)(f, outp, &cilen); } else cilen = 0; /* send the request to our peer */ fsm_sdata(f, CONFREQ, f->reqid, outp, cilen); /* start the retransmit timer */ --f->retransmits; TIMEOUT(fsm_timeout, f, f->timeouttime); FSMDEBUG((LOG_INFO, "%s: sending Configure-Request, id %d\n", PROTO_NAME(f), f->reqid)); } #endif /* PPP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/ipcp.h0000644000175000017500000001212711671615006017134 0ustar renzorenzo/***************************************************************************** * ipcp.h - PPP IP NCP: Internet Protocol Network Control Protocol header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-04 Guy Lancaster , Global Election Systems Inc. * Original derived from BSD codes. *****************************************************************************/ /* * ipcp.h - IP Control Protocol definitions. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * $Id: ipcp.h 26 2005-08-10 18:50:38Z rd235 $ */ #ifndef IPCP_H #define IPCP_H /************************* *** PUBLIC DEFINITIONS *** *************************/ /* * Options. */ #define CI_ADDRS 1 /* IP Addresses */ #define CI_COMPRESSTYPE 2 /* Compression Type */ #define CI_ADDR 3 #define CI_MS_WINS1 128 /* Primary WINS value */ #define CI_MS_DNS1 129 /* Primary DNS value */ #define CI_MS_WINS2 130 /* Secondary WINS value */ #define CI_MS_DNS2 131 /* Secondary DNS value */ #define IPCP_VJMODE_OLD 1 /* "old" mode (option # = 0x0037) */ #define IPCP_VJMODE_RFC1172 2 /* "old-rfc"mode (option # = 0x002d) */ #define IPCP_VJMODE_RFC1332 3 /* "new-rfc"mode (option # = 0x002d, */ /* maxslot and slot number compression) */ #define IPCP_VJ_COMP 0x002d /* current value for VJ compression option*/ #define IPCP_VJ_COMP_OLD 0x0037 /* "old" (i.e, broken) value for VJ */ /* compression option*/ /************************ *** PUBLIC DATA TYPES *** ************************/ typedef struct ipcp_options { u_int neg_addr : 1; /* Negotiate IP Address? */ u_int old_addrs : 1; /* Use old (IP-Addresses) option? */ u_int req_addr : 1; /* Ask peer to send IP address? */ u_int default_route : 1; /* Assign default route through interface? */ u_int proxy_arp : 1; /* Make proxy ARP entry for peer? */ u_int neg_vj : 1; /* Van Jacobson Compression? */ u_int old_vj : 1; /* use old (short) form of VJ option? */ u_int accept_local : 1; /* accept peer's value for ouraddr */ u_int accept_remote : 1; /* accept peer's value for hisaddr */ u_int req_dns1 : 1; /* Ask peer to send primary DNS address? */ u_int req_dns2 : 1; /* Ask peer to send secondary DNS address? */ u_short vj_protocol; /* protocol value to use in VJ option */ u_char maxslotindex; /* VJ slots - 1. */ u_char cflag; /* VJ slot compression flag. */ u32_t ouraddr, hisaddr; /* Addresses in NETWORK BYTE ORDER */ u32_t dnsaddr[2]; /* Primary and secondary MS DNS entries */ u32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ } ipcp_options; /***************************** *** PUBLIC DATA STRUCTURES *** *****************************/ extern fsm ipcp_fsm[]; extern ipcp_options ipcp_wantoptions[]; extern ipcp_options ipcp_gotoptions[]; extern ipcp_options ipcp_allowoptions[]; extern ipcp_options ipcp_hisoptions[]; extern struct protent ipcp_protent; /*********************** *** PUBLIC FUNCTIONS *** ***********************/ #endif /* IPCP_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/magic.h0000644000175000017500000000577611671615006017275 0ustar renzorenzo/***************************************************************************** * magic.h - Network Random Number Generator header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-04 Guy Lancaster , Global Election Systems Inc. * Original derived from BSD codes. *****************************************************************************/ /* * magic.h - PPP Magic Number definitions. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * $Id: magic.h 26 2005-08-10 18:50:38Z rd235 $ */ #ifndef MAGIC_H #define MAGIC_H /***************************************************************************** ************************** PUBLIC FUNCTIONS ********************************** *****************************************************************************/ void magicInit(void); /* Initialize the magic number generator */ u32_t magic(void); /* Returns the next magic number */ #endif /* MAGIC_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/auth.c0000644000175000017500000006262111671615006017141 0ustar renzorenzo/***************************************************************************** * auth.c - Network Authentication and Phase Control program file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * Copyright (c) 1997 by Global Election Systems Inc. All rights reserved. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-08 Guy Lancaster , Global Election Systems Inc. * Ported from public pppd code. *****************************************************************************/ /* * auth.c - PPP authentication and phase control. * * Copyright (c) 1993 The Australian National University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the Australian National University. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #include "ppp.h" #if PPP_SUPPORT > 0 #include "fsm.h" #include "lcp.h" #include "pap.h" #include "chap.h" #include "auth.h" #include "ipcp.h" #if CBCP_SUPPORT > 0 #include "cbcp.h" #endif #include "pppdebug.h" /*************************/ /*** LOCAL DEFINITIONS ***/ /*************************/ /* Bits in auth_pending[] */ #define PAP_WITHPEER 1 #define PAP_PEER 2 #define CHAP_WITHPEER 4 #define CHAP_PEER 8 /************************/ /*** LOCAL DATA TYPES ***/ /************************/ /* Used for storing a sequence of words. Usually malloced. */ struct wordlist { struct wordlist *next; char word[1]; }; /***********************************/ /*** LOCAL FUNCTION DECLARATIONS ***/ /***********************************/ extern char *crypt (const char *, const char *); /* Prototypes for procedures local to this file. */ static void network_phase (int); static void check_idle (void *); static void connect_time_expired (void *); #if 0 static int login (char *, char *, char **, int *); #endif static void logout (void); static int null_login (int); static int get_pap_passwd (int, char *, char *); static int have_pap_secret (void); static int have_chap_secret (char *, char *, u32_t); static int ip_addr_check (u32_t, struct wordlist *); #if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 */ static void set_allowed_addrs(int unit, struct wordlist *addrs); static void free_wordlist (struct wordlist *); #endif #if CBCP_SUPPORT > 0 static void callback_phase (int); #endif /******************************/ /*** PUBLIC DATA STRUCTURES ***/ /******************************/ /*****************************/ /*** LOCAL DATA STRUCTURES ***/ /*****************************/ #if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 /* The name by which the peer authenticated itself to us. */ static char peer_authname[MAXNAMELEN]; #endif /* Records which authentication operations haven't completed yet. */ static int auth_pending[NUM_PPP]; /* Set if we have successfully called login() */ static int logged_in; /* Set if we have run the /etc/ppp/auth-up script. */ static int did_authup; /* List of addresses which the peer may use. */ static struct wordlist *addresses[NUM_PPP]; /* Number of network protocols which we have opened. */ static int num_np_open; /* Number of network protocols which have come up. */ static int num_np_up; #if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 /* Set if we got the contents of passwd[] from the pap-secrets file. */ static int passwd_from_file; #endif /***********************************/ /*** PUBLIC FUNCTION DEFINITIONS ***/ /***********************************/ /* * An Open on LCP has requested a change from Dead to Establish phase. * Do what's necessary to bring the physical layer up. */ void link_required(int unit) { AUTHDEBUG((LOG_INFO, "link_required: %d\n", unit)); } /* * LCP has terminated the link; go to the Dead phase and take the * physical layer down. */ void link_terminated(int unit) { AUTHDEBUG((LOG_INFO, "link_terminated: %d\n", unit)); if (lcp_phase[unit] == PHASE_DEAD) return; if (logged_in) logout(); lcp_phase[unit] = PHASE_DEAD; AUTHDEBUG((LOG_NOTICE, "Connection terminated.\n")); pppMainWakeup(unit); } /* * LCP has gone down; it will either die or try to re-establish. */ void link_down(int unit) { int i; struct protent *protp; AUTHDEBUG((LOG_INFO, "link_down: %d\n", unit)); if (did_authup) { /* XXX Do link down processing. */ did_authup = 0; } for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) { if (!protp->enabled_flag) continue; if (protp->protocol != PPP_LCP && protp->lowerdown != NULL) (*protp->lowerdown)(unit); if (protp->protocol < 0xC000 && protp->close != NULL) (*protp->close)(unit, "LCP down"); } num_np_open = 0; num_np_up = 0; if (lcp_phase[unit] != PHASE_DEAD) lcp_phase[unit] = PHASE_TERMINATE; pppMainWakeup(unit); } /* * The link is established. * Proceed to the Dead, Authenticate or Network phase as appropriate. */ void link_established(int unit) { int auth; int i; struct protent *protp; lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *go = &lcp_gotoptions[unit]; #if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 lcp_options *ho = &lcp_hisoptions[unit]; #endif AUTHDEBUG((LOG_INFO, "link_established: %d\n", unit)); /* * Tell higher-level protocols that LCP is up. */ for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) if (protp->protocol != PPP_LCP && protp->enabled_flag && protp->lowerup != NULL) (*protp->lowerup)(unit); if (ppp_settings.auth_required && !(go->neg_chap || go->neg_upap)) { /* * We wanted the peer to authenticate itself, and it refused: * treat it as though it authenticated with PAP using a username * of "" and a password of "". If that's not OK, boot it out. */ if (!wo->neg_upap || !null_login(unit)) { AUTHDEBUG((LOG_WARNING, "peer refused to authenticate\n")); lcp_close(unit, "peer refused to authenticate"); return; } } lcp_phase[unit] = PHASE_AUTHENTICATE; auth = 0; #if CHAP_SUPPORT > 0 if (go->neg_chap) { ChapAuthPeer(unit, ppp_settings.our_name, go->chap_mdtype); auth |= CHAP_PEER; } #endif #if PAP_SUPPORT > 0 && CHAP_SUPPORT > 0 else #endif #if PAP_SUPPORT > 0 if (go->neg_upap) { upap_authpeer(unit); auth |= PAP_PEER; } #endif #if CHAP_SUPPORT > 0 if (ho->neg_chap) { ChapAuthWithPeer(unit, ppp_settings.user, ho->chap_mdtype); auth |= CHAP_WITHPEER; } #endif #if PAP_SUPPORT > 0 && CHAP_SUPPORT > 0 else #endif #if PAP_SUPPORT > 0 if (ho->neg_upap) { if (ppp_settings.passwd[0] == 0) { passwd_from_file = 1; if (!get_pap_passwd(unit, ppp_settings.user, ppp_settings.passwd)) AUTHDEBUG((LOG_ERR, "No secret found for PAP login\n")); } upap_authwithpeer(unit, ppp_settings.user, ppp_settings.passwd); auth |= PAP_WITHPEER; } #endif auth_pending[unit] = auth; if (!auth) network_phase(unit); } /* * The peer has failed to authenticate himself using `protocol'. */ void auth_peer_fail(int unit, u16_t protocol) { AUTHDEBUG((LOG_INFO, "auth_peer_fail: %d proto=%X\n", unit, protocol)); /* * Authentication failure: take the link down */ lcp_close(unit, "Authentication failed"); } #if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 /* * The peer has been successfully authenticated using `protocol'. */ void auth_peer_success(int unit, u16_t protocol, char *name, int namelen) { int pbit; AUTHDEBUG((LOG_INFO, "auth_peer_success: %d proto=%X\n", unit, protocol)); switch (protocol) { case PPP_CHAP: pbit = CHAP_PEER; break; case PPP_PAP: pbit = PAP_PEER; break; default: AUTHDEBUG((LOG_WARNING, "auth_peer_success: unknown protocol %x\n", protocol)); return; } /* * Save the authenticated name of the peer for later. */ if (namelen > sizeof(peer_authname) - 1) namelen = sizeof(peer_authname) - 1; BCOPY(name, peer_authname, namelen); peer_authname[namelen] = 0; /* * If there is no more authentication still to be done, * proceed to the network (or callback) phase. */ if ((auth_pending[unit] &= ~pbit) == 0) network_phase(unit); } /* * We have failed to authenticate ourselves to the peer using `protocol'. */ void auth_withpeer_fail(int unit, u16_t protocol) { int errCode = PPPERR_AUTHFAIL; AUTHDEBUG((LOG_INFO, "auth_withpeer_fail: %d proto=%X\n", unit, protocol)); if (passwd_from_file) BZERO(ppp_settings.passwd, MAXSECRETLEN); /* * XXX Warning: the unit number indicates the interface which is * not necessarily the PPP connection. It works here as long * as we are only supporting PPP interfaces. */ pppIOCtl(unit, PPPCTLS_ERRCODE, &errCode); /* * We've failed to authenticate ourselves to our peer. * He'll probably take the link down, and there's not much * we can do except wait for that. */ } /* * We have successfully authenticated ourselves with the peer using `protocol'. */ void auth_withpeer_success(int unit, u16_t protocol) { int pbit; AUTHDEBUG((LOG_INFO, "auth_withpeer_success: %d proto=%X\n", unit, protocol)); switch (protocol) { case PPP_CHAP: pbit = CHAP_WITHPEER; break; case PPP_PAP: if (passwd_from_file) BZERO(ppp_settings.passwd, MAXSECRETLEN); pbit = PAP_WITHPEER; break; default: AUTHDEBUG((LOG_WARNING, "auth_peer_success: unknown protocol %x\n", protocol)); pbit = 0; } /* * If there is no more authentication still being done, * proceed to the network (or callback) phase. */ if ((auth_pending[unit] &= ~pbit) == 0) network_phase(unit); } #endif /* * np_up - a network protocol has come up. */ void np_up(int unit, u16_t proto) { AUTHDEBUG((LOG_INFO, "np_up: %d proto=%X\n", unit, proto)); if (num_np_up == 0) { AUTHDEBUG((LOG_INFO, "np_up: maxconnect=%d idle_time_limit=%d\n",ppp_settings.maxconnect,ppp_settings.idle_time_limit)); /* * At this point we consider that the link has come up successfully. */ if (ppp_settings.idle_time_limit > 0) TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit); /* * Set a timeout to close the connection once the maximum * connect time has expired. */ if (ppp_settings.maxconnect > 0) TIMEOUT(connect_time_expired, 0, ppp_settings.maxconnect); } ++num_np_up; } /* * np_down - a network protocol has gone down. */ void np_down(int unit, u16_t proto) { AUTHDEBUG((LOG_INFO, "np_down: %d proto=%X\n", unit, proto)); if (--num_np_up == 0 && ppp_settings.idle_time_limit > 0) { UNTIMEOUT(check_idle, NULL); } } /* * np_finished - a network protocol has finished using the link. */ void np_finished(int unit, u16_t proto) { AUTHDEBUG((LOG_INFO, "np_finished: %d proto=%X\n", unit, proto)); if (--num_np_open <= 0) { /* no further use for the link: shut up shop. */ lcp_close(0, "No network protocols running"); } } /* * auth_reset - called when LCP is starting negotiations to recheck * authentication options, i.e. whether we have appropriate secrets * to use for authenticating ourselves and/or the peer. */ void auth_reset(int unit) { lcp_options *go = &lcp_gotoptions[unit]; lcp_options *ao = &lcp_allowoptions[0]; ipcp_options *ipwo = &ipcp_wantoptions[0]; u32_t remote; AUTHDEBUG((LOG_INFO, "auth_reset: %d\n", unit)); ao->neg_upap = !ppp_settings.refuse_pap && (ppp_settings.passwd[0] != 0 || get_pap_passwd(unit, NULL, NULL)); ao->neg_chap = !ppp_settings.refuse_chap && ppp_settings.passwd[0] != 0 /*have_chap_secret(ppp_settings.user, ppp_settings.remote_name, (u32_t)0)*/; if (go->neg_upap && !have_pap_secret()) go->neg_upap = 0; if (go->neg_chap) { remote = ipwo->accept_remote? 0: ipwo->hisaddr; if (!have_chap_secret(ppp_settings.remote_name, ppp_settings.our_name, remote)) go->neg_chap = 0; } } #if PAP_SUPPORT > 0 /* * check_passwd - Check the user name and passwd against the PAP secrets * file. If requested, also check against the system password database, * and login the user if OK. * * returns: * UPAP_AUTHNAK: Authentication failed. * UPAP_AUTHACK: Authentication succeeded. * In either case, msg points to an appropriate message. */ int check_passwd( int unit, char *auser, int userlen, char *apasswd, int passwdlen, char **msg, int *msglen ) { #if 1 *msg = (char *) 0; return UPAP_AUTHACK; /* XXX Assume all entries OK. */ #else int ret = 0; struct wordlist *addrs = NULL; char passwd[256], user[256]; char secret[MAXWORDLEN]; static u_short attempts = 0; /* * Make copies of apasswd and auser, then null-terminate them. */ BCOPY(apasswd, passwd, passwdlen); passwd[passwdlen] = '\0'; BCOPY(auser, user, userlen); user[userlen] = '\0'; *msg = (char *) 0; /* XXX Validate user name and password. */ ret = UPAP_AUTHACK; /* XXX Assume all entries OK. */ if (ret == UPAP_AUTHNAK) { if (*msg == (char *) 0) *msg = "Login incorrect"; *msglen = strlen(*msg); /* * Frustrate passwd stealer programs. * Allow 10 tries, but start backing off after 3 (stolen from login). * On 10'th, drop the connection. */ if (attempts++ >= 10) { AUTHDEBUG((LOG_WARNING, "%d LOGIN FAILURES BY %s\n", attempts, user)); /*ppp_panic("Excess Bad Logins");*/ } if (attempts > 3) { sys_msleep((attempts - 3) * 5); } if (addrs != NULL) { free_wordlist(addrs); } } else { attempts = 0; /* Reset count */ if (*msg == (char *) 0) *msg = "Login ok"; *msglen = strlen(*msg); set_allowed_addrs(unit, addrs); } BZERO(passwd, sizeof(passwd)); BZERO(secret, sizeof(secret)); return ret; #endif } #endif /* * auth_ip_addr - check whether the peer is authorized to use * a given IP address. Returns 1 if authorized, 0 otherwise. */ int auth_ip_addr(int unit, u32_t addr) { return ip_addr_check(addr, addresses[unit]); } /* * bad_ip_adrs - return 1 if the IP address is one we don't want * to use, such as an address in the loopback net or a multicast address. * addr is in network byte order. */ int bad_ip_adrs(u32_t addr) { addr = ntohl(addr); return (addr >> IN_CLASSA_NSHIFT) == IN_LOOPBACKNET || IN_MULTICAST(addr) || IN_BADCLASS(addr); } #if CHAP_SUPPORT > 0 /* * get_secret - open the CHAP secret file and return the secret * for authenticating the given client on the given server. * (We could be either client or server). */ int get_secret( int unit, char *client, char *server, char *secret, int *secret_len, int save_addrs ) { #if 1 int len; struct wordlist *addrs; addrs = NULL; if(!client || !client[0] || strcmp(client, ppp_settings.user)) { return 0; } len = strlen(ppp_settings.passwd); if (len > MAXSECRETLEN) { AUTHDEBUG((LOG_ERR, "Secret for %s on %s is too long\n", client, server)); len = MAXSECRETLEN; } BCOPY(ppp_settings.passwd, secret, len); *secret_len = len; return 1; #else int ret = 0, len; struct wordlist *addrs; char secbuf[MAXWORDLEN]; addrs = NULL; secbuf[0] = 0; /* XXX Find secret. */ if (ret < 0) return 0; if (save_addrs) set_allowed_addrs(unit, addrs); len = strlen(secbuf); if (len > MAXSECRETLEN) { AUTHDEBUG((LOG_ERR, "Secret for %s on %s is too long\n", client, server)); len = MAXSECRETLEN; } BCOPY(secbuf, secret, len); BZERO(secbuf, sizeof(secbuf)); *secret_len = len; return 1; #endif } #endif #if 0 /* UNUSED */ /* * auth_check_options - called to check authentication options. */ void auth_check_options(void) { lcp_options *wo = &lcp_wantoptions[0]; int can_auth; ipcp_options *ipwo = &ipcp_wantoptions[0]; u32_t remote; /* Default our_name to hostname, and user to our_name */ if (ppp_settings.our_name[0] == 0 || ppp_settings.usehostname) strcpy(ppp_settings.our_name, ppp_settings.hostname); if (ppp_settings.user[0] == 0) strcpy(ppp_settings.user, ppp_settings.our_name); /* If authentication is required, ask peer for CHAP or PAP. */ if (ppp_settings.auth_required && !wo->neg_chap && !wo->neg_upap) { wo->neg_chap = 1; wo->neg_upap = 1; } /* * Check whether we have appropriate secrets to use * to authenticate the peer. */ can_auth = wo->neg_upap && have_pap_secret(); if (!can_auth && wo->neg_chap) { remote = ipwo->accept_remote? 0: ipwo->hisaddr; can_auth = have_chap_secret(ppp_settings.remote_name, ppp_settings.our_name, remote); } if (ppp_settings.auth_required && !can_auth) { ppp_panic("No auth secret"); } } #endif /**********************************/ /*** LOCAL FUNCTION DEFINITIONS ***/ /**********************************/ /* * Proceed to the network phase. */ static void network_phase(int unit) { int i; struct protent *protp; lcp_options *go = &lcp_gotoptions[unit]; /* * If the peer had to authenticate, run the auth-up script now. */ if ((go->neg_chap || go->neg_upap) && !did_authup) { /* XXX Do setup for peer authentication. */ did_authup = 1; } #if CBCP_SUPPORT > 0 /* * If we negotiated callback, do it now. */ if (go->neg_cbcp) { lcp_phase[unit] = PHASE_CALLBACK; (*cbcp_protent.open)(unit); return; } #endif lcp_phase[unit] = PHASE_NETWORK; for (i = 0; (protp = ppp_protocols[i]) != NULL; ++i) if (protp->protocol < 0xC000 && protp->enabled_flag && protp->open != NULL) { (*protp->open)(unit); if (protp->protocol != PPP_CCP) ++num_np_open; } if (num_np_open == 0) /* nothing to do */ lcp_close(0, "No network protocols running"); } /* * check_idle - check whether the link has been idle for long * enough that we can shut it down. */ static void check_idle(void *arg) { struct ppp_idle idle; u_short itime; (void)arg; if (!get_idle_time(0, &idle)) return; itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); if (itime >= ppp_settings.idle_time_limit) { /* link is idle: shut it down. */ AUTHDEBUG((LOG_INFO, "Terminating connection due to lack of activity.\n")); lcp_close(0, "Link inactive"); } else { TIMEOUT(check_idle, NULL, ppp_settings.idle_time_limit - itime); } } /* * connect_time_expired - log a message and close the connection. */ static void connect_time_expired(void *arg) { (void)arg; AUTHDEBUG((LOG_INFO, "Connect time expired\n")); lcp_close(0, "Connect time expired"); /* Close connection */ } #if 0 /* * login - Check the user name and password against the system * password database, and login the user if OK. * * returns: * UPAP_AUTHNAK: Login failed. * UPAP_AUTHACK: Login succeeded. * In either case, msg points to an appropriate message. */ static int login(char *user, char *passwd, char **msg, int *msglen) { /* XXX Fail until we decide that we want to support logins. */ return (UPAP_AUTHNAK); } #endif /* * logout - Logout the user. */ static void logout(void) { logged_in = 0; } /* * null_login - Check if a username of "" and a password of "" are * acceptable, and iff so, set the list of acceptable IP addresses * and return 1. */ static int null_login(int unit) { (void)unit; /* XXX Fail until we decide that we want to support logins. */ return 0; } /* * get_pap_passwd - get a password for authenticating ourselves with * our peer using PAP. Returns 1 on success, 0 if no suitable password * could be found. */ static int get_pap_passwd(int unit, char *user, char *passwd) { /* normally we would reject PAP if no password is provided, but this causes problems with some providers (like CHT in Taiwan) who incorrectly request PAP and expect a bogus/empty password, so always provide a default user/passwd of "none"/"none" */ if(user) strcpy(user, "none"); if(passwd) strcpy(passwd, "none"); return 1; } /* * have_pap_secret - check whether we have a PAP file with any * secrets that we could possibly use for authenticating the peer. */ static int have_pap_secret(void) { /* XXX Fail until we set up our passwords. */ return 0; } /* * have_chap_secret - check whether we have a CHAP file with a * secret that we could possibly use for authenticating `client' * on `server'. Either can be the null string, meaning we don't * know the identity yet. */ static int have_chap_secret(char *client, char *server, u32_t remote) { (void)client; (void)server; (void)remote; /* XXX Fail until we set up our passwords. */ return 0; } #if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT > 0 */ /* * set_allowed_addrs() - set the list of allowed addresses. */ static void set_allowed_addrs(int unit, struct wordlist *addrs) { if (addresses[unit] != NULL) free_wordlist(addresses[unit]); addresses[unit] = addrs; #if 0 /* * If there's only one authorized address we might as well * ask our peer for that one right away */ if (addrs != NULL && addrs->next == NULL) { char *p = addrs->word; struct ipcp_options *wo = &ipcp_wantoptions[unit]; u32_t a; struct hostent *hp; if (wo->hisaddr == 0 && *p != '!' && *p != '-' && strchr(p, '/') == NULL) { hp = gethostbyname(p); if (hp != NULL && hp->h_addrtype == AF_INET) a = *(u32_t *)hp->h_addr; else a = inet_addr(p); if (a != (u32_t) -1) wo->hisaddr = a; } } #endif } #endif static int ip_addr_check(u32_t addr, struct wordlist *addrs) { /* don't allow loopback or multicast address */ if (bad_ip_adrs(addr)) return 0; if (addrs == NULL) return !ppp_settings.auth_required; /* no addresses authorized */ /* XXX All other addresses allowed. */ return 1; } #if 0 /* PAP_SUPPORT > 0 || CHAP_SUPPORT */ /* * free_wordlist - release memory allocated for a wordlist. */ static void free_wordlist(struct wordlist *wp) { struct wordlist *next; while (wp != NULL) { next = wp->next; free(wp); wp = next; } } #endif #endif /* PPP_SUPPORT */ lwipv6-1.5a/lwip-v6/src/netif/ppp/ppp.h0000644000175000017500000003561011671615006017002 0ustar renzorenzo/***************************************************************************** * ppp.h - Network Point to Point Protocol header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-11-05 Guy Lancaster , Global Election Systems Inc. * Original derived from BSD codes. *****************************************************************************/ #ifndef PPP_H #define PPP_H #include "lwip/opt.h" #if PPP_SUPPORT > 0 #include "lwip/sio.h" #include "lwip/api.h" #include "lwip/sockets.h" #include "lwip/stats.h" #include "lwip/mem.h" #include "lwip/tcpip.h" #include "lwip/netif.h" /* * pppd.h - PPP daemon global declarations. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * */ /* * ppp_defs.h - PPP definitions. * * Copyright (c) 1994 The Australian National University. * All rights reserved. * * Permission to use, copy, modify, and distribute this software and its * documentation is hereby granted, provided that the above copyright * notice appears in all copies. This software is provided without any * warranty, express or implied. The Australian National University * makes no representations about the suitability of this software for * any purpose. * * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, * OR MODIFICATIONS. */ #define TIMEOUT(f, a, t) sys_untimeout((f), (a)), sys_timeout((t)*1000, (f), (a)) #define UNTIMEOUT(f, a) sys_untimeout((f), (a)) # ifndef __u_char_defined /* Type definitions for BSD code. */ typedef unsigned long u_long; typedef unsigned int u_int; typedef unsigned short u_short; typedef unsigned char u_char; #endif /* * Constants and structures defined by the internet system, * Per RFC 790, September 1981, and numerous additions. */ /* * The basic PPP frame. */ #define PPP_HDRLEN 4 /* octets for standard ppp header */ #define PPP_FCSLEN 2 /* octets for FCS */ /* * Significant octet values. */ #define PPP_ALLSTATIONS 0xff /* All-Stations broadcast address */ #define PPP_UI 0x03 /* Unnumbered Information */ #define PPP_FLAG 0x7e /* Flag Sequence */ #define PPP_ESCAPE 0x7d /* Asynchronous Control Escape */ #define PPP_TRANS 0x20 /* Asynchronous transparency modifier */ /* * Protocol field values. */ #define PPP_IP 0x21 /* Internet Protocol */ #define PPP_AT 0x29 /* AppleTalk Protocol */ #define PPP_VJC_COMP 0x2d /* VJ compressed TCP */ #define PPP_VJC_UNCOMP 0x2f /* VJ uncompressed TCP */ #define PPP_COMP 0xfd /* compressed packet */ #define PPP_IPCP 0x8021 /* IP Control Protocol */ #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ #define PPP_CCP 0x80fd /* Compression Control Protocol */ #define PPP_LCP 0xc021 /* Link Control Protocol */ #define PPP_PAP 0xc023 /* Password Authentication Protocol */ #define PPP_LQR 0xc025 /* Link Quality Report protocol */ #define PPP_CHAP 0xc223 /* Cryptographic Handshake Auth. Protocol */ #define PPP_CBCP 0xc029 /* Callback Control Protocol */ /* * Values for FCS calculations. */ #define PPP_INITFCS 0xffff /* Initial FCS value */ #define PPP_GOODFCS 0xf0b8 /* Good final FCS value */ #define PPP_FCS(fcs, c) (((fcs) >> 8) ^ fcstab[((fcs) ^ (c)) & 0xff]) /* * Extended asyncmap - allows any character to be escaped. */ typedef u_char ext_accm[32]; /* * What to do with network protocol (NP) packets. */ enum NPmode { NPMODE_PASS, /* pass the packet through */ NPMODE_DROP, /* silently drop the packet */ NPMODE_ERROR, /* return an error */ NPMODE_QUEUE /* save it up for later. */ }; /* * Inline versions of get/put char/short/long. * Pointer is advanced; we assume that both arguments * are lvalues and will already be in registers. * cp MUST be u_char *. */ #define GETCHAR(c, cp) { \ (c) = *(cp)++; \ } #define PUTCHAR(c, cp) { \ *(cp)++ = (u_char) (c); \ } #define GETSHORT(s, cp) { \ (s) = *(cp)++ << 8; \ (s) |= *(cp)++; \ } #define PUTSHORT(s, cp) { \ *(cp)++ = (u_char) ((s) >> 8); \ *(cp)++ = (u_char) (s); \ } #define GETLONG(l, cp) { \ (l) = *(cp)++ << 8; \ (l) |= *(cp)++; (l) <<= 8; \ (l) |= *(cp)++; (l) <<= 8; \ (l) |= *(cp)++; \ } #define PUTLONG(l, cp) { \ *(cp)++ = (u_char) ((l) >> 24); \ *(cp)++ = (u_char) ((l) >> 16); \ *(cp)++ = (u_char) ((l) >> 8); \ *(cp)++ = (u_char) (l); \ } #define INCPTR(n, cp) ((cp) += (n)) #define DECPTR(n, cp) ((cp) -= (n)) #define BCMP(s0, s1, l) memcmp((u_char *)(s0), (u_char *)(s1), (l)) #define BCOPY(s, d, l) memcpy((d), (s), (l)) #define BZERO(s, n) memset(s, 0, n) #if PPP_DEBUG #define PRINTMSG(m, l) { m[l] = '\0'; ppp_trace(LOG_INFO, "Remote message: %s\n", m); } #else #define PRINTMSG(m, l) #endif /* * MAKEHEADER - Add PPP Header fields to a packet. */ #define MAKEHEADER(p, t) { \ PUTCHAR(PPP_ALLSTATIONS, p); \ PUTCHAR(PPP_UI, p); \ PUTSHORT(t, p); } /************************* *** PUBLIC DEFINITIONS *** *************************/ /* Error codes. */ #define PPPERR_NONE 0 /* No error. */ #define PPPERR_PARAM -1 /* Invalid parameter. */ #define PPPERR_OPEN -2 /* Unable to open PPP session. */ #define PPPERR_DEVICE -3 /* Invalid I/O device for PPP. */ #define PPPERR_ALLOC -4 /* Unable to allocate resources. */ #define PPPERR_USER -5 /* User interrupt. */ #define PPPERR_CONNECT -6 /* Connection lost. */ #define PPPERR_AUTHFAIL -7 /* Failed authentication challenge. */ #define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */ /* * PPP IOCTL commands. */ /* * Get the up status - 0 for down, non-zero for up. The argument must * point to an int. */ #define PPPCTLG_UPSTATUS 100 /* Get the up status - 0 down else up */ #define PPPCTLS_ERRCODE 101 /* Set the error code */ #define PPPCTLG_ERRCODE 102 /* Get the error code */ #define PPPCTLG_FD 103 /* Get the fd associated with the ppp */ /************************ *** PUBLIC DATA TYPES *** ************************/ /* * The following struct gives the addresses of procedures to call * for a particular protocol. */ struct protent { u_short protocol; /* PPP protocol number */ /* Initialization procedure */ void (*init) (int unit); /* Process a received packet */ void (*input) (int unit, u_char *pkt, int len); /* Process a received protocol-reject */ void (*protrej) (int unit); /* Lower layer has come up */ void (*lowerup) (int unit); /* Lower layer has gone down */ void (*lowerdown) (int unit); /* Open the protocol */ void (*open) (int unit); /* Close the protocol */ void (*close) (int unit, char *reason); #if 0 /* Print a packet in readable form */ int (*printpkt) (u_char *pkt, int len, void (*printer) (void *, char *, ...), void *arg); /* Process a received data packet */ void (*datainput) (int unit, u_char *pkt, int len); #endif int enabled_flag; /* 0 iff protocol is disabled */ char *name; /* Text name of protocol */ #if 0 /* Check requested options, assign defaults */ void (*check_options) (u_long); /* Configure interface for demand-dial */ int (*demand_conf) (int unit); /* Say whether to bring up link for this pkt */ int (*active_pkt) (u_char *pkt, int len); #endif }; /* * The following structure records the time in seconds since * the last NP packet was sent or received. */ struct ppp_idle { u_short xmit_idle; /* seconds since last NP packet sent */ u_short recv_idle; /* seconds since last NP packet received */ }; struct ppp_settings { u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */ u_int auth_required : 1; /* Peer is required to authenticate */ u_int explicit_remote : 1; /* remote_name specified with remotename opt */ u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */ u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */ u_int usehostname : 1; /* Use hostname for our_name */ u_int usepeerdns : 1; /* Ask peer for DNS adds */ u_short idle_time_limit; /* Shut down link if idle for this long */ int maxconnect; /* Maximum connect time (seconds) */ char user[MAXNAMELEN + 1];/* Username for PAP */ char passwd[MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */ char our_name[MAXNAMELEN + 1]; /* Our name for authentication purposes */ char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ }; struct ppp_addrs { struct ip_addr our_ipaddr, his_ipaddr, netmask, dns1, dns2; }; /***************************** *** PUBLIC DATA STRUCTURES *** *****************************/ /* Buffers for outgoing packets. */ extern u_char outpacket_buf[NUM_PPP][PPP_MRU+PPP_HDRLEN]; extern struct ppp_settings ppp_settings; extern struct protent *ppp_protocols[];/* Table of pointers to supported protocols */ /*********************** *** PUBLIC FUNCTIONS *** ***********************/ /* Initialize the PPP subsystem. */ void pppInit(void); /* Warning: Using PPPAUTHTYPE_ANY might have security consequences. * RFC 1994 says: * * In practice, within or associated with each PPP server, there is a * database which associates "user" names with authentication * information ("secrets"). It is not anticipated that a particular * named user would be authenticated by multiple methods. This would * make the user vulnerable to attacks which negotiate the least secure * method from among a set (such as PAP rather than CHAP). If the same * secret was used, PAP would reveal the secret to be used later with * CHAP. * * Instead, for each user name there should be an indication of exactly * one method used to authenticate that user name. If a user needs to * make use of different authentication methods under different * circumstances, then distinct user names SHOULD be employed, each of * which identifies exactly one authentication method. * */ enum pppAuthType { PPPAUTHTYPE_NONE, PPPAUTHTYPE_ANY, PPPAUTHTYPE_PAP, PPPAUTHTYPE_CHAP }; void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd); /* * Open a new PPP connection using the given I/O device. * This initializes the PPP control block but does not * attempt to negotiate the LCP session. * Return a new PPP connection descriptor on success or * an error code (negative) on failure. */ int pppOpen(sio_fd_t fd, void (*linkStatusCB)(void *ctx, int errCode, void *arg), void *linkStatusCtx); /* * Close a PPP connection and release the descriptor. * Any outstanding packets in the queues are dropped. * Return 0 on success, an error code on failure. */ int pppClose(int pd); /* * Indicate to the PPP process that the line has disconnected. */ void pppSigHUP(int pd); /* * Get and set parameters for the given connection. * Return 0 on success, an error code on failure. */ int pppIOCtl(int pd, int cmd, void *arg); /* * Return the Maximum Transmission Unit for the given PPP connection. */ u_int pppMTU(int pd); /* * Write n characters to a ppp link. * RETURN: >= 0 Number of characters written * -1 Failed to write to device */ int pppWrite(int pd, const u_char *s, int n); void pppMainWakeup(int pd); /* Configure i/f transmit parameters */ void ppp_send_config (int, int, u32_t, int, int); /* Set extended transmit ACCM */ void ppp_set_xaccm (int, ext_accm *); /* Configure i/f receive parameters */ void ppp_recv_config (int, int, u32_t, int, int); /* Find out how long link has been idle */ int get_idle_time (int, struct ppp_idle *); /* Configure VJ TCP header compression */ int sifvjcomp (int, int, int, int); /* Configure i/f down (for IP) */ int sifup (int); /* Set mode for handling packets for proto */ int sifnpmode (int u, int proto, enum NPmode mode); /* Configure i/f down (for IP) */ int sifdown (int); /* Configure IP addresses for i/f */ int sifaddr (int, u32_t, u32_t, u32_t, u32_t, u32_t); /* Reset i/f IP addresses */ int cifaddr (int, u32_t, u32_t); /* Create default route through i/f */ int sifdefaultroute (int, u32_t, u32_t); /* Delete default route through i/f */ int cifdefaultroute (int, u32_t, u32_t); /* Get appropriate netmask for address */ u32_t GetMask (u32_t); #endif /* PPP_SUPPORT */ #endif /* PPP_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/chap.h0000644000175000017500000001451011671615006017112 0ustar renzorenzo/***************************************************************************** * chap.h - Network Challenge Handshake Authentication Protocol header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1998 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-03 Guy Lancaster , Global Election Systems Inc. * Original built from BSD network code. ******************************************************************************/ /* * chap.h - Challenge Handshake Authentication Protocol definitions. * * Copyright (c) 1993 The Australian National University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the Australian National University. The name of the University * may not be used to endorse or promote products derived from this * software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Copyright (c) 1991 Gregory M. Christy * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the author. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * $Id: chap.h 26 2005-08-10 18:50:38Z rd235 $ */ #ifndef CHAP_H #define CHAP_H /************************* *** PUBLIC DEFINITIONS *** *************************/ /* Code + ID + length */ #define CHAP_HEADERLEN 4 /* * CHAP codes. */ #define CHAP_DIGEST_MD5 5 /* use MD5 algorithm */ #define MD5_SIGNATURE_SIZE 16 /* 16 bytes in a MD5 message digest */ #define CHAP_MICROSOFT 0x80 /* use Microsoft-compatible alg. */ #define MS_CHAP_RESPONSE_LEN 49 /* Response length for MS-CHAP */ #define CHAP_CHALLENGE 1 #define CHAP_RESPONSE 2 #define CHAP_SUCCESS 3 #define CHAP_FAILURE 4 /* * Challenge lengths (for challenges we send) and other limits. */ #define MIN_CHALLENGE_LENGTH 32 #define MAX_CHALLENGE_LENGTH 64 #define MAX_RESPONSE_LENGTH 64 /* sufficient for MD5 or MS-CHAP */ /* * Client (peer) states. */ #define CHAPCS_INITIAL 0 /* Lower layer down, not opened */ #define CHAPCS_CLOSED 1 /* Lower layer up, not opened */ #define CHAPCS_PENDING 2 /* Auth us to peer when lower up */ #define CHAPCS_LISTEN 3 /* Listening for a challenge */ #define CHAPCS_RESPONSE 4 /* Sent response, waiting for status */ #define CHAPCS_OPEN 5 /* We've received Success */ /* * Server (authenticator) states. */ #define CHAPSS_INITIAL 0 /* Lower layer down, not opened */ #define CHAPSS_CLOSED 1 /* Lower layer up, not opened */ #define CHAPSS_PENDING 2 /* Auth peer when lower up */ #define CHAPSS_INITIAL_CHAL 3 /* We've sent the first challenge */ #define CHAPSS_OPEN 4 /* We've sent a Success msg */ #define CHAPSS_RECHALLENGE 5 /* We've sent another challenge */ #define CHAPSS_BADAUTH 6 /* We've sent a Failure msg */ /************************ *** PUBLIC DATA TYPES *** ************************/ /* * Each interface is described by a chap structure. */ typedef struct chap_state { int unit; /* Interface unit number */ int clientstate; /* Client state */ int serverstate; /* Server state */ u_char challenge[MAX_CHALLENGE_LENGTH]; /* last challenge string sent */ u_char chal_len; /* challenge length */ u_char chal_id; /* ID of last challenge */ u_char chal_type; /* hash algorithm for challenges */ u_char id; /* Current id */ char *chal_name; /* Our name to use with challenge */ int chal_interval; /* Time until we challenge peer again */ int timeouttime; /* Timeout time in seconds */ int max_transmits; /* Maximum # of challenge transmissions */ int chal_transmits; /* Number of transmissions of challenge */ int resp_transmits; /* Number of transmissions of response */ u_char response[MAX_RESPONSE_LENGTH]; /* Response to send */ u_char resp_length; /* length of response */ u_char resp_id; /* ID for response messages */ u_char resp_type; /* hash algorithm for responses */ char *resp_name; /* Our name to send with response */ } chap_state; /****************** *** PUBLIC DATA *** ******************/ extern chap_state chap[]; extern struct protent chap_protent; /*********************** *** PUBLIC FUNCTIONS *** ***********************/ void ChapAuthWithPeer (int, char *, int); void ChapAuthPeer (int, char *, int); #endif /* CHAP_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/vj.h0000644000175000017500000001366411671615006016627 0ustar renzorenzo/* * Definitions for tcp compression routines. * * $Id: vj.h 26 2005-08-10 18:50:38Z rd235 $ * * Copyright (c) 1989 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by the University of California, Berkeley. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Van Jacobson (van@helios.ee.lbl.gov), Dec 31, 1989: * - Initial distribution. */ #ifndef VJ_H #define VJ_H #include "vjbsdhdr.h" #define MAX_SLOTS 16 /* must be > 2 and < 256 */ #define MAX_HDR 128 /* * Compressed packet format: * * The first octet contains the packet type (top 3 bits), TCP * 'push' bit, and flags that indicate which of the 4 TCP sequence * numbers have changed (bottom 5 bits). The next octet is a * conversation number that associates a saved IP/TCP header with * the compressed packet. The next two octets are the TCP checksum * from the original datagram. The next 0 to 15 octets are * sequence number changes, one change per bit set in the header * (there may be no changes and there are two special cases where * the receiver implicitly knows what changed -- see below). * * There are 5 numbers which can change (they are always inserted * in the following order): TCP urgent pointer, window, * acknowlegement, sequence number and IP ID. (The urgent pointer * is different from the others in that its value is sent, not the * change in value.) Since typical use of SLIP links is biased * toward small packets (see comments on MTU/MSS below), changes * use a variable length coding with one octet for numbers in the * range 1 - 255 and 3 octets (0, MSB, LSB) for numbers in the * range 256 - 65535 or 0. (If the change in sequence number or * ack is more than 65535, an uncompressed packet is sent.) */ /* * Packet types (must not conflict with IP protocol version) * * The top nibble of the first octet is the packet type. There are * three possible types: IP (not proto TCP or tcp with one of the * control flags set); uncompressed TCP (a normal IP/TCP packet but * with the 8-bit protocol field replaced by an 8-bit connection id -- * this type of packet syncs the sender & receiver); and compressed * TCP (described above). * * LSB of 4-bit field is TCP "PUSH" bit (a worthless anachronism) and * is logically part of the 4-bit "changes" field that follows. Top * three bits are actual packet type. For backward compatibility * and in the interest of conserving bits, numbers are chosen so the * IP protocol version number (4) which normally appears in this nibble * means "IP packet". */ /* packet types */ #define TYPE_IP 0x40 #define TYPE_UNCOMPRESSED_TCP 0x70 #define TYPE_COMPRESSED_TCP 0x80 #define TYPE_ERROR 0x00 /* Bits in first octet of compressed packet */ #define NEW_C 0x40 /* flag bits for what changed in a packet */ #define NEW_I 0x20 #define NEW_S 0x08 #define NEW_A 0x04 #define NEW_W 0x02 #define NEW_U 0x01 /* reserved, special-case values of above */ #define SPECIAL_I (NEW_S|NEW_W|NEW_U) /* echoed interactive traffic */ #define SPECIAL_D (NEW_S|NEW_A|NEW_W|NEW_U) /* unidirectional data */ #define SPECIALS_MASK (NEW_S|NEW_A|NEW_W|NEW_U) #define TCP_PUSH_BIT 0x10 /* * "state" data for each active tcp conversation on the wire. This is * basically a copy of the entire IP/TCP header from the last packet * we saw from the conversation together with a small identifier * the transmit & receive ends of the line use to locate saved header. */ struct cstate { struct cstate *cs_next; /* next most recently used state (xmit only) */ u_short cs_hlen; /* size of hdr (receive only) */ u_char cs_id; /* connection # associated with this state */ u_char cs_filler; union { char csu_hdr[MAX_HDR]; struct ip csu_ip; /* ip/tcp hdr from most recent packet */ } vjcs_u; }; #define cs_ip vjcs_u.csu_ip #define cs_hdr vjcs_u.csu_hdr struct vjstat { unsigned long vjs_packets; /* outbound packets */ unsigned long vjs_compressed; /* outbound compressed packets */ unsigned long vjs_searches; /* searches for connection state */ unsigned long vjs_misses; /* times couldn't find conn. state */ unsigned long vjs_uncompressedin; /* inbound uncompressed packets */ unsigned long vjs_compressedin; /* inbound compressed packets */ unsigned long vjs_errorin; /* inbound unknown type packets */ unsigned long vjs_tossed; /* inbound packets tossed because of error */ }; /* * all the state data for one serial line (we need one of these per line). */ struct vjcompress { struct cstate *last_cs; /* most recently used tstate */ u_char last_recv; /* last rcvd conn. id */ u_char last_xmit; /* last sent conn. id */ u_short flags; u_char maxSlotIndex; u_char compressSlot; /* Flag indicating OK to compress slot ID. */ #if LINK_STATS struct vjstat stats; #endif struct cstate tstate[MAX_SLOTS]; /* xmit connection states */ struct cstate rstate[MAX_SLOTS]; /* receive connection states */ }; /* flag values */ #define VJF_TOSS 1U /* tossing rcvd frames because of input err */ extern void vj_compress_init (struct vjcompress *comp); extern u_int vj_compress_tcp (struct vjcompress *comp, struct pbuf *pb); extern void vj_uncompress_err (struct vjcompress *comp); extern int vj_uncompress_uncomp(struct pbuf *nb, struct vjcompress *comp); extern int vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp); #endif /* VJ_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/auth.h0000644000175000017500000000770011671615006017143 0ustar renzorenzo/***************************************************************************** * auth.h - PPP Authentication and phase control header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1998 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-04 Guy Lancaster , Global Election Systems Inc. * Original derived from BSD pppd.h. *****************************************************************************/ /* * pppd.h - PPP daemon global declarations. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * */ #ifndef AUTH_H #define AUTH_H /*********************** *** PUBLIC FUNCTIONS *** ***********************/ void link_required (int); /* we are starting to use the link */ void link_terminated (int); /* we are finished with the link */ void link_down (int); /* the LCP layer has left the Opened state */ void link_established (int); /* the link is up; authenticate now */ void np_up (int, u16_t); /* a network protocol has come up */ void np_down (int, u16_t); /* a network protocol has gone down */ void np_finished (int, u16_t); /* a network protocol no longer needs link */ void auth_peer_fail (int, u16_t);/* peer failed to authenticate itself */ /* peer successfully authenticated itself */ void auth_peer_success (int, u16_t, char *, int); /* we failed to authenticate ourselves */ void auth_withpeer_fail (int, u16_t); /* we successfully authenticated ourselves */ void auth_withpeer_success (int, u16_t); /* check authentication options supplied */ void auth_check_options (void); void auth_reset (int); /* check what secrets we have */ /* Check peer-supplied username/password */ int check_passwd (int, char *, int, char *, int, char **, int *); /* get "secret" for chap */ int get_secret (int, char *, char *, char *, int *, int); /* check if IP address is authorized */ int auth_ip_addr (int, u32_t); /* check if IP address is unreasonable */ int bad_ip_adrs (u32_t); #endif /* AUTH_H */ lwipv6-1.5a/lwip-v6/src/netif/ppp/pap.h0000644000175000017500000001136211671615006016761 0ustar renzorenzo/***************************************************************************** * pap.h - PPP Password Authentication Protocol header file. * * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. * portions Copyright (c) 1997 Global Election Systems Inc. * * The authors hereby grant permission to use, copy, modify, distribute, * and license this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice and the following disclaimer are included verbatim in any * distributions. No written agreement, license, or royalty fee is required * for any of the authorized uses. * * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** * REVISION HISTORY * * 03-01-01 Marc Boucher * Ported to lwIP. * 97-12-04 Guy Lancaster , Global Election Systems Inc. * Original derived from BSD codes. *****************************************************************************/ /* * upap.h - User/Password Authentication Protocol definitions. * * Copyright (c) 1989 Carnegie Mellon University. * All rights reserved. * * Redistribution and use in source and binary forms are permitted * provided that the above copyright notice and this paragraph are * duplicated in all such forms and that any documentation, * advertising materials, and other materials related to such * distribution and use acknowledge that the software was developed * by Carnegie Mellon University. The name of the * University may not be used to endorse or promote products derived * from this software without specific prior written permission. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef PAP_H #define PAP_H /************************* *** PUBLIC DEFINITIONS *** *************************/ /* * Packet header = Code, id, length. */ #define UPAP_HEADERLEN (sizeof (u_char) + sizeof (u_char) + sizeof (u_short)) /* * UPAP codes. */ #define UPAP_AUTHREQ 1 /* Authenticate-Request */ #define UPAP_AUTHACK 2 /* Authenticate-Ack */ #define UPAP_AUTHNAK 3 /* Authenticate-Nak */ /* * Client states. */ #define UPAPCS_INITIAL 0 /* Connection down */ #define UPAPCS_CLOSED 1 /* Connection up, haven't requested auth */ #define UPAPCS_PENDING 2 /* Connection down, have requested auth */ #define UPAPCS_AUTHREQ 3 /* We've sent an Authenticate-Request */ #define UPAPCS_OPEN 4 /* We've received an Ack */ #define UPAPCS_BADAUTH 5 /* We've received a Nak */ /* * Server states. */ #define UPAPSS_INITIAL 0 /* Connection down */ #define UPAPSS_CLOSED 1 /* Connection up, haven't requested auth */ #define UPAPSS_PENDING 2 /* Connection down, have requested auth */ #define UPAPSS_LISTEN 3 /* Listening for an Authenticate */ #define UPAPSS_OPEN 4 /* We've sent an Ack */ #define UPAPSS_BADAUTH 5 /* We've sent a Nak */ /************************ *** PUBLIC DATA TYPES *** ************************/ /* * Each interface is described by upap structure. */ typedef struct upap_state { int us_unit; /* Interface unit number */ const char *us_user; /* User */ int us_userlen; /* User length */ const char *us_passwd; /* Password */ int us_passwdlen; /* Password length */ int us_clientstate; /* Client state */ int us_serverstate; /* Server state */ u_char us_id; /* Current id */ int us_timeouttime; /* Timeout (seconds) for auth-req retrans. */ int us_transmits; /* Number of auth-reqs sent */ int us_maxtransmits; /* Maximum number of auth-reqs to send */ int us_reqtimeout; /* Time to wait for auth-req from peer */ } upap_state; /*********************** *** PUBLIC FUNCTIONS *** ***********************/ extern upap_state upap[]; void upap_setloginpasswd(int unit, const char *luser, const char *lpassword); void upap_authwithpeer (int, char *, char *); void upap_authpeer (int); extern struct protent pap_protent; #endif /* PAP_H */ lwipv6-1.5a/lwip-v6/src/netif/slipif.c0000644000175000017500000001231611671615007016664 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * This file is built upon the file: src/arch/rtxc/netif/sioslip.c * * Author: Magnus Ivarsson */ /* * This is an arch independent SLIP netif. The specific serial hooks must be provided * by another file.They are sio_open, sio_recv and sio_send */ #include "netif/slipif.h" #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include "lwip/stats.h" #include "lwip/sio.h" #define SLIP_END 0300 #define SLIP_ESC 0333 #define SLIP_ESC_END 0334 #define SLIP_ESC_ESC 0335 #define MAX_SIZE 1500 /** * Send a pbuf doing the necessary SLIP encapsulation * * Uses the serial layer's sio_send() */ err_t slipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { struct pbuf *q; int i; u8_t c; /* Send pbuf out on the serial I/O device. */ sio_send(SLIP_END, netif->state); for(q = p; q != NULL; q = q->next) { for(i = 0; i < q->len; i++) { c = ((u8_t *)q->payload)[i]; switch (c) { case SLIP_END: sio_send(SLIP_ESC, netif->state); sio_send(SLIP_ESC_END, netif->state); break; case SLIP_ESC: sio_send(SLIP_ESC, netif->state); sio_send(SLIP_ESC_ESC, netif->state); break; default: sio_send(c, netif->state); break; } } } sio_send(SLIP_END, netif->state); return 0; } /** * Handle the incoming SLIP stream character by character * * Poll the serial layer by calling sio_recv() * * @return The IP packet when SLIP_END is received */ static struct pbuf * slipif_input( struct netif * netif ) { u8_t c; struct pbuf *p, *q; int recved; int i; q = p = NULL; recved = i = 0; c = 0; while (1) { c = sio_recv(netif->state); switch (c) { case SLIP_END: if (recved > 0) { /* Received whole packet. */ pbuf_realloc(q, recved); LINK_STATS_INC(link.recv); LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n")); return q; } break; case SLIP_ESC: c = sio_recv(netif->state); switch (c) { case SLIP_ESC_END: c = SLIP_END; break; case SLIP_ESC_ESC: c = SLIP_ESC; break; } /* FALLTHROUGH */ default: if (p == NULL) { LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n")); p = pbuf_alloc(PBUF_LINK, PBUF_POOL_BUFSIZE, PBUF_POOL); if (p == NULL) { LINK_STATS_INC(link.drop); LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n")); } if (q != NULL) { pbuf_cat(q, p); } else { q = p; } } if (p != NULL && recved < MAX_SIZE) { ((u8_t *)p->payload)[i] = c; recved++; i++; if (i >= p->len) { i = 0; if (p->next != NULL && p->next->len > 0) p = p->next; else p = NULL; } } break; } } return NULL; } /** * The SLIP input thread * * Feed the IP layer with incoming packets */ static void slipif_loop(void *nf) { struct pbuf *p; struct netif *netif = (struct netif *)nf; while (1) { p = slipif_input(netif); netif->input(p, netif); } } /** * SLIP netif initialization * * Call the arch specific sio_open and remember * the opened device in the state field of the netif. */ err_t slipif_init(struct netif *netif) { netif->name[0] = 's'; netif->name[1] = 'l'; netif->link_type = NETIF_SLIPIF; netif->num = netif_next_num(netif,NETIF_SLIPIF); LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%x\n", (int)netif->num)); netif->output = slipif_output; netif->mtu = 1500; netif->flags = NETIF_FLAG_POINTTOPOINT; netif->state = sio_open(netif->num); if (!netif->state) return ERR_IF; sys_thread_new(slipif_loop, netif, SLIPIF_THREAD_PRIO); return ERR_OK; } lwipv6-1.5a/lwip-v6/src/netif/etharp.c0000644000175000017500000011507011671615007016662 0ustar renzorenzo/** * @file * Address Resolution Protocol module for IP over Ethernet * * Functionally, ARP is divided into two parts. The first maps an IP address * to a physical address when sending a packet, and the second part answers * requests from other machines for our physical address. * * This implementation complies with RFC 826 (Ethernet ARP). It supports * Gratuitious ARP from RFC3220 (IP Mobility Support for IPv4) section 4.6 * if an interface calls etharp_query(our_netif, its_ip_addr, NULL) upon * address change. */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * Copyright (c) 2003-2004 Leon Woestenberg * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * */ #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/inet.h" #include "netif/etharp.h" #include "lwip/ip.h" #include "lwip/stats.h" #include "lwip/icmp.h" /* ARP needs to inform DHCP of any ARP replies? */ #if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) #include "lwip/dhcp.h" #endif /** the time an ARP entry stays valid after its last update, * (240 * 5) seconds = 20 minutes. */ //#define ARP_MAXAGE 240 /** the time an ARP entry stays valid after its last update, * (6 * 5) seconds = 0.5 minutes. */ #define ARP_MAXAGE 6 /** the time an ARP entry stays pending after first request, * (2 * 5) seconds = 10 seconds. * * @internal Keep this number at least 2, otherwise it might * run out instantly if the timeout occurs directly after a request. */ #define ARP_MAXPENDING 2 #define HWTYPE_ETHERNET 1 /** ARP message types */ #define ARP_REQUEST 1 #define ARP_REPLY 2 #define ARPH_HWLEN(hdr) (ntohs((hdr)->_hwlen_protolen) >> 8) #define ARPH_PROTOLEN(hdr) (ntohs((hdr)->_hwlen_protolen) & 0xff) #define ARPH_HWLEN_SET(hdr, len) (hdr)->_hwlen_protolen = htons(ARPH_PROTOLEN(hdr) | ((len) << 8)) #define ARPH_PROTOLEN_SET(hdr, len) (hdr)->_hwlen_protolen = htons((len) | (ARPH_HWLEN(hdr) << 8)) #define LINKOUTPUT(N,P) ({ \ ETH_CHECK_PACKET_OUT((N),(P)); \ (N)->linkoutput((N),(P)); \ }) enum etharp_state { ETHARP_STATE_EMPTY=0, ETHARP_STATE_PENDING, /** @internal transitional state used in etharp_tmr() for convenience*/ ETHARP_STATE_EXPIRED, ETHARP_STATE_STABLE, ETHARP_STATE_PERMANENT }; struct etharp_entry { #if ARP_QUEUEING /** * Pointer to queue of pending outgoing packets on this ARP entry. */ struct pbuf *p; #endif struct ip_addr ipaddr; struct eth_addr ethaddr; enum etharp_state state; u8_t ctime; u8_t if_id; }; static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}; static struct etharp_entry arp_table[ARP_TABLE_SIZE]; #define ARP_INSERT_FLAG 1 /** * Try hard to create a new entry - we want the IP address to appear in * the cache (even if this means removing an active entry or so). */ #define ETHARP_TRY_HARD 0x80000000 static s8_t find_entry(struct ip_addr *ipaddr, u32_t flags); err_t update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u32_t flags); /** * Initializes ARP module. */ void etharp_init(void) { /* global vars are zeroed by definition */ #if 0 u8_t i; /* clear ARP entries */ for(i = 0; i < ARP_TABLE_SIZE; ++i) { arp_table[i].state = ETHARP_STATE_EMPTY; #if ARP_QUEUEING arp_table[i].p = NULL; #endif arp_table[i].ctime = 0; } #endif } /** * Clears expired entries in the ARP table. * * This function should be called every ETHARP_TMR_INTERVAL microseconds (5 seconds), * in order to expire entries in the ARP table. */ void etharp_tmr(struct netif *netif) { u8_t i; LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer\n")); /* remove expired entries from the ARP table */ for (i = 0; i < ARP_TABLE_SIZE; ++i) { if (arp_table[i].if_id == netif->id) { arp_table[i].ctime++; /* stable entry? */ if ((arp_table[i].state == ETHARP_STATE_STABLE) && /* entry has become old? */ (arp_table[i].ctime >= ARP_MAXAGE)) { LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired stable entry %u.\n", i)); arp_table[i].state = ETHARP_STATE_EXPIRED; /* pending entry? */ } else if (arp_table[i].state == ETHARP_STATE_PENDING) { /* entry unresolved/pending for too long? */ if (arp_table[i].ctime >= ARP_MAXPENDING) { LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %u.\n", i)); arp_table[i].state = ETHARP_STATE_EXPIRED; #if ARP_QUEUEING } else if (arp_table[i].p != NULL) { /* resend an ARP query here */ #endif } } /* clean up entries that have just been expired */ if (arp_table[i].state == ETHARP_STATE_EXPIRED) { #if ARP_QUEUEING /* and empty packet queue */ if (arp_table[i].p != NULL) { /* remove all queued packets */ LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing entry %u, packet queue %p.\n", i, (void *)(arp_table[i].p))); pbuf_free(arp_table[i].p); arp_table[i].p = NULL; } #endif /* recycle entry for re-use */ arp_table[i].state = ETHARP_STATE_EMPTY; } } } } /** * Search the ARP table for a matching or new entry. * * If an IP address is given, return a pending or stable ARP entry that matches * the address. If no match is found, create a new entry with this address set, * but in state ETHARP_EMPTY. The caller must check and possibly change the * state of the returned entry. * * If ipaddr is NULL, return a initialized new entry in state ETHARP_EMPTY. * * In all cases, attempt to create new entries from an empty entry. If no * empty entries are available and ETHARP_TRY_HARD flag is set, recycle * old entries. Heuristic choose the least important entry for recycling. * * @param ipaddr IP address to find in ARP cache, or to add if not found. * @param flags * - ETHARP_TRY_HARD: Try hard to create a entry by allowing recycling of * active (stable or pending) entries. * * @return The ARP entry index that matched or is created, ERR_MEM if no * entry is found or could be recycled. */ static s8_t find_entry(struct ip_addr *ipaddr, u32_t flags) { s8_t old_pending = ARP_TABLE_SIZE, old_stable = ARP_TABLE_SIZE; s8_t empty = ARP_TABLE_SIZE; u8_t i = 0, age_pending = 0, age_stable = 0; #if ARP_QUEUEING /* oldest entry with packets on queue */ s8_t old_queue = ARP_TABLE_SIZE; /* its age */ u8_t age_queue = 0; #endif /** * a) do a search through the cache, remember candidates * b) select candidate entry * c) create new entry */ /* a) in a single search sweep, do all of this * 1) remember the first empty entry (if any) * 2) remember the oldest stable entry (if any) * 3) remember the oldest pending entry without queued packets (if any) * 4) remember the oldest pending entry with queued packets (if any) * 5) search for a matching IP entry, either pending or stable * until 5 matches, or all entries are searched for. */ for (i = 0; i < ARP_TABLE_SIZE; ++i) { /* no empty entry found yet and now we do find one? */ if ((empty == ARP_TABLE_SIZE) && (arp_table[i].state == ETHARP_STATE_EMPTY)) { LWIP_DEBUGF(ETHARP_DEBUG, ("find_entry: found empty entry %d\n", i)); /* remember first empty entry */ empty = i; } /* pending entry? */ else if (arp_table[i].state == ETHARP_STATE_PENDING) { /* if given, does IP address match IP address in ARP entry? */ if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching pending entry %d\n", i)); /* found exact IP address match, simply bail out */ return i; #if ARP_QUEUEING /* pending with queued packets? */ } else if (arp_table[i].p != NULL) { if (arp_table[i].ctime >= age_queue) { old_queue = i; age_queue = arp_table[i].ctime; } #endif /* pending without queued packets? */ } else { if (arp_table[i].ctime >= age_pending) { old_pending = i; age_pending = arp_table[i].ctime; } } } /* stable/permanent entry? */ else if (arp_table[i].state >= ETHARP_STATE_STABLE) { /* if given, does IP address match IP address in ARP entry? */ if (ipaddr && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: found matching stable entry %d\n", i)); /* found exact IP address match, simply bail out */ return i; /* remember entry with oldest stable entry in oldest, its age in maxtime */ } else if (arp_table[i].state == ETHARP_STATE_STABLE && arp_table[i].ctime >= age_stable) { old_stable = i; age_stable = arp_table[i].ctime; } } } /* { we have no match } => try to create a new entry */ /* no empty entry found and not allowed to recycle? */ if ((empty == ARP_TABLE_SIZE) && ((flags & ETHARP_TRY_HARD) == 0)) { return (s8_t)ERR_MEM; } /* b) choose the least destructive entry to recycle: * 1) empty entry * 2) oldest stable entry * 3) oldest pending entry without queued packets * 4) oldest pending entry without queued packets * * { ETHARP_TRY_HARD is set at this point } */ /* 1) empty entry available? */ if (empty < ARP_TABLE_SIZE) { i = empty; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting empty entry %d\n", i)); } /* 2) found recyclable stable entry? */ else if (old_stable < ARP_TABLE_SIZE) { /* recycle oldest stable*/ i = old_stable; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest stable entry %d\n", i)); #if ARP_QUEUEING /* no queued packets should exist on stable entries */ LWIP_ASSERT("arp_table[i].p == NULL", arp_table[i].p == NULL); #endif /* 3) found recyclable pending entry without queued packets? */ } else if (old_pending < ARP_TABLE_SIZE) { /* recycle oldest pending */ i = old_pending; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %d (without queue)\n", i)); #if ARP_QUEUEING /* 4) found recyclable pending entry with queued packets? */ } else if (old_queue < ARP_TABLE_SIZE) { /* recycle oldest pending */ i = old_queue; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("find_entry: selecting oldest pending entry %d, freeing packet queue %p\n", i, (void *)(arp_table[i].p))); pbuf_free(arp_table[i].p); arp_table[i].p = NULL; #endif /* no empty or recyclable entries found */ } else { return (s8_t)ERR_MEM; } /* { empty or recyclable entry found } */ LWIP_ASSERT("i < ARP_TABLE_SIZE", i < ARP_TABLE_SIZE); /* recycle entry (no-op for an already empty entry) */ arp_table[i].state = ETHARP_STATE_EMPTY; /* IP address given? */ if (ipaddr != NULL) { /* set IP address */ ip_addr_set(&arp_table[i].ipaddr, ipaddr); } arp_table[i].ctime = 0; return (err_t)i; } /** * Update (or insert) a IP/MAC address pair in the ARP cache. * * If a pending entry is resolved, any queued packets will be sent * at this point. * * @param ipaddr IP address of the inserted ARP entry. * @param ethaddr Ethernet address of the inserted ARP entry. * @param flags Defines behaviour: * - ETHARP_TRY_HARD Allows ARP to insert this as a new item. If not specified, * only existing ARP entries will be updated. * * @return * - ERR_OK Succesfully updated ARP cache. * - ERR_MEM If we could not add a new ARP entry when ETHARP_TRY_HARD was set. * - ERR_ARG Non-unicast address given, those will not appear in ARP cache. * * @see pbuf_free() */ err_t update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u32_t flags) { s8_t i, k; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n")); LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %lu.%lu.%lu.%lu - %02x:%02x:%02x:%02x:%02x:%02x\n", ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr), ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5])); /* non-unicast address? */ /* XXX XXX XXX broadcast control on netif!*/ if (ip_addr_isany(ipaddr) || /*ip_addr_is_v4broadcast(ipaddr, &(al->ipaddr), &(al->netmask)) ||*/ ip_addr_ismulticast(ipaddr)) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: will not add non-unicast IP address to ARP cache\n")); return ERR_ARG; } /* find or create ARP entry */ i = find_entry(ipaddr, flags); /* bail out if no entry could be found */ if (i < 0) return (err_t)i; /* mark it stable */ arp_table[i].state = (flags & ATF_PERM)?ETHARP_STATE_PERMANENT:ETHARP_STATE_STABLE; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating %s entry %u\n", (flags & ATF_PERM)?"permanent":"stable",i)); //printf("%lx %lx %lx %lx\n",ipaddr->addr[0],ipaddr->addr[1],ipaddr->addr[2],ipaddr->addr[3]); /* update address */ for (k = 0; k < netif->hwaddr_len; ++k) { arp_table[i].ethaddr.addr[k] = ethaddr->addr[k]; } arp_table[i].if_id=netif->id; /* reset time stamp */ arp_table[i].ctime = 0; /* this is where we will send out queued packets! */ #if ARP_QUEUEING while (arp_table[i].p != NULL) { /* get the first packet on the queue */ struct pbuf *p = arp_table[i].p; /* Ethernet header */ struct eth_hdr *ethhdr = p->payload; /* remember (and reference) remainder of queue */ /* note: this will also terminate the p pbuf chain */ arp_table[i].p = pbuf_dequeue(p); /* fill-in Ethernet header */ for (k = 0; k < netif->hwaddr_len; ++k) { ethhdr->dest.addr[k] = ethaddr->addr[k]; ethhdr->src.addr[k] = netif->hwaddr[k]; } // Fix by Renzo Davoli // ethhdr->type = htons(ETHTYPE_IP); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: sending queued IP packet %p.\n", (void *)p)); /* send the queued IP packet */ LINKOUTPUT(netif, p); /* free the queued IP packet */ pbuf_free(p); } #endif return ERR_OK; } /** * Updates the ARP table using the given IP packet. * * Uses the incoming IP packet's source address to update the * ARP cache for the local network. The function does not alter * or free the packet. This function must be called before the * packet p is passed to the IP layer. * * @param netif The lwIP network interface on which the IP packet pbuf arrived. * @param pbuf The IP packet that arrived on netif. * * @return NULL * * @see pbuf_free() */ static void etharp_ip4_input(struct netif *netif, struct pbuf *p) { struct ethip4_hdr *hdr; struct ip_addr src4; /* Only insert an entry if the source IP address of the incoming IP packet comes from a host on the local network. */ hdr = p->payload; IP64_CONV(&src4,&(hdr->ip.src)); if (!ip_addr_list_maskfind(netif->addrs, &(src4))) { /* do nothing */ return; } LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_ip4_input: updating ETHARP table.\n")); /* update ARP table, ask to insert entry */ update_arp_entry(netif, &(src4), &(hdr->eth.src), ARP_INSERT_FLAG); return; } void etharp_ip_input(struct netif *netif, struct pbuf *p) { struct ethip_hdr *hdr; LWIP_ASSERT("netif != NULL", netif != NULL); /* Only insert an entry if the source IP address of the incoming IP packet comes from a host on the local network. */ hdr = p->payload; if (hdr->eth.type == ETHTYPE_IP) etharp_ip4_input(netif,p); if (!ip_addr_list_maskfind(netif->addrs, &(hdr->ip.src))) { /* do nothing */ return; } LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n")); /* update ARP table */ /* @todo We could use ETHARP_TRY_HARD if we think we are going to talk * back soon (for example, if the destination IP address is ours. */ update_arp_entry(netif, &(hdr->ip.src), &(hdr->eth.src), ARP_INSERT_FLAG); } /** * Responds to ARP requests to us. Upon ARP replies to us, add entry to cache * send out queued IP packets. Updates cache with snooped address pairs. * * Should be called for incoming ARP packets. The pbuf in the argument * is freed by this function. * * @param netif The lwIP network interface on which the ARP packet pbuf arrived. * @param pbuf The ARP packet that arrived on netif. Is freed by this function. * @param ethaddr Ethernet address of netif. * * @return NULL * * @see pbuf_free() */ void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p) { struct etharp_hdr *hdr; /* these are aligned properly, whereas the ARP header fields might not be */ struct ip_addr_list *el; struct ip_addr v4dipaddr,v4sipaddr; u8_t i; LWIP_ASSERT("netif != NULL", netif != NULL); /* drop short ARP packets */ if (p->tot_len < sizeof(struct etharp_hdr)) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet dropped, too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr))); pbuf_free(p); return; } hdr = p->payload; IP64_CONV(&v4dipaddr,&(hdr->dipaddr)); IP64_CONV(&v4sipaddr,&(hdr->sipaddr)); el= ip_addr_list_find(netif->addrs,&v4dipaddr,NULL); /* ARP message directed to us? */ if (el != NULL) { /* add IP address in ARP cache; assume requester wants to talk to us. * can result in directly sending the queued packets for this host. */ update_arp_entry(netif, &v4sipaddr, &(hdr->shwaddr), ETHARP_TRY_HARD); /* ARP message not directed to us? */ } else { /* update the source IP address in the cache, if present */ update_arp_entry(netif, &v4sipaddr, &(hdr->shwaddr), 0); } /* now act on the message itself */ switch (htons(hdr->opcode)) { /* ARP request? */ case ARP_REQUEST: /* ARP request. If it asked for our address, we send out a * reply. In any case, we time-stamp any existing ARP entry, * and possiby send out an IP packet that was queued on it. */ LWIP_DEBUGF (ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request\n")); /* ARP request for our address? */ if (el != NULL) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n")); /* re-use pbuf to send ARP reply */ hdr->opcode = htons(ARP_REPLY); /*hdr->dipaddr = hdr->sipaddr; hdr->sipaddr = *(struct ip_addr2 *)&netif->ip_addr;*/ ip4_addr_set(&(hdr->dipaddr), &(hdr->sipaddr)); ip64_addr_set(&(hdr->sipaddr), &(el->ipaddr)); for(i = 0; i < netif->hwaddr_len; ++i) { hdr->dhwaddr.addr[i] = hdr->shwaddr.addr[i]; hdr->shwaddr.addr[i] = ethaddr->addr[i]; hdr->ethhdr.dest.addr[i] = hdr->dhwaddr.addr[i]; hdr->ethhdr.src.addr[i] = ethaddr->addr[i]; } hdr->hwtype = htons(HWTYPE_ETHERNET); ARPH_HWLEN_SET(hdr, netif->hwaddr_len); hdr->proto = htons(ETHTYPE_IP); ARPH_PROTOLEN_SET(hdr, sizeof(struct ip4_addr)); hdr->ethhdr.type = htons(ETHTYPE_ARP); /* return ARP reply */ LINKOUTPUT(netif, p); /* we are not configured? */ } #if 0 else if (netif->ip_addr.addr == 0) { /* { for_us == 0 and netif->ip_addr.addr == 0 } */ LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n")); /* request was not directed to us */ } #endif else { /* { for_us == 0 and netif->ip_addr.addr != 0 } */ LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP request was not for us.\n")); } break; case ARP_REPLY: /* ARP reply. We already updated the ARP cache earlier. */ LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n")); #if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) /* DHCP wants to know about ARP replies from any host with an * IP address also offered to us by the DHCP server. We do not * want to take a duplicate IP address on a single network. * @todo How should we handle redundant (fail-over) interfaces? * */ ///dhcp_arp_reply(netif, &sipaddr); dhcp_arp_reply(netif, (struct ip4_addr *) &(hdr->sipaddr)); #endif break; default: LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode))); break; } /* free ARP packet */ pbuf_free(p); } /** * Resolve and fill-in Ethernet address header for outgoing packet. * * For IP multicast and broadcast, corresponding Ethernet addresses * are selected and the packet is transmitted on the link. * * For unicast addresses, the packet is submitted to etharp_query(). In * case the IP address is outside the local network, the IP address of * the gateway is used. * * @param netif The lwIP network interface which the IP packet will be sent on. * @param ipaddr The IP address of the packet destination. * @param pbuf The pbuf(s) containing the IP packet to be sent. * * @return * - ERR_RTE No route to destination (no gateway to external networks), * or the return type of either etharp_query() or netif->linkoutput(). */ err_t etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q) { struct eth_addr *dest, *srcaddr, mcastaddr; struct ip_addr_list *al; struct eth_hdr *ethhdr; u8_t i; /* make room for Ethernet header - should not fail */ if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) { /* bail out */ LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n")); LINK_STATS_INC(link.lenerr); printf("etharp_output ERR\n"); return ERR_BUF; } /* assume unresolved Ethernet address */ dest = NULL; /* Determine on destination hardware address. Broadcasts and multicasts * are special, other IP addresses are looked up in the ARP table. */ /* broadcast destination IP address? */ if (ip_addr_is_v4comp(ipaddr)) { /* destination IP address is an IP multicast address? */ if (ip_addr_is_v4multicast(ipaddr)) { /* Hash IP multicast address to MAC address. */ mcastaddr.addr[0] = 0x01; mcastaddr.addr[1] = 0x00; mcastaddr.addr[2] = 0x5e; mcastaddr.addr[3] = ip4_addr2(ipaddr) & 0x7f; mcastaddr.addr[4] = ip4_addr3(ipaddr); mcastaddr.addr[5] = ip4_addr4(ipaddr); /* destination Ethernet address is multicast */ dest = &mcastaddr; /* unicast destination IP address? */ } /// CHANGED BY DIEGO BILLI else if (ip_addr_is_v4broadcast_allones(ipaddr)) { dest = (struct eth_addr *)ðbroadcast; } else { /* destination IP network address not on local network? * * IP layer wants us to forward to the default gateway */ if ((al=ip_addr_list_maskfind(netif->addrs, ipaddr)) == NULL) { return -1; } /* destination IP address is an IP broadcast address? */ if (ip_addr_isany(ipaddr) || ip_addr_is_v4broadcast(ipaddr, &(al->ipaddr), &(al->netmask))) { /* broadcast on Ethernet also */ dest = (struct eth_addr *)ðbroadcast; } } } else { if (ip_addr_isany(ipaddr) || ip_addr_ismulticast(ipaddr)) { mcastaddr.addr[0] = 0x33; mcastaddr.addr[1] = 0x33; mcastaddr.addr[2] = 0xff; mcastaddr.addr[3] = ipaddr->addr[3] >> 16 & 0xff; mcastaddr.addr[4] = ipaddr->addr[3] >> 8 & 0xff; mcastaddr.addr[5] = ipaddr->addr[3] & 0xff; dest = &mcastaddr; } /* destination IP network address not on local network? * IP layer wants us to forward to the default gateway */ /* XXX what is this? Is it incomplete code? */ else if ((al=ip_addr_list_maskfind(netif->addrs, ipaddr)) == NULL) { return ERR_RTE; } } /* XXX XXX XXX */ if (dest == NULL) { /* Ethernet address for IP destination address is in ARP cache? */ for (i = 0; i < ARP_TABLE_SIZE; ++i) { /* match found? */ if (arp_table[i].state == ETHARP_STATE_STABLE && ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { dest = &arp_table[i].ethaddr; break; } } /* could not find the destination Ethernet address in ARP cache? */ if (dest == NULL) { /* ARP query for the IP address, submit this IP packet for queueing */ /* TODO: How do we handle netif->ipaddr == ipaddr? */ etharp_query(al, ipaddr, q); /* { packet was queued (ERR_OK), or discarded } */ /* return nothing */ /*printf("QUERY NULL!\n");*/ return ERR_RTE; /*???*/ } /* destination Ethernet address resolved from ARP cache */ else { /* fallthrough */ } } /* destination Ethernet address known */ if (dest != NULL) { /* obtain source Ethernet address of the given interface */ srcaddr = (struct eth_addr *)netif->hwaddr; /* A valid IP->MAC address mapping was found, fill in the * Ethernet header for the outgoing packet */ ethhdr = q->payload; if (ip_addr_is_v4comp(ipaddr)) ethhdr->type = htons(ETHTYPE_IP); else ethhdr->type = htons(ETHTYPE_IP6); for(i = 0; i < netif->hwaddr_len; i++) { ethhdr->dest.addr[i] = dest->addr[i]; ethhdr->src.addr[i] = srcaddr->addr[i]; } /* return the outgoing packet */ return LINKOUTPUT(netif, q); } /* never reached; here for safety */ return 0; } #if 0 { { /* queue on destination Ethernet address belonging to ipaddr */ return etharp_query(netif, ipaddr, q); } /* continuation for multicast/broadcast destinations */ /* obtain source Ethernet address of the given interface */ srcaddr = (struct eth_addr *)netif->hwaddr; ethhdr = q->payload; for (i = 0; i < netif->hwaddr_len; i++) { ethhdr->dest.addr[i] = dest->addr[i]; ethhdr->src.addr[i] = srcaddr->addr[i]; } ethhdr->type = htons(ETHTYPE_IP); /* send packet directly on the link */ return netif->linkoutput(netif, q); } #endif /** * Send an ARP request for the given IP address and/or queue a packet. * * If the IP address was not yet in the cache, a pending ARP cache entry * is added and an ARP request is sent for the given address. The packet * is queued on this entry. * * If the IP address was already pending in the cache, a new ARP request * is sent for the given address. The packet is queued on this entry. * * If the IP address was already stable in the cache, and a packet is * given, it is directly sent and no ARP request is sent out. * * If the IP address was already stable in the cache, and no packet is * given, an ARP request is sent out. * * @param netif The lwIP network interface on which ipaddr * must be queried for. * @param ipaddr The IP address to be resolved. * @param q If non-NULL, a pbuf that must be delivered to the IP address. * q is not freed by this function. * * @return * - ERR_BUF Could not make room for Ethernet header. * - ERR_MEM Hardware address unknown, and no more ARP entries available * to query for address or queue the packet. * - ERR_MEM Could not queue packet due to memory shortage. * - ERR_RTE No route to destination (no gateway to external networks). * - ERR_ARG Non-unicast address given, those will not appear in ARP cache. * */ err_t etharp_query(struct ip_addr_list *al, struct ip_addr *ipaddr, struct pbuf *q) { struct pbuf *p; struct netif *netif=al->netif; struct eth_addr * srcaddr = (struct eth_addr *)netif->hwaddr; err_t result = ERR_MEM; s8_t i; /* ARP entry index */ u8_t k; /* Ethernet address octet index */ /* non-unicast address? */ if (ip_addr_is_v4broadcast(ipaddr, &(al->ipaddr), &(al->netmask)) || ip_addr_ismulticast(ipaddr) || ip_addr_isany(ipaddr)) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: will not add non-unicast IP address to ARP cache\n")); return ERR_ARG; } /* find entry in ARP cache, ask to create entry if queueing packet */ i = find_entry(ipaddr, ETHARP_TRY_HARD); /* could not find or create entry? */ if (i < 0) { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not create ARP entry\n")); if (q) LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: packet dropped\n")); return (err_t)i; } /* mark a fresh entry as pending (we just sent a request) */ if (arp_table[i].state == ETHARP_STATE_EMPTY) { arp_table[i].state = ETHARP_STATE_PENDING; } /* { i is either a STABLE or (new or existing) PENDING entry } */ LWIP_ASSERT("arp_table[i].state == PENDING or STABLE", ((arp_table[i].state == ETHARP_STATE_PENDING) || (arp_table[i].state == ETHARP_STATE_STABLE))); /* do we have a pending entry? or an implicit query request? */ if ((arp_table[i].state == ETHARP_STATE_PENDING) || (q == NULL)) { /* try to resolve it; send out ARP request */ result = etharp_request(al, ipaddr); } /* packet given? */ if (q != NULL) { struct eth_hdr *ethhdr = q->payload; if (ip_addr_is_v4comp(ipaddr)) ethhdr->type = htons(ETHTYPE_IP); else ethhdr->type = htons(ETHTYPE_IP6); /* stable entry? */ if (arp_table[i].state == ETHARP_STATE_STABLE) { /* we have a valid IP->Ethernet address mapping, * fill in the Ethernet header for the outgoing packet */ for(k = 0; k < netif->hwaddr_len; k++) { ethhdr->dest.addr[k] = arp_table[i].ethaddr.addr[k]; ethhdr->src.addr[k] = srcaddr->addr[k]; } LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: sending packet %p\n", (void *)q)); /* send the packet */ LINKOUTPUT(netif, q); /* pending entry? (either just created or already pending */ } else if (arp_table[i].state == ETHARP_STATE_PENDING) { #if ARP_QUEUEING /* queue the given q packet */ /* copy any PBUF_REF referenced payloads into PBUF_RAM */ /* (the caller of lwIP assumes the referenced payload can be * freed after it returns from the lwIP call that brought us here) */ p = pbuf_take(q); /* packet could be taken over? */ if (p != NULL) { /* queue packet ... */ if (arp_table[i].p == NULL) { /* ... in the empty queue */ pbuf_ref(p); arp_table[i].p = p; #if 0 /* multi-packet-queueing disabled, see bug #11400 */ } else { /* ... at tail of non-empty queue */ pbuf_queue(arp_table[i].p, p); #endif } LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: queued packet %p on ARP entry %d\n", (void *)q, i)); result = ERR_OK; } else { LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: could not queue a copy of PBUF_REF packet %p (out of memory)\n", (void *)q)); /* { result == ERR_MEM } through initialization */ } #else /* ARP_QUEUEING == 0 */ /* q && state == PENDING && ARP_QUEUEING == 0 => result = ERR_MEM */ /* { result == ERR_MEM } through initialization */ LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: Ethernet destination address unknown, queueing disabled, packet %p dropped\n", (void *)q)); #endif } } return result; } err_t etharp_request(struct ip_addr_list *al, struct ip_addr *ipaddr) { struct netif *netif = al->netif; struct stack *stack = netif->stack; struct eth_addr * srcaddr = (struct eth_addr *)netif->hwaddr; err_t result = ERR_OK; u8_t k; /* ARP entry index */ if (ip_addr_is_v4comp(ipaddr)) { struct pbuf *p; /* allocate a pbuf for the outgoing ARP request packet */ p = pbuf_alloc(PBUF_LINK, sizeof(struct etharp_hdr), PBUF_RAM); /* could allocate a pbuf for an ARP request? */ if (p != NULL) { struct etharp_hdr *hdr = p->payload; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_request: sending ARP request.\n")); hdr->opcode = htons(ARP_REQUEST); for (k = 0; k < netif->hwaddr_len; k++) { hdr->shwaddr.addr[k] = srcaddr->addr[k]; /* the hardware address is what we ask for, in * a request it is a don't-care value, we use zeroes */ hdr->dhwaddr.addr[k] = 0x00; } ip64_addr_set(&(hdr->dipaddr), ipaddr); ip64_addr_set(&(hdr->sipaddr), &(al->ipaddr)); hdr->hwtype = htons(HWTYPE_ETHERNET); ARPH_HWLEN_SET(hdr, netif->hwaddr_len); hdr->proto = htons(ETHTYPE_IP); ARPH_PROTOLEN_SET(hdr, sizeof(struct ip4_addr)); for (k = 0; k < netif->hwaddr_len; ++k) { /* broadcast to all network interfaces on the local network */ hdr->ethhdr.dest.addr[k] = 0xff; hdr->ethhdr.src.addr[k] = srcaddr->addr[k]; } hdr->ethhdr.type = htons(ETHTYPE_ARP); /* send ARP query */ result = LINKOUTPUT(netif, p); /* free ARP query packet */ pbuf_free(p); p = NULL; /* could not allocate pbuf for ARP request */ } else { result = ERR_MEM; LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_request: could not allocate pbuf for ARP request.\n")); } } else { icmp_neighbor_solicitation(stack, ipaddr, al); } return result; } #if LWIP_PACKET void eth_packet_mgmt(struct netif *netif, struct pbuf *p,u8_t pkttype) { struct stack *stack = netif->stack; struct sockaddr_ll sll; struct eth_hdr *eh=p->payload; memset(&sll, 0, sizeof(struct sockaddr_ll)); sll.sll_protocol = ntohs(eh->type); sll.sll_hatype = ARPHRD_ETHER; sll.sll_ifindex = netif->id; memcpy(sll.sll_addr,&(eh->src),sizeof(struct eth_addr)); if (pkttype != 0) sll.sll_pkttype = pkttype; else { if (memcmp(&(eh->dest),netif->hwaddr,sizeof(struct eth_addr))==0) sll.sll_pkttype = PACKET_HOST; else if (memcmp(&(eh->dest),ðbroadcast,sizeof(struct eth_addr))==0) sll.sll_pkttype = PACKET_BROADCAST; else if (eh->dest.addr[0] & 1) sll.sll_pkttype = PACKET_MULTICAST; else sll.sll_pkttype = PACKET_OTHERHOST; } packet_input(stack, p,&sll,sizeof(struct eth_hdr)); } u16_t eth_packet_out(struct netif *netif, struct pbuf *p, struct sockaddr_ll *sll, u16_t protocol, u16_t dgramflag) { struct pbuf *q; /* q will be sent down the stack */ if (dgramflag) { if (pbuf_header(p, sizeof(struct eth_hdr))) { /* XXX */ /* allocate header in new pbuf */ q = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM); /* new header pbuf could not be allocated? */ if (q == NULL) { LWIP_DEBUGF(PACKET_DEBUG | DBG_TRACE | 2, ("packet_sendto: could not allocate header\n")); return ERR_MEM; } /* chain header q in front of given pbuf p */ pbuf_chain(q, p); /* { first pbuf q points to header pbuf } */ LWIP_DEBUGF(PACKET_DEBUG, ("packet_sendto: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); pbuf_header(q, sizeof(struct eth_hdr)); } else { /* first pbuf q equals given pbuf */ q = p; } struct eth_hdr *eh=(struct eth_hdr *)q->payload; memcpy(&eh->dest,sll->sll_addr,sizeof(struct eth_addr)); memcpy(&eh->src,netif->hwaddr,sizeof(struct eth_addr)); eh->type=htons(protocol); } else q=p; netif->linkoutput(netif,q); /* did we chain a header earlier? */ if (q != p) { /* free the header */ pbuf_free(q); } return ERR_OK; } #endif int etharp_ioctl(struct stack *stack, int cmd,struct arpreq *arpreq #if LWIP_CAPABILITIES ,int cap #endif ) { int retval; if (arpreq == NULL) retval=EFAULT; else { struct netif *nip; if ((nip = netif_find(stack, arpreq->arp_dev)) == NULL) retval=EINVAL; else { struct ip_addr ipaddr; struct eth_addr ethaddr; int err; if (arpreq->arp_pa.sa_family == PF_INET6) memcpy(&(ipaddr),&(((struct sockaddr_in6 *)(&arpreq->arp_pa))->sin6_addr), sizeof(struct in6_addr)); else if (arpreq->arp_pa.sa_family == PF_INET) { ipaddr.addr[0] = 0; ipaddr.addr[1] = 0; ipaddr.addr[2] = IP64_PREFIX; memcpy(&(ipaddr.addr[3]),&(((struct sockaddr_in *)(&arpreq->arp_pa))->sin_addr), sizeof(struct in_addr)); } else memset(&ipaddr, 0, sizeof(ipaddr)); memcpy(ðaddr,arpreq->arp_ha.sa_data, sizeof(ethaddr)); switch (cmd) { case SIOCSARP: #if LWIP_CAPABILITIES if ((cap&LWIP_CAP_NET_ADMIN) == 0) { retval=EPERM; err=0; } else #endif err=update_arp_entry(nip, &ipaddr, ðaddr, arpreq->arp_flags | ETHARP_TRY_HARD); break; case SIOCDARP: #if LWIP_CAPABILITIES if ((cap&LWIP_CAP_NET_ADMIN) == 0) { retval=EPERM; err=0; } else #endif err=find_entry(&ipaddr, 0); if (err >= 0) { /* clean up entries that have just been expired */ arp_table[err].state == ETHARP_STATE_EXPIRED; #if ARP_QUEUEING /* and empty packet queue */ if (arp_table[err].p != NULL) { /* remove all queued packets */ LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_ioctl: freeing entry %u, packet queue %p.\n", err, (void *)(arp_table[err].p))); pbuf_free(arp_table[err].p); arp_table[err].p = NULL; } #endif /* recycle entry for re-use */ arp_table[err].state = ETHARP_STATE_EMPTY; err=0; } break; case SIOCGARP: err=find_entry(&ipaddr, 0); if (err >= 0) { arpreq->arp_pa.sa_family = AF_UNSPEC; memcpy(arpreq->arp_ha.sa_data,&(arp_table[err].ethaddr),sizeof(ethaddr)); err=0; } break; default: err=ERR_ARG; } if (err != ERR_OK) retval=EINVAL; } } return retval; } lwipv6-1.5a/lwip-v6/src/netif/ethernetif.c0000644000175000017500000001772511671615007017544 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* * modified for LWIPv6 Renzo Davoli - University of Bologna 2005 */ /* * This file is a skeleton for developing Ethernet network interface * drivers for lwIP. Add code to the low_level functions and do a * search-and-replace for the word "ethernetif" to replace it with * something that better describes your network interface. */ #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/mem.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include #include "netif/etharp.h" #if LWIP_NL #include "lwip/arphdr.h" #endif /* Define those to better describe your network interface. */ #define IFNAME0 'e' #define IFNAME1 'n' struct ethernetif { struct eth_addr *ethaddr; /* Add whatever per-interface state that is needed here. */ }; static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}}; /* Forward declarations. */ static void ethernetif_input(struct netif *netif); static err_t ethernetif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr); static int low_level_init(struct netif *netif) { struct ethernetif *ethernetif = netif->state; /* set MAC hardware address length */ netif->hwaddr_len = 6; /* set MAC hardware address */ netif->hwaddr[0] = ; ... netif->hwaddr[5] = ; /* maximum transfer unit */ netif->mtu = 1500; /* broadcast capability */ netif->flags = NETIF_FLAG_BROADCAST; /* Do whatever else is needed to initialize interface. */ return ERR_OK; } /* * low_level_output(): * * Should do the actual transmission of the packet. The packet is * contained in the pbuf that is passed to the function. This pbuf * might be chained. * */ static err_t low_level_output(struct netif *netif, struct pbuf *p) { struct ethernetif *ethernetif = netif->state; struct pbuf *q; initiate transfer(); #if ETH_PAD_SIZE pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ #endif for(q = p; q != NULL; q = q->next) { /* Send the data from the pbuf to the interface, one pbuf at a time. The size of the data in each pbuf is kept in the ->len variable. */ send data from(q->payload, q->len); } signal that packet should be sent(); #if ETH_PAD_SIZE pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ #endif #if LINK_STATS lwip_stats.link.xmit++; #endif /* LINK_STATS */ return ERR_OK; } /* * low_level_input(): * * Should allocate a pbuf and transfer the bytes of the incoming * packet from the interface into the pbuf. * */ static struct pbuf * low_level_input(struct netif *netif,,u16_t ifflags) { struct ethernetif *ethernetif = netif->state; struct pbuf *p, *q; u16_t len; /* Obtain the size of the packet and put it into the "len" variable. */ len = ; if (!(ETH_RECEIVING_RULE(buf,vdeif->ethaddr->addr,ifflags))) { return NULL; } #if ETH_PAD_SIZE len += ETH_PAD_SIZE; /* allow room for Ethernet padding */ #endif /* We allocate a pbuf chain of pbufs from the pool. */ p = pbuf_alloc(PBUF_RAW, len, PBUF_POOL); if (p != NULL) { #if ETH_PAD_SIZE pbuf_header(p, -ETH_PAD_SIZE); /* drop the padding word */ #endif /* We iterate over the pbuf chain until we have read the entire * packet into the pbuf. */ for(q = p; q != NULL; q = q->next) { /* Read enough bytes to fill this pbuf in the chain. The * available data in the pbuf is given by the q->len * variable. */ read data into(q->payload, q->len); } acknowledge that packet has been read(); #if ETH_PAD_SIZE pbuf_header(p, ETH_PAD_SIZE); /* reclaim the padding word */ #endif #if LINK_STATS lwip_stats.link.recv++; #endif /* LINK_STATS */ } else { drop packet(); #if LINK_STATS lwip_stats.link.memerr++; lwip_stats.link.drop++; #endif /* LINK_STATS */ } return p; } /* * ethernetif_output(): * * This function is called by the TCP/IP stack when an IP packet * should be sent. It calls the function called low_level_output() to * do the actual transmission of the packet. * */ static err_t ethernetif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { if (! (netif->flags & NETIF_FLAG_UP)) { return ERR_OK; } else /* resolve hardware address, then send (or queue) packet */ return etharp_output(netif, ipaddr, p); } /* * ethernetif_input(): * * This function should be called when a packet is ready to be read * from the interface. It uses the function low_level_input() that * should handle the actual reception of bytes from the network * interface. * */ static void ethernetif_input(struct netif *netif) { struct ethernetif *ethernetif; struct eth_hdr *ethhdr; struct pbuf *p; ethernetif = netif->state; /* move received packet into a new pbuf */ p = low_level_input(netif,netif->flags); /* no packet could be read, silently ignore this */ if (p == NULL) return; /* points to packet payload, which starts with an Ethernet header */ ethhdr = p->payload; #if LINK_STATS lwip_stats.link.recv++; #endif /* LINK_STATS */ ethhdr = p->payload; switch (htons(ethhdr->type)) { /* IP packet? */ case ETHTYPE_IP: /* update ARP table */ etharp_ip_input(netif, p); /* skip Ethernet header */ pbuf_header(p, -sizeof(struct eth_hdr)); /* pass to network layer */ netif->input(p, netif); break; case ETHTYPE_ARP: /* pass p to ARP module */ etharp_arp_input(netif, ethernetif->ethaddr, p); break; default: pbuf_free(p); p = NULL; break; } } static void arp_timer(void *arg) { etharp_tmr(); sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); } /* * ethernetif_init(): * * Should be called at the beginning of the program to set up the * network interface. It calls the function low_level_init() to do the * actual setup of the hardware. * */ err_t ethernetif_init(struct netif *netif) { struct ethernetif *ethernetif; ethernetif = mem_malloc(sizeof(struct ethernetif)); if (ethernetif == NULL) { LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_init: out of memory\n")); return ERR_MEM; } netif->state = ethernetif; netif->name[0] = IFNAME0; netif->name[1] = IFNAME1; netif->output = ethernetif_output; netif->linkoutput = low_level_output; ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]); low_level_init(netif); etharp_init(); sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); return ERR_OK; } lwipv6-1.5a/lwip-v6/src/netif/FILES0000644000175000017500000000216711671615007016022 0ustar renzorenzoThis directory contains generic network interface device drivers that do not contain any hardware or architecture specific code. The files are: etharp.c Implements the ARP (Address Resolution Protocol) over Ethernet. The code in this file should be used together with Ethernet device drivers. Note that this module has been largely made Ethernet independent so you should be able to adapt this for other link layers (such as Firewire). ethernetif.c An example of how an Ethernet device driver could look. This file can be used as a "skeleton" for developing new Ethernet network device drivers. It uses the etharp.c ARP code. loopif.c An example network interface that shows how a "loopback" interface would work. This is not really intended for actual use, but as a very basic example of how initialization and output functions work. slipif.c A generic implementation of the SLIP (Serial Line IP) protocol. It requires a sio (serial I/O) module to work. ppp/ Point-to-Point Protocol stack lwipv6-1.5a/lwip-v6/src/netif/loopif.c0000644000175000017500000000751511671615007016673 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/opt.h" #if LWIP_HAVE_LOOPIF #include "lwip/def.h" #include "netif/loopif.h" #include "lwip/mem.h" #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) #include "netif/tcpdump.h" #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ #include "lwip/tcp.h" #include "lwip/ip.h" #if LWIP_NL #include "lwip/arphdr.h" #endif #include "lwip/stack.h" #if 0 static void loopif_input( void * arg ) { //printf("loopif_input\n"); struct netif *netif = (struct netif *)( ((void **)arg)[ 0 ] ); struct pbuf *r = (struct pbuf *)( ((void **)arg)[ 1 ] ); //printf("R %p NETIF %p\n",r,netif); mem_free( arg ); netif->input( r, netif ); } #endif static err_t loopif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr) { struct pbuf *q, *r; char *ptr; //void **arg; #if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP) tcpdump(p); #endif /* LWIP_DEBUG && LWIP_TCPDUMP */ if (! (netif->flags & NETIF_FLAG_UP)) { return ERR_OK; } //printf("LOOPIFpbuf_alloc\n"); r = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); //printf("LOOPIFpbuf_alloc done\n"); if (r != NULL) { ptr = r->payload; for(q = p; q != NULL; q = q->next) { memcpy(ptr, q->payload, q->len); ptr += q->len; } netif->input( r, netif ); /* arg = mem_malloc( sizeof( void *[2])); if( NULL == arg ) { return ERR_MEM; */ /*}*/ /*arg[0] = netif; arg[1] = r; */ /** * workaround (patch #1779) to try to prevent bug #2595: * When connecting to "localhost" with the loopif interface, * tcp_output doesn't get the opportunity to finnish sending the * segment before tcp_process gets it, resulting in tcp_process * referencing pcb->unacked-> which still is NULL. * * TODO: Is there still a race condition here? Leon */ //printf("R %p NETIF %p\n",r,netif); //sys_timeout( 1, loopif_input, arg ); return ERR_OK; } return ERR_MEM; } err_t loopif_init(struct netif *netif) { struct stack *stack = netif->stack; netif->name[0] = 'l'; netif->name[1] = 'o'; netif->link_type = NETIF_LOOPIF; netif->num = netif_next_num(netif,NETIF_LOOPIF); netif->output = loopif_output; netif->flags |= NETIF_FLAG_UP | NETIF_FLAG_LOOPBACK; #if LWIP_NL netif->type = ARPHRD_LOOPBACK; #endif return ERR_OK; } #endif /* LWIP_HAVE_LOOPIF */ lwipv6-1.5a/lwip-v6/src/api/0000755000175000017500000000000011671615111014667 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/api/api_msg.c0000644000175000017500000006327711671615010016467 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/opt.h" #include "lwip/arch.h" #include "lwip/api_msg.h" #include "lwip/memp.h" #include "lwip/sys.h" #include "lwip/tcpip.h" static inline void pending_conn_mbox(struct netconn *conn) { conn->ack_pending = 1; } static inline void ack_conn_mbox(struct netconn *conn) { conn->ack_pending = 0; sys_mbox_post(conn->mbox, NULL); } #if LWIP_RAW static void recv_raw(void *arg, struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t protocol) { struct netbuf *buf; struct netconn *conn; conn = arg; if (!conn) return; if (conn->recvmbox != SYS_MBOX_NULL) { if (!(buf = memp_malloc(MEMP_NETBUF))) { return; } buf->p = p; buf->ptr = p; memcpy(&(buf->fromaddr),addr,sizeof(struct ip_addr)); buf->fromport = protocol; /*printf("RAW netbuf_fromaddr %x:%x:%x:%x buf %x port %d %x %x %d\n", buf->fromaddr.addr[0], buf->fromaddr.addr[1], buf->fromaddr.addr[2], buf->fromaddr.addr[3], buf, buf->fromport, p, p, p->tot_len);*/ /* IPV6 does not include headers in received RAW packets. * IPV4 need IP headers (to be verified XXX) */ if (! ip_addr_is_v4comp(addr)){ pbuf_header(p,-IP_HLEN); } conn->recv_avail += p->tot_len; /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len); sys_mbox_post(conn->recvmbox, buf); } } #endif #if LWIP_PACKET static void recv_packet(void *arg, struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t protocol) { struct netbuf *buf; struct netconn *conn; conn = arg; if (!conn) return; if (conn->recvmbox != SYS_MBOX_NULL) { if (!(buf = memp_malloc(MEMP_NETBUF))) { return; } buf->p = p; buf->ptr = p; memcpy(&(buf->fromaddr),addr,sizeof(struct ip_addr)); buf->fromport = protocol; /*printf("PACKET netbuf_fromaddr %lx:%lx:%lx:%lx buf %p port %x %p %d\n", buf->fromaddr.addr[0], buf->fromaddr.addr[1], buf->fromaddr.addr[2], buf->fromaddr.addr[3], buf, buf->fromport, p, p->tot_len); */ conn->recv_avail += p->tot_len; /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len); sys_mbox_post(conn->recvmbox, buf); } } #endif #if LWIP_UDP static void recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) { struct netbuf *buf; struct netconn *conn; conn = arg; if (conn == NULL) { pbuf_free(p); return; } if (conn->recvmbox != SYS_MBOX_NULL) { buf = memp_malloc(MEMP_NETBUF); if (buf == NULL) { pbuf_free(p); return; } else { buf->p = p; buf->ptr = p; memcpy(&(buf->fromaddr),addr,sizeof(struct ip_addr)); /*printf("UDP netbuf_fromaddr %x:%x:%x:%x\n", buf->fromaddr.addr[0], buf->fromaddr.addr[1], buf->fromaddr.addr[2], buf->fromaddr.addr[3]);*/ buf->fromport = port; } conn->recv_avail += p->tot_len; /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len); sys_mbox_post(conn->recvmbox, buf); } } #endif /* LWIP_UDP */ #if LWIP_TCP static err_t recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { struct netconn *conn; u16_t len; conn = arg; if (conn == NULL) { pbuf_free(p); return ERR_VAL; } if (conn->recvmbox != SYS_MBOX_NULL) { conn->err = err; if (p != NULL) { len = p->tot_len; conn->recv_avail += len; } else len = 0; /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, len); sys_mbox_post(conn->recvmbox, p); } return ERR_OK; } static err_t poll_tcp(void *arg, struct tcp_pcb *pcb) { struct netconn *conn; conn = arg; if (conn != NULL && (conn->state == NETCONN_WRITE || conn->state == NETCONN_CLOSE) && conn->sem != SYS_SEM_NULL) { sys_sem_signal(conn->sem); } return ERR_OK; } static err_t sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len) { struct netconn *conn; conn = arg; if (conn != NULL && conn->sem != SYS_SEM_NULL) sys_sem_signal(conn->sem); if (conn && conn->callback) if (tcp_sndbuf(conn->pcb.tcp) > TCP_SNDLOWAT) (*conn->callback)(conn, NETCONN_EVT_SENDPLUS, len); return ERR_OK; } static void err_tcp(void *arg, err_t err) { struct netconn *conn; conn = arg; conn->pcb.tcp = NULL; conn->err = err; if (conn->recvmbox != SYS_MBOX_NULL) { /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0); sys_mbox_post(conn->recvmbox, NULL); } /* NO! this spurious message breaks the dialogue api_lib/api_msg. THere must be exactly one message per request X999*/ /*if (conn->mbox != SYS_MBOX_NULL) { ack_conn_mbox(conn); }*/ /* new version X1010 */ if (conn->ack_pending) ack_conn_mbox(conn); if (conn->acceptmbox != SYS_MBOX_NULL) { /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0); sys_mbox_post(conn->acceptmbox, NULL); } if (conn->sem != SYS_SEM_NULL) { sys_sem_signal(conn->sem); } } static void setup_tcp(struct netconn *conn) { struct tcp_pcb *pcb; pcb = conn->pcb.tcp; tcp_arg(pcb, conn); tcp_recv(pcb, recv_tcp); tcp_sent(pcb, sent_tcp); tcp_poll(pcb, poll_tcp, 4); tcp_err(pcb, err_tcp); } static err_t accept_function(void *arg, struct tcp_pcb *newpcb, err_t err) { sys_mbox_t mbox; struct netconn *newconn; struct netconn *conn; //printf("accept fun\n"); #if API_MSG_DEBUG #if TCP_DEBUG tcp_debug_print_state(newpcb->state); #endif /* TCP_DEBUG */ #endif /* API_MSG_DEBUG */ conn = (struct netconn *)arg; mbox = conn->acceptmbox; newconn = memp_malloc(MEMP_NETCONN); if (newconn == NULL) { //printf("NO mem?\n"); return ERR_MEM; } /* FIX MULTISTACK: newpcb->stack == conn->stack */ newconn->stack = newpcb->stack; newconn->type = NETCONN_TCP; newconn->pcb.tcp = newpcb; setup_tcp(newconn); newconn->recvmbox = sys_mbox_new(); if (newconn->recvmbox == SYS_MBOX_NULL) { memp_free(MEMP_NETCONN, newconn); return ERR_MEM; } newconn->mbox = sys_mbox_new(); if (newconn->mbox == SYS_MBOX_NULL) { sys_mbox_free(newconn->recvmbox); memp_free(MEMP_NETCONN, newconn); return ERR_MEM; } /* why? */ /* X1005 */ /*newconn->sem = sys_sem_new(0); if (newconn->sem == SYS_SEM_NULL) { sys_mbox_free(newconn->recvmbox); sys_mbox_free(newconn->mbox); memp_free(MEMP_NETCONN, newconn); return ERR_MEM; }*/ newconn->sem = SYS_SEM_NULL; /* end of X1005 */ newconn->acceptmbox = SYS_MBOX_NULL; newconn->ack_pending = 0; newconn->err = err; newconn->recv_avail = 0; newconn->socket = conn->socket; newconn->callback = conn->callback; if (newconn->callback) (*newconn->callback)(newconn, NETCONN_EVT_ACCEPTPLUS, 0); //printf("conn->acceptmbox post!\n"); sys_mbox_post(mbox, newconn); /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0); return ERR_OK; } #endif /* LWIP_TCP */ static void do_newconn(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); if(msg->conn->pcb.tcp != NULL) { /* This "new" connection already has a PCB allocated. */ /* Is this an error condition? Should it be deleted? We currently just are happy and return. */ ack_conn_mbox(msg->conn); return; } msg->conn->err = ERR_OK; /* Allocate a PCB for this connection */ switch(msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: msg->conn->pcb.raw = raw_new(msg->conn->stack, msg->msg.bc.port); /* misusing the port field */ raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: msg->conn->pcb.udp = udp_new(msg->conn->stack); if(msg->conn->pcb.udp == NULL) { msg->conn->err = ERR_MEM; break; } udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE); udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; case NETCONN_UDPNOCHKSUM: msg->conn->pcb.udp = udp_new(msg->conn->stack); if(msg->conn->pcb.udp == NULL) { msg->conn->err = ERR_MEM; break; } udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM); udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; case NETCONN_UDP: msg->conn->pcb.udp = udp_new(msg->conn->stack); if(msg->conn->pcb.udp == NULL) { msg->conn->err = ERR_MEM; break; } udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; #endif /* LWIP_UDP */ #if LWIP_TCP case NETCONN_TCP: msg->conn->pcb.tcp = tcp_new(msg->conn->stack); if(msg->conn->pcb.tcp == NULL) { msg->conn->err = ERR_MEM; break; } setup_tcp(msg->conn); break; #endif default: break; } ack_conn_mbox(msg->conn); } static void do_delconn(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); if (msg->conn->pcb.tcp != NULL) { switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: raw_remove(msg->conn->pcb.raw); break; #endif #if LWIP_PACKET case NETCONN_PACKET_RAW: case NETCONN_PACKET_DGRAM: packet_remove(msg->conn->pcb.raw); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: msg->conn->pcb.udp->recv_arg = NULL; udp_remove(msg->conn->pcb.udp); break; #endif /* LWIP_UDP */ #if LWIP_TCP case NETCONN_TCP: if (msg->conn->pcb.tcp->state == LISTEN) { tcp_arg(msg->conn->pcb.tcp, NULL); tcp_accept(msg->conn->pcb.tcp, NULL); tcp_close(msg->conn->pcb.tcp); } else { tcp_arg(msg->conn->pcb.tcp, NULL); tcp_sent(msg->conn->pcb.tcp, NULL); tcp_recv(msg->conn->pcb.tcp, NULL); tcp_poll(msg->conn->pcb.tcp, NULL, 0); tcp_err(msg->conn->pcb.tcp, NULL); if (tcp_close(msg->conn->pcb.tcp) != ERR_OK) { tcp_abort(msg->conn->pcb.tcp); } } #endif default: break; } } /* Trigger select() in socket layer */ if (msg->conn->callback) { (*msg->conn->callback)(msg->conn, NETCONN_EVT_RCVPLUS, 0); (*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDPLUS, 0); } if (msg->conn->mbox != SYS_MBOX_NULL) { ack_conn_mbox(msg->conn); } } static void do_bind(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); if (msg->conn->pcb.tcp == NULL) { switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: msg->conn->pcb.raw = raw_new(msg->conn->stack, msg->msg.bc.port); /* misusing the port field as protocol */ raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn); break; #endif #if LWIP_PACKET case NETCONN_PACKET_RAW: msg->conn->pcb.raw = packet_new(msg->conn->stack, msg->msg.bc.port,0); /* misusing the port field as protocol */ raw_recv(msg->conn->pcb.raw, recv_packet, msg->conn); break; case NETCONN_PACKET_DGRAM: msg->conn->pcb.raw = packet_new(msg->conn->stack, msg->msg.bc.port,1); /* misusing the port field as protocol */ raw_recv(msg->conn->pcb.raw, recv_packet, msg->conn); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: msg->conn->pcb.udp = udp_new(msg->conn->stack); udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE); udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; case NETCONN_UDPNOCHKSUM: msg->conn->pcb.udp = udp_new(msg->conn->stack); udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM); udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; case NETCONN_UDP: msg->conn->pcb.udp = udp_new(msg->conn->stack); udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; #endif /* LWIP_UDP */ #if LWIP_TCP case NETCONN_TCP: msg->conn->pcb.tcp = tcp_new(msg->conn->stack); setup_tcp(msg->conn); #endif /* LWIP_TCP */ default: break; } } switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: msg->conn->err = raw_bind(msg->conn->pcb.raw,msg->msg.bc.ipaddr,msg->msg.bc.port); break; #endif #if LWIP_PACKET case NETCONN_PACKET_RAW: case NETCONN_PACKET_DGRAM: msg->conn->err = packet_bind(msg->conn->pcb.raw,msg->msg.bc.ipaddr,msg->msg.bc.port); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: msg->conn->err = udp_bind(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port #ifdef LWSLIRP ,NULL #endif ); break; #endif /* LWIP_UDP */ #if LWIP_TCP case NETCONN_TCP: msg->conn->err = tcp_bind(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port); #endif /* LWIP_TCP */ default: break; } ack_conn_mbox(msg->conn); } #if LWIP_TCP static err_t do_connected(void *arg, struct tcp_pcb *pcb, err_t err) { struct netconn *conn; conn = arg; if (conn == NULL) { return ERR_VAL; } conn->err = err; if (conn->type == NETCONN_TCP && err == ERR_OK) { setup_tcp(conn); } ack_conn_mbox(conn); return ERR_OK; } #endif static void do_connect(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); //printf("do_connect port %d\n",msg->msg.bc.port); if (msg->conn->pcb.tcp == NULL) { switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: msg->conn->pcb.raw = raw_new(msg->conn->stack, msg->msg.bc.port); /* misusing the port field as protocol */ raw_recv(msg->conn->pcb.raw, recv_raw, msg->conn); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: msg->conn->pcb.udp = udp_new(msg->conn->stack); if (msg->conn->pcb.udp == NULL) { msg->conn->err = ERR_MEM; ack_conn_mbox(msg->conn); return; } udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE); udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; case NETCONN_UDPNOCHKSUM: msg->conn->pcb.udp = udp_new(msg->conn->stack); if (msg->conn->pcb.udp == NULL) { msg->conn->err = ERR_MEM; ack_conn_mbox(msg->conn); return; } udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM); udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; case NETCONN_UDP: msg->conn->pcb.udp = udp_new(msg->conn->stack); if (msg->conn->pcb.udp == NULL) { msg->conn->err = ERR_MEM; ack_conn_mbox(msg->conn); return; } udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn); break; #endif /* LWIP_UDP */ #if LWIP_TCP case NETCONN_TCP: msg->conn->pcb.tcp = tcp_new(msg->conn->stack); if (msg->conn->pcb.tcp == NULL) { msg->conn->err = ERR_MEM; ack_conn_mbox(msg->conn); return; } #endif default: break; } } switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: raw_connect(msg->conn->pcb.raw, msg->msg.bc.ipaddr,msg->msg.bc.port); ack_conn_mbox(msg->conn); break; #endif #if LWIP_PACKET case NETCONN_PACKET_RAW: case NETCONN_PACKET_DGRAM: packet_connect(msg->conn->pcb.raw,msg->msg.bc.ipaddr,msg->msg.bc.port); ack_conn_mbox(msg->conn); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: udp_connect(msg->conn->pcb.udp, msg->msg.bc.ipaddr, msg->msg.bc.port); ack_conn_mbox(msg->conn); break; #endif #if LWIP_TCP case NETCONN_TCP: /* tcp_arg(msg->conn->pcb.tcp, msg->conn);*/ setup_tcp(msg->conn); tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port, do_connected); /*tcp_output(msg->conn->pcb.tcp);*/ #endif default: break; } } static void do_disconnect(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: /* Do nothing as connecting is only a helper for upper lwip layers */ break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: udp_disconnect(msg->conn->pcb.udp); break; #endif case NETCONN_TCP: break; default: break; } ack_conn_mbox(msg->conn); } static void do_listen(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); if (msg->conn->pcb.tcp != NULL) { switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: listen RAW: cannot listen for RAW.\n")); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: listen UDP: cannot listen for UDP.\n")); break; #endif /* LWIP_UDP */ #if LWIP_TCP case NETCONN_TCP: msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp); if (msg->conn->pcb.tcp == NULL) { msg->conn->err = ERR_MEM; } else { if (msg->conn->acceptmbox == SYS_MBOX_NULL) { msg->conn->acceptmbox = sys_mbox_new(); if (msg->conn->acceptmbox == SYS_MBOX_NULL) { msg->conn->err = ERR_MEM; break; default: break; } } tcp_arg(msg->conn->pcb.tcp, msg->conn); tcp_accept(msg->conn->pcb.tcp, accept_function); } #endif } } ack_conn_mbox(msg->conn); } static void do_accept(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); if (msg->conn->pcb.tcp != NULL) { switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: accept RAW: cannot accept for RAW.\n")); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: accept UDP: cannot accept for UDP.\n")); break; #endif /* LWIP_UDP */ case NETCONN_TCP: break; default: break; } } } static void do_send(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); if (msg->conn->pcb.tcp != NULL) { switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: raw_send(msg->conn->pcb.raw, msg->msg.p); break; #endif #if LWIP_PACKET case NETCONN_PACKET_RAW: case NETCONN_PACKET_DGRAM: packet_send(msg->conn->pcb.raw, msg->msg.p); break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: udp_send(msg->conn->pcb.udp, msg->msg.p); break; #endif /* LWIP_UDP */ case NETCONN_TCP: break; default: break; } } ack_conn_mbox(msg->conn); } static void do_recv(struct api_msg_msg *msg) { pending_conn_mbox(msg->conn); #if LWIP_TCP if (msg->conn->pcb.tcp != NULL) { if (msg->conn->type == NETCONN_TCP) { tcp_recved(msg->conn->pcb.tcp, msg->msg.len); } } #endif ack_conn_mbox(msg->conn); } static void do_write(struct api_msg_msg *msg) { #if LWIP_TCP err_t err; #endif pending_conn_mbox(msg->conn); if (msg->conn->pcb.tcp != NULL) { switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: msg->conn->err = ERR_VAL; break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: msg->conn->err = ERR_VAL; break; #endif /* LWIP_UDP */ #if LWIP_TCP case NETCONN_TCP: err = tcp_write(msg->conn->pcb.tcp, msg->msg.w.dataptr, msg->msg.w.len, msg->msg.w.copy); /* This is the Nagle algorithm: inhibit the sending of new TCP segments when new outgoing data arrives from the user if any previously transmitted data on the connection remains unacknowledged. */ if(err == ERR_OK && (msg->conn->pcb.tcp->unacked == NULL || (msg->conn->pcb.tcp->flags & TF_NODELAY)) ) { tcp_output(msg->conn->pcb.tcp); } msg->conn->err = err; if (msg->conn->callback) if (err == ERR_OK) { if (tcp_sndbuf(msg->conn->pcb.tcp) <= TCP_SNDLOWAT) (*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDMINUS, msg->msg.w.len); } #endif default: break; } } ack_conn_mbox(msg->conn); } static void do_close(struct api_msg_msg *msg) { err_t err; pending_conn_mbox(msg->conn); err = ERR_OK; if (msg->conn->pcb.tcp != NULL) { switch (msg->conn->type) { #if LWIP_RAW case NETCONN_RAW: break; #endif #if LWIP_UDP case NETCONN_UDPLITE: /* FALLTHROUGH */ case NETCONN_UDPNOCHKSUM: /* FALLTHROUGH */ case NETCONN_UDP: break; #endif /* LWIP_UDP */ #if LWIP_TCP case NETCONN_TCP: if (msg->conn->pcb.tcp->state == LISTEN) { err = tcp_close(msg->conn->pcb.tcp); } msg->conn->err = err; #endif default: break; } } ack_conn_mbox(msg->conn); } static void do_peer(struct api_msg_msg *msg) { struct netconn *conn=msg->conn; pending_conn_mbox(msg->conn); switch (conn->type) { case NETCONN_RAW: #if LWIP_PACKET case NETCONN_PACKET_RAW: case NETCONN_PACKET_DGRAM: #endif /* return an error as connecting is only a helper for upper layers */ msg->err = ERR_CONN; break; case NETCONN_UDPLITE: case NETCONN_UDPNOCHKSUM: case NETCONN_UDP: if (conn->pcb.udp == NULL || ((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0)) msg->err = ERR_CONN; else { *(msg->msg.bp.ipaddr) = (conn->pcb.udp->remote_ip); *(msg->msg.bp.port) = conn->pcb.udp->remote_port; } break; case NETCONN_TCP: if (conn->pcb.tcp == NULL) msg->err = ERR_CONN; else { *(msg->msg.bc.ipaddr) = (conn->pcb.tcp->remote_ip); *(msg->msg.bp.port) = conn->pcb.tcp->remote_port; } break; default: msg->err = ERR_ARG; } //fprintf(stderr, "DO_PEER %d\n", msg->err); ack_conn_mbox(msg->conn); } static void do_addr(struct api_msg_msg *msg) { struct netconn *conn=msg->conn; pending_conn_mbox(msg->conn); switch (conn->type) { case NETCONN_RAW: if (conn->pcb.raw == NULL) msg->err = ERR_CONN; else { *(msg->msg.bp.ipaddr) = (conn->pcb.raw->local_ip); *(msg->msg.bp.port) = conn->pcb.raw->in_protocol; } break; case NETCONN_UDPLITE: case NETCONN_UDPNOCHKSUM: case NETCONN_UDP: if (conn->pcb.udp == NULL) msg->err = ERR_CONN; else { *(msg->msg.bp.ipaddr) = (conn->pcb.udp->local_ip); *(msg->msg.bp.port) = conn->pcb.udp->local_port; } break; case NETCONN_TCP: if (conn->pcb.tcp == NULL) msg->err = ERR_CONN; else { *(msg->msg.bp.ipaddr) = (conn->pcb.tcp->local_ip); *(msg->msg.bp.port) = conn->pcb.tcp->local_port; } break; default: msg->err = ERR_ARG; } //fprintf(stderr, "DO_ADDR %d\n", msg->err); ack_conn_mbox(msg->conn); } static void do_callback(struct api_msg_msg *msg) { struct netconn *conn=msg->conn; pending_conn_mbox(msg->conn); msg->err = msg->msg.cb.fun(conn, msg->msg.cb.arg); ack_conn_mbox(msg->conn); } typedef void (* api_msg_decode)(struct api_msg_msg *msg); static api_msg_decode decode[API_MSG_MAX] = { do_newconn, do_delconn, do_bind, do_connect, do_disconnect, do_listen, do_accept, do_send, do_recv, do_write, do_close, do_peer, do_addr, do_callback }; void api_msg_input(struct api_msg *msg) { decode[msg->type](&(msg->msg)); } void api_msg_post(struct stack *stack, struct api_msg *msg) { tcpip_apimsg(stack, msg); } lwipv6-1.5a/lwip-v6/src/api/sockets.c0000644000175000017500000017410211671615010016511 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2008,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * * Improved by Marc Boucher and David Haas * */ #include #include #include #include #include #include #include #include #include #include "lwip/opt.h" #include "lwip/api.h" #include "lwip/arch.h" #include "lwip/sys.h" #include "lwip/mem.h" #define LWIP_TIMEVAL_PRIVATE #include "lwip/sockets.h" #include "lwip/tcpip.h" #if LWIP_NL #include "lwip/netlink.h" #endif #if LWIP_PACKET ///#include #include "lwip/packet.h" #endif #include "lwip/native_syscalls.h" #define NUM_SOCKETS MEMP_NUM_NETCONN #define SOCK_IP64_CONV(ipaddr, ip4) do { \ (ipaddr)->addr[0] = 0; \ (ipaddr)->addr[1] = 0; \ (ipaddr)->addr[2] = IP64_PREFIX; \ memcpy(&((ipaddr)->addr[3]),(ip4),sizeof(struct ip4_addr)); } while (0) #define SOCK_IP46_CONV(ip4, ipaddr) (memcpy((ip4),&((ipaddr)->addr[3]),sizeof(struct ip4_addr))) int _nofdfake = 0; #ifdef LWIP_DEBUG static char *domain_name(int domain) { switch (domain) { case PF_INET: return "PF_INET"; case PF_INET6: return "PF_INET6"; #if LWIP_NL case PF_NETLINK: return "PF_NETLINK"; #endif #if LWIP_PACKET case PF_PACKET: return "PF_PACKET"; #endif } return "UNKNOWN"; } #endif #define SOCKMAP_SIZE NUM_SOCKETS static int *lwip_sockmap=NULL; static int lwip_sockmap_len=0; struct lwip_socket { u16_t family; struct netconn *conn; struct netbuf *lastdata; u16_t lastoffset; u16_t rcvevent; u16_t sendevent; u16_t flags; int fdfake; int err; }; #define SOCK_ROK(s) ((((s)->flags & O_ACCMODE) + 1) & 1) #define SOCK_WOK(s) ((((s)->flags & O_ACCMODE) + 1) & 2) static struct lwip_socket **sockets=NULL; static int sockets_len=0; #if LWIP_NL #define NOT_CONN_SOCKET ((struct netconn *)(-1)) #endif static sys_sem_t socksem = 0; static sys_sem_t selectsem = 0; static u16_t so_map[]={ 0, /*not used */ SOF_DEBUG, /*SO_DEBUG*/ SOF_REUSEADDR, /*SO_REUSEADDR*/ 0, /* SO_TYPE */ 0, /* SO_ERROR */ SOF_DONTROUTE, /* SO_DONTROUTE */ SOF_BROADCAST, /* SO_BROADCAST */ 0, /* SO_SNDBUF */ 0, /* SO_RCVBUF */ SOF_KEEPALIVE, /* SO_KEEPALIVE */ SOF_OOBINLINE, /* SO_OOBINLINE */ 0, /* SO_NO_CHECK */ 0, /* SO_PRIORITY */ SOF_LINGER, /* SO_LINGER */ 0, /* SO_BSDCOMPAT */ SOF_REUSEPORT, /* SO_REUSEPORT */ 0, /* SO_RCVLOWAT */ 0, /* SO_SNDLOWAT */ 0, /* SO_RCVTIMEO */ 0, /* SO_SNDTIMEO */ 0, /* SO_PASSCRED */ 0, /* SO_PEERCRED */ 0, /* SO_SECURITY_AUTHENTICATION */ 0, /* SO_SECURITY_ENCRYPTION_TRANSPORT */ 0, /* SO_SECURITY_ENCRYPTION_NETWORK */ 0, /* SO_BINDTODEVICE */ 0, /* SO_ATTACH_FILTER */ 0, /* SO_DETACH_FILTER */ 0, /* SO_PEERNAME */ 0, /* SO_TIMESTAMP */ SOF_ACCEPTCONN /* SO_ACCEPTCONN */ }; static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len); static int err_to_errno_table[11] = { 0, /* ERR_OK 0 No error, everything OK. */ ENOMEM, /* ERR_MEM -1 Out of memory error. */ ENOBUFS, /* ERR_BUF -2 Buffer error. */ ECONNABORTED, /* ERR_ABRT -3 Connection aborted. */ ECONNRESET, /* ERR_RST -4 Connection reset. */ ESHUTDOWN, /* ERR_CLSD -5 Connection closed. */ ENOTCONN, /* ERR_CONN -6 Not connected. */ EINVAL, /* ERR_VAL -7 Illegal value. */ EIO, /* ERR_ARG -8 Illegal argument. */ EHOSTUNREACH, /* ERR_RTE -9 Routing problem. */ EADDRINUSE /* ERR_USE -10 Address in use. */ }; #define ERRNO #define err_to_errno(err) \ (-(err) < (sizeof(err_to_errno_table)/sizeof(int))) ? \ err_to_errno_table[-(err)] : EIO #ifdef ERRNO int lwip_errno; #define set_errno(err) do { \ errno = (err); \ lwip_errno = (err); \ } while (0) #else #define set_errno(err) #endif #define sock_set_errno(sk, e) do { \ sk->err = (e); \ set_errno(sk->err); \ } while (0) long lwip_version() { return 2; } static inline int get_lwip_sockmap(int s) { if (s < 0 || s >= lwip_sockmap_len) return -1; else return lwip_sockmap[s]; } static int set_lwip_sockmap(int s,short index) { if (s >= lwip_sockmap_len) { int newlen; int *new_lwip_sockmap; if (lwip_sockmap_len == 0) newlen=sysconf(_SC_OPEN_MAX); else newlen=lwip_sockmap_len; if (s >= newlen) newlen=s+SOCKMAP_SIZE; if ((new_lwip_sockmap=mem_realloc(lwip_sockmap,newlen*sizeof(int))) == NULL) return -1; else { lwip_sockmap=new_lwip_sockmap; for (;lwip_sockmap_len= sockets_len)) { LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s)); set_errno(EBADF); return NULL; } sock = sockets[index]; if (!sock->conn) { LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s)); set_errno(EBADF); return NULL; } return sock; } extern int socket(int domain, int type, int protocol); static int alloc_socket(struct netconn *newconn,u16_t family) { int i,fd; struct lwip_socket *this; if (!socksem) socksem = sys_sem_new(1); this=mem_malloc(sizeof(struct lwip_socket)); if (!this) { set_errno(ENOMEM); return -1; } else { this->family = family; this->conn = newconn; this->lastdata = NULL; this->lastoffset = 0; this->rcvevent = 0; this->sendevent = 1; /* TCP send buf is empty */ this->flags = O_RDWR; this->err = 0; /* Protect socket array */ sys_sem_wait(socksem); /* allocate a new socket identifier */ for(i = 0; 1 ; ++i) { if (i >= sockets_len) { int newlen=sockets_len+NUM_SOCKETS; struct lwip_socket **newsockets; if ((newsockets=mem_realloc(sockets,newlen*(sizeof(struct lwip_socket *)))) == NULL) { mem_free(this); set_errno(ENOMEM); sys_sem_signal(socksem); return -1; } sockets=newsockets; for (;sockets_lenfdfake=fd; set_lwip_sockmap(fd,i); return fd; } } return -1; } } /* syncronous access to pcb data */ #define OPT_SETVALUE 1 #define OPT_GETVALUE 2 #define OPT_SETBITS 3 #define OPT_CLRBITS 4 #define OPT_GETMASKED 5 #define OPT_SO_OPTIONS 1 #define OPT_FLAGS 2 #define OPT_TOS 3 #define OPT_TTL 4 #define OPT_KEEPALIVE 5 #define OPT_CHECKSUMOFFSET 6 #define opfield(op,field) (((op) << 5) | (field)) struct opt_data { u16_t opfieldtag; u32_t *value; }; static err_t sync_pcb_access(struct netconn *conn, void *arg) { struct opt_data *data = arg; switch (data->opfieldtag) { case opfield(OPT_SETBITS, OPT_SO_OPTIONS): conn->pcb.common->so_options |= *data->value; break; case opfield(OPT_CLRBITS, OPT_SO_OPTIONS): conn->pcb.common->so_options &= ~(*data->value); break; case opfield(OPT_GETMASKED, OPT_SO_OPTIONS): *data->value = conn->pcb.common->so_options & (*data->value); break; case opfield(OPT_SETBITS, OPT_FLAGS): conn->pcb.common->so_options |= *data->value; break; case opfield(OPT_CLRBITS, OPT_FLAGS): conn->pcb.common->so_options &= ~(*data->value); break; case opfield(OPT_GETMASKED, OPT_FLAGS): *data->value = conn->pcb.common->so_options & (*data->value); break; case opfield(OPT_SETVALUE, OPT_TOS): conn->pcb.tcp->tos = (*data->value); break; case opfield(OPT_GETVALUE, OPT_TOS): (*data->value) = conn->pcb.tcp->tos; break; case opfield(OPT_SETVALUE, OPT_TTL): conn->pcb.tcp->ttl = (*data->value); break; case opfield(OPT_GETVALUE, OPT_TTL): (*data->value) = conn->pcb.tcp->ttl; break; case opfield(OPT_SETVALUE, OPT_KEEPALIVE): conn->pcb.tcp->keepalive = (*data->value); break; case opfield(OPT_GETVALUE, OPT_KEEPALIVE): (*data->value) = conn->pcb.tcp->keepalive; break; case opfield(OPT_SETVALUE, OPT_CHECKSUMOFFSET): conn->pcb.raw->so_options |= SOF_IPV6_CHECKSUM; conn->pcb.raw->checksumoffset = (*data->value); break; } return ERR_OK; } static u32_t pcb_access(struct netconn *conn, u8_t op, u8_t field, u32_t value) { struct opt_data data = { .opfieldtag = opfield(op,field), .value = &value }; netconn_callback(conn, sync_pcb_access, &data); return value; } /* ----- end of syncronous access to pcb data functions ---- */ int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) { struct lwip_socket *sock; struct netconn *newconn; struct ip_addr naddr; u16_t port; int newsock; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s)); sock = get_socket(s); if (!sock #if LWIP_NL || sock->family == PF_NETLINK #endif #if LWIP_PACKET || sock->family == PF_PACKET #endif ) { set_errno(EBADF); return -1; } newconn = netconn_accept(sock->conn); /* get the IP address and port of the remote host */ netconn_peer(newconn, &naddr, &port); if (addr != NULL) { if (sock->family == PF_INET) { struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); sin.sin_family = sock->family; sin.sin_port = htons(port); /*memcpy(&(sin.sin_addr.s_addr),&(naddr.addr[3]),sizeof(sin.sin_addr.s_addr));*/ SOCK_IP46_CONV(&(sin.sin_addr.s_addr),&(naddr)); if (*addrlen > sizeof(sin)) *addrlen = sizeof(sin); memcpy(addr, &sin, *addrlen); } else { struct sockaddr_in6 sin; memset(&sin, 0, sizeof(sin)); sin.sin6_family = sock->family; sin.sin6_port = htons(port); memcpy(&(sin.sin6_addr),&(naddr.addr),sizeof(sin.sin6_addr)); if (*addrlen > sizeof(sin)) *addrlen = sizeof(sin); memcpy(addr, &sin, *addrlen); } } /* set by the EVT_ACCEPTPLUS event */ newsock = newconn->socket; //printf("ACCEPT return %d was %d %p was %p\n",newsock,s,newconn,sock->conn); if (newsock == -1) { netconn_delete(newconn); sock_set_errno(sock, ENOBUFS); return -1; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock)); ip_addr_debug_print(SOCKETS_DEBUG, &naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", port)); sock_set_errno(sock, 0); return newsock; } int lwip_bind(int s, struct sockaddr *name, socklen_t namelen) { struct lwip_socket *sock; struct ip_addr local_addr; u16_t local_port; err_t err; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } #if LWIP_NL if (sock->family == PF_NETLINK) { return netlink_bind(sock->conn,name,namelen); } else #endif { #if LWIP_PACKET if (sock->family == PF_PACKET) { struct sockaddr_ll *packname=(struct sockaddr_ll *)name; SALL2IPADDR(*packname,local_addr); local_port=packname->sll_protocol; } else #endif if (sock->family == PF_INET) { SOCK_IP64_CONV(&(local_addr),&(((struct sockaddr_in *)name)->sin_addr.s_addr)); local_port = ((struct sockaddr_in *)name)->sin_port; } else { memcpy(&(local_addr.addr),&(((struct sockaddr_in6 *)name)->sin6_addr),sizeof(local_addr.addr)); local_port = ((struct sockaddr_in6 *)name)->sin6_port; } #if LWIP_CAPABILITIES struct stack *stack=netconn_stack(sock->conn); if (stack->stack_capfun && (stack->stack_capfun()&LWIP_CAP_NET_BIND_SERVICE) == 0) { set_errno(EPERM); return -1; } #endif LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &local_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(local_port))); err = netconn_bind(sock->conn, &local_addr, ntohs(local_port)); if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err)); sock_set_errno(sock, err_to_errno(err)); return -1; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) succeeded\n", s)); sock_set_errno(sock, 0); return 0; } } int lwip_close(int s) { struct lwip_socket *sock; int err=0; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s)); if (!socksem) socksem = sys_sem_new(1); /* We cannot allow multiple closes of the same socket. */ sys_sem_wait(socksem); sock = get_socket(s); if (!sock) { sys_sem_signal(socksem); set_errno(EBADF); return -1; } #if LWIP_NL if (sock->family == PF_NETLINK) { err=netlink_close(sock->conn); sock->conn = NULL; } else #endif { netconn_delete(sock->conn); if (sock->lastdata) { netbuf_delete(sock->lastdata); } sock->lastdata = NULL; sock->lastoffset = 0; sock->conn = NULL; } sockets[get_lwip_sockmap(s)]=NULL; if (! _nofdfake) close(sock->fdfake); set_lwip_sockmap(sock->fdfake, -1); sock_set_errno(sock, err); mem_free(sock); sys_sem_signal(socksem); return err; } int lwip_connect(int s, struct sockaddr *name, socklen_t namelen) { struct lwip_socket *sock; err_t err; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } if (((struct sockaddr_in *)name)->sin_family == PF_UNSPEC) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, PF_UNSPEC)\n", s)); err = netconn_disconnect(sock->conn); } #if LWIP_NL else if (sock->family == PF_NETLINK) err=netlink_connect(sock->conn,name,namelen); #endif #if LWIP_PACKET // #endif else { struct ip_addr remote_addr; u16_t remote_port; if(sock->family == PF_INET) { SOCK_IP64_CONV(&(remote_addr),&(((struct sockaddr_in *)name)->sin_addr.s_addr)); remote_port = ((struct sockaddr_in *)name)->sin_port; } else { memcpy(&(remote_addr.addr),&(((struct sockaddr_in6 *)name)->sin6_addr),sizeof(remote_addr.addr)); remote_port = ((struct sockaddr_in6 *)name)->sin6_port; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port))); err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); } if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err)); sock_set_errno(sock, err_to_errno(err)); return -1; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) succeeded\n", s)); sock_set_errno(sock, 0); return 0; } int lwip_listen(int s, int backlog) { struct lwip_socket *sock; err_t err; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog)); sock = get_socket(s); if (!sock #if LWIP_NL || sock->family == PF_NETLINK #endif #if LWIP_PACKET || sock->family == PF_PACKET #endif ) { set_errno(EBADF); return -1; } err = netconn_listen(sock->conn); if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err)); sock_set_errno(sock, err_to_errno(err)); return -1; } sock_set_errno(sock, 0); return 0; } ssize_t lwip_recvfrom(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { struct lwip_socket *sock; struct netbuf *buf; u16_t buflen, copylen; struct ip_addr *addr; u16_t port; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags)); sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } #if LWIP_NL if (sock->family == PF_NETLINK) { return netlink_recvfrom(sock->conn,mem,len,flags,from,fromlen); } else #endif { /* Check if there is data left from the last recv operation. */ if (sock->lastdata) { buf = sock->lastdata; } else { /* If this is non-blocking call, then check first */ if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK)) && !sock->rcvevent) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s)); sock_set_errno(sock, EWOULDBLOCK); return -1; } /*printf("netconn_recv %p R %d L %p S %d\n", sock->conn, sock->rcvevent, sock->lastdata, sock->sendevent);*/ /* No data was left from the previous operation, so we try to get some from the network. */ buf = netconn_recv(sock->conn); if (!buf) { char *p=mem; /* We should really do some error checking here. */ LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL!\n", s)); *p=0; sock_set_errno(sock, 0); return 0; } } buflen = netbuf_len(buf); buflen -= sock->lastoffset; if (len > buflen) { copylen = buflen; } else { copylen = len; } /* copy the contents of the received buffer into the supplied memory pointer mem */ netbuf_copy_partial(buf, mem, copylen, sock->lastoffset); /* Check to see from where the data was. */ if (from && fromlen) { if (sock->family == PF_INET) { struct sockaddr_in sin; addr = netbuf_fromaddr(buf); port = netbuf_fromport(buf); memset(&sin, 0, sizeof(sin)); /*sin.sin_len = sizeof(sin);*/ sin.sin_family = PF_INET; sin.sin_port = htons(port); SOCK_IP46_CONV(&(sin.sin_addr.s_addr),addr); if (*fromlen > sizeof(sin)) *fromlen = sizeof(sin); memcpy(from, &sin, *fromlen); } else if (sock->family == PF_INET6) { struct sockaddr_in6 sin; addr = netbuf_fromaddr(buf); port = netbuf_fromport(buf); memset(&sin, 0, sizeof(sin)); sin.sin6_family = PF_INET6; sin.sin6_port = htons(port); memcpy(&(sin.sin6_addr),&(addr->addr),sizeof(sin.sin6_addr)); if (*fromlen > sizeof(sin)) *fromlen = sizeof(sin); memcpy(from, &sin, *fromlen); } #if LWIP_PACKET else if (sock->family == PF_PACKET) { struct sockaddr_ll sll; addr = netbuf_fromaddr(buf); port = netbuf_fromport(buf); memset(&sll, 0, sizeof(sll)); IPADDR2SALL(*addr,sll); sll.sll_protocol = htons(port); if (*fromlen > sizeof(sll)) *fromlen = sizeof(sll); memcpy(from, &sll, *fromlen); } #endif LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen)); } else { #if SOCKETS_DEBUG > 0 addr = netbuf_fromaddr(buf); port = netbuf_fromport(buf); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen)); #endif } if (flags & MSG_PEEK) { sock->lastdata = buf; /* lastoffset does not change, usually it is 0 and it keeps its value */ } /* If this is a TCP socket, check if there is data left in the buffer. If so, it should be saved in the sock structure for next time around. */ else if (netconn_type(sock->conn) == NETCONN_TCP && buflen - copylen > 0) { sock->lastdata = buf; sock->lastoffset += copylen; } else { sock->lastdata = NULL; sock->lastoffset = 0; netbuf_delete(buf); } sock_set_errno(sock, 0); if (flags & MSG_TRUNC) return buflen; else return copylen; } } ssize_t lwip_read(int s, void *mem, int len) { return lwip_recvfrom(s, mem, len, 0, NULL, NULL); } ssize_t lwip_recv(int s, void *mem, int len, unsigned int flags) { return lwip_recvfrom(s, mem, len, flags, NULL, NULL); } ssize_t lwip_recvmsg(int fd, struct msghdr *msg, int flags) { msg->msg_controllen=0; if (msg->msg_iovlen == 1) { ssize_t ret=lwip_recvfrom(fd, msg->msg_iov->iov_base,msg->msg_iov->iov_len,flags, msg->msg_name,&(msg->msg_namelen)); if (ret > msg->msg_iov->iov_len) msg->msg_flags |= MSG_TRUNC; return ret; } else { struct iovec *msg_iov; size_t msg_iovlen; unsigned int i,totalsize; size_t size; char *lbuf; msg_iov=msg->msg_iov; msg_iovlen=msg->msg_iovlen; for (i=0,totalsize=0;imsg_name,&(msg->msg_namelen)); if (size > totalsize) msg->msg_flags |= MSG_TRUNC; for (i=0;size > 0 && i msg_iov[i].iov_len)?msg_iov[i].iov_len:size; memcpy(msg_iov[i].iov_base,lbuf,qty); lbuf+=qty; size-=qty; } return size; } } ssize_t lwip_send(int s, void *data, int size, unsigned int flags) { struct lwip_socket *sock; struct netbuf *buf; err_t err; /* FIX: handle EWOULDBLOCK in the right way. POSIX write() blocks on a socket until all input data is written. Only with EWOULDBLOCK, input data and written data can be of different sizes */ LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d, data=%p, size=%d, flags=0x%x)\n", s, data, size, flags)); sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } #if LWIP_NL if (sock->family == PF_NETLINK) { return netlink_send(sock->conn,data,size,flags); } else #endif { /*netconn parms are u16*/ if (size > USHRT_MAX) size=USHRT_MAX; switch (netconn_type(sock->conn)) { case NETCONN_RAW: case NETCONN_UDP: case NETCONN_UDPLITE: #if LWIP_PACKET case NETCONN_PACKET_RAW: case NETCONN_PACKET_DGRAM: #endif /* create a buffer */ buf = netbuf_new(); if (!buf) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ENOBUFS\n", s)); sock_set_errno(sock, ENOBUFS); return -1; } /* make the buffer point to the data that should be sent */ netbuf_ref(buf, data, size); /* send the data */ err = netconn_send(sock->conn, buf); /* deallocated the buffer */ netbuf_delete(buf); break; case NETCONN_TCP: err = netconn_write(sock->conn, data, size, NETCONN_COPY); break; default: err = ERR_ARG; break; } if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d\n", s, err)); sock_set_errno(sock, err_to_errno(err)); return -1; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ok size=%d\n", s, size)); sock_set_errno(sock, 0); return size; } } ssize_t lwip_sendto(int s, void *data, int size, unsigned int flags, struct sockaddr *to, socklen_t tolen) { struct lwip_socket *sock; struct ip_addr remote_addr, addr; u16_t remote_port, port; int ret,connected; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } #if LWIP_NL if (sock->family == PF_NETLINK) { return netlink_sendto(sock->conn,data,size,flags,to,tolen); } else #endif { /* get the peer if currently connected */ connected = (netconn_peer(sock->conn, &addr, &port) == ERR_OK); if (tolen>0) { if (sock->family == PF_INET) { SOCK_IP64_CONV(&(remote_addr),&(((struct sockaddr_in *)to)->sin_addr.s_addr)); remote_port = ((struct sockaddr_in *)to)->sin_port; } else if (sock->family == PF_INET6) { memcpy(&(remote_addr.addr),&(((struct sockaddr_in6 *)to)->sin6_addr),sizeof(remote_addr.addr)); remote_port = ((struct sockaddr_in *)to)->sin_port; } #if LWIP_PACKET else if (sock->family == PF_PACKET) { SALL2IPADDR(*(struct sockaddr_ll *)to,remote_addr); remote_port=(((struct sockaddr_ll *)to)->sll_protocol); } #endif LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, size=%d, flags=0x%x to=", s, data, size, flags)); ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", ntohs(remote_port))); netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); } ret = lwip_send(s, data, size, flags); /* reset the remote address and port number of the connection */ if (connected) { if (tolen>0) netconn_connect(sock->conn, &addr, port); } else netconn_disconnect(sock->conn); return ret; } } ssize_t lwip_sendmsg(int fd, struct msghdr *msg, int flags) { msg->msg_controllen=0; if (msg->msg_iovlen == 1) { return lwip_sendto(fd, msg->msg_iov->iov_base,msg->msg_iov->iov_len,flags, msg->msg_name,msg->msg_namelen); } else { struct iovec *msg_iov; size_t msg_iovlen; unsigned int i,totalsize; size_t size; char *lbuf; msg_iov=msg->msg_iov; msg_iovlen=msg->msg_iovlen; for (i=0,totalsize=0;i 0 && imsg_name,msg->msg_namelen); return size; } } int lwip_msocket(struct stack *stack, int domain, int type, int protocol) { struct netconn *conn; int i; if (stack==NULL) { set_errno(ENONET); return -1; } if (domain != PF_INET && domain != PF_INET6 #if LWIP_NL && domain != PF_NETLINK #endif #if LWIP_PACKET && domain != PF_PACKET #endif ) { set_errno(EAFNOSUPPORT); return -1; } #if LWIP_CAPABILITIES if (domain == PF_PACKET || (domain == PF_INET || domain == PF_INET6) && type == SOCK_RAW) { if (stack->stack_capfun && (stack->stack_capfun()&LWIP_CAP_NET_RAW)==0) { set_errno(EPERM); return -1; } } #endif switch(domain) { #if LWIP_NL case PF_NETLINK: switch (type) { case SOCK_RAW: case SOCK_DGRAM: if (protocol != 0) { set_errno(EINVAL); return -1; } else { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s,XXX, %d) = ", domain_name(domain), protocol)); conn = netlink_open(stack, type, protocol); } break; default: set_errno(EINVAL); return -1; } break; #endif /* LWIP_NL */ #if LWIP_PACKET case PF_PACKET: switch (type) { case SOCK_RAW: conn = netconn_new_with_proto_and_callback(stack, NETCONN_PACKET_RAW, protocol, event_callback); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_RAW, %d) = ", domain_name(domain), protocol)); break; case SOCK_DGRAM: conn = netconn_new_with_proto_and_callback(stack, NETCONN_PACKET_DGRAM, protocol, event_callback); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ", domain_name(domain), protocol)); break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", domain, type, protocol)); set_errno(EINVAL); return -1; } break; #endif /* LWIP_PACKET */ case PF_INET: case PF_INET6: /* create a netconn */ switch (type) { case SOCK_RAW: conn = netconn_new_with_proto_and_callback(stack, NETCONN_RAW, protocol, event_callback); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_RAW, %d) = ", domain_name(domain), protocol)); break; case SOCK_DGRAM: conn = netconn_new_with_callback(stack, NETCONN_UDP, event_callback); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ", domain_name(domain), protocol)); break; case SOCK_STREAM: conn = netconn_new_with_callback(stack, NETCONN_TCP, event_callback); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ", domain_name(domain), protocol)); break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", domain, type, protocol)); set_errno(EINVAL); return -1; } break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d/UNKNOWN, %d, %d) = -1\n", domain, type, protocol)); } if (!conn) { LWIP_DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n")); set_errno(ENOBUFS); return -1; } i = alloc_socket(conn,domain); if (i == -1 #if LWIP_NL && domain != PF_NETLINK #endif ) { netconn_delete(conn); set_errno(ENOBUFS); return -1; } #if LWIP_NL if (domain != PF_NETLINK) #endif conn->socket = i; LWIP_DEBUGF(SOCKETS_DEBUG, ("%d\n", i)); set_errno(0); return i; } int lwip_socket(int domain, int type, int protocol) { lwip_msocket(tcpip_stack_get(),domain,type,protocol); } ssize_t lwip_write(int s, void *data, int size) { return lwip_send(s, data, size, 0); } #if 0 pfdset(int max, fd_set *fds) { register int i; if (fds == NULL) printf("NULL"); else for (i=0;icb=cb; new->arg=arg; new->fd=fd; new->events=events; new->next=um_sel_head; um_sel_head=new; } /* recursive is simpler but maybe not optimized */ static struct um_sel_wait *um_sel_rec_del(struct um_sel_wait *p,void *arg,int fd) { if (p==NULL) return NULL; else { struct um_sel_wait *next=um_sel_rec_del(p->next,arg,fd); if (p->arg == arg && p->fd == fd) { mem_free(p); return(next); } else { p->next=next; return(p); } } } static void um_sel_del(void *arg, int fd) { //printf("UMSELECT DEL arg %x\n",arg); um_sel_head=um_sel_rec_del(um_sel_head,arg,fd); } static struct um_sel_wait *um_sel_rec_signal(struct um_sel_wait *p,int fd, int events) { if (p==NULL) return NULL; else { if (fd == p->fd && (events & p->events) != 0) { /* found */ struct um_sel_wait *next=um_sel_rec_del(p->next,p->arg,fd); //printf("UMSELECT SIGNALED %d\n",fd); p->cb(p->arg); mem_free(p); return um_sel_rec_signal(next,fd,events); } else { p->next=um_sel_rec_signal(p->next,fd,events); return p; } } } static void um_sel_signal(int fd, int events) { //printf("UMSELECT SIGNAL fd %d events %x\n",fd,events); um_sel_head=um_sel_rec_signal(um_sel_head,fd,events); } int lwip_event_subscribe(void (* cb)(), void *arg, int fd, int events) { struct lwip_socket *psock=get_socket(fd); int rv=0; //printf("UMSELECT REGISTER %s %d events %x arg %x psock %x\n", //(cb != NULL)?"REG" : "DEL", fd,events,arg,psock); if (!selectsem) selectsem = sys_sem_new(1); sys_sem_wait(selectsem); if (psock) { //printf("R %d L %p S %d\n", psock->rcvevent, psock->lastdata, psock->sendevent); #if LWIP_NL if (psock->family == PF_NETLINK) rv=events; else #endif if ((rv= (events & POLLIN) * (psock->lastdata || psock->rcvevent || psock->conn->recv_avail) + (events & POLLOUT) * psock->sendevent) == 0 && cb != NULL) um_sel_add(cb,arg,fd,events); } if (cb == NULL || rv>0) um_sel_del(arg,fd); //printf("UMSELECT REGISTER returns %x %p %d %d\n",rv,psock->lastdata , psock->rcvevent , psock->conn->recv_avail); sys_sem_signal(selectsem); return rv; } static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) { int s; struct lwip_socket *sock; //printf("event_callback %p %d\n",conn,evt); /* Get socket */ if (conn) { s = conn->socket; if (s < 0) { /* This should never happen! */ printf("----socket hack already needed %d\n",conn->socket); return; } sock = get_socket(s); //printf("event_callback %p %d %d\n",conn,evt,s); if (!sock) return; if (evt == NETCONN_EVT_ACCEPTPLUS) { int newsock; newsock = alloc_socket(conn,sock->family); if (newsock >= 0) { sock = get_socket(newsock); sock->rcvevent =0; } conn->socket = newsock; //printf("NETCONN_EVT_ACCEPTPLUS %p %d \n",conn,newsock); return; } } else return; if (!selectsem) selectsem = sys_sem_new(1); sys_sem_wait(selectsem); /* Set event as required */ switch (evt) { case NETCONN_EVT_RCVPLUS: sock->rcvevent++; break; case NETCONN_EVT_RCVMINUS: sock->rcvevent--; break; case NETCONN_EVT_SENDPLUS: sock->sendevent = 1; break; case NETCONN_EVT_SENDMINUS: sock->sendevent = 0; break; } um_sel_signal(sock->fdfake, POLLIN * (sock->rcvevent || sock->lastdata || sock->conn->recv_avail) + POLLOUT * sock->sendevent); //printf("EVENT fd %d(%d) R%d S%d\n",s,evt,sock->rcvevent,sock->sendevent); sys_sem_signal(selectsem); } int lwip_shutdown(int s, int how) { struct lwip_socket *sock; int err=0; u16_t perm; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how)); if (!socksem) socksem = sys_sem_new(1); sys_sem_wait(socksem); sock = get_socket(s); if (!sock) { sys_sem_signal(socksem); set_errno(EBADF); return -1; } perm=(sock->flags & O_ACCMODE)+1; perm &= ~((how & O_ACCMODE)+1); sock->flags = (sock->flags & ~O_ACCMODE) | ((perm - 1) & O_ACCMODE); sys_sem_signal(socksem); return 0; } int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen) { struct lwip_socket *sock; struct ip_addr naddr; u16_t port; sock = get_socket(s); if (!sock #if LWIP_NL || sock->family == PF_NETLINK #endif #if LWIP_PACKET || sock->family == PF_PACKET #endif ) { set_errno(EBADF); return -1; } /* get the IP address and port of the remote host */ netconn_peer(sock->conn, &naddr, &port); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getpeername(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", port)); if (sock->family == PF_INET) { struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); sin.sin_family = PF_INET; sin.sin_port = htons(port); /*memcpy(&(sin.sin_addr.s_addr),&(naddr.addr),sizeof(sin.sin_addr.s_addr));*/ SOCK_IP46_CONV(&(sin.sin_addr.s_addr),&(naddr)); if (*namelen > sizeof(sin)) *namelen = sizeof(sin); memcpy(name, &sin, *namelen); } else { struct sockaddr_in6 sin; memset(&sin, 0, sizeof(sin)); sin.sin6_family = PF_INET6; sin.sin6_port = htons(port); memcpy(&(sin.sin6_addr),&(naddr.addr),sizeof(sin.sin6_addr)); if (*namelen > sizeof(sin)) *namelen = sizeof(sin); memcpy(name, &sin, *namelen); } sock_set_errno(sock, 0); return 0; } int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen) { struct lwip_socket *sock; struct ip_addr naddr; u16_t port; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } #if LWIP_NL if (sock->family == PF_NETLINK) { return netlink_getsockname (sock->conn,name,namelen); } else #endif { int err; /* get the IP address and port of the remote host */ err = netconn_addr(sock->conn, &naddr, &port); if (err != ERR_OK) { set_errno(EINVAL); return -1; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockname(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", port)); if (sock->family == PF_INET) { struct sockaddr_in sin; memset(&sin, 0, sizeof(sin)); sin.sin_family = PF_INET; sin.sin_port = htons(port); /*memcpy(&(sin.sin_addr.s_addr),&(naddr.addr),sizeof(sin.sin_addr.s_addr));*/ SOCK_IP46_CONV(&(sin.sin_addr.s_addr),&naddr); if (*namelen > sizeof(sin)) *namelen = sizeof(sin); memcpy(name, &sin, *namelen); /*printf("%x %d\n",sin.sin_addr.s_addr,*namelen);*/ } else { struct sockaddr_in6 sin; memset(&sin, 0, sizeof(sin)); sin.sin6_family = PF_INET6; sin.sin6_port = htons(port); memcpy(&(sin.sin6_addr),&naddr,sizeof(sin.sin6_addr)); if (*namelen > sizeof(sin)) *namelen = sizeof(sin); memcpy(name, &sin, *namelen); } sock_set_errno(sock, 0); return 0; } } int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen) { int err = 0; struct lwip_socket *sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } if( NULL == optval || NULL == optlen ) { sock_set_errno( sock, EFAULT ); return -1; } #if LWIP_NL if(sock->family == PF_NETLINK) { int err=netlink_getsockopt(sock->conn, level, optname, optval, optlen); if (err != 0) { sock_set_errno(sock, err); return -1; } else return 0; } #endif /* Do length and type checks for the various options first, to keep it readable. */ switch( level ) { /* Level: SOL_SOCKET */ case SOL_SOCKET: switch(optname) { case SO_ACCEPTCONN: case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ /* UNIMPL case SO_DONTROUTE: */ case SO_ERROR: case SO_KEEPALIVE: /* UNIMPL case SO_OOBINLINE: */ /* UNINPL case SO_RCVBUF: */ /* UNINPL case SO_SNDBUF: */ /* FAKE SO_RCVBUF, SO_SNDBUF */ case SO_RCVBUF: case SO_SNDBUF: /* UNIMPL case SO_RCVLOWAT: */ /* UNIMPL case SO_SNDLOWAT: */ #if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ case SO_TYPE: /* UNIMPL case SO_USELOOPBACK: */ if( *optlen < sizeof(int) ) { err = EINVAL; } break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level: IPPROTO_IP */ case IPPROTO_IP: switch(optname) { case IP_HDRINCL: /* UNIMPL case IP_RCVDSTADDR: */ /* UNIMPL case IP_RCVIF: */ case IP_TTL: case IP_TOS: if( *optlen < sizeof(int) ) { err = EINVAL; } break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level: IPPROTO_TCP */ case IPPROTO_TCP: if( *optlen < sizeof(int) ) { err = EINVAL; break; } /* If this is no TCP socket, ignore any options. */ if ( sock->conn->type != NETCONN_TCP ) return 0; switch( optname ) { case TCP_NODELAY: case TCP_KEEPALIVE: break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* UNDEFINED LEVEL */ default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname)); err = ENOPROTOOPT; } /* switch */ if( 0 != err ) { sock_set_errno(sock, err); return -1; } /* Now do the actual option processing */ switch(level) { /* Level: SOL_SOCKET */ case SOL_SOCKET: switch( optname ) { /* The option flags */ case SO_ACCEPTCONN: case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINCLUDE: */ #if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ /*case SO_USELOOPBACK: UNIMPL */ //*(int*)optval = sock->conn->pcb.tcp->so_options & so_map[optname]; *(int*)optval = pcb_access(sock->conn,OPT_GETMASKED,OPT_SO_OPTIONS,so_map[optname]); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, optname=0x%x, ..) = %s\n", s, optname, (*(int*)optval?"on":"off"))); break; case SO_TYPE: switch (sock->conn->type) { case NETCONN_RAW: *(int*)optval = SOCK_RAW; break; case NETCONN_TCP: *(int*)optval = SOCK_STREAM; break; case NETCONN_UDP: case NETCONN_UDPLITE: case NETCONN_UDPNOCHKSUM: *(int*)optval = SOCK_DGRAM; break; default: /* unrecognized socket type */ *(int*)optval = sock->conn->type; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE): unrecognized socket type %d\n", s, *(int *)optval)); } /* switch */ LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE) = %d\n", s, *(int *)optval)); break; case SO_ERROR: *(int *)optval = sock->err; sock->err = 0; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", s, *(int *)optval)); break; /*fake SO_RCVBUF, SO_SNDBUF, return the max value */ case SO_RCVBUF: case SO_SNDBUF: *(int *)optval = 262144; break; } /* switch */ break; /* Level: IPPROTO_IP */ case IPPROTO_IP: switch( optname ) { case IP_TTL: //*(int*)optval = sock->conn->pcb.tcp->ttl; *(int*)optval = pcb_access(sock->conn,OPT_GETVALUE,OPT_TTL,0); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TTL) = %d\n", s, *(int *)optval)); break; case IP_TOS: //*(int*)optval = sock->conn->pcb.tcp->tos; *(int*)optval = pcb_access(sock->conn,OPT_GETVALUE,OPT_TOS,0); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TOS) = %d\n", s, *(int *)optval)); break; case IP_HDRINCL: //*(int*)optval = (sock->conn->pcb.tcp->so_options & SOF_HDRINCL); *(int*)optval = pcb_access(sock->conn,OPT_GETMASKED,OPT_SO_OPTIONS,SOF_HDRINCL); break; } /* switch */ break; /* Level: IPPROTO_TCP */ case IPPROTO_TCP: switch( optname ) { case TCP_NODELAY: //*(int*)optval = (sock->conn->pcb.tcp->flags & TF_NODELAY); *(int*)optval = pcb_access(sock->conn,OPT_GETMASKED,OPT_FLAGS,TF_NODELAY); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, TCP_NODELAY) = %s\n", s, (*(int*)optval)?"on":"off") ); break; case TCP_KEEPALIVE: //*(int*)optval = sock->conn->pcb.tcp->keepalive; *(int*)optval = pcb_access(sock->conn,OPT_GETVALUE,OPT_KEEPALIVE,0); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPALIVE) = %d\n", s, *(int *)optval)); break; } /* switch */ break; } sock_set_errno(sock, err); return err ? -1 : 0; } int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen) { struct lwip_socket *sock; int err = 0; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } if( NULL == optval ) { sock_set_errno( sock, EFAULT ); /*printf("fault\n");*/ return -1; } #if LWIP_NL if(sock->family == PF_NETLINK) { int err=netlink_setsockopt(sock->conn, level, optname, optval, optlen); if (err != 0) { sock_set_errno(sock, err); return -1; } else return 0; } #endif /* Do length and type checks for the various options first, to keep it readable. */ switch( level ) { /* Level: SOL_SOCKET */ case SOL_SOCKET: switch(optname) { case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINLINE: */ /* UNIMPL case SO_RCVBUF: */ /* UNIMPL case SO_SNDBUF: */ /* FAKE SO_SNDBUF, SO_RCVBUF, SO_TIMESTAMP */ case SO_RCVBUF: case SO_SNDBUF: case SO_TIMESTAMP: /* UNIMPL case SO_RCVLOWAT: */ /* UNIMPL case SO_SNDLOWAT: */ #if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ /* UNIMPL case SO_USELOOPBACK: */ if( optlen < sizeof(int) ) { err = EINVAL; } break; /*case SO_ATTACH_FILTER: break;*/ default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level: IPPROTO_IP */ case IPPROTO_IP: switch(optname) { case IP_HDRINCL: /* UNIMPL case IP_RCVDSTADDR: */ /* UNIMPL case IP_RCVIF: */ case IP_TTL: case IP_TOS: /* FAKE IP_MTU_DISCOVER */ case IP_MTU_DISCOVER: case IP_RECVERR: case IP_RECVTTL: case IP_RECVTOS: if( optlen < sizeof(int) ) { err = EINVAL; } break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level: IPPROTO_TCP */ case IPPROTO_TCP: if( optlen < sizeof(int) ) { err = EINVAL; break; } /* If this is not a TCP socket, ignore any options. */ if ( sock->conn->type != NETCONN_TCP ) return 0; switch( optname ) { case TCP_NODELAY: case TCP_KEEPALIVE: break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level IPPROTO_IPV6 */ case IPPROTO_IPV6: switch( optname ) { case IPV6_HOPLIMIT: case IPV6_MULTICAST_HOPS: case IPV6_UNICAST_HOPS: break; default: printf("IPPROTO_IPV6 %d\n",optname); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IPV6, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } break; /* Level IPPROTO_ICMPV6 */ case IPPROTO_ICMPV6: switch( optname ) { case ICMPV6_FILTER: break; default: printf("IPPROTO_ICMPV6 %d\n",optname); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_ICMPV6, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } break; /* Level IPPROTO_RAW */ case IPPROTO_RAW: switch( optname ) { case IPV6_CHECKSUM: if( optlen < sizeof(int) ) { err = EINVAL; } break; default: //printf("IPPROTO_RAW %d\n",optname); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_RAW, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } break; #if LWIP_PACKET case SOL_PACKET: switch( optname ) { case PACKET_ADD_MEMBERSHIP: case PACKET_DROP_MEMBERSHIP: { const struct packet_mreq *pm = optval; if (optlen < sizeof(struct packet_mreq)) { err = EINVAL; } else { /* XXX Membership has not been managed yet */ printf("PACKET_MEMBERSHIP %d %d %d %d\n", optname,pm->mr_ifindex,pm->mr_type,pm->mr_alen); } } break; //case PACKET_RECV_OUTPUT: //case PACKET_RX_RING: //case PACKET_STATISTICS: default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_RAW, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; break; } break; #endif /* UNDEFINED LEVEL */ default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname)); err = ENOPROTOOPT; } /* switch */ if( 0 != err ) { sock_set_errno(sock, err); return -1; } /* Now do the actual option processing */ switch(level) { /* Level: SOL_SOCKET */ case SOL_SOCKET: switch(optname) { /* The option flags */ case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINCLUDE: */ #if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ /* UNIMPL case SO_USELOOPBACK: */ if ( *(int*)optval ) { //sock->conn->pcb.tcp->so_options |= so_map[optname]; pcb_access(sock->conn,OPT_SETBITS,OPT_SO_OPTIONS,so_map[optname]); } else { //sock->conn->pcb.tcp->so_options &= ~(so_map[optname]); pcb_access(sock->conn,OPT_CLRBITS,OPT_SO_OPTIONS,so_map[optname]); } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n", s, optname, (*(int*)optval?"on":"off"))); break; } /* switch */ break; /* Level: IPPROTO_IP */ case IPPROTO_IP: switch( optname ) { case IP_TTL: //sock->conn->pcb.tcp->ttl = (u8_t)(*(int*)optval); pcb_access(sock->conn,OPT_SETVALUE,OPT_TTL,(*(int*)optval)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TTL, ..) -> %u\n", s, sock->conn->pcb.tcp->ttl)); break; case IP_TOS: //sock->conn->pcb.tcp->tos = (u8_t)(*(int*)optval); pcb_access(sock->conn,OPT_SETVALUE,OPT_TOS,(*(int*)optval)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TOS, ..)-> %u\n", s, sock->conn->pcb.tcp->tos)); break; case IP_HDRINCL: if (*(int*)optval) //sock->conn->pcb.tcp->so_options |= SOF_HDRINCL; pcb_access(sock->conn,OPT_SETBITS,OPT_SO_OPTIONS,SOF_HDRINCL); else //sock->conn->pcb.tcp->so_options &= ~SOF_HDRINCL; pcb_access(sock->conn,OPT_CLRBITS,OPT_SO_OPTIONS,SOF_HDRINCL); break; } /* switch */ break; /* Level: IPPROTO_TCP */ case IPPROTO_TCP: switch( optname ) { case TCP_NODELAY: if ( *(int*)optval ) { //sock->conn->pcb.tcp->flags |= TF_NODELAY; pcb_access(sock->conn,OPT_SETBITS,OPT_FLAGS,TF_NODELAY); } else { //sock->conn->pcb.tcp->flags &= ~TF_NODELAY; pcb_access(sock->conn,OPT_CLRBITS,OPT_FLAGS,TF_NODELAY); } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_NODELAY) -> %s\n", s, (*(int *)optval)?"on":"off") ); break; case TCP_KEEPALIVE: //sock->conn->pcb.tcp->keepalive = (u32_t)(*(int*)optval); pcb_access(sock->conn,OPT_SETVALUE,OPT_KEEPALIVE,(u32_t)(*(int*)optval)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPALIVE) -> %u\n", s, (int) sock->conn->pcb.tcp->keepalive)); break; } /* switch */ /* Level IPPROTO_IPV6 */ case IPPROTO_IPV6: switch( optname ) { case IPV6_UNICAST_HOPS: case IPV6_MULTICAST_HOPS: /* TODO add a separate ttl for unicast */ //sock->conn->pcb.tcp->ttl = (u8_t)(*(int*)optval); pcb_access(sock->conn,OPT_SETVALUE,OPT_TTL,(*(int*)optval)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IPV6, IPV6_HOPLIMIT, ..) -> %u\n", s, sock->conn->pcb.tcp->ttl)); break; /* TODO IPV6_HOPLIMIT is a flag to allow packet to inspect * the hop limit value */ case IPV6_HOPLIMIT: break; default: break; } break; /* Level IPPROTO_ICMPV6 */ case IPPROTO_ICMPV6: switch( optname ) { default: break; } break; /* Level IPPROTO_RAW */ case IPPROTO_RAW: switch( optname ) { case IPV6_CHECKSUM: //sock->conn->pcb.raw->so_options |= SOF_IPV6_CHECKSUM; //sock->conn->pcb.raw->checksumoffset=*(int*)optval; pcb_access(sock->conn,OPT_SETVALUE,OPT_CHECKSUMOFFSET,*(int*)optval); break; default: break; } break; } /* switch */ sock_set_errno(sock, err); return err ? -1 : 0; } int multistack_cmd(int cmd, void *param); int lwip_ioctl(int s, unsigned long cmd, void *argp) { struct lwip_socket *sock = get_socket(s); struct stack *stack; int cap; if (!sock #if LWIP_NL || sock->family == PF_NETLINK #endif #ifdef LWIP_SOCKET || sock->family == PF_SOCKET #endif ) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, %u,... ) BADF\n", s, cmd)); set_errno(EBADF); return -1; } switch (cmd) { case FIONREAD: if (!argp) { sock_set_errno(sock, EINVAL); return -1; } *((u32_t*)argp) = sock->conn->recv_avail; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %lu\n", s, argp, *((u32_t*)argp))); sock_set_errno(sock, 0); return 0; case FIONBIO: if (argp && *(u32_t*)argp) sock->flags |= O_NONBLOCK; else sock->flags &= ~O_NONBLOCK; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, !!(sock->flags & O_NONBLOCK))); sock_set_errno(sock, 0); return 0; case SIOCGIFTXQLEN: /* XXX hack */ if (!argp) { sock_set_errno(sock, EINVAL); return -1; } *((u16_t*)argp) = 0; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, SIOCGIFTXQLEN, %p) = %u\n", s, argp, *((u16_t*)argp))); sock_set_errno(sock, 0); return 0; case SIOCGSTAMP: { struct timezone tz; struct timeval tv; gettimeofday(&tv,&tz); memcpy(argp,&tv,sizeof(struct timeval)); } return 0; default: stack=netconn_stack(sock->conn); #if LWIP_CAPABILITIES if (stack->stack_capfun) cap=stack->stack_capfun(); else cap= ~0; #endif if (cmd >= SIOCGIFNAME && cmd <= SIOCSIFTXQLEN) { int err; err=netif_ioctl(stack, cmd, argp #if LWIP_CAPABILITIES ,cap #endif ); sock_set_errno(sock, err); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, SIO TO NETIF) ret=%d\n",s,err)); if (err) return -1; else return 0; } else if (cmd >= SIOCDARP && cmd <= SIOCSARP) { int err=1; err=etharp_ioctl(stack, cmd, argp #if LWIP_CAPABILITIES ,cap #endif ); sock_set_errno(sock, err); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, SIO TO NETIF) ret=%d\n",s,err)); if (err) return -1; else return 0; } else { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp)); sock_set_errno(sock, ENOSYS); /* not yet implemented */ return -1; } } } #ifdef __USE_GNU #define FCNTL_SETFL_MASK (O_APPEND|O_ASYNC|O_DIRECT|O_NOATIME|O_NONBLOCK) #else #define FCNTL_SETFL_MASK (O_APPEND|O_ASYNC|O_NONBLOCK) #endif int lwip_fcntl64(int s, int cmd, long arg) { struct lwip_socket *sock = get_socket(s); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_fcntl(%d, %x)\n",s,cmd)); if (!sock #if LWIP_NL || sock->family == PF_NETLINK #endif #ifdef LWIP_SOCKET || sock->family == PF_SOCKET #endif ) { set_errno(EBADF); return -1; } switch (cmd) { case F_GETFL: return sock->flags; case F_SETFL: sock->flags = (sock->flags & ~FCNTL_SETFL_MASK) | (arg & FCNTL_SETFL_MASK); return 0; default: return -1; } } int lwip_fcntl(int s, int cmd, long arg) { return lwip_fcntl64(s,cmd,arg); } static int fdsplit(int max, fd_set *rfd, fd_set *wfd, fd_set *efd, fd_set *rlfd, fd_set *wlfd, fd_set *elfd, fd_set *rnfd, fd_set *wnfd, fd_set *enfd) { int lcount=0; register int i; if (rfd) *rlfd=*rnfd=*rfd; else { FD_ZERO(rlfd); FD_ZERO(rnfd); } if (wfd) *wlfd=*wnfd=*wfd; else { FD_ZERO(wlfd); FD_ZERO(wnfd); } if (efd) *elfd=*enfd=*efd; else { FD_ZERO(elfd); FD_ZERO(enfd); } for (i=0;i= 0) { if(FD_ISSET(i,rlfd) || FD_ISSET(i,wlfd) || FD_ISSET(i,elfd)) lcount++; FD_CLR(i,rnfd); FD_CLR(i,wnfd); FD_CLR(i,enfd); } else { FD_CLR(i,rlfd); FD_CLR(i,wlfd); FD_CLR(i,elfd); } } return lcount; } void lwip_pipecb(int *fdp) { write(fdp[1],"\0",1); } int lwip_pselect(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, const struct timespec *timeout, const sigset_t *sigmask) { int i; int rv,count; short *events; short revents=0; int fdp[2]; int newmaxp1; struct timespec now={0,0}; fd_set lwriteset; fd_set lreadset; fd_set lexceptset; struct lwip_socket *p_sock; pipe(fdp); if (readset) lreadset=*readset; else FD_ZERO(&lreadset); if (writeset) lwriteset=*writeset; else FD_ZERO(&lwriteset); if (exceptset) lexceptset=*exceptset; else FD_ZERO(&lexceptset); for (i=0;i= maxfdp1)?fdp[0]+1:maxfdp1; if (revents) rv=pselect(newmaxp1,&lreadset,&lwriteset,&lexceptset,&now,sigmask); else rv=pselect(newmaxp1,&lreadset,&lwriteset,&lexceptset,timeout,sigmask); count=0; for (i=0;i=0)?count:rv; } int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout) { struct timespec *ptimeout; if (timeout) { ptimeout=alloca(sizeof(struct timespec)); ptimeout->tv_sec=timeout->tv_sec; ptimeout->tv_nsec=timeout->tv_usec*1000; } else ptimeout=NULL; return lwip_pselect(maxfdp1,readset,writeset,exceptset,ptimeout,NULL); } static inline int pollrealfdcount(struct pollfd *fds, nfds_t nfds) { int i,count; for (i=count=0;ilastdata || p_sock->rcvevent || p_sock->conn->recv_avail)) count++; else if ((fds[i].events & POLLOUT) && p_sock->sendevent) count++; } } return count; } static int lwip_pollmerge(struct pollfd *fds, nfds_t nfds, struct pollfd *rfds) { int i,count,ri; for (i=ri=count=0;ilastdata || p_sock->rcvevent || p_sock->conn->recv_avail)) fds[i].revents |= POLLIN; if ((fds[i].events & POLLOUT) && p_sock->sendevent) fds[i].revents |= POLLOUT; } else { if (fds[i].fd != rfds[ri].fd) printf("ERROR misalignment!\n"); else { fds[i].revents=rfds[ri].revents; ri++; } } if (fds[i].revents) count++; } return count; } int lwip_ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout, const sigset_t *sigmask) { int i; int rv,count; short *events; short revents=0; int fdp[2]; struct timespec now={0,0}; int indexpipe=-1; int substitutedbypipe; pipe(fdp); events=alloca(nfds*sizeof(short)); for (i=0;i=0)?count:rv; } int lwip_poll(struct pollfd *fds, nfds_t nfds, int timeout) { int rv; struct timespec *ptimeout; if (timeout>=0) { ptimeout=alloca(sizeof(struct timespec)); ptimeout->tv_sec=timeout/1000; ptimeout->tv_nsec=(timeout%1000)*1000000; } else ptimeout=NULL; rv=lwip_ppoll(fds,nfds,ptimeout,NULL); } /* FIX: change implementations. Do not use a private buffer */ ssize_t lwip_writev(int s, struct iovec *vector, int count) { ssize_t totsize=0; int i; ssize_t pos; char *temp_buf; ssize_t ret; /* Check for invalid parameter */ if (count < 0 || count > UIO_MAXIOV) { set_errno(EINVAL); return -1; } /* FIX: check overflow of totsize and set EINVAL */ for (i=0; i UIO_MAXIOV) { set_errno(EINVAL); return -1; } /* FIX: check overflow of totsize and set EINVAL */ for (i=0; i * */ /* This is the part of the API that is linked with the application */ #include "lwip/opt.h" #include "lwip/api.h" #include "lwip/api_msg.h" #include "lwip/memp.h" struct netbuf *netbuf_new(void) { struct netbuf *buf; buf = memp_malloc(MEMP_NETBUF); if (buf != NULL) { buf->p = NULL; buf->ptr = NULL; return buf; } else { return NULL; } } void netbuf_delete(struct netbuf *buf) { if (buf != NULL) { if (buf->p != NULL) { pbuf_free(buf->p); buf->p = buf->ptr = NULL; } memp_free(MEMP_NETBUF, buf); } } void * netbuf_alloc(struct netbuf *buf, u16_t size) { /* Deallocate any previously allocated memory. */ if (buf->p != NULL) { pbuf_free(buf->p); } buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM); if (buf->p == NULL) { return NULL; } buf->ptr = buf->p; return buf->p->payload; } void netbuf_free(struct netbuf *buf) { if (buf->p != NULL) { pbuf_free(buf->p); } buf->p = buf->ptr = NULL; } void netbuf_ref(struct netbuf *buf, void *dataptr, u16_t size) { if (buf->p != NULL) { pbuf_free(buf->p); } buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF); buf->p->payload = dataptr; buf->p->len = buf->p->tot_len = size; buf->ptr = buf->p; } void netbuf_chain(struct netbuf *head, struct netbuf *tail) { pbuf_chain(head->p, tail->p); head->ptr = head->p; memp_free(MEMP_NETBUF, tail); } u16_t netbuf_len(struct netbuf *buf) { return buf->p->tot_len; } err_t netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len) { if (buf->ptr == NULL) { return ERR_BUF; } *dataptr = buf->ptr->payload; *len = buf->ptr->len; return ERR_OK; } s8_t netbuf_next(struct netbuf *buf) { if (buf->ptr->next == NULL) { return -1; } buf->ptr = buf->ptr->next; if (buf->ptr->next == NULL) { return 1; } return 0; } void netbuf_first(struct netbuf *buf) { buf->ptr = buf->p; } void netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset) { struct pbuf *p; u16_t i, left; left = 0; if(buf == NULL || dataptr == NULL) { return; } /* This implementation is bad. It should use bcopy instead. */ for(p = buf->p; left < len && p != NULL; p = p->next) { if (offset != 0 && offset >= p->len) { offset -= p->len; } else { for(i = offset; i < p->len; ++i) { ((char *)dataptr)[left] = ((char *)p->payload)[i]; if (++left >= len) { return; } } offset = 0; } } } void netbuf_copy(struct netbuf *buf, void *dataptr, u16_t len) { netbuf_copy_partial(buf, dataptr, len, 0); } struct ip_addr * netbuf_fromaddr(struct netbuf *buf) { /*printf("netbuf_fromaddr %x:%x:%x:%x\n", buf->fromaddr.addr[0], buf->fromaddr.addr[1], buf->fromaddr.addr[2], buf->fromaddr.addr[3]); */ return &(buf->fromaddr); } u16_t netbuf_fromport(struct netbuf *buf) { /*printf("netbuf_fromport %d %x\n",buf->fromport,buf);*/ return buf->fromport; } struct netconn *netconn_new_with_proto_and_callback(struct stack *stack, enum netconn_type t, u16_t proto, void (*callback)(struct netconn *, enum netconn_evt, u16_t len)) { struct netconn *conn; struct api_msg msg; conn = memp_malloc(MEMP_NETCONN); if (conn == NULL) { return NULL; } conn->stack = stack; conn->err = ERR_OK; conn->type = t; conn->pcb.tcp = NULL; if ((conn->mbox = sys_mbox_new()) == SYS_MBOX_NULL) { memp_free(MEMP_NETCONN, conn); return NULL; } /*conn->recvmbox = SYS_MBOX_NULL;*/ if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) { memp_free(MEMP_NETCONN, conn); return NULL; } conn->connected = 0; conn->acceptmbox = SYS_MBOX_NULL; conn->sem = SYS_SEM_NULL; conn->state = NETCONN_NONE; conn->socket = 0; conn->callback = callback; conn->recv_avail = 0; msg.type = API_MSG_NEWCONN; msg.msg.msg.bc.port = proto; /* misusing the port field */ msg.msg.conn = conn; api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); if ( conn->err != ERR_OK ) { memp_free(MEMP_NETCONN, conn); return NULL; } return conn; } struct netconn *netconn_new(struct stack *stack, enum netconn_type type) { return netconn_new_with_proto_and_callback(stack, type,0,NULL); } struct netconn *netconn_new_with_callback(struct stack *stack, enum netconn_type type, void (*callback)(struct netconn *, enum netconn_evt, u16_t len)) { return netconn_new_with_proto_and_callback(stack, type,0,callback); } err_t netconn_delete(struct netconn *conn) { struct api_msg msg; void *mem; //fprintf(stderr, "netconn_delete %p\n",conn); if (conn == NULL) { return ERR_OK; } msg.type = API_MSG_DELCONN; msg.msg.conn = conn; api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); /* Drain the recvmbox. */ if (conn->recvmbox != SYS_MBOX_NULL) { while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) { if (conn->type == NETCONN_TCP) { if (mem != NULL) pbuf_free((struct pbuf *)mem); } else { netbuf_delete((struct netbuf *)mem); } } sys_mbox_free(conn->recvmbox); conn->recvmbox = SYS_MBOX_NULL; } /* Drain the acceptmbox. */ if (conn->acceptmbox != SYS_MBOX_NULL) { while (sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != SYS_ARCH_TIMEOUT) { netconn_delete((struct netconn *)mem); } sys_mbox_free(conn->acceptmbox); conn->acceptmbox = SYS_MBOX_NULL; } sys_mbox_free(conn->mbox); conn->mbox = SYS_MBOX_NULL; if (conn->sem != SYS_SEM_NULL) { sys_sem_free(conn->sem); } conn->sem = SYS_SEM_NULL; /* this should not be commented out!*/ memp_free(MEMP_NETCONN, conn); return ERR_OK; } enum netconn_type netconn_type(struct netconn *conn) { return conn->type; } struct stack *netconn_stack(struct netconn* conn) { return conn->stack; } err_t netconn_peer(struct netconn *conn, struct ip_addr *addr, u16_t *port) { struct api_msg msg; err_t olderr = conn->err; if (conn == NULL) { return ERR_VAL; } msg.type = API_MSG_PEER; msg.msg.conn = conn; msg.msg.err = ERR_OK; msg.msg.msg.bp.ipaddr = addr; msg.msg.msg.bp.port = port; switch (conn->type) { case NETCONN_RAW: #if LWIP_PACKET case NETCONN_PACKET_RAW: case NETCONN_PACKET_DGRAM: #endif /* return an error as connecting is only a helper for upper layers */ return ERR_CONN; case NETCONN_UDPLITE: case NETCONN_UDPNOCHKSUM: case NETCONN_UDP: api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); return msg.msg.err; default: return ERR_ARG; } } err_t netconn_addr(struct netconn *conn, struct ip_addr *addr, u16_t *port) { struct api_msg msg; if (conn == NULL) { return ERR_VAL; } msg.type = API_MSG_PEER; msg.msg.conn = conn; msg.msg.err = ERR_OK; msg.msg.msg.bp.ipaddr = addr; msg.msg.msg.bp.port = port; switch (conn->type) { case NETCONN_PACKET_RAW: case NETCONN_PACKET_DGRAM: return ERR_CONN; case NETCONN_RAW: case NETCONN_UDPLITE: case NETCONN_UDPNOCHKSUM: case NETCONN_UDP: case NETCONN_TCP: api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); return msg.msg.err; default: return ERR_ARG; } } err_t netconn_bind(struct netconn *conn, struct ip_addr *addr, u16_t port) { struct api_msg msg; if (conn == NULL) { return ERR_VAL; } if (conn->type != NETCONN_TCP && conn->recvmbox == SYS_MBOX_NULL) { if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) { return ERR_MEM; } } msg.type = API_MSG_BIND; msg.msg.conn = conn; msg.msg.msg.bc.ipaddr = addr; msg.msg.msg.bc.port = port; api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); return conn->err; } err_t netconn_connect(struct netconn *conn, struct ip_addr *addr, u16_t port) { struct api_msg msg; if (conn == NULL) { return ERR_VAL; } if (conn->recvmbox == SYS_MBOX_NULL) { if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) { return ERR_MEM; } } msg.type = API_MSG_CONNECT; msg.msg.conn = conn; msg.msg.msg.bc.ipaddr = addr; msg.msg.msg.bc.port = port; api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); if (conn->err == ERR_OK) conn->connected = 1; return conn->err; } err_t netconn_disconnect(struct netconn *conn) { struct api_msg msg; if (conn == NULL) { return ERR_VAL; } msg.type = API_MSG_DISCONNECT; msg.msg.conn = conn; api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); if (conn->err == ERR_OK) conn->connected = 0; return conn->err; } err_t netconn_listen(struct netconn *conn) { struct api_msg msg; if (conn == NULL) { return ERR_VAL; } if (conn->acceptmbox == SYS_MBOX_NULL) { conn->acceptmbox = sys_mbox_new(); if (conn->acceptmbox == SYS_MBOX_NULL) { return ERR_MEM; } } msg.type = API_MSG_LISTEN; msg.msg.conn = conn; api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); return conn->err; } struct netconn * netconn_accept(struct netconn *conn) { struct netconn *newconn; if (conn == NULL) { return NULL; } sys_mbox_fetch(conn->acceptmbox, (void **)&newconn); /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, 0); if (newconn != NULL) newconn->connected = 1; return newconn; } struct netbuf * netconn_recv(struct netconn *conn) { struct api_msg msg; struct netbuf *buf; struct pbuf *p; u16_t len; if (conn == NULL) { return NULL; } /*printf("netconn_recv %p %p\n",conn,conn->recvmbox);*/ if (conn->recvmbox == SYS_MBOX_NULL) { conn->err = ERR_CONN; return NULL; } if (conn->err != ERR_OK) { return NULL; } if (conn->type == NETCONN_TCP) { /* RD1013 do not inspect pcb. use conn->connected instead */ if (conn->connected == 0) { conn->err = ERR_CONN; return NULL; } buf = memp_malloc(MEMP_NETBUF); if (buf == NULL) { conn->err = ERR_MEM; return NULL; } sys_mbox_fetch(conn->recvmbox, (void **)&p); if (p != NULL) { len = p->tot_len; conn->recv_avail -= len; } else len = 0; /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, len); /* If we are closed, we indicate that we no longer wish to receive data by setting conn->recvmbox to SYS_MBOX_NULL. */ if (p == NULL) { memp_free(MEMP_NETBUF, buf); sys_mbox_free(conn->recvmbox); conn->recvmbox = SYS_MBOX_NULL; return NULL; } buf->p = p; buf->ptr = p; buf->fromport = 0; /*buf->addr.fromaddr = NULL;*/ /* Let the stack know that we have taken the data. */ msg.type = API_MSG_RECV; msg.msg.conn = conn; if (buf != NULL) { msg.msg.msg.len = buf->p->tot_len; } else { msg.msg.msg.len = 1; } api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); } else { sys_mbox_fetch(conn->recvmbox, (void **)&buf); conn->recv_avail -= buf->p->tot_len; /* Register event with callback */ if (conn->callback) (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, buf->p->tot_len); } LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_recv: received %p (err %d) len %d\n", (void *)buf, conn->err, buf->p->tot_len)); return buf; } err_t netconn_send(struct netconn *conn, struct netbuf *buf) { struct stack *stack = conn->stack; struct api_msg msg; if (conn == NULL) { return ERR_VAL; } /* if (conn->err != ERR_OK) { return conn->err; }*/ LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %d bytes\n", buf->p->tot_len)); msg.type = API_MSG_SEND; msg.msg.conn = conn; msg.msg.msg.p = buf->p; api_msg_post(stack, &msg); sys_mbox_fetch(conn->mbox, NULL); return conn->err; } err_t netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy) { struct stack *stack = conn->stack; struct api_msg msg; u16_t len; if (conn == NULL) { return ERR_VAL; } if (conn->err != ERR_OK) { return conn->err; } if (conn->sem == SYS_SEM_NULL) { conn->sem = sys_sem_new(0); if (conn->sem == SYS_SEM_NULL) { return ERR_MEM; } } msg.type = API_MSG_WRITE; msg.msg.conn = conn; conn->state = NETCONN_WRITE; while (conn->err == ERR_OK && size > 0) { msg.msg.msg.w.dataptr = dataptr; msg.msg.msg.w.copy = copy; if (conn->type == NETCONN_TCP) { int avail; while ((avail=tcp_sndbuf(conn->pcb.tcp)) == 0) { sys_sem_wait(conn->sem); if (conn->err != ERR_OK) { goto ret; } } if (size > avail) { /* We cannot send more than one send buffer's worth of data at a time. */ len = avail; } else { len = size; } } else { len = size; } LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_write: writing %d bytes (%d)\n", len, copy)); msg.msg.msg.w.len = len; api_msg_post(stack, &msg); sys_mbox_fetch(conn->mbox, NULL); if (conn->err == ERR_OK) { dataptr = (void *)((char *)dataptr + len); size -= len; } else if (conn->err == ERR_MEM) { conn->err = ERR_OK; sys_sem_wait(conn->sem); } else { goto ret; } } ret: conn->state = NETCONN_NONE; // X1004 /* if (conn->sem != SYS_SEM_NULL) { sys_sem_free(conn->sem); conn->sem = SYS_SEM_NULL; } // */ return conn->err; } err_t netconn_close(struct netconn *conn) { struct stack *stack = conn->stack; struct api_msg msg; if (conn == NULL) { return ERR_VAL; } conn->state = NETCONN_CLOSE; again: msg.type = API_MSG_CLOSE; msg.msg.conn = conn; api_msg_post(stack, &msg); sys_mbox_fetch(conn->mbox, NULL); if (conn->err == ERR_MEM && conn->sem != SYS_SEM_NULL) { sys_sem_wait(conn->sem); goto again; } conn->state = NETCONN_NONE; return conn->err; } err_t netconn_callback(struct netconn *conn, err_t (*fun)(struct netconn *conn, void *), void *arg) { struct api_msg msg; if (conn == NULL) { return ERR_VAL; } msg.type = API_MSG_CALLBACK; msg.msg.conn = conn; msg.msg.err = ERR_OK; msg.msg.msg.cb.fun = fun; msg.msg.msg.cb.arg = arg; api_msg_post(conn->stack, &msg); sys_mbox_fetch(conn->mbox, NULL); return msg.msg.err; } err_t netconn_err(struct netconn *conn) { return conn->err; } lwipv6-1.5a/lwip-v6/src/api/renzosocket.c0000644000175000017500000012575611671615010017417 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * * Improved by Marc Boucher and David Haas * */ #include #include #include #include #include #include #include #include #include "lwip/opt.h" #include "lwip/api.h" #include "lwip/arch.h" #include "lwip/sys.h" #include "lwip/sockets.h" #define NUM_SOCKETS MEMP_NUM_NETCONN static short lwip_sockmap[OPEN_MAX]; struct lwip_socket { struct netconn *conn; struct netbuf *lastdata; u16_t lastoffset; u16_t rcvevent; u16_t sendevent; u16_t flags; int fdfake; int err; }; struct lwip_select_cb { struct lwip_select_cb *next; fd_set *readset; fd_set *writeset; fd_set *exceptset; int sem_signalled; #if RD235LIB int pipe[2]; #else sys_sem_t sem; #endif }; static struct lwip_socket sockets[NUM_SOCKETS]; static struct lwip_select_cb *select_cb_list = 0; static sys_sem_t socksem = 0; static sys_sem_t selectsem = 0; static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len); static int err_to_errno_table[11] = { 0, /* ERR_OK 0 No error, everything OK. */ ENOMEM, /* ERR_MEM -1 Out of memory error. */ ENOBUFS, /* ERR_BUF -2 Buffer error. */ ECONNABORTED, /* ERR_ABRT -3 Connection aborted. */ ECONNRESET, /* ERR_RST -4 Connection reset. */ ESHUTDOWN, /* ERR_CLSD -5 Connection closed. */ ENOTCONN, /* ERR_CONN -6 Not connected. */ EINVAL, /* ERR_VAL -7 Illegal value. */ EIO, /* ERR_ARG -8 Illegal argument. */ EHOSTUNREACH, /* ERR_RTE -9 Routing problem. */ EADDRINUSE /* ERR_USE -10 Address in use. */ }; #define err_to_errno(err) \ ((err) < (sizeof(err_to_errno_table)/sizeof(int))) ? \ err_to_errno_table[-(err)] : EIO #ifdef ERRNO #define set_errno(err) errno = (err) #else #define set_errno(err) #endif #define sock_set_errno(sk, e) do { \ sk->err = (e); \ set_errno(sk->err); \ } while (0) static struct lwip_socket * get_socket(int s) { struct lwip_socket *sock; int index=(int)lwip_sockmap[s]-1; if ((index < 0) || (index > NUM_SOCKETS)) { LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s)); set_errno(EBADF); return NULL; } sock = &sockets[index]; if (!sock->conn) { LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s)); set_errno(EBADF); return NULL; } return sock; } static int alloc_socket(struct netconn *newconn) { int i,fd; if (!socksem) socksem = sys_sem_new(1); /* Protect socket array */ sys_sem_wait(socksem); /* allocate a new socket identifier */ for(i = 0; i < NUM_SOCKETS; ++i) { if (!sockets[i].conn) { sockets[i].conn = newconn; sockets[i].lastdata = NULL; sockets[i].lastoffset = 0; sockets[i].rcvevent = 0; sockets[i].sendevent = 1; /* TCP send buf is empty */ sockets[i].flags = 0; sockets[i].err = 0; fd=socket(PF_INET, SOCK_DGRAM, 0); if (fd < 0) { sys_sem_signal(socksem); return -1; } sys_sem_signal(socksem); sockets[i].fdfake=fd; lwip_sockmap[fd]=i+1; return fd; } } printf("LU\n"); sys_sem_signal(socksem); return -1; } int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen) { struct lwip_socket *sock; struct netconn *newconn; struct ip_addr naddr; u16_t port; int newsock; struct sockaddr_in sin; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s)); sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } newconn = netconn_accept(sock->conn); /* get the IP address and port of the remote host */ netconn_peer(newconn, &naddr, &port); memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_port = htons(port); sin.sin_addr.s_addr = naddr.addr; if (*addrlen > sizeof(sin)) *addrlen = sizeof(sin); memcpy(addr, &sin, *addrlen); newsock = alloc_socket(newconn); if (newsock == -1) { netconn_delete(newconn); sock_set_errno(sock, ENOBUFS); return -1; } newconn->callback = event_callback; sock = get_socket(newsock); sys_sem_wait(socksem); sock->rcvevent += -1 - newconn->socket; newconn->socket = newsock; sys_sem_signal(socksem); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock)); ip_addr_debug_print(SOCKETS_DEBUG, &naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", port)); sock_set_errno(sock, 0); return newsock; } int lwip_bind(int s, struct sockaddr *name, socklen_t namelen) { struct lwip_socket *sock; struct ip_addr local_addr; u16_t local_port; err_t err; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } local_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr; local_port = ((struct sockaddr_in *)name)->sin_port; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &local_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(local_port))); err = netconn_bind(sock->conn, &local_addr, ntohs(local_port)); if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err)); sock_set_errno(sock, err_to_errno(err)); return -1; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) succeeded\n", s)); sock_set_errno(sock, 0); return 0; } int lwip_close(int s) { struct lwip_socket *sock; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s)); /* We cannot allow multiple closes of the same socket. */ sys_sem_wait(socksem); sock = get_socket(s); if (!sock) { sys_sem_signal(socksem); set_errno(EBADF); return -1; } netconn_delete(sock->conn); if (sock->lastdata) { netbuf_delete(sock->lastdata); } sock->lastdata = NULL; sock->lastoffset = 0; sock->conn = NULL; lwip_sockmap[sock->fdfake]=0; sys_sem_signal(socksem); sock_set_errno(sock, 0); return 0; } int lwip_connect(int s, struct sockaddr *name, socklen_t namelen) { struct lwip_socket *sock; err_t err; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } if (((struct sockaddr_in *)name)->sin_family == AF_UNSPEC) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s)); err = netconn_disconnect(sock->conn); } else { struct ip_addr remote_addr; u16_t remote_port; remote_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr; remote_port = ((struct sockaddr_in *)name)->sin_port; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port))); err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); } if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err)); sock_set_errno(sock, err_to_errno(err)); return -1; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) succeeded\n", s)); sock_set_errno(sock, 0); return 0; } int lwip_listen(int s, int backlog) { struct lwip_socket *sock; err_t err; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog)); sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } err = netconn_listen(sock->conn); if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err)); sock_set_errno(sock, err_to_errno(err)); return -1; } sock_set_errno(sock, 0); return 0; } int lwip_recvfrom(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { struct lwip_socket *sock; struct netbuf *buf; u16_t buflen, copylen; struct ip_addr *addr; u16_t port; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags)); sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } /* Check if there is data left from the last recv operation. */ if (sock->lastdata) { buf = sock->lastdata; } else { /* If this is non-blocking call, then check first */ if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK)) && !sock->rcvevent) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s)); sock_set_errno(sock, EWOULDBLOCK); return -1; } /* No data was left from the previous operation, so we try to get some from the network. */ buf = netconn_recv(sock->conn); if (!buf) { /* We should really do some error checking here. */ LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL!\n", s)); sock_set_errno(sock, 0); return 0; } } buflen = netbuf_len(buf); buflen -= sock->lastoffset; if (len > buflen) { copylen = buflen; } else { copylen = len; } /* copy the contents of the received buffer into the supplied memory pointer mem */ netbuf_copy_partial(buf, mem, copylen, sock->lastoffset); /* Check to see from where the data was. */ if (from && fromlen) { struct sockaddr_in sin; addr = netbuf_fromaddr(buf); port = netbuf_fromport(buf); memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; sin.sin_port = htons(port); sin.sin_addr.s_addr = addr->addr; if (*fromlen > sizeof(sin)) *fromlen = sizeof(sin); memcpy(from, &sin, *fromlen); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen)); } else { #if SOCKETS_DEBUG addr = netbuf_fromaddr(buf); port = netbuf_fromport(buf); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen)); #endif } /* If this is a TCP socket, check if there is data left in the buffer. If so, it should be saved in the sock structure for next time around. */ if (netconn_type(sock->conn) == NETCONN_TCP && buflen - copylen > 0) { sock->lastdata = buf; sock->lastoffset += copylen; } else { sock->lastdata = NULL; sock->lastoffset = 0; netbuf_delete(buf); } sock_set_errno(sock, 0); return copylen; } int lwip_read(int s, void *mem, int len) { return lwip_recvfrom(s, mem, len, 0, NULL, NULL); } int lwip_recv(int s, void *mem, int len, unsigned int flags) { return lwip_recvfrom(s, mem, len, flags, NULL, NULL); } int lwip_send(int s, void *data, int size, unsigned int flags) { struct lwip_socket *sock; struct netbuf *buf; err_t err; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d, data=%p, size=%d, flags=0x%x)\n", s, data, size, flags)); sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } switch (netconn_type(sock->conn)) { case NETCONN_RAW: case NETCONN_UDP: case NETCONN_UDPLITE: case NETCONN_UDPNOCHKSUM: /* create a buffer */ buf = netbuf_new(); if (!buf) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ENOBUFS\n", s)); sock_set_errno(sock, ENOBUFS); return -1; } /* make the buffer point to the data that should be sent */ netbuf_ref(buf, data, size); /* send the data */ err = netconn_send(sock->conn, buf); /* deallocated the buffer */ netbuf_delete(buf); break; case NETCONN_TCP: err = netconn_write(sock->conn, data, size, NETCONN_COPY); break; default: err = ERR_ARG; break; } if (err != ERR_OK) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d\n", s, err)); sock_set_errno(sock, err_to_errno(err)); return -1; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ok size=%d\n", s, size)); sock_set_errno(sock, 0); return size; } int lwip_sendto(int s, void *data, int size, unsigned int flags, struct sockaddr *to, socklen_t tolen) { struct lwip_socket *sock; struct ip_addr remote_addr, addr; u16_t remote_port, port; int ret,connected; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } /* get the peer if currently connected */ connected = (netconn_peer(sock->conn, &addr, &port) == ERR_OK); remote_addr.addr = ((struct sockaddr_in *)to)->sin_addr.s_addr; remote_port = ((struct sockaddr_in *)to)->sin_port; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, size=%d, flags=0x%x to=", s, data, size, flags)); ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", ntohs(remote_port))); netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); ret = lwip_send(s, data, size, flags); /* reset the remote address and port number of the connection */ if (connected) netconn_connect(sock->conn, &addr, port); else netconn_disconnect(sock->conn); return ret; } int lwip_socket(int domain, int type, int protocol) { struct netconn *conn; int i; if (!socksem) socksem = sys_sem_new(1); /* create a netconn */ switch (type) { case SOCK_RAW: conn = netconn_new_with_proto_and_callback(NETCONN_RAW, protocol, event_callback); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_RAW, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); break; case SOCK_DGRAM: conn = netconn_new_with_callback(NETCONN_UDP, event_callback); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); break; case SOCK_STREAM: conn = netconn_new_with_callback(NETCONN_TCP, event_callback); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", domain, type, protocol)); set_errno(EINVAL); return -1; } if (!conn) { LWIP_DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n")); set_errno(ENOBUFS); return -1; } i = alloc_socket(conn); if (i == -1) { netconn_delete(conn); set_errno(ENOBUFS); return -1; } conn->socket = i; LWIP_DEBUGF(SOCKETS_DEBUG, ("%d\n", i)); set_errno(0); return i; } int lwip_write(int s, void *data, int size) { return lwip_send(s, data, size, 0); } static int lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset) { int i, nready = 0; fd_set lreadset, lwriteset, lexceptset; struct lwip_socket *p_sock; FD_ZERO(&lreadset); FD_ZERO(&lwriteset); FD_ZERO(&lexceptset); /* Go through each socket in each list to count number of sockets which currently match */ for(i = 0; i < maxfdp1; i++) { if (FD_ISSET(i, readset)) { /* See if netconn of this socket is ready for read */ p_sock = get_socket(i); if (p_sock && (p_sock->lastdata || p_sock->rcvevent)) { FD_SET(i, &lreadset); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i)); nready++; } } if (FD_ISSET(i, writeset)) { /* See if netconn of this socket is ready for write */ p_sock = get_socket(i); if (p_sock && p_sock->sendevent) { FD_SET(i, &lwriteset); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i)); nready++; } } } *readset = lreadset; *writeset = lwriteset; FD_ZERO(exceptset); return nready; } #ifndef RD235LIB int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout) { int i; int nready; fd_set lreadset, lwriteset, lexceptset; u32_t msectimeout; struct lwip_select_cb select_cb; struct lwip_select_cb *p_selcb; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n", maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, timeout ? timeout->tv_sec : -1L, timeout ? timeout->tv_usec : -1L)); select_cb.next = 0; select_cb.readset = readset; select_cb.writeset = writeset; select_cb.exceptset = exceptset; select_cb.sem_signalled = 0; /* Protect ourselves searching through the list */ if (!selectsem) selectsem = sys_sem_new(1); sys_sem_wait(selectsem); if (readset) lreadset = *readset; else FD_ZERO(&lreadset); if (writeset) lwriteset = *writeset; else FD_ZERO(&lwriteset); if (exceptset) lexceptset = *exceptset; else FD_ZERO(&lexceptset); /* Go through each socket in each list to count number of sockets which currently match */ nready = lwip_selscan(maxfdp1, &lreadset, &lwriteset, &lexceptset); /* If we don't have any current events, then suspend if we are supposed to */ if (!nready) { if (timeout && timeout->tv_sec == 0 && timeout->tv_usec == 0) { sys_sem_signal(selectsem); if (readset) FD_ZERO(readset); if (writeset) FD_ZERO(writeset); if (exceptset) FD_ZERO(exceptset); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n")); set_errno(0); return 0; } /* add our semaphore to list */ /* We don't actually need any dynamic memory. Our entry on the * list is only valid while we are in this function, so it's ok * to use local variables */ select_cb.sem = sys_sem_new(0); /* Note that we are still protected */ /* Put this select_cb on top of list */ select_cb.next = select_cb_list; select_cb_list = &select_cb; /* Now we can safely unprotect */ sys_sem_signal(selectsem); /* Now just wait to be woken */ if (timeout == 0) /* Wait forever */ msectimeout = 0; else msectimeout = ((timeout->tv_sec * 1000) + ((timeout->tv_usec + 500)/1000)); i = sys_sem_wait_timeout(select_cb.sem, msectimeout); /* Take us off the list */ sys_sem_wait(selectsem); if (select_cb_list == &select_cb) select_cb_list = select_cb.next; else for (p_selcb = select_cb_list; p_selcb; p_selcb = p_selcb->next) if (p_selcb->next == &select_cb) { p_selcb->next = select_cb.next; break; } sys_sem_signal(selectsem); sys_sem_free(select_cb.sem); if (i == 0) /* Timeout */ { if (readset) FD_ZERO(readset); if (writeset) FD_ZERO(writeset); if (exceptset) FD_ZERO(exceptset); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n")); set_errno(0); return 0; } if (readset) lreadset = *readset; else FD_ZERO(&lreadset); if (writeset) lwriteset = *writeset; else FD_ZERO(&lwriteset); if (exceptset) lexceptset = *exceptset; else FD_ZERO(&lexceptset); /* See what's set */ nready = lwip_selscan(maxfdp1, &lreadset, &lwriteset, &lexceptset); } else sys_sem_signal(selectsem); if (readset) *readset = lreadset; if (writeset) *writeset = lwriteset; if (exceptset) *exceptset = lexceptset; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready)); set_errno(0); return nready; } #endif static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len) { int s; struct lwip_socket *sock; struct lwip_select_cb *scb; /* Get socket */ if (conn) { s = conn->socket; if (s < 0) { /* Data comes in right away after an accept, even though * the server task might not have created a new socket yet. * Just count down (or up) if that's the case and we * will use the data later. Note that only receive events * can happen before the new socket is set up. */ if (evt == NETCONN_EVT_RCVPLUS) conn->socket--; return; } sock = get_socket(s); if (!sock) return; } else return; if (!selectsem) selectsem = sys_sem_new(1); sys_sem_wait(selectsem); /* Set event as required */ switch (evt) { case NETCONN_EVT_RCVPLUS: sock->rcvevent++; break; case NETCONN_EVT_RCVMINUS: sock->rcvevent--; break; case NETCONN_EVT_SENDPLUS: sock->sendevent = 1; break; case NETCONN_EVT_SENDMINUS: sock->sendevent = 0; break; } sys_sem_signal(selectsem); /* Now decide if anyone is waiting for this socket */ /* NOTE: This code is written this way to protect the select link list but to avoid a deadlock situation by releasing socksem before signalling for the select. This means we need to go through the list multiple times ONLY IF a select was actually waiting. We go through the list the number of waiting select calls + 1. This list is expected to be small. */ while (1) { sys_sem_wait(selectsem); for (scb = select_cb_list; scb; scb = scb->next) { if (scb->sem_signalled == 0) { /* Test this select call for our socket */ if (scb->readset && FD_ISSET(s, scb->readset)) if (sock->rcvevent) break; if (scb->writeset && FD_ISSET(s, scb->writeset)) if (sock->sendevent) break; } } if (scb) { scb->sem_signalled = 1; sys_sem_signal(selectsem); #if RD235LIB write(scb->pipe[1]," ",1); #else sys_sem_signal(scb->sem); #endif } else { sys_sem_signal(selectsem); break; } } } int lwip_shutdown(int s, int how) { LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how)); return lwip_close(s); /* XXX temporary hack until proper implementation */ } int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen) { struct lwip_socket *sock; struct sockaddr_in sin; struct ip_addr naddr; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; /* get the IP address and port of the remote host */ netconn_peer(sock->conn, &naddr, &sin.sin_port); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getpeername(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, &naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port)); sin.sin_port = htons(sin.sin_port); sin.sin_addr.s_addr = naddr.addr; if (*namelen > sizeof(sin)) *namelen = sizeof(sin); memcpy(name, &sin, *namelen); sock_set_errno(sock, 0); return 0; } int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen) { struct lwip_socket *sock; struct sockaddr_in sin; struct ip_addr *naddr; sock = get_socket(s); if (!sock) { set_errno(EBADF); return -1; } memset(&sin, 0, sizeof(sin)); sin.sin_len = sizeof(sin); sin.sin_family = AF_INET; /* get the IP address and port of the remote host */ netconn_addr(sock->conn, &naddr, &sin.sin_port); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockname(%d, addr=", s)); ip_addr_debug_print(SOCKETS_DEBUG, naddr); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port)); sin.sin_port = htons(sin.sin_port); sin.sin_addr.s_addr = naddr->addr; if (*namelen > sizeof(sin)) *namelen = sizeof(sin); memcpy(name, &sin, *namelen); sock_set_errno(sock, 0); return 0; } int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen) { int err = 0; struct lwip_socket *sock = get_socket(s); if(!sock) { set_errno(EBADF); return -1; } if( NULL == optval || NULL == optlen ) { sock_set_errno( sock, EFAULT ); return -1; } /* Do length and type checks for the various options first, to keep it readable. */ switch( level ) { /* Level: SOL_SOCKET */ case SOL_SOCKET: switch(optname) { case SO_ACCEPTCONN: case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ /* UNIMPL case SO_DONTROUTE: */ case SO_ERROR: case SO_KEEPALIVE: /* UNIMPL case SO_OOBINLINE: */ /* UNIMPL case SO_RCVBUF: */ /* UNIMPL case SO_SNDBUF: */ /* UNIMPL case SO_RCVLOWAT: */ /* UNIMPL case SO_SNDLOWAT: */ #if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ case SO_TYPE: /* UNIMPL case SO_USELOOPBACK: */ if( *optlen < sizeof(int) ) { err = EINVAL; } break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level: IPPROTO_IP */ case IPPROTO_IP: switch(optname) { /* UNIMPL case IP_HDRINCL: */ /* UNIMPL case IP_RCVDSTADDR: */ /* UNIMPL case IP_RCVIF: */ case IP_TTL: case IP_TOS: if( *optlen < sizeof(int) ) { err = EINVAL; } break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level: IPPROTO_TCP */ case IPPROTO_TCP: if( *optlen < sizeof(int) ) { err = EINVAL; break; } /* If this is no TCP socket, ignore any options. */ if ( sock->conn->type != NETCONN_TCP ) return 0; switch( optname ) { case TCP_NODELAY: case TCP_KEEPALIVE: break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* UNDEFINED LEVEL */ default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname)); err = ENOPROTOOPT; } /* switch */ if( 0 != err ) { sock_set_errno(sock, err); return -1; } /* Now do the actual option processing */ switch(level) { /* Level: SOL_SOCKET */ case SOL_SOCKET: switch( optname ) { /* The option flags */ case SO_ACCEPTCONN: case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINCLUDE: */ #if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ /*case SO_USELOOPBACK: UNIMPL */ *(int*)optval = sock->conn->pcb.tcp->so_options & optname; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, optname=0x%x, ..) = %s\n", s, optname, (*(int*)optval?"on":"off"))); break; case SO_TYPE: switch (sock->conn->type) { case NETCONN_RAW: *(int*)optval = SOCK_RAW; break; case NETCONN_TCP: *(int*)optval = SOCK_STREAM; break; case NETCONN_UDP: case NETCONN_UDPLITE: case NETCONN_UDPNOCHKSUM: *(int*)optval = SOCK_DGRAM; break; default: /* unrecognized socket type */ *(int*)optval = sock->conn->type; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE): unrecognized socket type %d\n", s, *(int *)optval)); } /* switch */ LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_TYPE) = %d\n", s, *(int *)optval)); break; case SO_ERROR: *(int *)optval = sock->err; sock->err = 0; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", s, *(int *)optval)); break; } /* switch */ break; /* Level: IPPROTO_IP */ case IPPROTO_IP: switch( optname ) { case IP_TTL: *(int*)optval = sock->conn->pcb.tcp->ttl; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TTL) = %d\n", s, *(int *)optval)); break; case IP_TOS: *(int*)optval = sock->conn->pcb.tcp->tos; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, IP_TOS) = %d\n", s, *(int *)optval)); break; } /* switch */ break; /* Level: IPPROTO_TCP */ case IPPROTO_TCP: switch( optname ) { case TCP_NODELAY: *(int*)optval = (sock->conn->pcb.tcp->flags & TF_NODELAY); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_TCP, TCP_NODELAY) = %s\n", s, (*(int*)optval)?"on":"off") ); break; case TCP_KEEPALIVE: *(int*)optval = (int)sock->conn->pcb.tcp->keepalive; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_IP, TCP_KEEPALIVE) = %d\n", s, *(int *)optval)); break; } /* switch */ break; } sock_set_errno(sock, err); return err ? -1 : 0; } int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen) { struct lwip_socket *sock = get_socket(s); int err = 0; if(!sock) { set_errno(EBADF); return -1; } if( NULL == optval ) { sock_set_errno( sock, EFAULT ); return -1; } /* Do length and type checks for the various options first, to keep it readable. */ switch( level ) { /* Level: SOL_SOCKET */ case SOL_SOCKET: switch(optname) { case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINLINE: */ /* UNIMPL case SO_RCVBUF: */ /* UNIMPL case SO_SNDBUF: */ /* UNIMPL case SO_RCVLOWAT: */ /* UNIMPL case SO_SNDLOWAT: */ #if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ /* UNIMPL case SO_USELOOPBACK: */ if( optlen < sizeof(int) ) { err = EINVAL; } break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level: IPPROTO_IP */ case IPPROTO_IP: switch(optname) { /* UNIMPL case IP_HDRINCL: */ /* UNIMPL case IP_RCVDSTADDR: */ /* UNIMPL case IP_RCVIF: */ case IP_TTL: case IP_TOS: if( optlen < sizeof(int) ) { err = EINVAL; } break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* Level: IPPROTO_TCP */ case IPPROTO_TCP: if( optlen < sizeof(int) ) { err = EINVAL; break; } /* If this is no TCP socket, ignore any options. */ if ( sock->conn->type != NETCONN_TCP ) return 0; switch( optname ) { case TCP_NODELAY: case TCP_KEEPALIVE: break; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, UNIMPL: optname=0x%x, ..)\n", s, optname)); err = ENOPROTOOPT; } /* switch */ break; /* UNDEFINED LEVEL */ default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname)); err = ENOPROTOOPT; } /* switch */ if( 0 != err ) { sock_set_errno(sock, err); return -1; } /* Now do the actual option processing */ switch(level) { /* Level: SOL_SOCKET */ case SOL_SOCKET: switch(optname) { /* The option flags */ case SO_BROADCAST: /* UNIMPL case SO_DEBUG: */ /* UNIMPL case SO_DONTROUTE: */ case SO_KEEPALIVE: /* UNIMPL case SO_OOBINCLUDE: */ #if SO_REUSE case SO_REUSEADDR: case SO_REUSEPORT: #endif /* SO_REUSE */ /* UNIMPL case SO_USELOOPBACK: */ if ( *(int*)optval ) { sock->conn->pcb.tcp->so_options |= optname; } else { sock->conn->pcb.tcp->so_options &= ~optname; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, optname=0x%x, ..) -> %s\n", s, optname, (*(int*)optval?"on":"off"))); break; } /* switch */ break; /* Level: IPPROTO_IP */ case IPPROTO_IP: switch( optname ) { case IP_TTL: sock->conn->pcb.tcp->ttl = (u8_t)(*(int*)optval); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TTL, ..) -> %u\n", s, sock->conn->pcb.tcp->ttl)); break; case IP_TOS: sock->conn->pcb.tcp->tos = (u8_t)(*(int*)optval); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_IP, IP_TOS, ..)-> %u\n", s, sock->conn->pcb.tcp->tos)); break; } /* switch */ break; /* Level: IPPROTO_TCP */ case IPPROTO_TCP: switch( optname ) { case TCP_NODELAY: if ( *(int*)optval ) { sock->conn->pcb.tcp->flags |= TF_NODELAY; } else { sock->conn->pcb.tcp->flags &= ~TF_NODELAY; } LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_NODELAY) -> %s\n", s, (*(int *)optval)?"on":"off") ); break; case TCP_KEEPALIVE: sock->conn->pcb.tcp->keepalive = (u32_t)(*(int*)optval); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_TCP, TCP_KEEPALIVE) -> %lu\n", s, sock->conn->pcb.tcp->keepalive)); break; } /* switch */ break; } /* switch */ sock_set_errno(sock, err); return err ? -1 : 0; } int lwip_ioctl(int s, long cmd, void *argp) { struct lwip_socket *sock = get_socket(s); if(!sock) { set_errno(EBADF); return -1; } switch (cmd) { case FIONREAD: if (!argp) { sock_set_errno(sock, EINVAL); return -1; } *((u16_t*)argp) = sock->conn->recv_avail; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %u\n", s, argp, *((u16_t*)argp))); sock_set_errno(sock, 0); return 0; case FIONBIO: if (argp && *(u32_t*)argp) sock->flags |= O_NONBLOCK; else sock->flags &= ~O_NONBLOCK; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, !!(sock->flags & O_NONBLOCK))); sock_set_errno(sock, 0); return 0; default: LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp)); sock_set_errno(sock, ENOSYS); /* not yet implemented */ return -1; } } #if RD235LIB static int fdsplit(int max, fd_set *rfd, fd_set *wfd, fd_set *efd, fd_set *rlfd, fd_set *wlfd, fd_set *elfd, fd_set *rnfd, fd_set *wnfd, fd_set *enfd) { int lcount=0; register int i; if (rfd) *rlfd=*rnfd=*rfd; else { FD_ZERO(rlfd); FD_ZERO(rnfd); } if (wfd) *wlfd=*wnfd=*wfd; else { FD_ZERO(wlfd); FD_ZERO(wnfd); } if (efd) *elfd=*enfd=*efd; else { FD_ZERO(elfd); FD_ZERO(enfd); } for (i=0;i 0) { if(FD_ISSET(i,rlfd) || FD_ISSET(i,wlfd) || FD_ISSET(i,elfd)) lcount++; FD_CLR(i,rnfd); FD_CLR(i,wnfd); FD_CLR(i,enfd); } else { FD_CLR(i,rlfd); FD_CLR(i,wlfd); FD_CLR(i,elfd); } } return lcount; } int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout) { int i; int nready,nready_native,nlwip; fd_set lreadset, lwriteset, lexceptset; fd_set lnreadset, lnwriteset, lnexceptset; int maxfdpipe=maxfdp1; u32_t msectimeout; struct lwip_select_cb select_cb; struct lwip_select_cb *p_selcb; struct timeval now; LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n", maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, timeout ? timeout->tv_sec : -1L, timeout ? timeout->tv_usec : -1L)); /*pfdset(maxfdp1,readset); pfdset(maxfdp1,writeset); pfdset(maxfdp1,exceptset);*/ select_cb.next = 0; select_cb.readset = readset; select_cb.writeset = writeset; select_cb.exceptset = exceptset; select_cb.sem_signalled = 0; nlwip = fdsplit (maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset, &lnreadset, &lnwriteset, &lnexceptset); if (nlwip == 0) { nready_native=select(maxfdp1,readset,writeset,exceptset,timeout); return nready_native; } now.tv_sec=now.tv_usec=0; /* Protect ourselves searching through the list */ if (!selectsem) selectsem = sys_sem_new(1); sys_sem_wait(selectsem); /* Go through each socket in each list to count number of sockets which currently match */ nready = lwip_selscan(maxfdp1, &lreadset, &lwriteset, &lexceptset); nready_native = select(maxfdp1,&lnreadset,&lnwriteset,&lnexceptset, &now); /* If we don't have any current events, then suspend if we are supposed to */ if (!(nready+nready_native)) { if (timeout && timeout->tv_sec == 0 && timeout->tv_usec == 0) { sys_sem_signal(selectsem); if (readset) FD_ZERO(readset); if (writeset) FD_ZERO(writeset); if (exceptset) FD_ZERO(exceptset); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n")); set_errno(0); return 0; } nlwip = fdsplit (maxfdp1, readset, writeset, exceptset, &lreadset, &lwriteset, &lexceptset, &lnreadset, &lnwriteset, &lnexceptset); /* add our semaphore to list */ /* We don't actually need any dynamic memory. Our entry on the * list is only valid while we are in this function, so it's ok * to use local variables */ pipe(select_cb.pipe); /* Note that we are still protected */ /* Put this select_cb on top of list */ select_cb.next = select_cb_list; select_cb_list = &select_cb; /* Now we can safely unprotect */ sys_sem_signal(selectsem); /* Now just wait to be woken */ if (timeout == 0) /* Wait forever */ msectimeout = 0; else msectimeout = ((timeout->tv_sec * 1000) + ((timeout->tv_usec + 500)/1000)); FD_SET(select_cb.pipe[0], &lnreadset); if (select_cb.pipe[0]+1 > maxfdpipe) maxfdpipe = select_cb.pipe[0]+1; nready_native=select(maxfdpipe,&lnreadset,&lnwriteset,&lnexceptset,timeout); /* Take us off the list */ sys_sem_wait(selectsem); if (select_cb_list == &select_cb) select_cb_list = select_cb.next; else for (p_selcb = select_cb_list; p_selcb; p_selcb = p_selcb->next) if (p_selcb->next == &select_cb) { p_selcb->next = select_cb.next; break; } sys_sem_signal(selectsem); close(select_cb.pipe[0]); close(select_cb.pipe[1]); if (nready_native == 0) /* Timeout */ { if (readset) FD_ZERO(readset); if (writeset) FD_ZERO(writeset); if (exceptset) FD_ZERO(exceptset); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n")); set_errno(0); return 0; } if (FD_ISSET(select_cb.pipe[0], &lnreadset)) { nready_native--; FD_CLR(select_cb.pipe[0], &lnreadset); } nready = lwip_selscan(maxfdp1, &lreadset, &lwriteset, &lexceptset); } else sys_sem_signal(selectsem); if (readset) FD_ZERO(readset); if (writeset) FD_ZERO(writeset); if (writeset) FD_ZERO(exceptset); for (i=0;i UIO_MAXIOV) { set_errno(EINVAL); return -1; } /* FIX: check overflow of totsize and set EINVAL */ for (i=0; i UIO_MAXIOV) { set_errno(EINVAL); return -1; } /* FIX: check overflow of totsize and set EINVAL */ for (i=0; i * */ #include "lwip/err.h" #ifdef LWIP_DEBUG static char *err_strerr[] = {"Ok.", "Out of memory error.", "Buffer error.", "Connection aborted.", "Connection reset.", "Connection closed.", "Not connected.", "Illegal value.", "Illegal argument.", "Routing problem.", "Address in use." }; char * lwip_strerr(err_t err) { return err_strerr[-err]; } #endif /* LWIP_DEBUG */ lwipv6-1.5a/lwip-v6/src/api/tcpip.c0000644000175000017500000003625111671615010016157 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * updated: * Copyright 2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/opt.h" #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/memp.h" #include "lwip/pbuf.h" #include "lwip/ip.h" #include "lwip/udp.h" #include "lwip/tcp.h" #include "lwip/tcpip.h" /*---------------------------------------------------------------------------*/ /* * The idea is to run the stack code in a different thread and * to comunicate with it (or shutdown it) by using messages. * Remember that each interface has its own thread too. * * After tcpip_shutdown() any call has no effect. * * main thread TCPIP_THREAD netif thread(s) * | * | * tcpip_init()---------------> *new* * | | * tcpip_netif_add()....msg.....> |-------------------> *new* * | | | * ... ... ... * | | <.......msg...... tcpip_input() * | | <.......msg...... tcpip_input() * ... ... ... * | | | * tcpip_shutdown().....msg.....> | | * | netif_cleanup().......> *exit* * | | * | *exit* * tcpip_input() * | * exit() */ /*---------------------------------------------------------------------------*/ #if LWIP_TCP static void tcpip_tcp_timer(void *arg) { struct stack *stack = (struct stack *) arg; /* call TCP timer handler */ tcp_tmr(stack); /* timer still needed? */ if (stack->tcp_active_pcbs || stack->tcp_tw_pcbs) { /* restart timer */ sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, (void*)stack); } else { /* disable timer */ stack->tcpip_tcp_timer_active = 0; } } #if !NO_SYS void tcp_timer_needed(struct stack *stack) { /* timer is off but needed again? */ if (!stack->tcpip_tcp_timer_active && (stack->tcp_active_pcbs || stack->tcp_tw_pcbs)) { /* enable and start timer */ stack->tcpip_tcp_timer_active = 1; sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, (void*)stack); } } #endif /* !NO_SYS */ #endif /* LWIP_TCP */ /*--------------------------------------------------------------------------*/ static void tcpip_set_down_interfaces(struct stack *stack) { struct netif *nip; for (nip=stack->netif_list; nip!=NULL; nip=nip->next) { ip_notify(nip, NETIF_CHANGE_DOWN); netif_set_down_low(nip); } } /*--------------------------------------------------------------------------*/ static void init_layers(struct stack *stack) { netif_init(stack); ip_init(stack); #if LWIP_UDP udp_init(stack); #endif #if LWIP_TCP tcp_init(stack); #endif } static void shutdown_layers(struct stack *stack) { #if LWIP_UDP udp_shutdown(stack); #endif #if LWIP_TCP tcp_shutdown(stack); #endif /* Handle special transport/network protocol tasks */ tcpip_set_down_interfaces(stack); ip_shutdown(stack); netif_shutdown(stack); } static void tcpip_thread(void *arg) { struct stack *stack; int loop; struct tcpip_msg *msg; //(void)arg; stack = (struct stack *) arg; LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] starting...\n", stack)); /* Initialize network layers */ init_layers(stack); /* Create stack event queue */ stack->stack_queue = sys_mbox_new(); /* Signal tcp_init() function */ sys_sem_signal(stack->tcpip_init_sem); /* Call user defined callback */ if (stack->tcpip_init_done != NULL) { stack->tcpip_init_done(stack->tcpip_init_done_arg); } LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] started\n", stack)); loop = 1; while (loop) { /* MAIN Loop */ LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] waiting.\n", stack)); sys_mbox_fetch(stack->stack_queue, (void *)&msg); if (msg==NULL) { printf("tcpip NULL MSG, this should not happen!\n"); } else { switch (msg->type) { case TCPIP_MSG_INPUT: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] IP packet %p\n", stack, (void *)msg)); ip_input(msg->msg.inp.p, msg->msg.inp.netif); break; case TCPIP_MSG_API: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] API message %p %p\n", stack, (void *)msg, (void *)msg->msg.apimsg)); api_msg_input(msg->msg.apimsg); break; case TCPIP_MSG_CALLBACK: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] callback %p\n", stack, (void *)msg)); msg->msg.cb.f(msg->msg.cb.ctx); break; case TCPIP_MSG_SYNC_CALLBACK: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] callback %p\n", stack, (void *)msg)); msg->msg.cb.f(msg->msg.cb.ctx); sys_sem_signal(*msg->msg.cb.sem); break; case TCPIP_MSG_NETIFADD: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] add netif %p START\n", stack, (void *)msg)); *msg->msg.netif.retval = netif_add(stack, msg->msg.netif.netif, msg->msg.netif.state, msg->msg.netif.init, msg->msg.netif.input, msg->msg.netif.change); /* signal interface creation */ sys_sem_signal(* msg->msg.netif.sem); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] add netif %p DONE!\n", stack, (void *)msg)); break; case TCPIP_MSG_NETIF_NOTIFY: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] netif state change! %p\n", stack, (void *)msg)); ip_notify(msg->msg.netif_notify.netif, msg->msg.netif_notify.type); sys_sem_signal(* msg->msg.netif_notify.sem); break; case TCPIP_MSG_SHUTDOWN: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] SHUTDOWN! %p\n", stack, (void *)msg)); loop = 0; break; default: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] UNKNOWN MSGTYPE %d\n", stack, msg->type)); break; } memp_free(MEMP_TCPIP_MSG, msg); } } LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] cleaning up interfaces.\n", stack)); /* Shutdown network layers */ shutdown_layers(stack); /* Call user defined callback */ if (stack->tcpip_shutdown_done != NULL) { stack->tcpip_shutdown_done(stack->tcpip_shutdown_done_arg); } /* Signal tcp_shutdown() function */ sys_sem_signal(stack->tcpip_shutdown_sem); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: [%d] exit.\n", stack)); } /*---------------------------------------------------------------------------*/ static struct stack *current_stack; int tcpip_init(void) { current_stack = NULL; LWIP_DEBUGF(TCPIP_DEBUG, ("%s: done\n",__func__)); return 0; } static struct stack *tcpip_alloc(void) { int i; struct stack *new=mem_malloc(sizeof(struct stack)); if (new) memset(new,0,sizeof(struct stack)); return new; } static void tcpip_free(struct stack *stack) { mem_free(stack); } struct stack * #if LWIP_CAPABILITIES tcpip_start(tcpip_handler init_func, void *arg, unsigned long flags, lwip_capfun capfun) #else tcpip_start(tcpip_handler init_func, void *arg, unsigned long flags) #endif { struct stack *stack; stack = tcpip_alloc(); if (stack == NULL) { LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_start: unable to create a new stack!!\n")); return NULL; } LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_start: new stack %d\n",stack)); stack->tcpip_init_sem = sys_sem_new(0); stack->tcpip_init_done = init_func; stack->tcpip_init_done_arg = arg; stack->stack_flags = flags; #if LWIP_CAPABILITIES stack->stack_capfun = capfun; #endif sys_thread_new(tcpip_thread, (void*)stack, TCPIP_THREAD_PRIO); /* Wait for stack initialization */ sys_sem_wait(stack->tcpip_init_sem); sys_sem_free(stack->tcpip_init_sem); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_start: stack %p running.\n",stack)); return stack; } struct stack *tcpip_stack_get(void) { return current_stack; } struct stack *tcpip_stack_set(struct stack * id) { current_stack = id; return id; } /*---------------------------------------------------------------------------*/ void tcpip_shutdown(struct stack *stack, tcpip_handler shutdown_func, void *arg) { struct tcpip_msg *msg; LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_shutdown: %d ...\n",stack)); /* Inform to the thread to shutdown */ msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) return; stack->tcpip_shutdown_sem = sys_sem_new(0); stack->tcpip_shutdown_done = shutdown_func; stack->tcpip_shutdown_done_arg = arg; msg->type = TCPIP_MSG_SHUTDOWN; sys_mbox_post(stack->stack_queue, msg); /* Wait for stack Shutdown */ sys_sem_wait(stack->tcpip_shutdown_sem); sys_sem_free(stack->tcpip_shutdown_sem); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_shutdown: %d stopped.\n",stack)); /* Stack no more active for sure */ tcpip_free(stack); } /*---------------------------------------------------------------------------*/ err_t tcpip_callback(struct stack *stack, void (*f)(void *ctx), void *ctx, enum tcpip_sync sync) { struct tcpip_msg *msg; /* Check if the stack is valid */ if (stack==NULL) { LWIP_DEBUGF(TCPIP_DEBUG,("%s: stack %d does not exist!\n", __func__, stack)); return -1; } LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: tcpip_callback %p \n", f)); msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) return ERR_MEM; msg->msg.cb.f = f; msg->msg.cb.ctx = ctx; if (sync) { sys_sem_t sync; msg->type = TCPIP_MSG_SYNC_CALLBACK; sync = sys_sem_new(0); msg->msg.cb.sem = &sync; sys_mbox_post(stack->stack_queue, msg); sys_sem_wait_timeout(sync, 0); sys_sem_free(sync); } else { msg->type = TCPIP_MSG_CALLBACK; msg->msg.cb.sem = NULL; sys_mbox_post(stack->stack_queue, msg); } return ERR_OK; } /*---------------------------------------------------------------------------*/ void tcpip_apimsg(struct stack *stack, struct api_msg *apimsg) { struct tcpip_msg *msg; msg = memp_malloc(MEMP_TCPIP_MSG); while (msg == NULL) { sys_msleep(API_MSG_RETRY_DELAY); msg = memp_malloc(MEMP_TCPIP_MSG); } msg->type = TCPIP_MSG_API; msg->msg.apimsg = apimsg; sys_mbox_post(stack->stack_queue, msg); } #if 0 /* this should be the right way! a semaphone should be used instead of * NULL smgs! */ void tcpip_apimsg(struct stack *stack, struct api_msg *apimsg) { struct tcpip_msg msg; msg.type = TCPIP_MSG_API; msg.msg.apimsg = apimsg; sys_mbox_post(stack->stack_queue, msg); sys_arch_sem_wait(apimsg->msg.conn->op_completed, 0); } #endif /*---------------------------------------------------------------------------*/ err_t tcpip_input(struct pbuf *p, struct netif *inp) { struct stack *stack = inp->stack; struct tcpip_msg *msg; //LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: tcpip_input %p %p\n", (void *)p, (void *) inp)); msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) { pbuf_free(p); return ERR_MEM; } msg->type = TCPIP_MSG_INPUT; msg->msg.inp.p = p; msg->msg.inp.netif = inp; sys_mbox_post(stack->stack_queue, msg); return ERR_OK; } /*---------------------------------------------------------------------------*/ void tcpip_notify(struct netif *netif, u32_t type) { /* Get stack number from interface */ struct stack *stack = netif->stack; struct tcpip_msg *msg; sys_sem_t msg_wait; //LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: tcpip_change %c%c%d type %d (stack=%d)\n", // netif->name[0], // netif->name[1], // netif->num, // (int)type, // stack)); msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) return; msg->type = TCPIP_MSG_NETIF_NOTIFY; msg->msg.netif_notify.netif = netif; msg->msg.netif_notify.type = type; msg_wait = sys_sem_new(0); msg->msg.netif_notify.sem = &msg_wait; sys_mbox_post(stack->stack_queue, msg); /* Make this function syncronous. Wait until interface creation */ sys_sem_wait_timeout(msg_wait, 0); sys_sem_free(msg_wait); } /*---------------------------------------------------------------------------*/ struct netif * tcpip_netif_add( struct stack *stack, struct netif *netif, void *state, err_t (* init) (struct netif *netif), err_t (* input) (struct pbuf *p, struct netif *netif), void (* change)(struct netif *netif, u32_t type)) { struct netif *retval; struct tcpip_msg *msg; sys_sem_t msg_wait; LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_netif_add: (stack=%d)!\n", stack)); msg = memp_malloc(MEMP_TCPIP_MSG); if (msg == NULL) return NULL; msg->type = TCPIP_MSG_NETIFADD; msg->msg.netif.netif = netif; msg->msg.netif.state = state; msg->msg.netif.init = init; msg->msg.netif.input = input; msg->msg.netif.change = change; msg->msg.netif.retval = &retval; msg_wait = sys_sem_new(0); msg->msg.netif.sem = &msg_wait; sys_mbox_post(stack->stack_queue, msg); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_netif_add: (stack=%d) wait!\n", stack)); /* Make this function syncronous. Wait until interface creation */ sys_sem_wait_timeout(msg_wait, 0); sys_sem_free(msg_wait); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_netif_add: (stack=%d) ok!\n", stack)); return retval; } lwipv6-1.5a/lwip-v6/src/api/netlink.c0000644000175000017500000002533011671615010016500 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "lwip/opt.h" #if LWIP_NL #include "lwip/api.h" #include "lwip/tcpip.h" #include "lwip/sockets.h" #include "lwip/netlink.h" #include "lwip/netif.h" #include "ipv6/lwip/ip_route.h" #include "ipv6/lwip/ip_addr.h" #define MAX_NL 4 #define BUF_STDLEN 8192 #define MAX_BUFLEN 32768 struct netlinkbuf { int length; char *data; }; struct netlink { struct stack *stack; char flags; int proto; u32_t pid; struct sockaddr_nl name; struct nlmsghdr hdr; struct pbuf *answer[2]; int sndbufsize; int rcvbufsize; } nl_t[MAX_NL]; #define NL_ALLOC (0x1) static u32_t pid_counter; void netlink_addanswer(void *inbuf,int *offset,void *in,int len) { char *s=in; struct netlinkbuf *buf=inbuf; register int i; for (i=0; ilength; i++, (*offset)++) buf->data[(*offset)]=s[i]; } int mask2prefix (struct ip_addr *netmask) { int result=0; register int i,j; for (i=0; i<4; i++) if (~netmask->addr[i]==0) result+=32; else break; if (i<4 && netmask->addr[i] != 0) for (j=0; j<32; j++) if (ntohl(netmask->addr[i]) & 1 << (31 - j)) result++; return result; } void prefix2mask(int prefix,struct ip_addr *netmask) { register int i,j; register int tmp; for (i=0; i<4; i++, prefix -= 32) { if (prefix > 32) netmask->addr[i]=0xffffffff; else if (prefix > 0) { tmp=0; for (j=0;jaddr[i]=htonl(tmp); } else netmask->addr[i]=0; } } typedef void (*netlink_mgmt)(struct stack *stack, struct nlmsghdr *msg,void * buf,int *offset); #define NETLINK_IS_GET(X) ((X) % 4 == 2) static netlink_mgmt mgmt_table[]={ /* NEW/DEL/GET/SET link */ netif_netlink_adddellink, netif_netlink_adddellink, netif_netlink_getlink, NULL, /* NEW/DEL/GET addr */ netif_netlink_adddeladdr, netif_netlink_adddeladdr, netif_netlink_getaddr, NULL, /* NEW/DEL/GET route */ ip_route_netlink_adddelroute, ip_route_netlink_adddelroute, ip_route_netlink_getroute, NULL }; #define MGMT_TABLE_SIZE (sizeof(mgmt_table)/sizeof(netlink_mgmt)) void netlink_ackerror(void *msg,int ackerr,void *buf,int *offset) { struct nlmsghdr *h=(struct nlmsghdr *)msg; int myoffset=*offset; int restorelen=h->nlmsg_len; /*printf("netlink_ackerror %d\n",ackerr);*/ *offset += sizeof(struct nlmsghdr); netlink_addanswer(buf,offset,&ackerr,sizeof(int)); netlink_addanswer(buf,offset,msg,sizeof(struct nlmsghdr)); h->nlmsg_len=*offset-myoffset; h->nlmsg_flags=0; h->nlmsg_type=NLMSG_ERROR; netlink_addanswer(buf,&myoffset,msg,sizeof(struct nlmsghdr)); h->nlmsg_len=restorelen; } static void netlink_decode (struct stack *stack, void *msg,int size,int bufsize,struct pbuf **out,u32_t pid #if LWIP_CAPABILITIES ,int cap #endif ) { //char buf[BUF_MAXLEN]; struct netlinkbuf nlbuf; struct nlmsghdr *h=(struct nlmsghdr *)msg; int offset=0; if ((nlbuf.data=(char *) mem_malloc (bufsize)) == NULL) nlbuf.length=0; else nlbuf.length=bufsize; /*int success=1;*/ while (NLMSG_OK(h, size)) { /*int err;*/ int type; /*printf("h->nlmsg_type %x %d\n",h->nlmsg_type,h->nlmsg_type);*/ if (h->nlmsg_type == NLMSG_DONE) return; type=h->nlmsg_type - RTM_BASE; h->nlmsg_pid=pid; if (type >= 0 && type < MGMT_TABLE_SIZE && mgmt_table[type] != NULL) { #if LWIP_CAPABILITIES if (!NETLINK_IS_GET(type) && (cap&LWIP_CAP_NET_ADMIN) == 0) netlink_ackerror(h,-EPERM,&nlbuf,&offset); else #endif mgmt_table[type](stack, h,&nlbuf,&offset); } h = NLMSG_NEXT(h, size); } if (size) { fprintf(stderr, "netlink malformed packet: extra %d bytes\n", size); } if (offset > 0) { *out=pbuf_alloc(PBUF_RAW,offset,PBUF_RAM); memcpy((*out)->payload,nlbuf.data,offset); } mem_free(nlbuf.data); } #if 0 static void dump(unsigned char *data,int size) { register int i,j; printf("DUMP size=%d\n",size); for (i=0; i<(size+15)/16; i++) { for (j=0; j<16; j++) if (i*16+j < size) printf("%02x ",data[i*16+j]); else printf(" "); for (j=0; j<16; j++) if (i*16+j < size) printf("%c ",(data[i*16+j]>=' ' && data[i*16+j] <= '~')? data[i*16+j]:'.'); else printf(" "); printf("\n"); } } #endif struct netconn * netlink_open(struct stack *stack, int type,int proto) { register int i; for (i=0;iname),name,sizeof(struct sockaddr_nl)); return 0; } int netlink_close(void *sock) { struct netlink *nl=sock; /*printf("netlink_close\n");*/ nl->flags &= ~NL_ALLOC; return 0; } int netlink_connect(void *sock, struct sockaddr *name, socklen_t namelen) { /*printf("netlink_connect\n");*/ return 0; } int netlink_recvfrom(void *sock, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { struct netlink *nl=sock; struct stack *stack = nl->stack; /*printf("netlink_recvfrom\n");*/ if (from) { memset(from,0,*fromlen); from->sa_family=PF_NETLINK; } if (nl->answer[0]==NULL) { /*printf("netlink: answNULL\n");*/ return 0; } /* it is not able to split the answer into several messages */ else if (flags & MSG_PEEK) { register int outlen=nl->answer[0]->tot_len; /*printf("PEEK\n"); dump(mem,outlen);*/ memcpy(mem,nl->answer[0]->payload,(len < outlen) ? len : outlen); return outlen; } else if (nl->answer[0]->tot_len > len) { pbuf_free(nl->answer[0]); nl->answer[0]=NULL; if (nl->answer[1] != NULL) { pbuf_free(nl->answer[1]); nl->answer[1]=NULL; } /*printf("LEN %d\n",len);*/ return 0; } else { register int outlen=nl->answer[0]->tot_len; memcpy(mem,nl->answer[0]->payload,outlen); /*printf("ANSWER\n"); dump(mem,outlen);*/ pbuf_free(nl->answer[0]); nl->answer[0]=nl->answer[1]; nl->answer[1]=NULL; return outlen; } } /* netlink_send is the only function that reads/sets stack parameters like ip addrs/routes. These operations must be done in a synchronous way */ struct netlink_send_data { struct netlink *nl; void *data; int size; #if LWIP_CAPABILITIES int cap; #endif }; static void netlink_sync_send(void *arg) { struct netlink_send_data *nlss_data=arg; struct netlink *nl=nlss_data->nl; struct stack *stack = nl->stack; /*printf("netlink_send\n"); dump(data,size);*/ /*if (0 && nl->answer[0] != NULL) return (-1); else { */ netlink_decode(stack, nlss_data->data,nlss_data->size,nl->rcvbufsize,nl->answer,nl->pid #if LWIP_CAPABILITIES ,nlss_data->cap #endif ); memcpy(&(nl->hdr),nlss_data->data,sizeof(struct nlmsghdr)); /* } */ } int netlink_send(void *sock, void *data, int size, unsigned int flags) { struct netlink *nl=sock; struct stack *stack = nl->stack; struct netlink_send_data nlss_data; err_t rv; nlss_data.nl = nl; nlss_data.data = data; nlss_data.size = size; #if LWIP_CAPABILITIES if (stack->stack_capfun) nlss_data.cap=stack->stack_capfun(); else nlss_data.cap= ~0; #endif /* one single answer pending, multiple requests return one long answer */ rv = tcpip_callback(stack, netlink_sync_send, &nlss_data, SYNC); return 0; } int netlink_sendto(void *sock, void *data, int size, unsigned int flags, struct sockaddr *to, socklen_t tolen) { /*printf("netlink_sendto\n");*/ netlink_send(sock,data,size,flags); return 0; } int netlink_getsockname (void *sock, struct sockaddr *name, socklen_t *namelen) { struct netlink *nl=sock; struct sockaddr_nl snl; memset(&snl, 0, sizeof(snl)); snl.nl_family = PF_NETLINK; snl.nl_pid=nl->pid; snl.nl_groups=0; /*printf("netlink_getsockname\n");*/ memcpy(name,&snl,sizeof(snl)); *namelen=sizeof(snl); return(0); } int netlink_getsockopt (void *sock, int level, int optname, void *optval, socklen_t *optlen) { struct netlink *nl=sock; int err=0; //printf("netlink_getsockopt\n"); switch( level ) { case SOL_SOCKET: switch(optname) { case SO_RCVBUF: case SO_SNDBUF: if( *optlen < sizeof(int) ) { err = EINVAL; } break; default: err = ENOPROTOOPT; } break; default: err = ENOPROTOOPT; } /* switch */ if( err != 0 ) { return err; } else { switch( level ) { case SOL_SOCKET: switch(optname) { case SO_RCVBUF: *(int *) optval =nl->rcvbufsize; break; case SO_SNDBUF: //printf("SO_SNDBUF\n"); *(int *) optval =nl->sndbufsize; break; } break; } /* switch */ return 0; } } int netlink_setsockopt (void *sock, int level, int optname, const void *optval, socklen_t optlen) { struct netlink *nl=sock; int err=0; //printf("netlink_setsockopt %d\n",optname); switch( level ) { case SOL_SOCKET: switch(optname) { case SO_RCVBUF: case SO_SNDBUF: if( optlen < sizeof(int) ) { //printf("EINVAL\n"); err = EINVAL; } break; default: //printf("ENOPROTOOPT1\n"); err = ENOPROTOOPT; } break; default: //printf("ENOPROTOOPT2\n"); err = ENOPROTOOPT; } /* switch */ if(err != 0 ) { return err; } else { switch( level ) { case SOL_SOCKET: switch(optname) { case SO_RCVBUF: nl->rcvbufsize= *(int *) optval; if (nl->rcvbufsize > MAX_BUFLEN) nl->rcvbufsize = MAX_BUFLEN; break; case SO_SNDBUF: //printf("SO_SNDBUF\n"); nl->sndbufsize= *(int *) optval; if (nl->sndbufsize > MAX_BUFLEN) nl->sndbufsize = MAX_BUFLEN; break; } break; } /* switch */ return 0; } } #endif /* LWIP_NL */ lwipv6-1.5a/lwip-v6/src/core/0000755000175000017500000000000011671615111015046 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/core/inet6.c0000644000175000017500000003063511671615010016244 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* inet6.c * * Functions common to all TCP/IP modules, such as the Internet checksum and the * byte order functions. * */ #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/sockets.h" #include "lwip/inet.h" /* chksum: * * Sums up all 16 bit words in a memory portion. Also includes any odd byte. * This function is used by the other checksum functions. * * For now, this is not optimized. Must be optimized for the particular processor * arcitecture on which it is to run. Preferebly coded in assembler. */ static u32_t chksum(void *dataptr, u16_t len) { u16_t *sdataptr = dataptr; u32_t acc; for(acc = 0; len > 1; len -= 2) { acc += *sdataptr++; } /* add up any odd byte */ if (len == 1) { acc += htons((u16_t)((*(u8_t *)sdataptr) &0xff) << 8); } return acc; } /* inet_chksum_pseudo: * * Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain. */ u16_t inet6_chksum_pseudo(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t proto, u32_t proto_len) { u32_t acc; struct pbuf *q; u8_t swapped, i; //ip_addr_debug_print(IP_DEBUG, src); //ip_addr_debug_print(IP_DEBUG, dest); //printf("proto %d proto_len %d\n",proto,proto_len); acc = 0; swapped = 0; for(q = p; q != NULL; q = q->next) { acc += chksum(q->payload, q->len); while (acc >> 16) acc = (acc & 0xffffUL) + (acc >> 16); if (q->len % 2 != 0) { swapped = 1 - swapped; acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8); } } if (swapped) { acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8); } for(i = ip_addr_is_v4comp(src)?6:0; i < 8; i++) { acc += ((u16_t *)src->addr)[i] & 0xffffUL; acc += ((u16_t *)dest->addr)[i] & 0xffffUL; while (acc >> 16) acc = (acc & 0xffffUL) + (acc >> 16); } acc += (u16_t)htons((u16_t)proto); acc += htons(((u16_t *)&proto_len)[0]) & 0xffffUL; acc += htons(((u16_t *)&proto_len)[1]) & 0xffffUL; while (acc >> 16) acc = (acc & 0xffffUL) + (acc >> 16); return ~(acc & 0xffffUL); } /* inet_chksum: * * Calculates the Internet checksum over a portion of memory. Used primarely for IP * and ICMP. */ u16_t inet_chksum(void *dataptr, u16_t len) { u32_t acc, sum; acc = chksum(dataptr, len); sum = (acc & 0xffff) + (acc >> 16); sum += (sum >> 16); return ~(sum & 0xffff); } u16_t inet_chksum_pbuf(struct pbuf *p) { u32_t acc; struct pbuf *q; u8_t swapped; acc = 0; swapped = 0; for(q = p; q != NULL; q = q->next) { acc += chksum(q->payload, q->len); while (acc >> 16) { acc = (acc & 0xffff) + (acc >> 16); } if (q->len % 2 != 0) { swapped = 1 - swapped; acc = (acc & 0xff << 8) | (acc & 0xff00 >> 8); } } if (swapped) { acc = ((acc & 0xff) << 8) | ((acc & 0xff00) >> 8); } return ~(acc & 0xffff); } /******************************************************************************/ #if 0 /* Here for now until needed in other places in lwIP */ #ifndef isascii #define in_range(c, lo, up) ((u8_t)c >= lo && (u8_t)c <= up) #define isascii(c) in_range(c, 0x20, 0x7f) #define isdigit(c) in_range(c, '0', '9') #define isxdigit(c) (isdigit(c) || in_range(c, 'a', 'f') || in_range(c, 'A', 'F')) #define islower(c) in_range(c, 'a', 'z') #define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v') #endif /* * Ascii internet address interpretation routine. * The value returned is in network order. */ /* */ /* inet_addr */ u32_t inet_addr(const char *cp) { struct in_addr val; if (inet_aton(cp, &val)) { return (val.s_addr); } return (INADDR_NONE); } /* * Check whether "cp" is a valid ascii representation * of an Internet address and convert to a binary address. * Returns 1 if the address is valid, 0 if not. * This replaces inet_addr, the return value from which * cannot distinguish between failure and a local broadcast address. */ /* */ /* inet_aton */ int inet_aton(const char *cp, struct in_addr *addr) { u32_t val; int base, n; char c; u32_t parts[4]; u32_t* pp = parts; c = *cp; for (;;) { /* * Collect number up to ``.''. * Values are specified as for C: * 0x=hex, 0=octal, isdigit=decimal. */ if (!isdigit(c)) return (0); val = 0; base = 10; if (c == '0') { c = *++cp; if (c == 'x' || c == 'X') base = 16, c = *++cp; else base = 8; } for (;;) { if (isdigit(c)) { val = (val * base) + (int)(c - '0'); c = *++cp; } else if (base == 16 && isxdigit(c)) { val = (val << 4) | (int)(c + 10 - (islower(c) ? 'a' : 'A')); c = *++cp; } else break; } if (c == '.') { /* * Internet format: * a.b.c.d * a.b.c (with c treated as 16 bits) * a.b (with b treated as 24 bits) */ if (pp >= parts + 3) return (0); *pp++ = val; c = *++cp; } else break; } /* * Check for trailing characters. */ if (c != '\0' && (!isascii(c) || !isspace(c))) return (0); /* * Concoct the address according to * the number of parts specified. */ n = pp - parts + 1; switch (n) { case 0: return (0); /* initial nondigit */ case 1: /* a -- 32 bits */ break; case 2: /* a.b -- 8.24 bits */ if (val > 0xffffff) return (0); val |= parts[0] << 24; break; case 3: /* a.b.c -- 8.8.16 bits */ if (val > 0xffff) return (0); val |= (parts[0] << 24) | (parts[1] << 16); break; case 4: /* a.b.c.d -- 8.8.8.8 bits */ if (val > 0xff) return (0); val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); break; } if (addr) addr->s_addr = htonl(val); return (1); } /* Convert numeric IP address into decimal dotted ASCII representation. * returns ptr to static buffer; not reentrant! */ char *inet_ntoa(struct in_addr addr) { static char str[16]; u32_t s_addr = addr.s_addr; char inv[3]; char *rp; u8_t *ap; u8_t rem; u8_t n; u8_t i; rp = str; ap = (u8_t *)&s_addr; for(n = 0; n < 4; n++) { i = 0; do { rem = *ap % (u8_t)10; *ap /= (u8_t)10; inv[i++] = '0' + rem; } while(*ap); while(i--) *rp++ = inv[i]; *rp++ = '.'; ap++; } *--rp = 0; return str; } /******************************************************************************/ /* FIX: review these */ #include "lwip/ip_addr.h" #include "lwip/sockets.h" #define INT16_SZ 2 #define IN4ADDR_SZ 4 #define IN6ADDR_SZ 16 static int inet_pton4(const char *src, unsigned char *dst) { static const char digits[] = "0123456789"; unsigned char tmp[IN4ADDR_SZ], *tp; int saw_digit, octets, ch; saw_digit = 0; octets = 0; *(tp = tmp) = 0; while ((ch = *src++) != '\0') { const char *pch; if ((pch = strchr(digits, ch)) != NULL) { unsigned int new = *tp * 10 + (pch - digits); if (new > 255) return 0; *tp = new; if (! saw_digit) { if (++octets > 4) return 0; saw_digit = 1; } } else if (ch == '.' && saw_digit) { if (octets == 4) return 0; *++tp = 0; saw_digit = 0; } else return 0; } if (octets < 4) return 0; memcpy(dst, tmp, IN4ADDR_SZ); return 1; } static int inet_pton6(const char *src, unsigned char *dst) { static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; unsigned char tmp[IN6ADDR_SZ], *tp, *endp, *colonp; const char *xdigits, *curtok; int ch, saw_xdigit; unsigned int val; tp = tmp; memset((tp = tmp), '\0', IN6ADDR_SZ); endp = tp + IN6ADDR_SZ; colonp = NULL; /* Leading :: requires some special handling. */ if (*src == ':') if (*++src != ':') return 0; curtok = src; saw_xdigit = 0; val = 0; while ((ch = *src++) != '\0') { const char *pch; if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) pch = strchr((xdigits = xdigits_u), ch); if (pch != NULL) { val <<= 4; val |= (pch - xdigits); if (val > 0xffff) return 0; saw_xdigit = 1; continue; } if (ch == ':') { curtok = src; if (!saw_xdigit) { if (colonp) return 0; colonp = tp; continue; } if (tp + INT16_SZ > endp) return 0; *tp++ = (unsigned char) (val >> 8) & 0xff; *tp++ = (unsigned char) val & 0xff; saw_xdigit = 0; val = 0; continue; } if (ch == '.' && ((tp + IN4ADDR_SZ) <= endp) && inet_pton4(curtok, tp) > 0) { tp += IN4ADDR_SZ; saw_xdigit = 0; break; /* '\0' was seen by inet_pton4(). */ } return 0; } if (saw_xdigit) { if (tp + INT16_SZ > endp) return 0; *tp++ = (unsigned char) (val >> 8) & 0xff; *tp++ = (unsigned char) val & 0xff; } if (colonp != NULL) { const int n = tp - colonp; int i; for (i = 1; i <= n; i++) { endp[- i] = colonp[n - i]; colonp[n - i] = 0; } tp = endp; } if (tp != endp) return 0; memcpy(dst, tmp, IN6ADDR_SZ); return 1; } int inet_pton(int af, const char *src, void *dst) { int r; struct ip4_addr ip4; switch (af) { case AF_INET: r = inet_pton4(src, (void *)&ip4); if (r != 1) return r; IP64_CONV((struct ip_addr *) dst, &ip4); return r; case AF_INET6: return inet_pton6(src, dst); default: #ifdef LWIP_PROVIDE_ERRNO errno = EAFNOSUPPORT; #endif return -1; } } /*------------------------------------------------------------------------*/ #ifndef BYTE_ORDER #error BYTE_ORDER is not defined #endif #ifndef htons #if BYTE_ORDER == LITTLE_ENDIAN u16_t htons(u16_t n) { return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); } u16_t ntohs(u16_t n) { return htons(n); } u32_t htonl(u32_t n) { return ((n & 0xff) << 24) | ((n & 0xff00) << 8) | ((n & 0xff0000) >> 8) | ((n & 0xff000000) >> 24); } u32_t ntohl(u32_t n) { return htonl(n); } #endif #endif /* BYTE_ORDER == LITTLE_ENDIAN */ #endif lwipv6-1.5a/lwip-v6/src/core/sys.c0000644000175000017500000002565511671615010016043 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/sys.h" #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/memp.h" #if (NO_SYS == 0) struct sswt_cb { int timeflag; sys_sem_t *psem; }; void sys_mbox_fetch(sys_mbox_t mbox, void **msg) { u32_t time; struct sys_timeouts *timeouts; struct sys_timeout *tmptimeout; sys_timeout_handler h; void *arg; again: timeouts = sys_arch_timeouts(); if (!timeouts || !timeouts->next) { sys_arch_mbox_fetch(mbox, msg, 0); } else { if (timeouts->next->time > 0) { time = sys_arch_mbox_fetch(mbox, msg, timeouts->next->time); } else { time = SYS_ARCH_TIMEOUT; } if (time == SYS_ARCH_TIMEOUT) { /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message could be fetched. We should now call the timeout handler and deallocate the memory allocated for the timeout. */ tmptimeout = timeouts->next; timeouts->next = tmptimeout->next; h = tmptimeout->h; arg = tmptimeout->arg; if (tmptimeout->raw != 1) /// Added by Diego Billi memp_free(MEMP_SYS_TIMEOUT, tmptimeout); if (h != NULL) { LWIP_DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void *)h, (void *)arg)); h(arg); } if (tmptimeout->raw == 1) /// Added by Diego Billi tmptimeout->next = NULL; /// Added by Diego Billi /* We try again to fetch a message from the mbox. */ goto again; } else { /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout occured. The time variable is set to the number of milliseconds we waited for the message. */ if (time <= timeouts->next->time) { timeouts->next->time -= time; } else { timeouts->next->time = 0; } } } } void sys_sem_wait(sys_sem_t sem) { u32_t time; struct sys_timeouts *timeouts; struct sys_timeout *tmptimeout; sys_timeout_handler h; void *arg; /* while (sys_arch_sem_wait(sem, 1000) == 0); return;*/ again: timeouts = sys_arch_timeouts(); if (!timeouts || !timeouts->next) { sys_arch_sem_wait(sem, 0); } else { if (timeouts->next->time > 0) { time = sys_arch_sem_wait(sem, timeouts->next->time); } else { time = SYS_ARCH_TIMEOUT; } if (time == SYS_ARCH_TIMEOUT) { /* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message could be fetched. We should now call the timeout handler and deallocate the memory allocated for the timeout. */ tmptimeout = timeouts->next; timeouts->next = tmptimeout->next; h = tmptimeout->h; arg = tmptimeout->arg; if (tmptimeout->raw != 1) /// Added by Diego Billi memp_free(MEMP_SYS_TIMEOUT, tmptimeout); if (h != NULL) { LWIP_DEBUGF(SYS_DEBUG, ("ssw h=%p(%p)\n", (void *)h, (void *)arg)); h(arg); } if (tmptimeout->raw == 1) /// Added by Diego Billi tmptimeout->next = NULL; /// Added by Diego Billi /* We try again to fetch a message from the mbox. */ goto again; } else { /* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout occured. The time variable is set to the number of milliseconds we waited for the message. */ if (time <= timeouts->next->time) { timeouts->next->time -= time; } else { timeouts->next->time = 0; } } } } void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg) { struct sys_timeouts *timeouts; struct sys_timeout *timeout, *t; timeout = memp_malloc(MEMP_SYS_TIMEOUT); if (timeout == NULL) { return; } timeout->next = NULL; timeout->h = h; timeout->arg = arg; timeout->time = msecs; timeout->raw = 0; /// Added by Diego Billi timeouts = sys_arch_timeouts(); LWIP_DEBUGF(SYS_DEBUG, ("sys_timeout: %p msecs=%lu h=%p arg=%p\n", (void *)timeout, msecs, (void *)h, (void *)arg)); LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL); if (timeouts->next == NULL) { timeouts->next = timeout; return; } if (timeouts->next->time > msecs) { timeouts->next->time -= msecs; timeout->next = timeouts->next; timeouts->next = timeout; } else { for(t = timeouts->next; t != NULL; t = t->next) { timeout->time -= t->time; if (t->next == NULL || t->next->time > timeout->time) { if (t->next != NULL) { t->next->time -= timeout->time; } timeout->next = t->next; t->next = timeout; break; } } } } /* Go through timeout list (for this task only) and remove the first matching entry, even though the timeout has not triggered yet. */ void sys_untimeout(sys_timeout_handler h, void *arg) { struct sys_timeouts *timeouts; struct sys_timeout *prev_t, *t; timeouts = sys_arch_timeouts(); if (timeouts->next == NULL) return; for (t = timeouts->next, prev_t = NULL; t != NULL; prev_t = t, t = t->next) { if ((t->h == h) && (t->arg == arg)) { /* We have a match */ /* Unlink from previous in list */ if (prev_t == NULL) timeouts->next = t->next; else prev_t->next = t->next; /* If not the last one, add time of this one back to next */ if (t->next != NULL) t->next->time += t->time; if (t->raw != 1) memp_free(MEMP_SYS_TIMEOUT, t); return; } } return; } static void sswt_handler(void *arg) { struct sswt_cb *sswt_cb = (struct sswt_cb *) arg; /* Timeout. Set flag to TRUE and signal semaphore */ sswt_cb->timeflag = 1; sys_sem_signal(*(sswt_cb->psem)); } /* Wait for a semaphore with timeout (specified in ms) */ /* timeout = 0: wait forever */ /* Returns 0 on timeout. 1 otherwise */ int sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout) { struct sswt_cb sswt_cb; sswt_cb.psem = &sem; sswt_cb.timeflag = 0; /* If timeout is zero, then just wait forever */ if (timeout > 0) /* Create a timer and pass it the address of our flag */ sys_timeout(timeout, sswt_handler, &sswt_cb); sys_sem_wait(sem); /* Was it a timeout? */ if (sswt_cb.timeflag) { /* timeout */ return 0; } else { /* Not a timeout. Remove timeout entry */ sys_untimeout(sswt_handler, &sswt_cb); return 1; } } void sys_msleep(u32_t ms) { sys_sem_t delaysem = sys_sem_new(0); sys_sem_wait_timeout(delaysem, ms); sys_sem_free(delaysem); } /******************************************************************************/ /******************************************************************************/ /******************************************************************************/ /******************************************************************************/ /******************************************************************************/ /* This functions and timers will be used in the porting of Radvd code on Lwip */ /* Try to remove timeout 'h' with argument 'arg'. Return 1 if a timeout is removed */ int sys_untimeout_and_check(sys_timeout_handler h, void *arg) { struct sys_timeouts *timeouts; struct sys_timeout *prev_t, *t; timeouts = sys_arch_timeouts(); if (timeouts->next == NULL) return 0 ; for (t = timeouts->next, prev_t = NULL; t != NULL; prev_t = t, t = t->next) { if ((t->h == h) && (t->arg == arg)) { /* We have a match */ /* Unlink from previous in list */ if (prev_t == NULL) timeouts->next = t->next; else prev_t->next = t->next; /* If not the last one, add time of this one back to next */ if (t->next != NULL) t->next->time += t->time; if (t->raw != 1) memp_free(MEMP_SYS_TIMEOUT, t); return 1; } } return 0; } void sys_timeout_raw(struct sys_timeout * timeout) { struct sys_timeouts *timeouts; struct sys_timeout *t; u32_t msecs; timeout->raw = 1; msecs = timeout->time; timeouts = sys_arch_timeouts(); if (timeouts->next == NULL) { timeouts->next = timeout; return; } if (timeouts->next->time > msecs) { timeouts->next->time -= msecs; timeout->next = timeouts->next; timeouts->next = timeout; } else { for(t = timeouts->next; t != NULL; t = t->next) { timeout->time -= t->time; if (t->next == NULL || t->next->time > timeout->time) { if (t->next != NULL) { t->next->time -= timeout->time; } timeout->next = t->next; t->next = timeout; break; } } } } int sys_untimeout_raw(struct sys_timeout *timeout) { struct sys_timeouts *timeouts; struct sys_timeout *prev_t, *t; timeouts = sys_arch_timeouts(); /* If it's not pending */ if (timeout->next == NULL) return 0; if (timeouts->next == NULL) { return 0; } for (t = timeouts->next, prev_t = NULL; t != NULL; prev_t = t, t = t->next) { if (t == timeout) { /* We have a match */ /* Unlink from previous in list */ if (prev_t == NULL) timeouts->next = t->next; else prev_t->next = t->next; /* If not the last one, add time of this one back to next */ if (t->next != NULL) t->next->time += t->time; t->next = NULL; return 1; } } return 0; } #endif /* NO_SYS */ lwipv6-1.5a/lwip-v6/src/core/mem.c0000644000175000017500000002016311671615010015770 0ustar renzorenzo/** @file * * Dynamic memory manager * */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include "lwip/arch.h" #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/mem.h" #include "lwip/sys.h" #include "lwip/stats.h" struct mem { mem_size_t next, prev; #if MEM_ALIGNMENT == 1 u8_t used; #elif MEM_ALIGNMENT == 2 u16_t used; #elif MEM_ALIGNMENT == 4 u32_t used; #elif MEM_ALIGNMENT == 8 u64_t used; #else #error "unhandled MEM_ALIGNMENT size" #endif /* MEM_ALIGNMENT */ }; static struct mem *ram_end; static u8_t ram[MEM_SIZE + sizeof(struct mem) + MEM_ALIGNMENT]; #define MIN_SIZE 12 #define SIZEOF_STRUCT_MEM (sizeof(struct mem) + \ (((sizeof(struct mem) % MEM_ALIGNMENT) == 0)? 0 : \ (4 - (sizeof(struct mem) % MEM_ALIGNMENT)))) static struct mem *lfree; /* pointer to the lowest free block */ static sys_sem_t mem_sem; static void plug_holes(struct mem *mem) { struct mem *nmem; struct mem *pmem; LWIP_ASSERT("plug_holes: mem >= ram", (u8_t *)mem >= ram); LWIP_ASSERT("plug_holes: mem < ram_end", (u8_t *)mem < (u8_t *)ram_end); LWIP_ASSERT("plug_holes: mem->used == 0", mem->used == 0); /* plug hole forward */ LWIP_ASSERT("plug_holes: mem->next <= MEM_SIZE", mem->next <= MEM_SIZE); nmem = (struct mem *)&ram[mem->next]; if (mem != nmem && nmem->used == 0 && (u8_t *)nmem != (u8_t *)ram_end) { if (lfree == nmem) { lfree = mem; } mem->next = nmem->next; ((struct mem *)&ram[nmem->next])->prev = (u8_t *)mem - ram; } /* plug hole backward */ pmem = (struct mem *)&ram[mem->prev]; if (pmem != mem && pmem->used == 0) { if (lfree == mem) { lfree = pmem; } pmem->next = mem->next; ((struct mem *)&ram[mem->next])->prev = (u8_t *)pmem - ram; } } void mem_init(void) { struct mem *mem; memset(ram, 0, MEM_SIZE); mem = (struct mem *)ram; mem->next = MEM_SIZE; mem->prev = 0; mem->used = 0; ram_end = (struct mem *)&ram[MEM_SIZE]; ram_end->used = 1; ram_end->next = MEM_SIZE; ram_end->prev = MEM_SIZE; mem_sem = sys_sem_new(1); lfree = (struct mem *)ram; #if MEM_STATS lwip_stats.mem.avail = MEM_SIZE; #endif /* MEM_STATS */ } void mem_free(void *rmem) { struct mem *mem; if (rmem == NULL) { LWIP_DEBUGF(MEM_DEBUG | DBG_TRACE | 2, ("mem_free(p == NULL) was called.\n")); return; } sys_sem_wait(mem_sem); LWIP_ASSERT("mem_free: legal memory", (u8_t *)rmem >= (u8_t *)ram && (u8_t *)rmem < (u8_t *)ram_end); if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_free: illegal memory\n")); #if MEM_STATS ++lwip_stats.mem.err; #endif /* MEM_STATS */ sys_sem_signal(mem_sem); return; } mem = (struct mem *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); LWIP_ASSERT("mem_free: mem->used", mem->used); mem->used = 0; if (mem < lfree) { lfree = mem; } #if MEM_STATS lwip_stats.mem.used -= mem->next - ((u8_t *)mem - ram); #endif /* MEM_STATS */ plug_holes(mem); sys_sem_signal(mem_sem); } void * mem_reallocm(void *rmem, mem_size_t newsize) { void *nmem; nmem = mem_malloc(newsize); if (nmem == NULL) { return mem_realloc(rmem, newsize); } memcpy(nmem, rmem, newsize); mem_free(rmem); return nmem; } void * mem_realloc(void *rmem, mem_size_t newsize) { mem_size_t size; mem_size_t ptr, ptr2; struct mem *mem, *mem2; /* Expand the size of the allocated memory region so that we can adjust for alignment. */ if ((newsize % MEM_ALIGNMENT) != 0) { newsize += MEM_ALIGNMENT - ((newsize + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT); } if (newsize > MEM_SIZE) { return NULL; } sys_sem_wait(mem_sem); LWIP_ASSERT("mem_realloc: legal memory", (u8_t *)rmem >= (u8_t *)ram && (u8_t *)rmem < (u8_t *)ram_end); if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_realloc: illegal memory\n")); return rmem; } mem = (struct mem *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); ptr = (u8_t *)mem - ram; size = mem->next - ptr - SIZEOF_STRUCT_MEM; #if MEM_STATS lwip_stats.mem.used -= (size - newsize); #endif /* MEM_STATS */ if (newsize + SIZEOF_STRUCT_MEM + MIN_SIZE < size) { ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize; mem2 = (struct mem *)&ram[ptr2]; mem2->used = 0; mem2->next = mem->next; mem2->prev = ptr; mem->next = ptr2; if (mem2->next != MEM_SIZE) { ((struct mem *)&ram[mem2->next])->prev = ptr2; } plug_holes(mem2); } sys_sem_signal(mem_sem); return rmem; } void * mem_malloc(mem_size_t size) { mem_size_t ptr, ptr2; struct mem *mem, *mem2; if (size == 0) { return NULL; } /* Expand the size of the allocated memory region so that we can adjust for alignment. */ if ((size % MEM_ALIGNMENT) != 0) { size += MEM_ALIGNMENT - ((size + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT); } if (size > MEM_SIZE) { return NULL; } sys_sem_wait(mem_sem); for (ptr = (u8_t *)lfree - ram; ptr < MEM_SIZE; ptr = ((struct mem *)&ram[ptr])->next) { mem = (struct mem *)&ram[ptr]; if (!mem->used && mem->next - (ptr + SIZEOF_STRUCT_MEM) >= size + SIZEOF_STRUCT_MEM) { ptr2 = ptr + SIZEOF_STRUCT_MEM + size; mem2 = (struct mem *)&ram[ptr2]; mem2->prev = ptr; mem2->next = mem->next; mem->next = ptr2; if (mem2->next != MEM_SIZE) { ((struct mem *)&ram[mem2->next])->prev = ptr2; } mem2->used = 0; mem->used = 1; #if MEM_STATS lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM); /* if (lwip_stats.mem.max < lwip_stats.mem.used) { lwip_stats.mem.max = lwip_stats.mem.used; } */ if (lwip_stats.mem.max < ptr2) { lwip_stats.mem.max = ptr2; } #endif /* MEM_STATS */ if (mem == lfree) { /* Find next free block after mem */ while (lfree->used && lfree != ram_end) { lfree = (struct mem *)&ram[lfree->next]; } LWIP_ASSERT("mem_malloc: !lfree->used", !lfree->used); } sys_sem_signal(mem_sem); LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.", (mem_ptr_t)mem + SIZEOF_STRUCT_MEM + size <= (mem_ptr_t)ram_end); LWIP_ASSERT("mem_malloc: allocated memory properly aligned.", (unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0); return (u8_t *)mem + SIZEOF_STRUCT_MEM; } } LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %d bytes\n", (int)size)); #if MEM_STATS ++lwip_stats.mem.err; #endif /* MEM_STATS */ sys_sem_signal(mem_sem); return NULL; } lwipv6-1.5a/lwip-v6/src/core/tcp.c0000644000175000017500000011376111671615010016007 0ustar renzorenzo/** * @file * * Transmission Control Protocol for IP */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2010,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include /* tcp.c * * This file contains common functions for the TCP implementation, such as functinos * for manipulating the data structures and the TCP timer functions. TCP functions * related to input and output is found in tcp_input.c and tcp_output.c respectively. * */ #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/mem.h" #include "lwip/memp.h" #include "lwip/tcp.h" #if LWIP_TCP const u8_t tcp_backoff[13] = { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7}; #if 0 STACK FIELDS /* Incremented every coarse grained timer shot (typically every 500 ms, determined by TCP_COARSE_TIMEOUT). */ u32_t tcp_ticks; /* The TCP PCB lists. */ /* List of all TCP PCBs in LISTEN state. */ union tcp_listen_pcbs_t tcp_listen_pcbs; struct tcp_pcb *tcp_active_pcb; /* List of all TCP PCBs that are in a state in which they accept or send data. */ struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ static u8_t tcp_timer; #endif static u16_t tcp_new_port(struct stack *stack); /* * tcp_init(): * * Initializes the TCP layer. */ void tcp_init(struct stack *stack) { /* Clear globals. */ stack->tcp_listen_pcbs.listen_pcbs = NULL; stack->tcp_active_pcbs = NULL; stack->tcp_tw_pcbs = NULL; /* initialize timer */ stack->tcp_ticks = 0; stack->tcp_timer = 0; } void tcp_shutdown(struct stack *stack) { /* FIX: TODO */ } /* * tcp_tmr(): * * Called periodically to dispatch TCP timers. * */ void tcp_tmr(struct stack *stack) { /* Call tcp_fasttmr() every 250 ms */ tcp_fasttmr(stack); if (++stack->tcp_timer & 1) { /* Call tcp_tmr() every 500 ms, i.e., every other timer tcp_tmr() is called. */ tcp_slowtmr(stack); } } /* * tcp_close(): * * Closes the connection held by the PCB. * */ err_t tcp_close(struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; err_t err; #if TCP_DEBUG LWIP_DEBUGF(TCP_DEBUG, ("tcp_close: closing in state ")); tcp_debug_print_state(pcb->state); LWIP_DEBUGF(TCP_DEBUG, ("\n")); #endif /* TCP_DEBUG */ switch (pcb->state) { case CLOSED: /* Closing a pcb in the CLOSED state might seem erroneous, * however, it is in this state once allocated and as yet unused * and the user needs some way to free it should the need arise. * Calling tcp_close() with a pcb that has already been closed, (i.e. twice) * or for a pcb that has been used and then entered the CLOSED state * is erroneous, but this should never happen as the pcb has in those cases * been freed, and so any remaining handles are bogus. */ err = ERR_OK; memp_free(MEMP_TCP_PCB, pcb); pcb = NULL; break; case LISTEN: err = ERR_OK; tcp_pcb_remove((struct tcp_pcb **)&stack->tcp_listen_pcbs.pcbs, pcb); memp_free(MEMP_TCP_PCB_LISTEN, pcb); pcb = NULL; break; case SYN_SENT: err = ERR_OK; tcp_pcb_remove(&stack->tcp_active_pcbs, pcb); memp_free(MEMP_TCP_PCB, pcb); pcb = NULL; break; case SYN_RCVD: case ESTABLISHED: err = tcp_send_ctrl(pcb, TCP_FIN); if (err == ERR_OK) { pcb->state = FIN_WAIT_1; } break; case CLOSE_WAIT: err = tcp_send_ctrl(pcb, TCP_FIN); if (err == ERR_OK) { pcb->state = LAST_ACK; } break; default: /* Has already been closed, do nothing. */ err = ERR_OK; pcb = NULL; break; } if (pcb != NULL && err == ERR_OK) { err = tcp_output(pcb); } return err; } /* * tcp_abort() * * Aborts a connection by sending a RST to the remote host and deletes * the local protocol control block. This is done when a connection is * killed because of shortage of memory. * */ void tcp_abort(struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; u32_t seqno, ackno; u16_t remote_port, local_port; struct ip_addr remote_ip, local_ip; #if LWIP_CALLBACK_API void (* errf)(void *arg, err_t err); #endif /* LWIP_CALLBACK_API */ void *errf_arg; /* Figure out on which TCP PCB list we are, and remove us. If we are in an active state, call the receive function associated with the PCB with a NULL argument, and send an RST to the remote end. */ if (pcb->state == TIME_WAIT) { tcp_pcb_remove(&stack->tcp_tw_pcbs, pcb); memp_free(MEMP_TCP_PCB, pcb); } else { seqno = pcb->snd_nxt; ackno = pcb->rcv_nxt; ip_addr_set(&local_ip, &(pcb->local_ip)); ip_addr_set(&remote_ip, &(pcb->remote_ip)); local_port = pcb->local_port; remote_port = pcb->remote_port; #if LWIP_CALLBACK_API errf = pcb->errf; #endif /* LWIP_CALLBACK_API */ errf_arg = pcb->callback_arg; tcp_pcb_remove(&stack->tcp_active_pcbs, pcb); if (pcb->unacked != NULL) { tcp_segs_free(pcb->unacked); } if (pcb->unsent != NULL) { tcp_segs_free(pcb->unsent); } #if TCP_QUEUE_OOSEQ if (pcb->ooseq != NULL) { tcp_segs_free(pcb->ooseq); } #endif /* TCP_QUEUE_OOSEQ */ memp_free(MEMP_TCP_PCB, pcb); TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abort: sending RST\n")); tcp_rst(stack, seqno, ackno, &local_ip, &remote_ip, local_port, remote_port); } } /* * tcp_bind(): * * Binds the connection to a local portnumber and IP address. If the * IP address is not given (i.e., ipaddr == NULL), the IP address of * the outgoing network interface is used instead. * */ err_t tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) { struct stack *stack = pcb->stack; struct tcp_pcb *cpcb; #if SO_REUSE int reuse_port_all_set = 1; #endif /* SO_REUSE */ if (port == 0) { port = tcp_new_port(stack); } #if SO_REUSE == 0 /* Check if the address already is in use. */ for(cpcb = (struct tcp_pcb *)tcp_listen_pcbs.pcbs; cpcb != NULL; cpcb = cpcb->next) { if (cpcb->local_port == port) { if (ip_addr_isany(&(cpcb->local_ip)) || ip_addr_isany(ipaddr) || ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { return ERR_USE; } } } for(cpcb = stack->tcp_active_pcbs; cpcb != NULL; cpcb = cpcb->next) { if (cpcb->local_port == port) { if (ip_addr_isany(&(cpcb->local_ip)) || ip_addr_isany(ipaddr) || ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { return ERR_USE; } } } #else /* SO_REUSE */ /* Search through list of PCB's in LISTEN state. If there is a PCB bound to specified port and IP_ADDR_ANY another PCB can be bound to the interface IP or to the loopback address on the same port if SOF_REUSEADDR is set. Any combination of PCB's bound to the same local port, but to one address out of {IP_ADDR_ANY, 127.0.0.1, interface IP} at a time is valid. But no two PCB's bound to same local port and same local address is valid. If SOF_REUSEPORT is set several PCB's can be bound to same local port and same local address also. But then all PCB's must have the SOF_REUSEPORT option set. When the two options aren't set and specified port is already bound, ERR_USE is returned saying that address is already in use. */ for(cpcb = (struct tcp_pcb *)stack->tcp_listen_pcbs.pcbs; cpcb != NULL; cpcb = cpcb->next) { if(cpcb->local_port == port) { if(ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { if(pcb->so_options & SOF_REUSEPORT) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in listening PCB's: SO_REUSEPORT set and same address.\n")); reuse_port_all_set = (reuse_port_all_set && (cpcb->so_options & SOF_REUSEPORT)); } else { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in listening PCB's: SO_REUSEPORT not set and same address.\n")); return ERR_USE; } } else if((ip_addr_isany(ipaddr) && !ip_addr_isany(&(cpcb->local_ip))) || (!ip_addr_isany(ipaddr) && ip_addr_isany(&(cpcb->local_ip)))) { if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in listening PCB's SO_REUSEPORT or SO_REUSEADDR not set and not the same address.\n")); return ERR_USE; } else { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in listening PCB's SO_REUSEPORT or SO_REUSEADDR set and not the same address.\n")); } } } } /* Search through list of PCB's in a state in which they can accept or send data. Same decription as for PCB's in state LISTEN applies to this PCB's regarding the options SOF_REUSEADDR and SOF_REUSEPORT. */ for(cpcb = stack->tcp_active_pcbs; cpcb != NULL; cpcb = cpcb->next) { if(cpcb->local_port == port) { if(ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { if(pcb->so_options & SOF_REUSEPORT) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in active PCB's SO_REUSEPORT set and same address.\n")); reuse_port_all_set = (reuse_port_all_set && (cpcb->so_options & SOF_REUSEPORT)); } else { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in active PCB's SO_REUSEPORT not set and same address.\n")); return ERR_USE; } } else if((ip_addr_isany(ipaddr) && !ip_addr_isany(&(cpcb->local_ip))) || (!ip_addr_isany(ipaddr) && ip_addr_isany(&(cpcb->local_ip)))) { if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in active PCB's SO_REUSEPORT or SO_REUSEADDR not set and not the same address.\n")); return ERR_USE; } else { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in active PCB's SO_REUSEPORT or SO_REUSEADDR set and not the same address.\n")); } } } } /* Search through list of PCB's in TIME_WAIT state. If SO_REUSEADDR is set a bound combination [IP, port} can be rebound. The same applies when SOF_REUSEPORT is set. If SOF_REUSEPORT is set several PCB's can be bound to same local port and same local address also. But then all PCB's must have the SOF_REUSEPORT option set. When the two options aren't set and specified port is already bound, ERR_USE is returned saying that address is already in use. */ for(cpcb = stack->tcp_tw_pcbs; cpcb != NULL; cpcb = cpcb->next) { if(cpcb->local_port == port) { if(ip_addr_cmp(&(cpcb->local_ip), ipaddr)) { if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in TIME_WAIT PCB's SO_REUSEPORT or SO_REUSEADDR not set and same address.\n")); return ERR_USE; } else if(pcb->so_options & SOF_REUSEPORT) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: in TIME_WAIT PCB's SO_REUSEPORT set and same address.\n")); reuse_port_all_set = (reuse_port_all_set && (cpcb->so_options & SOF_REUSEPORT)); } } } } /* If SOF_REUSEPORT isn't set in all PCB's bound to specified port and local address specified then {IP, port} can't be reused. */ if(!reuse_port_all_set) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: not all sockets have SO_REUSEPORT set.\n")); return ERR_USE; } #endif /* SO_REUSE */ if (!ip_addr_isany(ipaddr)) { pcb->local_ip = *ipaddr; } pcb->local_port = port; LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %u\n", port)); return ERR_OK; } #if LWIP_CALLBACK_API static err_t tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err) { (void)arg; (void)pcb; (void)err; return ERR_ABRT; } #endif /* LWIP_CALLBACK_API */ /* * tcp_listen(): * * Set the state of the connection to be LISTEN, which means that it * is able to accept incoming connections. The protocol control block * is reallocated in order to consume less memory. Setting the * connection to LISTEN is an irreversible process. * */ struct tcp_pcb * tcp_listen(struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; struct tcp_pcb_listen *lpcb; /* already listening? */ if (pcb->state == LISTEN) { return pcb; } lpcb = memp_malloc(MEMP_TCP_PCB_LISTEN); if (lpcb == NULL) { return NULL; } lpcb->stack = stack; #ifdef LWSLIRP lpcb->slirp_fddata = pcb->slirp_fddata; lpcb->slirp_state = pcb->slirp_state; #endif lpcb->callback_arg = pcb->callback_arg; lpcb->local_port = pcb->local_port; lpcb->remote_port = pcb->remote_port; lpcb->state = LISTEN; lpcb->so_options = pcb->so_options; lpcb->so_options |= SOF_ACCEPTCONN; lpcb->ttl = pcb->ttl; lpcb->tos = pcb->tos; ip_addr_set(&lpcb->local_ip, &pcb->local_ip); memp_free(MEMP_TCP_PCB, pcb); #if LWIP_CALLBACK_API lpcb->accept = tcp_accept_null; #endif /* LWIP_CALLBACK_API */ TCP_REG(&stack->tcp_listen_pcbs.listen_pcbs, lpcb); return (struct tcp_pcb *)lpcb; } /* * tcp_recved(): * * This function should be called by the application when it has * processed the data. The purpose is to advertise a larger window * when the data has been processed. * */ void tcp_recved(struct tcp_pcb *pcb, u16_t len) { if ((u32_t)pcb->rcv_wnd + len > TCP_WND) { pcb->rcv_wnd = TCP_WND; } else { pcb->rcv_wnd += len; } if (!(pcb->flags & TF_ACK_DELAY) && !(pcb->flags & TF_ACK_NOW)) { /* * We send an ACK here (if one is not already pending, hence * the above tests) as tcp_recved() implies that the application * has processed some data, and so we can open the receiver's * window to allow more to be transmitted. This could result in * two ACKs being sent for each received packet in some limited cases * (where the application is only receiving data, and is slow to * process it) but it is necessary to guarantee that the sender can * continue to transmit. */ tcp_ack(pcb); } else if (pcb->flags & TF_ACK_DELAY && pcb->rcv_wnd >= TCP_WND/2) { /* If we can send a window update such that there is a full * segment available in the window, do so now. This is sort of * nagle-like in its goals, and tries to hit a compromise between * sending acks each time the window is updated, and only sending * window updates when a timer expires. The "threshold" used * above (currently TCP_WND/2) can be tuned to be more or less * aggressive */ tcp_ack_now(pcb); } LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %u bytes, wnd %u (%u).\n", len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd)); } /* * tcp_new_port(): * * A nastly hack featuring 'goto' statements that allocates a * new TCP local port. */ static u16_t tcp_new_port(struct stack *stack) { struct tcp_pcb *pcb; #ifndef TCP_LOCAL_PORT_RANGE_START #define TCP_LOCAL_PORT_RANGE_START 4096 #define TCP_LOCAL_PORT_RANGE_END 0x7fff #endif static u16_t port = TCP_LOCAL_PORT_RANGE_START; again: if (++port > TCP_LOCAL_PORT_RANGE_END) { port = TCP_LOCAL_PORT_RANGE_START; } for(pcb = stack->tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { if (pcb->local_port == port) { goto again; } } for(pcb = stack->tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { if (pcb->local_port == port) { goto again; } } for(pcb = (struct tcp_pcb *)stack->tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) { if (pcb->local_port == port) { goto again; } } return port; } /* * tcp_connect(): * * Connects to another host. The function given as the "connected" * argument will be called when the connection has been established. * */ err_t tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port, err_t (* connected)(void *arg, struct tcp_pcb *tpcb, err_t err)) { struct stack *stack = pcb->stack; u32_t optdata; err_t ret; u32_t iss; LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %u\n", port)); if (ipaddr != NULL) { pcb->remote_ip = *ipaddr; } else { return ERR_VAL; } pcb->remote_port = port; if (pcb->local_port == 0) { pcb->local_port = tcp_new_port(stack); } iss = tcp_next_iss(stack); pcb->rcv_nxt = 0; pcb->snd_nxt = iss; pcb->lastack = iss - 1; pcb->snd_lbb = iss - 1; pcb->rcv_wnd = TCP_WND; pcb->snd_wnd = TCP_WND; pcb->mss = TCP_MSS; pcb->cwnd = 1; pcb->ssthresh = pcb->mss * 10; pcb->state = SYN_SENT; #if LWIP_CALLBACK_API pcb->connected = connected; #endif /* LWIP_CALLBACK_API */ TCP_REG(&stack->tcp_active_pcbs, pcb); /* Build an MSS option */ optdata = htonl(((u32_t)2 << 24) | ((u32_t)4 << 16) | (((u32_t)pcb->mss / 256) << 8) | (pcb->mss & 255)); ret = tcp_enqueue(pcb, NULL, 0, TCP_SYN, 0, (u8_t *)&optdata, 4); if (ret == ERR_OK) { tcp_output(pcb); } return ret; } /* * tcp_slowtmr(): * * Called every 500 ms and implements the retransmission timer and the timer that * removes PCBs that have been in TIME-WAIT for enough time. It also increments * various timers such as the inactivity timer in each PCB. */ void tcp_slowtmr(struct stack *stack) { struct tcp_pcb *pcb, *pcb2, *prev; u32_t eff_wnd; u8_t pcb_remove; /* flag if a PCB should be removed */ err_t err; err = ERR_OK; ++stack->tcp_ticks; /* Steps through all of the active PCBs. */ prev = NULL; pcb = stack->tcp_active_pcbs; if (pcb == NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n")); } while (pcb != NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n")); LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED); LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN); LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT\n", pcb->state != TIME_WAIT); pcb_remove = 0; if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) { ++pcb_remove; LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n")); } else if (pcb->nrtx == TCP_MAXRTX) { ++pcb_remove; LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n")); } else { ++pcb->rtime; if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) { /* Time for a retransmission. */ LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %u pcb->rto %u\n", pcb->rtime, pcb->rto)); /* Double retransmission time-out unless we are trying to * connect to somebody (i.e., we are in SYN_SENT). */ if (pcb->state != SYN_SENT) { pcb->rto = ((pcb->sa >> 3) + pcb->sv) << tcp_backoff[pcb->nrtx]; } /* Reduce congestion window and ssthresh. */ eff_wnd = LWIP_MIN(pcb->cwnd, pcb->snd_wnd); pcb->ssthresh = eff_wnd >> 1; if (pcb->ssthresh < pcb->mss) { pcb->ssthresh = pcb->mss * 2; } pcb->cwnd = pcb->mss; LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %u ssthresh %u\n", pcb->cwnd, pcb->ssthresh)); /* The following needs to be called AFTER cwnd is set to one mss - STJ */ tcp_rexmit_rto(pcb); } } /* Check if this PCB has stayed too long in FIN-WAIT-2 */ if (pcb->state == FIN_WAIT_2) { if ((u32_t)(stack->tcp_ticks - pcb->tmr) > TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { ++pcb_remove; LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); } } /* Check if KEEPALIVE should be sent */ if((pcb->so_options & SOF_KEEPALIVE) && ((pcb->state == ESTABLISHED) || (pcb->state == CLOSE_WAIT))) { if((u32_t)(stack->tcp_ticks - pcb->tmr) > (pcb->keepalive + TCP_MAXIDLE) / TCP_SLOW_INTERVAL) { #ifndef IPv6 LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: KEEPALIVE timeout. Aborting connection to %u.%u.%u.%u.\n", ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip))); #endif tcp_abort(pcb); } else if((u32_t)(stack->tcp_ticks - pcb->tmr) > (pcb->keepalive + pcb->keep_cnt * TCP_KEEPINTVL) / TCP_SLOW_INTERVAL) { tcp_keepalive(pcb); pcb->keep_cnt++; } } /* If this PCB has queued out of sequence data, but has been inactive for too long, will drop the data (it will eventually be retransmitted). */ #if TCP_QUEUE_OOSEQ if (pcb->ooseq != NULL && (u32_t)stack->tcp_ticks - pcb->tmr >= pcb->rto * TCP_OOSEQ_TIMEOUT) { tcp_segs_free(pcb->ooseq); pcb->ooseq = NULL; LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: dropping OOSEQ queued data\n")); } #endif /* TCP_QUEUE_OOSEQ */ /* Check if this PCB has stayed too long in SYN-RCVD */ if (pcb->state == SYN_RCVD) { if ((u32_t)(stack->tcp_ticks - pcb->tmr) > TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { ++pcb_remove; LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n")); } } /* If the PCB should be removed, do it. */ if (pcb_remove) { tcp_pcb_purge(pcb); /* Remove PCB from tcp_active_pcbs list. */ if (prev != NULL) { LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != stack->tcp_active_pcbs); prev->next = pcb->next; } else { /* This PCB was the first. */ LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_active_pcbs", stack->tcp_active_pcbs == pcb); stack->tcp_active_pcbs = pcb->next; } TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_ABRT); pcb2 = pcb->next; memp_free(MEMP_TCP_PCB, pcb); pcb = pcb2; } else { /* We check if we should poll the connection. */ ++pcb->polltmr; if (pcb->polltmr >= pcb->pollinterval) { pcb->polltmr = 0; LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: polling application\n")); TCP_EVENT_POLL(pcb, err); if (err == ERR_OK) { tcp_output(pcb); } } prev = pcb; pcb = pcb->next; } } /* Steps through all of the TIME-WAIT PCBs. */ prev = NULL; pcb = stack->tcp_tw_pcbs; while (pcb != NULL) { LWIP_ASSERT("tcp_slowtmr: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); pcb_remove = 0; /* Check if this PCB has stayed long enough in TIME-WAIT */ if ((u32_t)(stack->tcp_ticks - pcb->tmr) > 2 * TCP_MSL / TCP_SLOW_INTERVAL) { ++pcb_remove; } /* If the PCB should be removed, do it. */ if (pcb_remove) { tcp_pcb_purge(pcb); /* Remove PCB from tcp_tw_pcbs list. */ if (prev != NULL) { LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != stack->tcp_tw_pcbs); prev->next = pcb->next; } else { /* This PCB was the first. */ LWIP_ASSERT("tcp_slowtmr: first pcb == tcp_tw_pcbs", stack->stackw_pcbs == pcb); stack->tcp_tw_pcbs = pcb->next; } pcb2 = pcb->next; memp_free(MEMP_TCP_PCB, pcb); pcb = pcb2; } else { prev = pcb; pcb = pcb->next; } } } /* * tcp_fasttmr(): * * Is called every TCP_FAST_INTERVAL (250 ms) and sends delayed ACKs. */ void tcp_fasttmr(struct stack *stack) { struct tcp_pcb *pcb; /* send delayed ACKs */ for(pcb = stack->tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { if (pcb->flags & TF_ACK_DELAY) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n")); tcp_ack_now(pcb); pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); } } } /* * tcp_segs_free(): * * Deallocates a list of TCP segments (tcp_seg structures). * */ u8_t tcp_segs_free(struct tcp_seg *seg) { u8_t count = 0; struct tcp_seg *next; while (seg != NULL) { next = seg->next; count += tcp_seg_free(seg); seg = next; } return count; } /* * tcp_seg_free(): * * Frees a TCP segment. * */ u8_t tcp_seg_free(struct tcp_seg *seg) { u8_t count = 0; if (seg != NULL) { if (seg->p != NULL) { count = pbuf_free(seg->p); #if TCP_DEBUG seg->p = NULL; #endif /* TCP_DEBUG */ } memp_free(MEMP_TCP_SEG, seg); } return count; } /* * tcp_setprio(): * * Sets the priority of a connection. * */ void tcp_setprio(struct tcp_pcb *pcb, u8_t prio) { pcb->prio = prio; } #if TCP_QUEUE_OOSEQ /* * tcp_seg_copy(): * * Returns a copy of the given TCP segment. * */ struct tcp_seg * tcp_seg_copy(struct tcp_seg *seg) { struct tcp_seg *cseg; cseg = memp_malloc(MEMP_TCP_SEG); if (cseg == NULL) { return NULL; } memcpy((char *)cseg, (const char *)seg, sizeof(struct tcp_seg)); pbuf_ref(cseg->p); return cseg; } #endif #if LWIP_CALLBACK_API static err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { arg = arg; if (p != NULL) { pbuf_free(p); } else if (err == ERR_OK) { return tcp_close(pcb); } return ERR_OK; } #endif /* LWIP_CALLBACK_API */ static void tcp_kill_prio(struct stack *stack, u8_t prio) { struct tcp_pcb *pcb, *inactive; u32_t inactivity; u8_t mprio; mprio = TCP_PRIO_MAX; /* We kill the oldest active connection that has lower priority than prio. */ inactivity = 0; inactive = NULL; for(pcb = stack->tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { if (pcb->prio <= prio && pcb->prio <= mprio && (u32_t)(stack->tcp_ticks - pcb->tmr) >= inactivity) { inactivity = stack->tcp_ticks - pcb->tmr; inactive = pcb; mprio = pcb->prio; } } if (inactive != NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB %p (%ld)\n", (void *)inactive, inactivity)); tcp_abort(inactive); } } static void tcp_kill_timewait(struct stack *stack) { struct tcp_pcb *pcb, *inactive; u32_t inactivity; inactivity = 0; inactive = NULL; for(pcb = stack->tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { if ((u32_t)(stack->tcp_ticks - pcb->tmr) >= inactivity) { inactivity = stack->tcp_ticks - pcb->tmr; inactive = pcb; } } if (inactive != NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB %p (%ld)\n", (void *)inactive, inactivity)); tcp_abort(inactive); } } struct tcp_pcb * tcp_alloc(struct stack *stack, u8_t prio) { struct tcp_pcb *pcb; u32_t iss; pcb = memp_malloc(MEMP_TCP_PCB); if (pcb == NULL) { /* Try killing oldest connection in TIME-WAIT. */ LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n")); tcp_kill_timewait(stack); pcb = memp_malloc(MEMP_TCP_PCB); if (pcb == NULL) { tcp_kill_prio(stack, prio); pcb = memp_malloc(MEMP_TCP_PCB); } } if (pcb != NULL) { memset(pcb, 0, sizeof(struct tcp_pcb)); pcb->stack = stack; #ifdef LWSLIRP pcb->slirp_fddata = NULL; pcb->slirp_state = SS_NOFDREF; #endif pcb->prio = TCP_PRIO_NORMAL; pcb->snd_buf = TCP_SND_BUF; pcb->snd_queuelen = 0; pcb->rcv_wnd = TCP_WND; pcb->tos = 0; pcb->ttl = TCP_TTL; pcb->mss = TCP_MSS; pcb->rto = 3000 / TCP_SLOW_INTERVAL; pcb->sa = 0; pcb->sv = 3000 / TCP_SLOW_INTERVAL; pcb->rtime = 0; pcb->cwnd = 1; iss = tcp_next_iss(stack); pcb->snd_wl2 = iss; pcb->snd_nxt = iss; pcb->snd_max = iss; pcb->lastack = iss; pcb->snd_lbb = iss; pcb->tmr = stack->tcp_ticks; pcb->polltmr = 0; #if LWIP_CALLBACK_API pcb->recv = tcp_recv_null; #endif /* LWIP_CALLBACK_API */ /* Init KEEPALIVE timer */ pcb->keepalive = TCP_KEEPDEFAULT; pcb->keep_cnt = 0; } return pcb; } /* * tcp_new(): * * Creates a new TCP protocol control block but doesn't place it on * any of the TCP PCB lists. * */ struct tcp_pcb * tcp_new(struct stack *stack) { return tcp_alloc(stack, TCP_PRIO_NORMAL); } /* * tcp_arg(): * * Used to specify the argument that should be passed callback * functions. * */ void tcp_arg(struct tcp_pcb *pcb, void *arg) { //fprintf(stderr,"tcp_arg %p %p\n",pcb,arg); pcb->callback_arg = arg; } #if LWIP_CALLBACK_API /* * tcp_recv(): * * Used to specify the function that should be called when a TCP * connection receives data. * */ void tcp_recv(struct tcp_pcb *pcb, err_t (* recv)(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)) { //fprintf(stderr,"tcp_recv %p %p\n",pcb,recv); pcb->recv = recv; } /* * tcp_sent(): * * Used to specify the function that should be called when TCP data * has been successfully delivered to the remote host. * */ void tcp_sent(struct tcp_pcb *pcb, err_t (* sent)(void *arg, struct tcp_pcb *tpcb, u16_t len)) { //fprintf(stderr,"tcp_sent %p %p\n",pcb,sent); pcb->sent = sent; } /* * tcp_err(): * * Used to specify the function that should be called when a fatal error * has occured on the connection. * */ void tcp_err(struct tcp_pcb *pcb, void (* errf)(void *arg, err_t err)) { //fprintf(stderr,"tcp_err %p %p\n",pcb,errf); pcb->errf = errf; } /* * tcp_accept(): * * Used for specifying the function that should be called when a * LISTENing connection has been connected to another host. * */ void tcp_accept(struct tcp_pcb *pcb, err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err)) { //fprintf(stderr,"tcp_accept %p %p\n",pcb,accept); ((struct tcp_pcb_listen *)pcb)->accept = accept; } #endif /* LWIP_CALLBACK_API */ /* * tcp_poll(): * * Used to specify the function that should be called periodically * from TCP. The interval is specified in terms of the TCP coarse * timer interval, which is called twice a second. * */ void tcp_poll(struct tcp_pcb *pcb, err_t (* poll)(void *arg, struct tcp_pcb *tpcb), u8_t interval) { #if LWIP_CALLBACK_API pcb->poll = poll; #endif /* LWIP_CALLBACK_API */ pcb->pollinterval = interval; } /* * tcp_pcb_purge(): * * Purges a TCP PCB. Removes any buffered data and frees the buffer memory. * */ void tcp_pcb_purge(struct tcp_pcb *pcb) { if (pcb->state != CLOSED && pcb->state != TIME_WAIT && pcb->state != LISTEN) { #ifdef LWSLIRP if (pcb->slirp_fddata != NULL) slirp_tcp_close(pcb); #endif LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge\n")); if (pcb->unsent != NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: not all data sent\n")); } if (pcb->unacked != NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->unacked\n")); } #if TCP_QUEUE_OOSEQ /* LW */ if (pcb->ooseq != NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->ooseq\n")); } tcp_segs_free(pcb->ooseq); pcb->ooseq = NULL; #endif /* TCP_QUEUE_OOSEQ */ tcp_segs_free(pcb->unsent); tcp_segs_free(pcb->unacked); pcb->unacked = pcb->unsent = NULL; } } /* * tcp_pcb_remove(): * * Purges the PCB and removes it from a PCB list. Any delayed ACKs are sent first. * */ void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb) { TCP_RMV(pcblist, pcb); tcp_pcb_purge(pcb); /* if there is an outstanding delayed ACKs, send it */ if (pcb->state != TIME_WAIT && pcb->state != LISTEN && pcb->flags & TF_ACK_DELAY) { pcb->flags |= TF_ACK_NOW; tcp_output(pcb); } pcb->state = CLOSED; LWIP_ASSERT("tcp_pcb_remove: tcp_pcbs_sane()", tcp_pcbs_sane()); } /* * tcp_next_iss(): * * Calculates a new initial sequence number for new connections. * */ u32_t tcp_next_iss(struct stack *stack) { static u32_t iss = 6510; iss += stack->tcp_ticks; /* XXX */ return iss; } #if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG void tcp_debug_print(struct tcp_hdr *tcphdr) { LWIP_DEBUGF(TCP_DEBUG, ("TCP header:\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| %5u | %5u | (src port, dest port)\n", ntohs(tcphdr->src), ntohs(tcphdr->dest))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| %010lu | (seq no)\n", ntohl(tcphdr->seqno))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| %010lu | (ack no)\n", ntohl(tcphdr->ackno))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| %2u | |%u%u%u%u%u%u| %5u | (hdrlen, flags (", TCPH_HDRLEN(tcphdr), TCPH_FLAGS(tcphdr) >> 5 & 1, TCPH_FLAGS(tcphdr) >> 4 & 1, TCPH_FLAGS(tcphdr) >> 3 & 1, TCPH_FLAGS(tcphdr) >> 2 & 1, TCPH_FLAGS(tcphdr) >> 1 & 1, TCPH_FLAGS(tcphdr) & 1, ntohs(tcphdr->wnd))); tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); LWIP_DEBUGF(TCP_DEBUG, ("), win)\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("| 0x%04x | %5u | (chksum, urgp)\n", ntohs(tcphdr->chksum), ntohs(tcphdr->urgp))); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); } void tcp_debug_print_state(enum tcp_state s) { LWIP_DEBUGF(TCP_DEBUG, ("State: ")); switch (s) { case CLOSED: LWIP_DEBUGF(TCP_DEBUG, ("CLOSED\n")); break; case LISTEN: LWIP_DEBUGF(TCP_DEBUG, ("LISTEN\n")); break; case SYN_SENT: LWIP_DEBUGF(TCP_DEBUG, ("SYN_SENT\n")); break; case SYN_RCVD: LWIP_DEBUGF(TCP_DEBUG, ("SYN_RCVD\n")); break; case ESTABLISHED: LWIP_DEBUGF(TCP_DEBUG, ("ESTABLISHED\n")); break; case FIN_WAIT_1: LWIP_DEBUGF(TCP_DEBUG, ("FIN_WAIT_1\n")); break; case FIN_WAIT_2: LWIP_DEBUGF(TCP_DEBUG, ("FIN_WAIT_2\n")); break; case CLOSE_WAIT: LWIP_DEBUGF(TCP_DEBUG, ("CLOSE_WAIT\n")); break; case CLOSING: LWIP_DEBUGF(TCP_DEBUG, ("CLOSING\n")); break; case LAST_ACK: LWIP_DEBUGF(TCP_DEBUG, ("LAST_ACK\n")); break; case TIME_WAIT: LWIP_DEBUGF(TCP_DEBUG, ("TIME_WAIT\n")); break; } } void tcp_debug_print_flags(u8_t flags) { if (flags & TCP_FIN) { LWIP_DEBUGF(TCP_DEBUG, ("FIN ")); } if (flags & TCP_SYN) { LWIP_DEBUGF(TCP_DEBUG, ("SYN ")); } if (flags & TCP_RST) { LWIP_DEBUGF(TCP_DEBUG, ("RST ")); } if (flags & TCP_PSH) { LWIP_DEBUGF(TCP_DEBUG, ("PSH ")); } if (flags & TCP_ACK) { LWIP_DEBUGF(TCP_DEBUG, ("ACK ")); } if (flags & TCP_URG) { LWIP_DEBUGF(TCP_DEBUG, ("URG ")); } if (flags & TCP_ECE) { LWIP_DEBUGF(TCP_DEBUG, ("ECE ")); } if (flags & TCP_CWR) { LWIP_DEBUGF(TCP_DEBUG, ("CWR ")); } } void tcp_debug_print_pcbs(void) { struct tcp_pcb *pcb; struct stack *stack=pcb->stack; LWIP_DEBUGF(TCP_DEBUG, ("Active PCB states:\n")); for(pcb = stack->tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); } LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n")); for(pcb = (struct tcp_pcb *)stack->tcp_listen_pcbs.pcbs; pcb != NULL; pcb = pcb->next) { LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); } LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n")); for(pcb = stack->tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", pcb->local_port, pcb->remote_port, pcb->snd_nxt, pcb->rcv_nxt)); tcp_debug_print_state(pcb->state); } } int tcp_pcbs_sane(void) { struct tcp_pcb *pcb; struct stack *stack=pcb->stack; for(pcb = stack->tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != CLOSED", pcb->state != CLOSED); LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != LISTEN", pcb->state != LISTEN); LWIP_ASSERT("tcp_pcbs_sane: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); } for(pcb = stack->tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_ASSERT("tcp_pcbs_sane: tw pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); } return 1; } #endif /* TCP_DEBUG */ #endif /* LWIP_TCP */ lwipv6-1.5a/lwip-v6/src/core/tcp_in.c0000644000175000017500000014716511671615010016502 0ustar renzorenzo/* * @file * * Transmission Control Protocol, incoming traffic */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2010,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* tcp_input.c * * The input processing functions of TCP. * * These functions are generally called in the order (ip_input() ->) tcp_input() -> * tcp_process() -> tcp_receive() (-> application). * */ #include "lwip/def.h" #include "lwip/opt.h" #include "lwip/netif.h" #include "lwip/mem.h" #include "lwip/memp.h" #include "lwip/inet.h" #include "lwip/tcp.h" #include "lwip/stack.h" #include "lwip/stats.h" #include "lwip/lwslirp.h" #include "arch/perf.h" #if LWIP_TCP /* Forward declarations. */ static err_t tcp_process(struct tcp_pcb *pcb,struct pseudo_iphdr *piphdr); static void tcp_receive(struct tcp_pcb *pcb); static void tcp_parseopt(struct tcp_pcb *pcb); static err_t tcp_listen_input(struct tcp_pcb_listen *pcb,struct pseudo_iphdr *piphdr #ifdef LWSLIRP , struct netif *slirpif #endif ); static err_t tcp_timewait_input(struct tcp_pcb *pcb); #ifdef LWSLIRP #define DROPWITHRESET(stack, tcphdr, piphdr) do {\ tcp_rst(stack, 0, \ ntohl((tcphdr)->seqno) + 1, (piphdr)->dest, (piphdr)->src, \ ntohs((tcphdr)->dest), \ ntohs((tcphdr)->src)); \ return; \ } while(0) #endif /* tcp_input: * * The initial input processing of TCP. It verifies the TCP header, demultiplexes * the segment between the PCBs and passes it on to tcp_process(), which implements * the TCP finite state machine. This function is called by the IP layer (in * ip_input()). */ void tcp_input(struct pbuf *p, struct ip_addr_list *inad, struct pseudo_iphdr *piphdr #ifdef LWSLIRP , struct netif *slirpif #endif ) { struct netif *netif = inad->netif; struct stack *stack = netif->stack; struct tcp_pcb *pcb, *prev; struct tcp_pcb_listen *lpcb; u8_t hdrlen; err_t err; /*struct netif *inp=inad->netif;*/ #if SO_REUSE struct tcp_pcb *pcb_temp; int reuse = 0; int reuse_port = 0; #endif /* SO_REUSE */ PERF_START; TCP_STATS_INC(tcp.recv); /*iphdr = p->payload; */ /*tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + IPH_HL(iphdr) * 4);*/ stack->tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + piphdr -> iphdrlen); #if TCP_INPUT_DEBUG tcp_debug_print(stack->tcphdr); #endif /* remove header from payload */ /*if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) */ if (pbuf_header(p, - piphdr -> iphdrlen)|| (p->tot_len < sizeof(struct tcp_hdr))) { /* drop short packets */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%u bytes) discarded\n", p->tot_len)); TCP_STATS_INC(tcp.lenerr); TCP_STATS_INC(tcp.drop); pbuf_free(p); return; } /* Don't even process incoming broadcasts/multicasts. */ /*if (ip_addr_ismulticast(&(iphdr->dest)) || ip_addr_is_v4broadcast(&(iphdr->dest),&(inad->ipaddr),&(inad->netmask)) || ip_addr_is_v4multicast(&(iphdr->dest))) */ if (ip_addr_ismulticast(piphdr->dest) || ip_addr_is_v4broadcast(piphdr->dest,&(inad->ipaddr),&(inad->netmask)) || ip_addr_is_v4multicast(piphdr->dest)) { pbuf_free(p); return; } /* Verify TCP checksum. */ if (inet6_chksum_pseudo(p, piphdr->src, piphdr->dest, IP_PROTO_TCP, p->tot_len) != 0) { /*printf("+++++++ chksumv6 %x\n",inet6_chksum_pseudo(p, piphdr->src, piphdr->dest, IP_PROTO_TCP, p->tot_len));*/ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04x\n", inet6_chksum_pseudo(p, piphdr->src, piphdr->dest, IP_PROTO_TCP, p->tot_len))); #if TCP_DEBUG tcp_debug_print(stack->tcphdr); #endif /* TCP_DEBUG */ TCP_STATS_INC(tcp.chkerr); TCP_STATS_INC(tcp.drop); pbuf_free(p); return; } /* Move the payload pointer in the pbuf so that it points to the TCP data instead of the TCP header. */ hdrlen = TCPH_HDRLEN(stack->tcphdr); pbuf_header(p, -(hdrlen * 4)); /* Convert fields in TCP header to host byte order. */ stack->tcphdr->src = ntohs(stack->tcphdr->src); stack->tcphdr->dest = ntohs(stack->tcphdr->dest); stack->seqno = stack->tcphdr->seqno = ntohl(stack->tcphdr->seqno); stack->ackno = stack->tcphdr->ackno = ntohl(stack->tcphdr->ackno); stack->tcphdr->wnd = ntohs(stack->tcphdr->wnd); stack->flags = TCPH_FLAGS(stack->tcphdr) & TCP_FLAGS; stack->tcplen = p->tot_len + ((stack->flags & TCP_FIN || stack->flags & TCP_SYN)? 1: 0); /* Demultiplex an incoming segment. First, we check if it is destined for an active connection. */ prev = NULL; #if SO_REUSE pcb_temp = stack->tcp_active_pcbs; again_1: /* Iterate through the TCP pcb list for a fully matching pcb */ for(pcb = pcb_temp; pcb != NULL; pcb = pcb->next) #else /* SO_REUSE */ for(pcb = stack->tcp_active_pcbs; pcb != NULL; pcb = pcb->next) #endif /* SO_REUSE */ { LWIP_ASSERT("tcp_input: active pcb->state != CLOSED", pcb->state != CLOSED); LWIP_ASSERT("tcp_input: active pcb->state != TIME-WAIT", pcb->state != TIME_WAIT); LWIP_ASSERT("tcp_input: active pcb->state != LISTEN", pcb->state != LISTEN); #if 0 fprintf(stderr, "ACTIVE %x %x %x %x:%d %x %x %x %x %d\n", pcb->local_ip.addr[0], pcb->local_ip.addr[1], pcb->local_ip.addr[2], pcb->local_ip.addr[3], pcb->local_port, pcb->remote_ip.addr[0], pcb->remote_ip.addr[1], pcb->remote_ip.addr[2], pcb->remote_ip.addr[3], pcb->remote_port, slirpif); #endif if (pcb->remote_port == stack->tcphdr->src && pcb->local_port == stack->tcphdr->dest && ip_addr_cmp(&(pcb->remote_ip), piphdr->src) && ip_addr_cmp(&(pcb->local_ip), piphdr->dest)) { #if SO_REUSE if(pcb->so_options & SOF_REUSEPORT) { if(reuse) { /* We processed one PCB already */ LWIP_DEBUGF(TCP_INPUT_DEBUG,("tcp_input: second or later PCB and SOF_REUSEPORT set.\n")); } else { /* First PCB with this address */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: first PCB and SOF_REUSEPORT set.\n")); reuse = 1; } reuse_port = 1; p->ref++; /* We want to search on next socket after receiving */ pcb_temp = pcb->next; LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: reference counter on PBUF set to %i\n", p->ref)); } else { if(reuse) { /* We processed one PCB already */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: second or later PCB but SOF_REUSEPORT not set !\n")); } } #endif /* SO_REUSE */ /* Move this PCB to the front of the list so that subsequent lookups will be faster (we exploit locality in TCP segment arrivals). */ LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb); if (prev != NULL) { prev->next = pcb->next; pcb->next = stack->tcp_active_pcbs; stack->tcp_active_pcbs = pcb; } LWIP_ASSERT("tcp_input: pcb->next != pcb (after cache)", pcb->next != pcb); break; } prev = pcb; } if (pcb == NULL) { /* If it did not go to an active connection, we check the connections in the TIME-WAIT state. */ for(pcb = stack->tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_ASSERT("tcp_input: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT); if (pcb->remote_port == stack->tcphdr->src && pcb->local_port == stack->tcphdr->dest && ip_addr_cmp(&(pcb->remote_ip), piphdr->src) && ip_addr_cmp(&(pcb->local_ip), piphdr->dest)) { /* We don't really care enough to move this PCB to the front of the list since we are not very likely to receive that many segments for connections in TIME-WAIT. */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n")); tcp_timewait_input(pcb); pbuf_free(p); return; } } /* Finally, if we still did not get a match, we check all PCBs that are LISTENing for incoming connections. */ prev = NULL; for(lpcb = stack->tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { #if 0 fprintf(stderr, "LISTEN %x %x %x %x:%d %x %x %x %x %d %p\n", lpcb->local_ip.addr[0], lpcb->local_ip.addr[1], lpcb->local_ip.addr[2], lpcb->local_ip.addr[3], lpcb->local_port, lpcb->remote_ip.addr[0], lpcb->remote_ip.addr[1], lpcb->remote_ip.addr[2], lpcb->remote_ip.addr[3], lpcb->remote_port, slirpif); #endif if ((( #ifdef LWSLIRP /* X1011: inaddr_any is for local interfaces only */ slirpif == NULL && #endif ip_addr_isany(&(lpcb->local_ip))) || ip_addr_cmp(&(lpcb->local_ip), piphdr->dest)) && lpcb->local_port == stack->tcphdr->dest #ifdef LWSLIRP /* RD1014 slirpif connections need remote port match! otherwise slirp misunderstands all the connections to the same target host! */ && (!slirpif || lpcb->remote_port == stack->tcphdr->src) #endif ) { /* Move this PCB to the front of the list so that subsequent lookups will be faster (we exploit locality in TCP segment arrivals). */ if (prev != NULL) { ((struct tcp_pcb_listen *)prev)->next = lpcb->next; /* our successor is the remainder of the listening list */ lpcb->next = stack->tcp_listen_pcbs.listen_pcbs; /* put this listening pcb at the head of the listening list */ stack->tcp_listen_pcbs.listen_pcbs = lpcb; } LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection, ")); #ifdef LWSLIRP if (slirpif && ip_addr_cmp(&(lpcb->remote_ip), piphdr->src) && lpcb->remote_port == stack->tcphdr->src) { #if LWSLIRP_DEBUG slirp_debug_print_state(TCP_INPUT_DEBUG, (struct tcp_pcb *)lpcb ); #endif LWIP_DEBUGF(TCP_INPUT_DEBUG, ("\n")); /* If the socket is not configured (= -1) ... */ if(lpcb->slirp_state & SS_NOFDREF) { /* There are two cases in which ->slirp_state == SS_NOFDREF: * 1. The tcp pcb in new, and I try to connect its socket ->s with * the real world, so its ->s is == -1. * or * 2. The connection of the socket ->s is already failed so * ->slirp_state has become SS_NOFDREF _but_ ->s its != -1 */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: lpcb->slirp_fddata %p\n", lpcb->slirp_fddata)); if(lpcb->slirp_fddata == NULL) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: lpcb->slirp = %p, so try to connect it.\n", lpcb->slirp_fddata)); /* ... set up it and try to connect the socket. */ /* * Haven't connected yet, save the current pbuf, * and return */ /* I restore the packet as it was before the call of tcp_input, * so: */ /* 1. I restore the tcp header field in network order */ stack->tcphdr->src = htons(stack->tcphdr->src); stack->tcphdr->dest = htons(stack->tcphdr->dest); stack->tcphdr->seqno = htonl(stack->tcphdr->seqno); stack->tcphdr->ackno = htonl(stack->tcphdr->ackno); stack->tcphdr->wnd = htons(stack->tcphdr->wnd); /* 2. I restore the payload pointer to include the IP e TCP header */ pbuf_header(p, (TCPH_HDRLEN(stack->tcphdr) * 4) + piphdr->iphdrlen); /* 3. Save the packet */ lpcb->slirp_m = p; if(slirp_tcp_fconnect(lpcb, ntohs(stack->tcphdr->dest), piphdr->dest, slirpif) == -1 && errno != EINPROGRESS) { /* Some errors (different from EINPROGRESS) happen */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: socket connection to " "Internet failed, errno %d-%s\n", errno, strerror(errno))); if(errno == ECONNREFUSED) { /* abort the conncetion: ACK the SYN, send RST to refuse the connection */ /* XXX NO! abort does not work on listen_tcp */ DROPWITHRESET(stack, stack->tcphdr, piphdr); /* tcp_abort((struct tcp_pcb *) lpcb); */ } else { enum icmp_dur_type code = ICMP_DUR_NET; if(errno == EHOSTUNREACH) code = ICMP_DUR_HOST; /* send host/net unreachable */ icmp_dest_unreach(stack, p, code); } /* close the connection and free the packet */ tcp_close((struct tcp_pcb *) lpcb); pbuf_free(p); } /* I return without menage the incoming packet. * I wait that the 3-way handshake teminates in the * real world connection and tcp_listen_input() will * be call in slirp_select_pool if the connection was right setup*/ return; } else { /* (->slirp_state & SS_NOFDREF && ->so != -1) */ /* an error is occurred during connection */ /* tcp_close((struct tcp_pcb *) lpcb); */ /* tcp_abort((struct tcp_pcb *) lpcb);*/ DROPWITHRESET(stack, stack->tcphdr, piphdr); tcp_close((struct tcp_pcb *) lpcb); pbuf_free(p); } } else { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: lpcb->slirp = %p is connecting, ", lpcb->slirp_fddata)); #if LWSLIRP_DEBUG slirp_debug_print_state(TCP_INPUT_DEBUG, (struct tcp_pcb *)lpcb); #endif LWIP_DEBUGF(TCP_INPUT_DEBUG, ("\n")); /* ...otherwise menage the incoming packet. It should be a SYN packet.*/ if(tcp_listen_input(lpcb,piphdr,slirpif) != ERR_OK) DROPWITHRESET(stack, stack->tcphdr, piphdr); pbuf_free(p); /* Now that I have created a connected TCP pcb, I remove the * listen pcb from the list and I delete it. */ TCP_RMV(&stack->tcp_listen_pcbs.listen_pcbs, lpcb); memp_free(MEMP_TCP_PCB_LISTEN, lpcb); return; } } else #endif /* LWSLIRP */ { tcp_listen_input(lpcb,piphdr #ifdef LWSLIRP ,slirpif #endif ); pbuf_free(p); return; } } prev = (struct tcp_pcb *)lpcb; } } #if TCP_INPUT_DEBUG LWIP_DEBUGF(TCP_INPUT_DEBUG, ("+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ")); tcp_debug_print_flags(TCPH_FLAGS(stack->tcphdr)); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n")); #endif /* TCP_INPUT_DEBUG */ if (pcb != NULL) { /* The incoming segment belongs to a connection. */ #if TCP_INPUT_DEBUG #if TCP_DEBUG tcp_debug_print_state(pcb->state); #endif /* TCP_DEBUG */ #endif /* TCP_INPUT_DEBUG */ /* Set up a tcp_seg structure. */ stack->inseg.next = NULL; stack->inseg.len = p->tot_len; stack->inseg.dataptr = p->payload; stack->inseg.p = p; stack->inseg.tcphdr = stack->tcphdr; stack->recv_data = NULL; stack->recv_flags = 0; stack->tcp_input_pcb = pcb; err = tcp_process(pcb,piphdr); stack->tcp_input_pcb = NULL; /* A return value of ERR_ABRT means that tcp_abort() was called and that the pcb has been freed. If so, we don't do anything. */ if (err != ERR_ABRT) { if (stack->recv_flags & TF_RESET) { /* TF_RESET means that the connection was reset by the other end. We then call the error callback to inform the application that the connection is dead before we deallocate the PCB. */ TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST); tcp_pcb_remove(&stack->tcp_active_pcbs, pcb); memp_free(MEMP_TCP_PCB, pcb); } else if (stack->recv_flags & TF_CLOSED) { /* The connection has been closed and we will deallocate the PCB. */ tcp_pcb_remove(&stack->tcp_active_pcbs, pcb); memp_free(MEMP_TCP_PCB, pcb); } else { err = ERR_OK; /* If the application has registered a "sent" function to be called when new send buffer space is available, we call it now. */ if (pcb->acked > 0) { TCP_EVENT_SENT(pcb, pcb->acked, err); } if (stack->recv_data != NULL) { /* Notify application that data has been received. */ TCP_EVENT_RECV(pcb, stack->recv_data, ERR_OK, err); } /* If a FIN segment was received, we call the callback function with a NULL buffer to indicate EOF. */ if (stack->recv_flags & TF_GOT_FIN) { TCP_EVENT_RECV(pcb, NULL, ERR_OK, err); } /* If there were no errors, we try to send something out. */ if (err == ERR_OK) { tcp_output(pcb); } } } /* We deallocate the incoming pbuf. If it was buffered by the application, the application should have called pbuf_ref() to increase the reference counter in the pbuf. If so, the buffer isn't actually deallocated by the call to pbuf_free(), only the reference count is decreased. */ if (stack->inseg.p != NULL) pbuf_free(stack->inseg.p); #if TCP_INPUT_DEBUG #if TCP_DEBUG tcp_debug_print_state(pcb->state); #endif /* TCP_DEBUG */ #endif /* TCP_INPUT_DEBUG */ #if SO_REUSE /* First socket should receive now */ if(reuse_port) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: searching next PCB.\n")); reuse_port = 0; /* We are searching connected sockets */ goto again_1; } #endif /* SO_REUSE */ } else { #if SO_REUSE if(reuse) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: freeing PBUF with reference counter set to %i\n", p->ref)); pbuf_free(p); goto end; } #endif /* SO_REUSE */ #ifdef LWSLIRP if (slirpif) { struct tcp_pcb *tcp_pcb; struct tcp_pcb *ltcp_pcb; LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: no PCB match found\n")); /* XXX If a TCB does not exist, and the TCP_SYN flag is * the only flag set, then create a session, mark it * as if it was LISTENING, and continue... */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("(flags & (TCP_SYN | TCP_FIN | " "TCP_RST | TCP_URG | TCP_ACK))(%d) != TCP_SYN (%d)=> %d\n", (stack->flags & (TCP_SYN | TCP_FIN | TCP_RST | TCP_URG | TCP_ACK)), TCP_SYN, (stack->flags & (TCP_SYN | TCP_FIN | TCP_RST | TCP_URG | TCP_ACK) != TCP_SYN))); if((stack->flags & (TCP_SYN | TCP_FIN | TCP_RST | TCP_URG | TCP_ACK)) != TCP_SYN) { DROPWITHRESET(stack, stack->tcphdr, piphdr); return; } LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: only TCP_SYN flag set, so i create a new pcb.\n")); /* I create a new tcp control block ...*/ if((tcp_pcb = tcp_new(stack)) == NULL) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: creation of a new pcb failed.\n")); DROPWITHRESET(stack, stack->tcphdr, piphdr); } /* ... I set the reuse port option ...*/ tcp_pcb->so_options |= SOF_REUSEPORT; LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: tcp_pcb->so_options & SOF_REUSEPORT(%d) = %d, tcp_pcb = %p, tcp_pcb->slirp =%p\n", SOF_REUSEPORT, tcp_pcb->so_options & SOF_REUSEPORT, tcp_pcb, tcp_pcb->slirp_fddata)); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: new TCP pcb created = %p.\n", tcp_pcb)); /* ... and i bind it to the destination address/port of the packet*/ if(tcp_bind(tcp_pcb, piphdr->dest, stack->tcphdr->dest) != ERR_OK) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: tcp_bind() error.\n")); DROPWITHRESET(stack, stack->tcphdr, piphdr); } /* set the state of the connection to LISTEN */ if((ltcp_pcb = tcp_listen(tcp_pcb)) == NULL){ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: setting pcb in LISTEN state failed.\n")); DROPWITHRESET(stack, stack->tcphdr, piphdr); } /* I register the callback function accept */ tcp_accept(ltcp_pcb, slirp_tcp_accept); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: after tcp_listen, tcp_pcb = %p.\n", tcp_pcb)); ip_addr_set(&(ltcp_pcb->remote_ip), piphdr->src); ltcp_pcb->remote_port = stack->tcphdr->src; /* I go up, and search again in the TCP PCB, so now for this packet a pcb is * found in the tcp_listen_pcbs list and is managed by the stack. */ goto again_1; } else #endif { /* If no matching PCB was found, send a TCP RST (reset) to the sender. */ LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n")); if (!(TCPH_FLAGS(stack->tcphdr) & TCP_RST)) { TCP_STATS_INC(tcp.proterr); TCP_STATS_INC(tcp.drop); tcp_rst(stack, stack->ackno, stack->seqno + stack->tcplen, piphdr->dest, piphdr->src, stack->tcphdr->dest, stack->tcphdr->src); } pbuf_free(p); } } #if SO_REUSE end: #endif /* SO_REUSE */ LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane()); PERF_STOP("tcp_input"); } /* tcp_listen_input(): * * Called by tcp_input() when a segment arrives for a listening * connection. */ static err_t tcp_listen_input(struct tcp_pcb_listen *pcb, struct pseudo_iphdr *piphdr #ifdef LWSLIRP , struct netif *slirpif #endif ) { struct stack *stack = pcb->stack; struct tcp_pcb *npcb; u32_t optdata; /* In the LISTEN state, we check for incoming SYN segments, creates a new PCB, and responds with a SYN|ACK. */ if (stack->flags & TCP_ACK) { /* For incoming segments with the ACK flag set, respond with a RST. */ LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n")); tcp_rst(stack, stack->ackno + 1, stack->seqno + stack->tcplen, piphdr->dest, piphdr->src, stack->tcphdr->dest, stack->tcphdr->src); } else if (stack->flags & TCP_SYN) { LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %u -> %u.\n", stack->tcphdr->src, stack->tcphdr->dest)); npcb = tcp_alloc(stack, pcb->prio); /* If a new PCB could not be created (probably due to lack of memory), we don't do anything, but rely on the sender will retransmit the SYN at a time when we have more memory available. */ if (npcb == NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n")); TCP_STATS_INC(tcp.memerr); return ERR_MEM; } /* Set up the new PCB. */ npcb->stack = stack; ip_addr_set(&(npcb->local_ip), piphdr->dest); npcb->local_port = pcb->local_port; ip_addr_set(&(npcb->remote_ip), piphdr->src); npcb->remote_port = stack->tcphdr->src; npcb->state = SYN_RCVD; npcb->rcv_nxt = stack->seqno + 1; npcb->snd_wnd = stack->tcphdr->wnd; npcb->ssthresh = npcb->snd_wnd; npcb->snd_wl1 = stack->seqno - 1;/* initialise to seqno-1 to force window update */ npcb->callback_arg = pcb->callback_arg; #ifdef LWSLIRP if (slirpif) { npcb->slirp_fddata = pcb->slirp_fddata; npcb->slirp_state = pcb->slirp_state; LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: npcb->slirp = %p\n", npcb->slirp_fddata)); /* I restore the ->s and the ->slirp_state fields, for new connections */ pcb->slirp_fddata = NULL; pcb->slirp_state = SS_NOFDREF; LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: lpcb->slirp = %p\n", pcb->slirp_fddata)); } #endif /* LWSLIRP */ #if LWIP_CALLBACK_API npcb->accept = pcb->accept; #ifdef LWSLIRP if (slirpif) { tcp_arg(npcb, NULL); tcp_recv(npcb, slirp_tcp_recv); tcp_sent(npcb, slirp_tcp_sent); } #endif #endif /* LWIP_CALLBACK_API */ /* inherit socket options */ npcb->so_options = pcb->so_options & (SOF_DEBUG|SOF_DONTROUTE|SOF_KEEPALIVE|SOF_OOBINLINE|SOF_LINGER); #ifdef LWSLIRP if (slirpif) npcb->so_options |= SOF_REUSEPORT; #endif /* Register the new PCB so that we can begin receiving segments for it. */ TCP_REG(&stack->tcp_active_pcbs, npcb); #ifdef LWSLIRP slirp_tcp_update_listen2data(npcb); #endif /* Parse any options in the SYN. */ tcp_parseopt(npcb); /* Build an MSS option. */ optdata = htonl(((u32_t)2 << 24) | ((u32_t)4 << 16) | (((u32_t)npcb->mss / 256) << 8) | (npcb->mss & 255)); /* Send a SYN|ACK together with the MSS option. */ tcp_enqueue(npcb, NULL, 0, TCP_SYN | TCP_ACK, 0, (u8_t *)&optdata, 4); return tcp_output(npcb); } return ERR_OK; } /* tcp_timewait_input(): * * Called by tcp_input() when a segment arrives for a connection in * TIME_WAIT. */ static err_t tcp_timewait_input(struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; if (TCP_SEQ_GT(stack->seqno + stack->tcplen, pcb->rcv_nxt)) { pcb->rcv_nxt = stack->seqno + stack->tcplen; } if (stack->tcplen > 0) { tcp_ack_now(pcb); } return tcp_output(pcb); } /* tcp_process * * Implements the TCP state machine. Called by tcp_input. In some * states tcp_receive() is called to receive data. The tcp_seg * argument will be freed by the caller (tcp_input()) unless the * recv_data pointer in the pcb is set. */ static err_t tcp_process(struct tcp_pcb *pcb,struct pseudo_iphdr *piphdr) { struct stack *stack = pcb->stack; struct tcp_seg *rseg; u8_t acceptable = 0; err_t err; err = ERR_OK; /* Process incoming RST segments. */ if (stack->flags & TCP_RST) { /* First, determine if the reset is acceptable. */ if (pcb->state == SYN_SENT) { if (stack->ackno == pcb->snd_nxt) { acceptable = 1; } } else { /*if (TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) && TCP_SEQ_LEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) */ if(TCP_SEQ_BETWEEN(stack->seqno, pcb->rcv_nxt, pcb->rcv_nxt+pcb->rcv_wnd)) { acceptable = 1; } } if (acceptable) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: Connection RESET\n")); LWIP_ASSERT("tcp_input: pcb->state != CLOSED", pcb->state != CLOSED); stack->recv_flags = TF_RESET; pcb->flags &= ~TF_ACK_DELAY; return ERR_RST; } else { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n", stack->seqno, pcb->rcv_nxt)); LWIP_DEBUGF(TCP_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n", stack->seqno, pcb->rcv_nxt)); return ERR_OK; } } /* Update the PCB (in)activity timer. */ pcb->tmr = stack->tcp_ticks; pcb->keep_cnt = 0; /* Do different things depending on the TCP state. */ switch (pcb->state) { case SYN_SENT: LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %lu pcb->snd_nxt %lu unacked %lu\n", stack->ackno, pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno))); /* received SYN ACK with expected sequence number? */ if ((stack->flags & TCP_ACK) && (stack->flags & TCP_SYN) && stack->ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) { pcb->snd_buf ++; pcb->rcv_nxt = stack->seqno + 1; pcb->lastack = stack->ackno; pcb->snd_wnd = stack->tcphdr->wnd; pcb->snd_wl1 = stack->seqno - 1; /* initialise to seqno - 1 to force window update */ pcb->state = ESTABLISHED; pcb->cwnd = pcb->mss; --pcb->snd_queuelen; LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_process: SYN-SENT --queuelen %u\n", (unsigned int)pcb->snd_queuelen)); rseg = pcb->unacked; pcb->unacked = rseg->next; tcp_seg_free(rseg); /* Parse any options in the SYNACK. */ tcp_parseopt(pcb); /* Call the user specified function to call when sucessfully * connected. */ TCP_EVENT_CONNECTED(pcb, ERR_OK, err); tcp_ack(pcb); } /* received ACK? possibly a half-open connection */ else if (stack->flags & TCP_ACK) { /* send a RST to bring the other side in a non-synchronized state. */ tcp_rst(stack, stack->ackno, stack->seqno + stack->tcplen, piphdr->dest, piphdr->src, stack->tcphdr->dest, stack->tcphdr->src); } break; case SYN_RCVD: if (stack->flags & TCP_ACK && !(stack->flags & TCP_RST)) { /* expected ACK number? */ if(TCP_SEQ_BETWEEN(stack->ackno, pcb->lastack+1, pcb->snd_nxt)){ pcb->state = ESTABLISHED; LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %u -> %u.\n", stack->inseg.tcphdr->src, stack->inseg.tcphdr->dest)); #if LWIP_CALLBACK_API LWIP_ASSERT("pcb->accept != NULL", pcb->accept != NULL); #endif /* Call the accept function. */ TCP_EVENT_ACCEPT(pcb, ERR_OK, err); if (err != ERR_OK) { /* If the accept function returns with an error, we abort * the connection. */ tcp_abort(pcb); return ERR_ABRT; } /* If there was any data contained within this ACK, * we'd better pass it on to the application as well. */ tcp_receive(pcb); pcb->cwnd = pcb->mss; } /* incorrect ACK number */ else { /* send RST */ tcp_rst(stack, stack->ackno, stack->seqno + stack->tcplen, piphdr->dest, piphdr->src, stack->tcphdr->dest, stack->tcphdr->src); } } break; case CLOSE_WAIT: /* FALLTHROUGH */ case ESTABLISHED: tcp_receive(pcb); if (stack->flags & TCP_FIN) { tcp_ack_now(pcb); pcb->state = CLOSE_WAIT; } break; case FIN_WAIT_1: tcp_receive(pcb); if (stack->flags & TCP_FIN) { if (stack->flags & TCP_ACK && stack->ackno == pcb->snd_nxt) { LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %d -> %d.\n", stack->inseg.tcphdr->src, stack->inseg.tcphdr->dest)); tcp_ack_now(pcb); tcp_pcb_purge(pcb); TCP_RMV(&stack->tcp_active_pcbs, pcb); pcb->state = TIME_WAIT; TCP_REG(&stack->tcp_tw_pcbs, pcb); } else { tcp_ack_now(pcb); pcb->state = CLOSING; } } else if (stack->flags & TCP_ACK && stack->ackno == pcb->snd_nxt) { pcb->state = FIN_WAIT_2; } break; case FIN_WAIT_2: tcp_receive(pcb); if (stack->flags & TCP_FIN) { LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %u -> %u.\n", stack->inseg.tcphdr->src, stack->inseg.tcphdr->dest)); tcp_ack_now(pcb); tcp_pcb_purge(pcb); TCP_RMV(&stack->tcp_active_pcbs, pcb); pcb->state = TIME_WAIT; TCP_REG(&stack->tcp_tw_pcbs, pcb); } break; case CLOSING: tcp_receive(pcb); if (stack->flags & TCP_ACK && stack->ackno == pcb->snd_nxt) { LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %u -> %u.\n", stack->inseg.tcphdr->src, stack->inseg.tcphdr->dest)); tcp_ack_now(pcb); tcp_pcb_purge(pcb); TCP_RMV(&stack->tcp_active_pcbs, pcb); pcb->state = TIME_WAIT; TCP_REG(&stack->tcp_tw_pcbs, pcb); } break; case LAST_ACK: tcp_receive(pcb); if (stack->flags & TCP_ACK && stack->ackno == pcb->snd_nxt) { LWIP_DEBUGF(TCP_DEBUG, ("TCP connection closed %u -> %u.\n", stack->inseg.tcphdr->src, stack->inseg.tcphdr->dest)); pcb->state = CLOSED; stack->recv_flags = TF_CLOSED; } break; default: break; } return ERR_OK; } /* tcp_receive: * * Called by tcp_process. Checks if the given segment is an ACK for outstanding * data, and if so frees the memory of the buffered data. Next, is places the * segment on any of the receive queues (pcb->recved or pcb->ooseq). If the segment * is buffered, the pbuf is referenced by pbuf_ref so that it will not be freed until * i it has been removed from the buffer. * * If the incoming segment constitutes an ACK for a segment that was used for RTT * estimation, the RTT is estimated here as well. */ static void tcp_receive(struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; struct tcp_seg *next; #if TCP_QUEUE_OOSEQ struct tcp_seg *prev, *cseg; #endif struct pbuf *p; s32_t off; int m; u32_t right_wnd_edge; u16_t new_tot_len; if (stack->flags & TCP_ACK) { right_wnd_edge = pcb->snd_wnd + pcb->snd_wl1; /* Update window. */ if (TCP_SEQ_LT(pcb->snd_wl1, stack->seqno) || (pcb->snd_wl1 == stack->seqno && TCP_SEQ_LT(pcb->snd_wl2, stack->ackno)) || (pcb->snd_wl2 == stack->ackno && stack->tcphdr->wnd > pcb->snd_wnd)) { pcb->snd_wnd = stack->tcphdr->wnd; pcb->snd_wl1 = stack->seqno; pcb->snd_wl2 = stack->ackno; LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %lu\n", pcb->snd_wnd)); #if TCP_WND_DEBUG } else { if (pcb->snd_wnd != stack->tcphdr->wnd) { LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: no window update lastack %lu snd_max %lu ackno %lu wl1 %lu seqno %lu wl2 %lu\n", pcb->lastack, pcb->snd_max, stack->ackno, pcb->snd_wl1, stack->seqno, pcb->snd_wl2)); } #endif /* TCP_WND_DEBUG */ } if (pcb->lastack == stack->ackno) { pcb->acked = 0; if (pcb->snd_wl1 + pcb->snd_wnd == right_wnd_edge){ ++pcb->dupacks; if (pcb->dupacks >= 3 && pcb->unacked != NULL) { if (!(pcb->flags & TF_INFR)) { /* This is fast retransmit. Retransmit the first unacked segment. */ LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupacks %u (%lu), fast retransmit %lu\n", (unsigned int)pcb->dupacks, pcb->lastack, ntohl(pcb->unacked->tcphdr->seqno))); tcp_rexmit(pcb); /* Set ssthresh to max (FlightSize / 2, 2*SMSS) */ /*pcb->ssthresh = LWIP_MAX((pcb->snd_max - pcb->lastack) / 2, 2 * pcb->mss);*/ /* Set ssthresh to half of the minimum of the currenct cwnd and the advertised window */ if(pcb->cwnd > pcb->snd_wnd) pcb->ssthresh = pcb->snd_wnd / 2; else pcb->ssthresh = pcb->cwnd / 2; pcb->cwnd = pcb->ssthresh + 3 * pcb->mss; pcb->flags |= TF_INFR; } else { /* Inflate the congestion window, but not if it means that the value overflows. */ if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { pcb->cwnd += pcb->mss; } } } } else { LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupack averted %lu %lu\n", pcb->snd_wl1 + pcb->snd_wnd, right_wnd_edge)); } } else { /*if (TCP_SEQ_LT(pcb->lastack, ackno) && TCP_SEQ_LEQ(ackno, pcb->snd_max)) */ if(TCP_SEQ_BETWEEN(stack->ackno, pcb->lastack+1, pcb->snd_max)) { /* We come here when the ACK acknowledges new data. */ /* Reset the "IN Fast Retransmit" flag, since we are no longer in fast retransmit. Also reset the congestion window to the slow start threshold. */ if (pcb->flags & TF_INFR) { pcb->flags &= ~TF_INFR; pcb->cwnd = pcb->ssthresh; } /* Reset the number of retransmissions. */ pcb->nrtx = 0; /* Reset the retransmission time-out. */ pcb->rto = (pcb->sa >> 3) + pcb->sv; /* Update the send buffer space. */ pcb->acked = stack->ackno - pcb->lastack; /* FIX: Data split over odd boundaries */ pcb->snd_buf += ((pcb->acked+1) & ~0x1); /* Even the send buffer */ /* Reset the fast retransmit variables. */ pcb->dupacks = 0; pcb->lastack = stack->ackno; /* Update the congestion control variables (cwnd and ssthresh). */ if (pcb->state >= ESTABLISHED) { if (pcb->cwnd < pcb->ssthresh) { if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { pcb->cwnd += pcb->mss; } LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %u\n", pcb->cwnd)); } else { u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd); if (new_cwnd > pcb->cwnd) { pcb->cwnd = new_cwnd; } LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %u\n", pcb->cwnd)); } } LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %lu, unacked->seqno %lu:%lu\n", stack->ackno, pcb->unacked != NULL? ntohl(pcb->unacked->tcphdr->seqno): 0, pcb->unacked != NULL? ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0)); /* Remove segment from the unacknowledged list if the incoming ACK acknowlegdes them. */ while (pcb->unacked != NULL && TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked), stack->ackno)) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unacked\n", ntohl(pcb->unacked->tcphdr->seqno), ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked))); next = pcb->unacked; pcb->unacked = pcb->unacked->next; LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %u ... ", (unsigned int)pcb->snd_queuelen)); pcb->snd_queuelen -= pbuf_clen(next->p); tcp_seg_free(next); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%u (after freeing unacked)\n", (unsigned int)pcb->snd_queuelen)); if (pcb->snd_queuelen != 0) { LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || pcb->unsent != NULL); } } pcb->polltmr = 0; } } /* We go through the ->unsent list to see if any of the segments on the list are acknowledged by the ACK. This may seem strange since an "unsent" segment shouldn't be acked. The rationale is that lwIP puts all outstanding segments on the ->unsent list after a retransmission, so these segments may in fact have been sent once. */ while (pcb->unsent != NULL && /*TCP_SEQ_LEQ(ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent), ackno) && TCP_SEQ_LEQ(ackno, pcb->snd_max)*/ TCP_SEQ_BETWEEN(stack->ackno, ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent), pcb->snd_max) ) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unsent\n", ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent))); next = pcb->unsent; pcb->unsent = pcb->unsent->next; LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %u ... ", (unsigned int)pcb->snd_queuelen)); pcb->snd_queuelen -= pbuf_clen(next->p); tcp_seg_free(next); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%u (after freeing unsent)\n", (unsigned int)pcb->snd_queuelen)); if (pcb->snd_queuelen != 0) { LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || pcb->unsent != NULL); } if (pcb->unsent != NULL) { pcb->snd_nxt = htonl(pcb->unsent->tcphdr->seqno); } } /* End of ACK for new data processing. */ LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: pcb->rttest %ld rtseq %lu ackno %lu\n", pcb->rttest, pcb->rtseq, stack->ackno)); /* RTT estimation calculations. This is done by checking if the incoming segment acknowledges the segment we use to take a round-trip time measurement. */ if (pcb->rttest && TCP_SEQ_LT(pcb->rtseq, stack->ackno)) { m = stack->tcp_ticks - pcb->rttest; LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %u ticks (%u msec).\n", m, m * TCP_SLOW_INTERVAL)); /* This is taken directly from VJs original code in his paper */ m = m - (pcb->sa >> 3); pcb->sa += m; if (m < 0) { m = -m; } m = m - (pcb->sv >> 2); pcb->sv += m; pcb->rto = (pcb->sa >> 3) + pcb->sv; LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: RTO %u (%u miliseconds)\n", pcb->rto, pcb->rto * TCP_SLOW_INTERVAL)); pcb->rttest = 0; } } /* If the incoming segment contains data, we must process it further. */ if (stack->tcplen > 0) { /* This code basically does three things: +) If the incoming segment contains data that is the next in-sequence data, this data is passed to the application. This might involve trimming the first edge of the data. The rcv_nxt variable and the advertised window are adjusted. +) If the incoming segment has data that is above the next sequence number expected (->rcv_nxt), the segment is placed on the ->ooseq queue. This is done by finding the appropriate place in the ->ooseq queue (which is ordered by sequence number) and trim the segment in both ends if needed. An immediate ACK is sent to indicate that we received an out-of-sequence segment. +) Finally, we check if the first segment on the ->ooseq queue now is in sequence (i.e., if rcv_nxt >= ooseq->seqno). If rcv_nxt > ooseq->seqno, we must trim the first edge of the segment on ->ooseq before we adjust rcv_nxt. The data in the segments that are now on sequence are chained onto the incoming segment so that we only need to call the application once. */ /* First, we check if we must trim the first edge. We have to do this if the sequence number of the incoming segment is less than rcv_nxt, and the sequence number plus the length of the segment is larger than rcv_nxt. */ /* if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){ if (TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) */ if(TCP_SEQ_BETWEEN(pcb->rcv_nxt, stack->seqno+1, stack->seqno+stack->tcplen-1)) /* Trimming the first edge is done by pushing the payload pointer in the pbuf downwards. This is somewhat tricky since we do not want to discard the full contents of the pbuf up to the new starting point of the data since we have to keep the TCP header which is present in the first pbuf in the chain. What is done is really quite a nasty hack: the first pbuf in the pbuf chain is pointed to by inseg.p. Since we need to be able to deallocate the whole pbuf, we cannot change this inseg.p pointer to point to any of the later pbufs in the chain. Instead, we point the ->payload pointer in the first pbuf to data in one of the later pbufs. We also set the inseg.data pointer to point to the right place. This way, the ->p pointer will still point to the first pbuf, but the ->p->payload pointer will point to data in another pbuf. After we are done with adjusting the pbuf pointers we must adjust the ->data pointer in the seg and the segment length.*/ { off = pcb->rcv_nxt - stack->seqno; p = stack->inseg.p; if (stack->inseg.p->len < off) { new_tot_len = stack->inseg.p->tot_len - off; while (p->len < off) { off -= p->len; /* KJM following line changed (with addition of new_tot_len var) to fix bug #9076 inseg.p->tot_len -= p->len; */ p->tot_len = new_tot_len; p->len = 0; p = p->next; } pbuf_header(p, -off); } else { pbuf_header(stack->inseg.p, -off); } /* KJM following line changed to use p->payload rather than inseg->p->payload to fix bug #9076 */ stack->inseg.dataptr = p->payload; stack->inseg.len -= pcb->rcv_nxt - stack->seqno; stack->inseg.tcphdr->seqno = stack->seqno = pcb->rcv_nxt; } else { if(TCP_SEQ_LT(stack->seqno, pcb->rcv_nxt)){ /* the whole segment is < rcv_nxt */ /* must be a duplicate of a packet that has already been correctly handled */ LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %lu\n", stack->seqno)); tcp_ack_now(pcb); } } /* The sequence number must be within the window (above rcv_nxt and below rcv_nxt + rcv_wnd) in order to be further processed. */ /*if (TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) && TCP_SEQ_LT(seqno, pcb->rcv_nxt + pcb->rcv_wnd))*/ if(TCP_SEQ_BETWEEN(stack->seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd - 1)) { if (pcb->rcv_nxt == stack->seqno) { /* The incoming segment is the next in sequence. We check if we have to trim the end of the segment and update rcv_nxt and pass the data to the application. */ #if TCP_QUEUE_OOSEQ if (pcb->ooseq != NULL && TCP_SEQ_LEQ(pcb->ooseq->tcphdr->seqno, stack->seqno + stack->inseg.len)) { /* We have to trim the second edge of the incoming segment. */ stack->inseg.len = pcb->ooseq->tcphdr->seqno - stack->seqno; pbuf_realloc(stack->inseg.p, stack->inseg.len); } #endif /* TCP_QUEUE_OOSEQ */ stack->tcplen = TCP_TCPLEN(&stack->inseg); pcb->rcv_nxt += stack->tcplen; /* Update the receiver's (our) window. */ if (pcb->rcv_wnd < stack->tcplen) { pcb->rcv_wnd = 0; } else { pcb->rcv_wnd -= stack->tcplen; } /* If there is data in the segment, we make preparations to pass this up to the application. The ->recv_data variable is used for holding the pbuf that goes to the application. The code for reassembling out-of-sequence data chains its data on this pbuf as well. If the segment was a FIN, we set the TF_GOT_FIN flag that will be used to indicate to the application that the remote side has closed its end of the connection. */ if (stack->inseg.p->tot_len > 0) { stack->recv_data = stack->inseg.p; /* Since this pbuf now is the responsibility of the application, we delete our reference to it so that we won't (mistakingly) deallocate it. */ stack->inseg.p = NULL; } if (TCPH_FLAGS(stack->inseg.tcphdr) & TCP_FIN) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN.\n")); stack->recv_flags = TF_GOT_FIN; } #if TCP_QUEUE_OOSEQ /* We now check if we have segments on the ->ooseq queue that is now in sequence. */ while (pcb->ooseq != NULL && pcb->ooseq->tcphdr->seqno == pcb->rcv_nxt) { cseg = pcb->ooseq; stack->seqno = pcb->ooseq->tcphdr->seqno; pcb->rcv_nxt += TCP_TCPLEN(cseg); if (pcb->rcv_wnd < TCP_TCPLEN(cseg)) { pcb->rcv_wnd = 0; } else { pcb->rcv_wnd -= TCP_TCPLEN(cseg); } if (cseg->p->tot_len > 0) { /* Chain this pbuf onto the pbuf that we will pass to the application. */ if (stack->recv_data) { pbuf_cat(stack->recv_data, cseg->p); } else { stack->recv_data = cseg->p; } cseg->p = NULL; } if (TCPH_FLAGS(cseg->tcphdr) & TCP_FIN) { LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN.\n")); stack->recv_flags = TF_GOT_FIN; } pcb->ooseq = cseg->next; tcp_seg_free(cseg); } #endif /* TCP_QUEUE_OOSEQ */ /* Acknowledge the segment(s). */ tcp_ack(pcb); } else { /* We get here if the incoming segment is out-of-sequence. */ tcp_ack_now(pcb); #if TCP_QUEUE_OOSEQ /* We queue the segment on the ->ooseq queue. */ if (pcb->ooseq == NULL) { pcb->ooseq = tcp_seg_copy(&stack->inseg); } else { /* If the queue is not empty, we walk through the queue and try to find a place where the sequence number of the incoming segment is between the sequence numbers of the previous and the next segment on the ->ooseq queue. That is the place where we put the incoming segment. If needed, we trim the second edges of the previous and the incoming segment so that it will fit into the sequence. If the incoming segment has the same sequence number as a segment on the ->ooseq queue, we discard the segment that contains less data. */ prev = NULL; for(next = pcb->ooseq; next != NULL; next = next->next) { if (stack->seqno == next->tcphdr->seqno) { /* The sequence number of the incoming segment is the same as the sequence number of the segment on ->ooseq. We check the lengths to see which one to discard. */ if (stack->inseg.len > next->len) { /* The incoming segment is larger than the old segment. We replace the old segment with the new one. */ cseg = tcp_seg_copy(&stack->inseg); if (cseg != NULL) { cseg->next = next->next; if (prev != NULL) { prev->next = cseg; } else { pcb->ooseq = cseg; } } break; } else { /* Either the lenghts are the same or the incoming segment was smaller than the old one; in either case, we ditch the incoming segment. */ break; } } else { if (prev == NULL) { if (TCP_SEQ_LT(stack->seqno, next->tcphdr->seqno)) { /* The sequence number of the incoming segment is lower than the sequence number of the first segment on the queue. We put the incoming segment first on the queue. */ if (TCP_SEQ_GT(stack->seqno + stack->inseg.len, next->tcphdr->seqno)) { /* We need to trim the incoming segment. */ stack->inseg.len = next->tcphdr->seqno - stack->seqno; pbuf_realloc(stack->inseg.p, stack->inseg.len); } cseg = tcp_seg_copy(&stack->inseg); if (cseg != NULL) { cseg->next = next; pcb->ooseq = cseg; } break; } } else /*if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) && TCP_SEQ_LT(seqno, next->tcphdr->seqno)) */ if(TCP_SEQ_BETWEEN(stack->seqno, prev->tcphdr->seqno+1, next->tcphdr->seqno-1)) /* The sequence number of the incoming segment is in between the sequence numbers of the previous and the next segment on ->ooseq. We trim and insert the incoming segment and trim the previous segment, if needed. */ { if (TCP_SEQ_GT(stack->seqno + stack->inseg.len, next->tcphdr->seqno)) { /* We need to trim the incoming segment. */ stack->inseg.len = next->tcphdr->seqno - stack->seqno; pbuf_realloc(stack->inseg.p, stack->inseg.len); } cseg = tcp_seg_copy(&stack->inseg); if (cseg != NULL) { cseg->next = next; prev->next = cseg; if (TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, stack->seqno)) { /* We need to trim the prev segment. */ prev->len = stack->seqno - prev->tcphdr->seqno; pbuf_realloc(prev->p, prev->len); } } break; } /* If the "next" segment is the last segment on the ooseq queue, we add the incoming segment to the end of the list. */ if (next->next == NULL && TCP_SEQ_GT(stack->seqno, next->tcphdr->seqno)) { next->next = tcp_seg_copy(&stack->inseg); if (next->next != NULL) { if (TCP_SEQ_GT(next->tcphdr->seqno + next->len, stack->seqno)) { /* We need to trim the last segment. */ next->len = stack->seqno - next->tcphdr->seqno; pbuf_realloc(next->p, next->len); } } break; } } prev = next; } } #endif /* TCP_QUEUE_OOSEQ */ } } else { /*if (TCP_SEQ_GT(pcb->rcv_nxt, seqno) || TCP_SEQ_GEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) */ if(!TCP_SEQ_BETWEEN(stack->seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd-1)) { tcp_ack_now(pcb); } } } else { /* Segments with length 0 is taken care of here. Segments that fall out of the window are ACKed. */ /*if (TCP_SEQ_GT(pcb->rcv_nxt, seqno) || TCP_SEQ_GEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) */ if(!TCP_SEQ_BETWEEN(stack->seqno, pcb->rcv_nxt, pcb->rcv_nxt + pcb->rcv_wnd-1)) { tcp_ack_now(pcb); } } } /* * tcp_parseopt: * * Parses the options contained in the incoming segment. (Code taken * from uIP with only small changes.) * */ static void tcp_parseopt(struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; u8_t c; u8_t *opts, opt; u16_t mss; opts = (u8_t *)stack->tcphdr + TCP_HLEN; /* Parse the TCP MSS option, if present. */ if(TCPH_HDRLEN(stack->tcphdr) > 0x5) { for(c = 0; c < (TCPH_HDRLEN(stack->tcphdr) - 5) << 2 ;) { opt = opts[c]; if (opt == 0x00) { /* End of options. */ break; } else if (opt == 0x01) { ++c; /* NOP option. */ } else if (opt == 0x02 && opts[c + 1] == 0x04) { /* An MSS option with the right option length. */ mss = (opts[c + 2] << 8) | opts[c + 3]; pcb->mss = mss > TCP_MSS? TCP_MSS: mss; /* And we are done processing options. */ break; } else { if (opts[c + 1] == 0) { /* If the length field is zero, the options are malformed and we don't process them further. */ break; } /* All other options have a length field, so that we easily can skip past them. */ c += opts[c + 1]; } } } } #endif /* LWIP_TCP */ lwipv6-1.5a/lwip-v6/src/core/raw.c0000644000175000017500000003073511671615010016011 0ustar renzorenzo/** * @file * * Implementation of raw protocol PCBs for low-level handling of * different types of protocols besides (or overriding) those * already available in lwIP. * */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/memp.h" #include "lwip/inet.h" #include "lwip/ip_addr.h" #include "lwip/netif.h" #include "lwip/raw.h" #include "lwip/stats.h" #include "arch/perf.h" #include "lwip/snmp.h" #include "lwip/stack.h" #if LWIP_RAW void raw_init(struct stack *stack) { stack->raw_pcbs = NULL; } /** * Determine if in incoming IP packet is covered by a RAW PCB * and if so, pass it to a user-provided receive callback function. * * Given an incoming IP datagram (as a chain of pbufs) this function * finds a corresponding RAW PCB and calls the corresponding receive * callback function. * * @param pbuf pbuf to be demultiplexed to a RAW PCB. * @param netif network interface on which the datagram was received. * @Return - 1 if the packet has been eaten by a RAW PCB receive * callback function. The caller MAY NOT not reference the * packet any longer, and MAY NOT call pbuf_free(). * @return - 0 if packet is not eaten (pbuf is still referenced by the * caller). * */ u8_t raw_input(struct pbuf *p, struct ip_addr_list *inad, struct pseudo_iphdr *piphdr) { struct raw_pcb *pcb; u16_t proto; struct netif *netif = inad->netif; struct stack *stack = netif->stack; LWIP_DEBUGF(RAW_DEBUG, ("raw_input\n")); proto = piphdr->proto; pcb = stack->raw_pcbs; /* loop through all raw pcbs */ /* this allows multiple pcbs to match against the packet by design */ while ( (pcb != NULL)) { if (pcb->in_protocol == proto) { /* receive callback function available? */ if (pcb->recv != NULL) { struct pbuf *r, *q; char *ptr; r = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); if (r != NULL) { ptr = r->payload; for(q = p; q != NULL; q = q->next) { memcpy(ptr, q->payload, q->len); ptr += q->len; } pcb->recv(pcb->recv_arg, pcb, r, piphdr->src, proto); } } /* no receive callback function was set for this raw PCB */ /* drop the packet */ } pcb = pcb->next; } LWIP_DEBUGF(RAW_DEBUG, ("raw_input leave\n")); return 0; } /** * Bind a RAW PCB. * * @param pcb RAW PCB to be bound with a local address ipaddr. * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to * bind to all local interfaces. * * @return lwIP error code. * - ERR_OK. Successful. No error occured. * - ERR_USE. The specified IP address is already bound to by * another RAW PCB. * * @see raw_disconnect() */ err_t raw_bind(struct raw_pcb *pcb, struct ip_addr *ipaddr, u16_t protocol) { ip_addr_set(&pcb->local_ip, ipaddr); if (protocol) pcb->in_protocol=protocol; return ERR_OK; } /** * Connect an RAW PCB. This function is required by upper layers * of lwip. Using the raw api you could use raw_sendto() instead * * This will associate the RAW PCB with the remote address. * * @param pcb RAW PCB to be connected with remote address ipaddr and port. * @param ipaddr remote IP address to connect with. * * @return lwIP error code * * @see raw_disconnect() and raw_sendto() */ err_t raw_connect(struct raw_pcb *pcb, struct ip_addr *ipaddr, u16_t port) { ip_addr_set(&pcb->remote_ip, ipaddr); return ERR_OK; } /** * Set the callback function for received packets that match the * raw PCB's protocol and binding. * * The callback function MUST either * - eat the packet by calling pbuf_free() and returning non-zero. The * packet will not be passed to other raw PCBs or other protocol layers. * - not free the packet, and return zero. The packet will be matched * against further PCBs and/or forwarded to another protocol layers. * * @return non-zero if the packet was free()d, zero if the packet remains * available for others. */ void raw_recv(struct raw_pcb *pcb, void (* recv)(void *arg, struct raw_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t protocol), void *recv_arg) { /* remember recv() callback and user data */ pcb->recv = recv; pcb->recv_arg = recv_arg; } /** * Send the raw IP packet to the given address. Note that actually you cannot * modify the IP headers (this is inconsistent with the receive callback where * you actually get the IP headers), you can only specify the IP payload here. * It requires some more changes in lwIP. (there will be a raw_send() function * then.) * * @param pcb the raw pcb which to send * @param p the IP payload to send * @param ipaddr the destination address of the IP packet * */ err_t raw_sendto(struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr) { err_t err; struct netif *netif; struct ip_addr *src_ip; struct pbuf *q; /* q will be sent down the stack */ struct ip_addr *nexthop; int flags; struct stack *stack = pcb->stack; LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 3, ("raw_sendto\n")); /*fprintf(stderr,"RAW sendto %p %p\n",p,p->payload);*/ if (! (pcb->so_options & SOF_HDRINCL)) { /* not enough space to add an IP header to first pbuf in given p chain? */ if (pbuf_header(p, ip_addr_is_v4comp(ipaddr)?IP4_HLEN:IP_HLEN)) { /* allocate header in new pbuf */ q = pbuf_alloc(PBUF_IP, 0, PBUF_RAM); /* new header pbuf could not be allocated? */ if (q == NULL) { LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 2, ("raw_sendto: could not allocate header\n")); return ERR_MEM; } /* chain header q in front of given pbuf p */ pbuf_chain(q, p); /* { first pbuf q points to header pbuf } */ LWIP_DEBUGF(RAW_DEBUG, ("raw_sendto: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); } else { /* first pbuf q equals given pbuf */ q = p; pbuf_header(q, - (ip_addr_is_v4comp(ipaddr)?IP4_HLEN:IP_HLEN)); } } else { q = pbuf_alloc(PBUF_LINK, p->len, PBUF_RAM); if (q == NULL) { LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 2, ("raw_sendto: could not allocate HDRINCL packet\n")); return ERR_MEM; } memcpy(q->payload,p->payload,p->len); /*printf("pbuf_header %d %d %d\n",ip_addr_is_v4comp(ipaddr),- (ip_addr_is_v4comp(ipaddr)?IP4_HLEN:IP_HLEN),p->tot_len); pbuf_header(q, - (ip_addr_is_v4comp(ipaddr)?IP4_HLEN:IP_HLEN));*/ } /*printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>1\n");*/ ip_addr_debug_print(IP_DEBUG, ipaddr); if(ip_route_findpath(stack, ipaddr,&nexthop,&netif,&flags) != ERR_OK) { LWIP_DEBUGF(RAW_DEBUG | 1, ("raw_sendto: No route to %p\n", ipaddr->addr)); #if RAW_STATS /* ++lwip_stats.raw.rterr;*/ #endif /* RAW_STATS */ /* free any temporary header pbuf allocated by pbuf_header() */ if (q != p) { pbuf_free(q); } return ERR_RTE; } /*printf("nexthop: "); ip_addr_debug_print(IP_DEBUG, nexthop); printf("\n");*/ if (ip_addr_isany(&(pcb->local_ip))) { /* use outgoing network interface IP address as source address */ struct ip_addr_list *el; el = ip_route_select_source_ip(netif, &pcb->remote_ip, nexthop); if (el != NULL) { src_ip = &(el->ipaddr); } else { src_ip = &(pcb->local_ip); // FIX: should we do these instead? //if (q != p) // pbuf_free(q); //return ERR_RTE; } } else { /* use RAW PCB local IP address as source address */ src_ip = &(pcb->local_ip); } /*printf("outping %lx:%lx:%lx:%lx proto=%d\n", ipaddr->addr[0], ipaddr->addr[1], ipaddr->addr[2], ipaddr->addr[3],pcb->out_protocol);*/ if (pcb->so_options & SOF_IPV6_CHECKSUM) { u16_t *checksump; /*printf("checksum offset %d\n",pcb->checksumoffset); printf("checksum %d len %d \n",pcb->protocol,p->tot_len);*/ checksump=(u16_t *) (((u8_t *)p->payload)+pcb->checksumoffset); /*printf("checksum in %x\n",*checksump);*/ *checksump=inet6_chksum_pseudo(p, src_ip, ipaddr, pcb->in_protocol, p->tot_len); } err = ip_output_if (stack, q, src_ip, (pcb->so_options & SOF_HDRINCL)?IP_LWHDRINCL:ipaddr, pcb->ttl, pcb->tos, pcb->in_protocol, netif, nexthop, flags); /* did we chain a header earlier? */ if (q != p) { /* free the header */ pbuf_free(q); } return err; } /** * Send the raw IP packet to the address given by raw_connect() * * @param pcb the raw pcb which to send * @param p the IP payload to send * @param ipaddr the destination address of the IP packet * */ err_t raw_send(struct raw_pcb *pcb, struct pbuf *p) { return raw_sendto(pcb, p, &pcb->remote_ip); } /** * Remove an RAW PCB. * * @param pcb RAW PCB to be removed. The PCB is removed from the list of * RAW PCB's and the data structure is freed from memory. * * @see raw_new() */ void raw_remove(struct raw_pcb *pcb) { struct stack *stack = pcb->stack; struct raw_pcb *pcb2; /* pcb to be removed is first in list? */ if (stack->raw_pcbs == pcb) { /* make list start at 2nd pcb */ stack->raw_pcbs = stack->raw_pcbs->next; /* pcb not 1st in list */ } else for(pcb2 = stack->raw_pcbs; pcb2 != NULL; pcb2 = pcb2->next) { /* find pcb in raw_pcbs list */ if (pcb2->next != NULL && pcb2->next == pcb) { /* remove pcb from list */ pcb2->next = pcb->next; } } memp_free(MEMP_RAW_PCB, pcb); } /** * Create a RAW PCB. * * @return The RAW PCB which was created. NULL if the PCB data structure * could not be allocated. * * @param proto the protocol number of the IPs payload (e.g. IP_PROTO_ICMP) * * @see raw_remove() */ struct raw_pcb * raw_new(struct stack *stack, u16_t proto) { struct raw_pcb *pcb; LWIP_DEBUGF(RAW_DEBUG | DBG_TRACE | 3, ("raw_new\n")); pcb = memp_malloc(MEMP_RAW_PCB); /* could allocate RAW PCB? */ if (pcb != NULL) { /* initialize PCB to all zeroes */ memset(pcb, 0, sizeof(struct raw_pcb)); pcb->stack = stack; #ifdef LWSLIRP pcb->slirp_fddata = NULL; #endif pcb->in_protocol = proto; pcb->ttl = RAW_TTL; pcb->next = stack->raw_pcbs; //pcb->checksumoffset=0; //already 0 for memset stack->raw_pcbs = pcb; } return pcb; } #endif /* LWIP_RAW */ lwipv6-1.5a/lwip-v6/src/core/lwslirp.c0000644000175000017500000013407411671615010016715 0ustar renzorenzo/* This is part of Slirpvde6 * Developed for the VDE project * Virtual Distributed Ethernet * * Copyright 2010,2011 Renzo Davoli * based on a previous work by Andrea Forni 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "lwip/opt.h" #include "lwip/lwslirp.h" #ifdef LWSLIRP #include "lwip/mem.h" #include "lwip/ip_addr.h" #include "lwip/debug.h" #include "lwip/pbuf.h" #include "lwip/udp.h" #include "lwip/tcp.h" #include "lwip/err.h" #include "lwip/stack.h" #include #include #include #include #include #include #include #include #include #include //#undef LWSLIRP_DEBUG //#define LWSLIRP_DEBUG DBG_ON //#define THREAD_DEBUG #ifdef THREAD_DEBUG #define PRINTTHREAD(X) do {\ printf("thread %s: %p\n",(X),pthread_self());\ } while(0); #else #define PRINTTHREAD(X) #endif #if 0 void slirp_dump(void *data, int len) { u8_t *p=data; int i; fprintf(stderr,"%p=",data); for (i=0; ilen; struct netif_fddata *fddata = arg->pcb->slirp_fddata; PRINTTHREAD("callback_from_tcp_output"); /*if(arg->len > tcp_sndbuf(arg->pcb)) tcp_output(arg->pcb);*/ if(arg->len > tcp_sndbuf(arg->pcb)) { arg->len = tcp_sndbuf(arg->pcb); if (nin > 0 && arg->len == 0 && fddata) fddata->events &= ~POLLIN; } } static int callback_to_tcp_sndbuf_output(struct stack *stack,struct tcp_pcb *pcb,int len) { /* NETIF THREAD (w4callback)*/ struct tcp_sndbuf_output_arg arg; arg.pcb=pcb; arg.len=len; tcpip_callback(stack, callback_from_tcp_sndbuf_output, &arg, SYNC); return arg.len; } struct tcp_write_arg { struct tcp_pcb *pcb; char *buf; int len; }; static void callback_from_tcp_write(void *varg) { /* TCPIP THREAD */ struct tcp_write_arg *arg = varg; int res; PRINTTHREAD("callback_from_tcp_write"); res=tcp_write(arg->pcb, arg->buf, arg->len, 1); mem_free(arg->buf); if(res == ERR_MEM) { /* I close the connection */ LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: error memory, I close the connection.\n")); tcp_close(arg->pcb); } else { tcp_output(arg->pcb); } mem_free(arg); } static void callback_to_tcp_write(struct stack *stack,struct tcp_pcb *pcb,char *buf,int len) { /* NETIF THREAD */ struct tcp_write_arg *arg=mem_malloc(sizeof(struct tcp_write_arg)); if (arg) { arg->pcb=pcb; arg->buf=buf; arg->len=len; tcpip_callback(stack, callback_from_tcp_write, arg, ASYNC); } } struct tcp_input_arg { struct tcp_pcb_listen *pcb; struct netif *netif; }; static void callback_from_tcp_input(void *varg) { /* TCPIP THREAD */ struct tcp_input_arg *arg = varg; PRINTTHREAD("callback_from_tcp_input"); struct pseudo_iphdr piphdr; struct ip_addr src4,dest4; struct ip_addr_list *addr; struct tcp_pcb_listen *pcb=arg->pcb; struct stack *stack=pcb->stack; /* I build a new pseudo header for tcp_input() */ /* I don't test the return value of ip_build_piphdr because I know * that it's right, infact the packet in pbuf ->slirp_m was already controlled * by ip_input() the first time it arrived. */ ip_build_piphdr(&piphdr, arg->pcb->slirp_m, &src4, &dest4); /* I set the ip address list */ addr = ip_addr_list_alloc(stack); if(addr == NULL) { /* There aren't no more ip_addr_list avaible, so I abort.*/ LWIP_DEBUGF(LWSLIRP_DEBUG, ("callback_from_tcp_input: ip_addr_list_alloc() returned NULL, so I abort!\n")); } else { addr->netif = arg->netif; addr->next = NULL; memcpy(&addr->ipaddr, &piphdr.dest, sizeof(struct ip_addr)); tcp_input(pcb->slirp_m, addr, &piphdr, arg->netif); } /* free the ip address list*/ ip_addr_list_free(stack, addr); mem_free(arg); } static void callback_to_tcp_input(struct stack *stack,struct tcp_pcb_listen *pcb,struct netif *netif) { /* NETIF THREAD */ struct tcp_input_arg *arg=mem_malloc(sizeof(struct tcp_input_arg)); if (arg) { arg->pcb=pcb; arg->netif=netif; tcpip_callback(stack, callback_from_tcp_input, arg, ASYNC); } } struct udp_sendto_arg { struct udp_pcb *pcb; struct pbuf *m; }; static void callback_from_udp_sendto(void *varg) { /* TCPIP THREAD */ struct udp_sendto_arg *arg = varg; struct udp_pcb *pcb = arg->pcb; PRINTTHREAD("callback_from_udp_sendto"); udp_sendto(pcb, arg->m, &pcb->remote_ip, pcb->remote_port); pbuf_free(arg->m); mem_free(arg); } static void callback_to_udp_sendto(struct stack *stack,struct udp_pcb *pcb,struct pbuf *m) { /* NETIF THREAD */ struct udp_sendto_arg *arg=mem_malloc(sizeof(struct udp_sendto_arg)); if (arg) { arg->pcb=pcb; arg->m=m; tcpip_callback(stack, callback_from_udp_sendto, arg, ASYNC); } } static void callback_from_tcp_close(void *varg) { /* TCPIP THREAD */ struct tcp_pcb *pcb=varg; if (pcb->state == LISTEN) { struct tcp_pcb_listen *lpcb=varg; if (lpcb->slirp_m != NULL) { struct pbuf *p=lpcb->slirp_m; struct pseudo_iphdr piphdr; struct ip_addr src4,dest4; struct ip_addr_list *addr; struct stack *stack=lpcb->stack; struct tcp_hdr *tcphdr; ip_build_piphdr(&piphdr, lpcb->slirp_m, &src4, &dest4); tcphdr = (struct tcp_hdr *)((u8_t *)p->payload + piphdr.iphdrlen); tcp_rst(stack, 0, ntohl(tcphdr->seqno) + 1 , piphdr.dest, piphdr.src, ntohs(tcphdr->dest), ntohs(tcphdr->src)); pbuf_free(lpcb->slirp_m); } tcp_close((struct tcp_pcb *)lpcb); } else { tcp_arg(pcb, NULL); tcp_sent(pcb, NULL); tcp_recv(pcb, NULL); tcp_poll(pcb, NULL, 0); tcp_err(pcb, NULL); //fprintf(stderr,"callback_from_tcp_close %p\n",pcb); if (tcp_close(pcb) != ERR_OK) tcp_abort(pcb); } } static void callback_to_tcp_close(struct stack *stack,void *pcb) { /* NETIF THREAD */ tcpip_callback(stack, callback_from_tcp_close, pcb, ASYNC); } struct new_forwarding_arg { struct stack *stack; struct netif *slirpif; int fd; struct ip_addr *src; int srcport; struct ip_addr *dest; int destport; void *new_pcb; }; static void callback_from_tcp_new_forwarding(void *varg){ /* TCPIP THREAD (w4callback) */ struct new_forwarding_arg *arg=varg; struct tcp_pcb *pcb; /* new pcb tcp */ if ((pcb = tcp_new(arg->stack)) != NULL) { tcp_arg(pcb, NULL); /* callbacks */ tcp_recv(pcb, slirp_tcp_recv); tcp_sent(pcb, slirp_tcp_sent); /* bind to "fake" the remote sender on the packets */ tcp_bind(pcb, arg->src, arg->srcport); /* add the new fd to the main event loop */ pcb->keep_cnt=0; pcb->slirp_fddata = netif_addfd(arg->slirpif, arg->fd, slirp_connecting_io, pcb, NETIF_ARGS_1SEC_POLL, 0); /* connect to the internal/virtual/lwipv6 end of the connection */ tcp_connect(pcb, arg->dest, arg->destport, slirp_tcp_connected); } arg->new_pcb=pcb; } static void callback_from_udp_new_forwarding(void *varg){ /* TCPIP THREAD (w4callback) */ struct new_forwarding_arg *arg=varg; struct udp_pcb *pcb; /* set up the new udp pcb */ if ((pcb = udp_new(arg->stack)) != NULL) { udp_recv(pcb, slirp_udp_recv, arg->slirpif); pcb->so_options |= SOF_REUSEPORT; /* bind the pcb to the source of the packet (such that the packet will be forwarded with the right/real-world src/srcport) */ udp_bind(pcb, arg->src, arg->srcport, NULL); pcb->slirp_expire = time_now() + UDP_PCB_EXPIRE; /* add the socket to the main event loop poll (with the new parms) */ pcb->slirp_fddata = netif_addfd(arg->slirpif, arg->fd, slirp_udp_input, pcb, NETIF_ARGS_1SEC_POLL, POLLIN); /* connect the socket to the (virtual LWIP-side) remote address (target of forwarding) */ udp_connect(pcb, arg->dest, arg->destport); } arg->new_pcb=pcb; } static struct tcp_pcb *callback_to_tcp_new_forwarding(struct stack *stack, struct netif *slirpif, int fd, struct ip_addr *src, int srcport, struct ip_addr *dest, int destport) { /* NETIF THREAD (w4callback)*/ struct new_forwarding_arg arg; arg.stack=stack; arg.slirpif=slirpif; arg.fd=fd; arg.src=src; arg.srcport=srcport; arg.dest=dest; arg.destport=destport; tcpip_callback(stack,callback_from_tcp_new_forwarding,&arg, SYNC); return (struct tcp_pcb *)(arg.new_pcb); } static struct udp_pcb *callback_to_udp_new_forwarding(struct stack *stack, struct netif *slirpif, int fd, struct ip_addr *src, int srcport, struct ip_addr *dest, int destport) { /* NETIF THREAD (w4callback)*/ struct new_forwarding_arg arg; arg.stack=stack; arg.slirpif=slirpif; arg.fd=fd; arg.src=src; arg.srcport=srcport; arg.dest=dest; arg.destport=destport; tcpip_callback(stack,callback_from_udp_new_forwarding,&arg, SYNC); return (struct udp_pcb *)(arg.new_pcb); } /* TCP ****************************************************************************************/ /* This callback function is called when the TCP state goes from * SYN_RCVD to ESTABLISHED and it changes the socket state to * SS_ISFCONNECTED */ err_t slirp_tcp_accept(void *arg, struct tcp_pcb *pcb, err_t err) { /* TCPIP THREAD */ PRINTTHREAD("slirp_tcp_accept"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_accept: I change the state of socket %p from ", pcb->slirp_fddata)); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); slirp_isfconnected(pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, (" to ")); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); return ERR_OK; } /* This callback function is called when the TCP state goes from * SYN_SENT to ESTABLISHED and it changes the socket state to * SS_ISFCONNECTED */ err_t slirp_tcp_connected(void *arg, struct tcp_pcb *pcb, err_t err) { /* TCPIP THREAD */ PRINTTHREAD("slirp_tcp_connected"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_connected: I change the state of socket %p from ", pcb->slirp_fddata)); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); slirp_isfconnected(pcb); slirp_tcp_update_listen2data(pcb); pcb->keep_cnt=0; LWIP_DEBUGF(LWSLIRP_DEBUG, (" to ")); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); return ERR_OK; } /* this callback function is called when tcp data is leaving the sndbuf */ err_t slirp_tcp_sent(void *arg, struct tcp_pcb *pcb, u16_t len) { /* TCPIP THREAD */ struct netif_fddata *fddata=pcb->slirp_fddata; if (fddata && (fddata->events & POLLIN) == 0) { fddata->events |= POLLIN; netif_thread_wake(pcb->stack); } return ERR_OK; } /* This callback function is called when (in-sequence) data has arrived * in the TCP buffer of "pcb". These data, contained in pbuf "p" are * added to the pcb->slirp_recvbuf, that is the buffer where the socket * takes the data to send.*/ err_t slirp_tcp_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) { /* TCPIP THREAD */ struct netif_fddata *fddata=pcb->slirp_fddata; PRINTTHREAD("slirp_tcp_recv"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_recv: pbuf p (%p)", p)); #if LWSLIRP_DEBUG if(p != NULL) LWIP_DEBUGF(LWSLIRP_DEBUG, (", I have receved %d bytes " "(p->tot_len = %d)\n", p->len, p->tot_len)); else LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); #endif /* LWSLIRP_DEBUG */ if(p == NULL) { /* p == NULL, FIN segment received, so p == NULL indicate EOF */ /* I don't do anything. I could call close(pcb->slirp_fddata), I don't do it, * because if a FIN segment was received, the stack will call some * close function that will call tcp_pcb_purge() which will close * the socket. */ return ERR_OK; } /* Else all ok!*/ /* If the buffer is null, p become the head of it ...*/ /* Concatenate the new pbuf p at the end of pcb->slirp_recvbuf */ if(pcb->slirp_recvbuf == NULL) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_recv: ->slirp_recvbuf == " "NULL, so p (%p) become the head of it\n", p)); pcb->slirp_recvbuf = p; } else { /*... otherwise I concatenate p at the end of the buffer*/ pbuf_cat(pcb->slirp_recvbuf, p); } if (fddata) { /* X1002: */ #if 1 if ((fddata->events & POLLOUT) == 0) slirp_write(pcb, fddata->netif); #else fddata->events |= POLLOUT; netif_thread_wake(pcb->stack); #endif } return ERR_OK; } /* Read data from a slirp interface */ static int slirp_read (struct stack *stack, struct tcp_pcb *pcb, struct netif_fddata *fddata) { /* NETIF THREAD */ int ret, nin, n; err_t res; char *buf; int slirp_fd=fddata->fd; PRINTTHREAD("slirp_read"); /* I get the number of bytes I can read from the read buffer */ ioctl(slirp_fd, FIONREAD, &nin); /* I test if there is enough room in the send queue of the TCP pcb */ n=callback_to_tcp_sndbuf_output(stack,pcb,nin); /*if (nin != n) printf("slirp_read ready %d - read %d\n",nin,n);*/ if (nin > 0 && n == 0) return ERR_OK; /* moved to TCPIP thread */ /*if (nin > 0 && n==0) { fddata->events &= ~POLLIN; return ERR_OK; }*/ //printf("enqueue! tcp_sndbuf %d toread %d\n",tcp_sndbuf(pcb),n); /* There is room for store the read data, so I read it */ LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_read: I can read %d bytes, and I have read ", n)); buf = mem_malloc(n); ret = read(slirp_fd, buf, n); LWIP_DEBUGF(LWSLIRP_DEBUG, ("%d bytes\n", ret)); if(ret <= 0) { if(ret < 0 && (errno == EINTR || errno == EAGAIN)) { mem_free(buf); return 0; } else { /* ret = 0, So */ LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_read: disconnected, ret = %d, errno = %d-%s\n", ret, errno,strerror(errno))); mem_free(buf); slirp_fcantrcvmore(fddata, pcb); callback_to_tcp_close(stack, pcb); return -1; } } callback_to_tcp_write(stack, pcb, buf, n); return ERR_OK; } /* discard data from a slirp interface when the interface is down */ static void slirp_discard_input(int slirp_fd) { /* NETIF THREAD */ int n; char *buf; PRINTTHREAD("slirp_discard_input"); /* I get the number of bytes I can read from the read buffer */ ioctl(slirp_fd, FIONREAD, &n); buf = mem_malloc(n); if (buf) { read(slirp_fd, buf, n); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_read: Interface is down: %d bytes discarded ", n)); mem_free(buf); } } /* write data to a slirp interface */ static int slirp_write(struct tcp_pcb *pcb, struct netif *netif) { /* TCPIP THREAD */ int ret, total_ret = 0; struct pbuf *p; struct stack *stack = pcb->stack; struct netif_fddata *fddata=pcb->slirp_fddata; int slirp_fd; if (fddata == NULL) return -1; slirp_fd = fddata->fd; PRINTTHREAD("slirp_write"); /*assert(pcb->slirp_recvbuf != NULL);*/ if (pcb->slirp_recvbuf == NULL) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: ->slirp_recvbuf = NULL!!!!!!!!!!!!!!!!!!!!!\n")); return 0; } LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: ->slirp_recvbuf = %p, total lenght of recv " "queue = %d.\n", pcb->slirp_recvbuf, pcb->slirp_recvbuf->tot_len)); p = pcb->slirp_recvbuf; while(p != NULL) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: Try to send (write) %d bytes of pbuf %p. (totlen = %d)\n", p->len, p, p->tot_len)); if (netif->flags & NETIF_FLAG_UP) { ret = write(slirp_fd, p->payload, p->len); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: write %d of %d bytes of pbuf %p\n", ret, p->len, p)); } else { ret = p->len; LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: Interface is down: %d bytes discarded\n", ret)); } //printf("RET PLEN %d %d %s\n",ret, p->len, (retlen)?"<<<<<<<<<<<<<<<<<<":""); /* This should never happen, but people tell me it does *shrug* */ if (ret < 0 && (errno == EAGAIN || errno == EINTR)) return 0; if(ret < 0) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: disconnected, ret = %d, errno = %d-%s\n", ret, errno,strerror(errno))); slirp_fcantsendmore(fddata, pcb); tcp_close(pcb); return -1; } tcp_recved(pcb, ret); /* no error, I control how much I have written */ if(ret == p->len) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: ret (%d) == p->len (%d), so " "I remove p (%p) from the list [p->ref = %d].\n", ret, p->len, p, p->ref)); /* I have send all the pcb, so I remove it from the list */ pbuf_ref(p->next); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: after pbuf_ref(%p), p->next->ref = %d\n", p->next, p->next == NULL ? 0:p->next->ref)); pcb->slirp_recvbuf = pbuf_dechain(p); pbuf_free(p); p = pcb->slirp_recvbuf; LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: after pbuf_dechain, next " "pbuf will be p = %p", p)); #if LWSLIRP_DEBUG if(p != NULL) LWIP_DEBUGF(LWSLIRP_DEBUG, (", p->len = %d, p->tot_len = %d\n", p->len, p->tot_len)); else LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); #endif /* LWSLIRP_DEBUG */ total_ret += ret; } else if (ret < p->len ) { /* I have send not all the pcb payload, so I adjust the payload pointer * to point to the data unsent. */ fddata->events |= POLLOUT; netif_thread_wake(pcb->stack); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: ret (%d) < p->len (%d), so " "I adjust the payload of p (%p) from " "%x I add (%d)\n", ret, p->len, p, p->payload, ret )); pbuf_header(p, -ret); LWIP_DEBUGF(LWSLIRP_DEBUG, ("%x(%d).\n", p->payload, p->payload)); /* I cannot send more, so I exit from the while */ total_ret += ret; break; } else { /* ret > p -> len : It's impossible! */ LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_write: ret (%d) > p->len (%d): Impossible!\n", ret, p->len)); assert(ret <= p->len); } } //tcp_recved(pcb, total_ret); return total_ret; } struct slirp_write_arg { struct tcp_pcb *pcb; struct netif *netif; }; static void callback_from_slirp_write(void *varg) { /* TCPIP THREAD (w4callback) */ struct slirp_write_arg *arg = varg; int rv; PRINTTHREAD("callback_from_slirp_write"); rv=slirp_write(arg->pcb, arg->netif); mem_free(arg); } static int callback_to_slirp_write(struct stack *stack,struct tcp_pcb *pcb,struct netif *netif) { /* NETIF THREAD (w4callback)*/ struct slirp_write_arg *arg; arg=mem_malloc(sizeof (struct slirp_write_arg)); if (arg) { arg->pcb=pcb; arg->netif=netif; tcpip_callback(stack, callback_from_slirp_write, arg, ASYNC); } } /* * Various session state calls */ static void slirp_isfconnecting(struct tcp_pcb *pcb) { /* TCPIP THREAD */ PRINTTHREAD("slirp_isfconnecting"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_isfconnecting: before changes: ")); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); pcb->slirp_state &= ~(SS_NOFDREF|SS_ISFCONNECTED|SS_FCANTRCVMORE| SS_FCANTSENDMORE|SS_FWDRAIN); pcb->slirp_state |= SS_ISFCONNECTING; /* Clobber other states */ LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_isfconnecting: after changes: ")); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); } static void slirp_isfconnected(struct tcp_pcb *pcb) { /* TCPIP THREAD */ PRINTTHREAD("slirp_isfconnected"); pcb->slirp_state &= ~(SS_ISFCONNECTING|SS_FWDRAIN|SS_NOFDREF); pcb->slirp_state |= SS_ISFCONNECTED; } static void slirp_fcantrcvmore(struct netif_fddata *fddata, struct tcp_pcb *pcb) { /* NETIF THREAD */ struct stack *stack = pcb->stack; int slirp_fd = fddata->fd; PRINTTHREAD("slirp_fcantrcvmore"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_isfcantrcvmore: SHUT_RD = %d\n", SHUT_RD)); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_isfcantrcvmore: before changes: ")); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); /* if there is no reference of the fd, close this side of the socket connection, * so that all the incoming packet will be discarded and remove the socket from the * write fd set*/ if (!(pcb->slirp_state & SS_NOFDREF)) { shutdown(slirp_fd, SHUT_RD); /* SHUT_RD: further receptions will be disallowed */ fddata->events &= ~(POLLIN | POLLPRI); } pcb->slirp_state &= ~(SS_ISFCONNECTING); /* If the socket cannnot send data, remove the fd reference, otherwise * set the state to SS_FCANTRCVMORE so that it cannot receive other data. */ if (pcb->slirp_state & SS_FCANTSENDMORE) pcb->slirp_state = SS_NOFDREF; /* Don't select it */ /* XXX close() here as well? */ else pcb->slirp_state |= SS_FCANTRCVMORE; LWIP_DEBUGF(LWSLIRP_DEBUG, (" after changes: ")); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); } static void slirp_fcantsendmore(struct netif_fddata *fddata, struct tcp_pcb *pcb) { /* TCPIP THREAD */ struct stack *stack = pcb->stack; int slirp_fd=fddata->fd; PRINTTHREAD("slirp_fcantsendmore"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_fcantsendmore: is SHUT_WR (%d) == 1?\n", SHUT_WR)); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_isfcantsendmore: before changes: ")); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); if (!(pcb->slirp_state & SS_NOFDREF)) { shutdown(slirp_fd, SHUT_WR); /* SHUT_WR : further transmissions will be disallowed. */ //netif_slirp_events(pcb) &= ~(POLLIN | POLLPRI); fddata->events &= ~(POLLOUT); } pcb->slirp_state &= ~(SS_ISFCONNECTING); if (pcb->slirp_state & SS_FCANTRCVMORE) pcb->slirp_state = SS_NOFDREF; /* as above */ else pcb->slirp_state |= SS_FCANTSENDMORE; LWIP_DEBUGF(LWSLIRP_DEBUG, (" after changes: ")); slirp_debug_print_state(LWSLIRP_DEBUG, pcb); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); } /* * Set fd non-blocking */ static void slirp_fd_nonblock(int fd) { int opt; opt = fcntl(fd, F_GETFL, 0); opt |= O_NONBLOCK; fcntl(fd, F_SETFL, opt); } static void slirp_tcp_io(struct netif_fddata *fddata, short revents) { /* NETIF THREAD */ struct netif *netif = fddata->netif; struct tcp_pcb *pcb = fddata->opaque; struct stack *stack = netif->stack; PRINTTHREAD("slirp_tcp_io"); //fprintf(stderr, "pcb %p pcb->fddata %p fddata %p REVENTS %d\n",pcb, pcb->slirp_fddata, fddata,revents); if (pcb->slirp_state & SS_NOFDREF || pcb->slirp_fddata == NULL) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_io: tcp_pcb(%p) (->slirp_state%d & SS_NOFDREF) OR (->slirp == %p). return\n", pcb, pcb->slirp_state, pcb->slirp_fddata)); return; } if (revents & POLLPRI) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_io: socket(%p) has urgent data, I read them.\n", pcb->slirp_fddata)); if (netif->flags & NETIF_FLAG_UP) { if (slirp_read(stack, pcb, fddata) >= 0) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_io: socket(%p) sending urgent data to tcp_output.\n", pcb->slirp_fddata)); } } else slirp_discard_input(fddata->fd); } if (revents & POLLIN) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_io: socket(%p) has data, I read them.\n", pcb->slirp_fddata)); if (netif->flags & NETIF_FLAG_UP) { if (slirp_read(stack, pcb, fddata) >= 0) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_io: socket(%p) sending data to tcp_output.\n", pcb->slirp_fddata)); } } else slirp_discard_input(fddata->fd); } if (revents & POLLOUT) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_io: socket(%p) sending data\n", pcb->slirp_fddata)); fddata->events &= ~POLLOUT; callback_to_slirp_write(stack,pcb, netif); } } static void slirp_connecting_io(struct netif_fddata *fddata, short revents) { /* NETIF THREAD */ struct netif *netif = fddata->netif; struct tcp_pcb *pcb = fddata->opaque; struct stack *stack = netif->stack; int slirp_fd=fddata->fd; pcb->keep_cnt++; //printf("waiting %d\n", pcb->keep_cnt); if (pcb->keep_cnt > 2) callback_to_tcp_close(stack,pcb); } static void slirp_listening_io(struct netif_fddata *fddata, short revents) { /* NETIF THREAD */ struct netif *netif = fddata->netif; struct tcp_pcb_listen *pcb = fddata->opaque; PRINTTHREAD("slirp_listening_io"); //fprintf(stderr,"xxxxxxxxxxxxxx slirp_listening_io %p %p %p STATE=%d\n", pcb, fddata, pcb->slirp_fddata, pcb->state); struct stack *stack = netif->stack; int slirp_fd=fddata->fd; if (pcb->slirp_state & SS_NOFDREF || pcb->slirp_fddata == NULL) { //printf("slirp_listening_io LOOP!\n"); PRINTTHREAD("slirp_listening_io LOOP"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listening_io: tcp_pcb(%p) (->slirp_state%d & SS_NOFDREF) OR (->slirp%p == NULL). return\n", pcb, pcb->slirp_state, pcb->slirp_fddata)); //netif_delfd(stack,posfd); return; } if (revents & POLLOUT) { if(pcb->slirp_state & SS_ISFCONNECTING) { int ret; LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listening_io: socket(%p) is try to connect to the peer (SS_ISFCONNECTING state)." "Is connected?... ", pcb->slirp_fddata)); /* If ret > 0, the socket is still connecting, so * the write is used to test this. */ pcb->slirp_state &= ~SS_ISFCONNECTING; ret = write(slirp_fd, &ret, 0); /*if (ret < 0) printf("ERRNO %d\n",errno);*/ if(ret < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINPROGRESS || errno == ENOTCONN) { LWIP_DEBUGF(LWSLIRP_DEBUG, (" Not now, but is already trying.\n")); return; } /* else failed*/ close(slirp_fd); PRINTTHREAD("slirp_listening_io netif_delfd\n"); pcb->slirp_fddata = NULL; pcb->slirp_state = SS_NOFDREF; LWIP_DEBUGF(LWSLIRP_DEBUG, (" NO, so I set the state to SS_NOFDREF.\n")); /* X1012 */ //callback_to_tcp_listen_close(stack, pcb); callback_to_tcp_close(stack, pcb); return; } LWIP_DEBUGF(LWSLIRP_DEBUG, (" YES.\n")); /* * Continue tcp_input */ LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listening_io: now that it is connected send the SYN to the stack and forawrd the pending packets\n")); fddata->events &= ~(POLLOUT); //fprintf(stderr, "USING SAVED PBUF %p %p %p\n",pcb,pcb->slirp_m,pcb->slirp_fddata); callback_to_tcp_input(stack, pcb, netif); } } } /* * Connect to a host on the Internet * Called by tcp_input * Only do a connect, the tcp fields will be set in tcp_input * return 0 if there's a result of the connect, * else return -1 means we're still connecting * The return value is almost always -1 since the socket is * nonblocking. Connect returns after the SYN is sent, and does * not wait for ACK+SYN. */ int slirp_tcp_fconnect(struct tcp_pcb_listen *lpcb, u16_t dest_port, struct ip_addr *dest_addr, struct netif *slirpif) { /* TCPIP THREAD */ int ret = 0; int lslirp_fd; PRINTTHREAD("slirp_tcp_fconnect"); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_fconnect: start. Try to connect a socket to the listening tcp pcb.\n")); if((slirpif->flags & NETIF_FLAG_UP) && (lslirp_fd = slirpif->netifctl(slirpif, NETIFCTL_SLIRPSOCK_STREAM,NULL)) >= 0) { int opt; unsigned char version; struct sockaddr_in6 addr6; struct ip_addr *remote_addr; /* Set the socket non blocking */ slirp_fd_nonblock(lslirp_fd); /* Set the socket options: reuse address ad in-line out of band data*/ opt = 1; setsockopt(lslirp_fd,SOL_SOCKET,SO_REUSEADDR,(char *)&opt,sizeof(opt )); opt = 1; setsockopt(lslirp_fd,SOL_SOCKET,SO_OOBINLINE,(char *)&opt,sizeof(opt )); addr6.sin6_family = AF_INET6; version = ip_addr_is_v4comp(&lpcb->local_ip) ? 4 : 6; remote_addr = &lpcb->local_ip; /* I convert remote_addr (a ip_addr IPv6 address) in a in6_addr. */ SO_IP_ADDR2IN6_ADDR(remote_addr, &addr6.sin6_addr); addr6.sin6_port = htons(dest_port); #if LWSLIRP_DEBUG { char str_addr6[INET6_ADDRSTRLEN]; LWIP_DEBUGF(LWSLIRP_DEBUG, ("tcp_fconnect: connect()ing, addr.sin_port = %d, " "addr.sin_addr.s_addr = %s\n", ntohs(addr6.sin6_port), inet_ntop(AF_INET6, &addr6.sin6_addr, str_addr6, sizeof(str_addr6)))); } #endif /* LWSLIRP_DEBUG */ //fprintf(stderr,"netif_addfd_sync slirp_tcp_fconnect %p\n",lpcb->slirp_fddata); lpcb->slirp_fddata = netif_addfd(slirpif, lslirp_fd, slirp_listening_io, lpcb, 0, POLLOUT); /* I do the connect*/ ret = connect(lslirp_fd,(struct sockaddr *)&addr6, sizeof(addr6)); LWIP_DEBUGF(LWSLIRP_DEBUG, ("tcp_fconnect: after connect of socket %p, " "ret = %d(%d)\n", lpcb->slirp_fddata, ret, errno)); /* * If it's not in progress, it failed, so we just return 0, * without clearing SS_NOFDREF */ slirp_isfconnecting((struct tcp_pcb*) lpcb); } return ret; } void slirp_tcp_update_listen2data(struct tcp_pcb *pcb) { /* TCPIP THREAD */ PRINTTHREAD("slirp_tcp_update_listen2data"); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("slirp_tcp_update_listen2data connection ok -> now data.\n")); /* netif_updatefd(pcb->stack, pcb->slirp_fddata, slirp_tcp_io, pcb, 0); netif_slirp_events(pcb) |= POLLIN | POLLPRI; */ struct netif_fddata *fddata = pcb->slirp_fddata; //fprintf(stderr, "slirp_tcp_update_listen2data %p\n", fddata); if (fddata) { fddata->fun = slirp_tcp_io; fddata->opaque = pcb; fddata->events |= POLLIN | POLLPRI; } } void slirp_tcp_close(struct tcp_pcb *pcb) { /* TCPIP THREAD */ PRINTTHREAD("slirp_tcp_close"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_tcp_close connection closed.\n")); //netif_delfd_sync(pcb->stack,pcb->slirp_fddata); struct netif_fddata *fddata = pcb->slirp_fddata; #if 0 if (fddata) fprintf(stderr,"slirp_tcp_close %p %d\n",pcb->slirp_fddata,fddata->fd); else fprintf(stderr,"slirp_tcp_close %p\n",pcb->slirp_fddata); #endif if (fddata) { pcb->slirp_fddata = NULL; close(fddata->fd); } } /* UDP ****************************************************************************************/ /* from lwipv6 to slirp (outgoing stream). */ int slirp_udp_bind(struct udp_pcb *pcb, struct netif *slirpif, int flags) { /* TCPIP THREAD */ int slirp_fd; PRINTTHREAD("slirp_udp_bind"); if (slirpif->netifctl != NULL) { struct sockaddr_in6 addr6; LWIP_DEBUGF(UDP_DEBUG, ("slirp_udp_bind: I'll bind the socket to a %s address\n", ip_addr_is_v4comp(&pcb->local_ip) == 6 ? "IPv6" : "v4-mapped-v6")); if((slirp_fd = slirpif->netifctl(slirpif, NETIFCTL_SLIRPSOCK_DGRAM, NULL)) != -1) { memset(&addr6, 0, sizeof(&addr6)); addr6.sin6_family = AF_INET6; addr6.sin6_port = 0; addr6.sin6_addr = in6addr_any; if( bind(slirp_fd, (struct sockaddr *)&addr6, sizeof(addr6)) < 0) { /* Error, I close the socket */ LWIP_DEBUGF(UDP_DEBUG, ("slirp_udp_bind: socket bind error.\n")); close(slirp_fd); pcb->slirp_fddata = NULL; } else { /* success */ LWIP_DEBUGF(UDP_DEBUG, ("slirp_udp_bind: socket bind successful\n")); pcb->slirp_expire = time_now() + UDP_PCB_EXPIRE; LWIP_DEBUGF(UDP_DEBUG, ("slirp_udp_bind: pcb->slirp_expire = (%ld + %ld) = %ld\n", time_now(), UDP_PCB_EXPIRE, pcb->slirp_expire)); pcb->slirp_fddata = netif_addfd(slirpif, slirp_fd, slirp_udp_input, pcb, NETIF_ARGS_1SEC_POLL, POLLIN); } } } } void slirp_udp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) { /* TCPIP THREAD */ PRINTTHREAD("slirp_udp_recv"); LWIP_DEBUGF(UDP_DEBUG, ("slirp_udp_rcv: received pbuf %p, tot_len = %d\n", p, p->tot_len)); { char str_addr[INET6_ADDRSTRLEN]; LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_udp_recv: FROM %s : %u\n", inet_ntop(AF_INET6, addr, str_addr, sizeof(str_addr)), port)); } /* Try to send it */ if(slirp_sendto(pcb, p, arg) == -1 ) { LWIP_DEBUGF(UDP_DEBUG, ("udp_input: slirp_sendto() error, I send a ICMP destination unreachable.\n")); /* icmp_dest_unreach() supports only IPv6, so I send it only * if the connection is IPv6 */ if(!ip_addr_is_v4comp(addr)) { pbuf_header(p, UDP_HLEN + IP_HLEN); icmp_dest_unreach(pcb->stack, p, ICMP_DUR_NET); } } /* It was send without errors, so I delete it. */ pbuf_free(p); } static int slirp_sendto(struct udp_pcb *pcb, struct pbuf *p, struct netif *slirpif) { /* TCPIP THREAD */ int ret; unsigned char version; char *full_payload, *temp; struct pbuf *q; struct sockaddr_in6 addr6; struct ip_addr *remote_addr; struct stack *stack = slirpif->stack; struct netif_fddata *fddata = pcb->slirp_fddata; int slirp_fd; if (fddata == NULL) return -1; slirp_fd=fddata->fd; PRINTTHREAD("slirp_sendto"); if (!(slirpif->flags & NETIF_FLAG_UP)) return -1; version = ip_addr_is_v4comp(&pcb->local_ip) ? 4 : 6; LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_sendto: I'll send a %s packet.\n", version == 6 ? "IPv6" : "v4-mapped-v6")); /* I sets the family */ addr6.sin6_family = AF_INET6; remote_addr = &pcb->local_ip; /* I convert remote_addr (a ip_addr IPv6 address) in a in6_addr. */ SO_IP_ADDR2IN6_ADDR(remote_addr, &addr6.sin6_addr); addr6.sin6_port = htons(pcb->local_port); #if LWSLIRP_DEBUG { char str_addr6[INET6_ADDRSTRLEN]; LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_sendto: I send to %s : %u, using socket %p\n", inet_ntop(AF_INET6, &addr6.sin6_addr, str_addr6, sizeof(str_addr6)), ntohs(addr6.sin6_port), pcb->slirp_fddata)); } #endif /* LWSLIRP_DEBUG */ /* put all the pbuff fragment in one buffer */ full_payload = mem_malloc(p->tot_len); temp = full_payload; for(q = p; q != NULL; q = q->next) { memcpy(temp, q->payload, q->len); temp += q->len; } ret = sendto(slirp_fd, full_payload, p->tot_len, 0, (struct sockaddr *)&addr6, sizeof (addr6)); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_sendto: I have to send %d bytes, and I have send %d bytes\n", p->tot_len, ret)); mem_free(full_payload); if( ret < 0 ) return -1; /* Kill the socket if there's no reply in 4 minutes, * but only if it's an expirable socket */ LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_sendto: BEFORE pcb->slirp_expire = %d -- ", pcb->slirp_expire)); pcb->slirp_expire = time_now() + UDP_PCB_EXPIRE; LWIP_DEBUGF(LWSLIRP_DEBUG, ("AFTER pcb->slirp_expire = (%ld + %ld) = %ld\n", time_now(), UDP_PCB_EXPIRE, pcb->slirp_expire)); return 0; } static void slirp_udp_input(struct netif_fddata *fddata, short revents) { /* NETIF THREAD */ struct netif *netif = fddata->netif; struct udp_pcb *pcb = fddata->opaque; struct sockaddr_in6 addr6; int addrlen = sizeof(struct sockaddr_in6); struct pbuf *m; int n; int ret; struct stack *stack = netif->stack; int slirp_fd=fddata->fd; PRINTTHREAD("slirp_udp_input"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_udp_input: pcb = %p\n", pcb)); /* get the number of bytes I can read from the read buffer */ ret=ioctl(slirp_fd, FIONREAD, &n); if (n == 0) { unsigned long now=time_now(); if (now > pcb->slirp_expire) { //netif_delfd(stack,posfd); close(slirp_fd); udp_remove(pcb); } return; } /* create the buffer */ m = pbuf_alloc(PBUF_TRANSPORT, n, PBUF_RAM); /* read the data*/ ret = recvfrom(slirp_fd, m->payload, n, 0,(struct sockaddr *)&addr6, &addrlen); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_udp_input: called ioctl, I can read %d bytes, " "and I have read %d bytes, errno = %d-%s\n", n, ret, errno, strerror(errno))); if(ret == -1 || ret == 0) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_udp_input: error.\n")); /* icmp_dest_unreach() supports only IPv6, so I send it only * if the connection is IPv6 */ if(!ip_addr_is_v4comp(&pcb->local_ip)) { enum icmp_dur_type type; struct pbuf *p; struct ip_hdr *iphdr; type = ICMP_DUR_PORT; if(errno == EHOSTUNREACH) type = ICMP_DUR_HOST; else if(errno == ENETUNREACH) type = ICMP_DUR_NET; /* Because icmp_dest_unreach() needs a pbuf, but I have not it, * I create a pbuf and I fill it with the necessary * informations. */ p = pbuf_alloc(PBUF_IP, IP_HLEN, PBUF_RAM); iphdr = p->payload; ip_addr_set(&iphdr->src, &pcb->remote_ip); ip_addr_set(&iphdr->dest, &pcb->local_ip); /* I send dest unreach */ icmp_dest_unreach(stack, p, type); /* I free the packet created. */ pbuf_free(p); } pbuf_free(m); } else { if (netif->flags & NETIF_FLAG_UP) { LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_udp_input: src = ")); ip_addr_debug_print(LWSLIRP_DEBUG, &pcb->local_ip); LWIP_DEBUGF(LWSLIRP_DEBUG, (", ")); LWIP_DEBUGF(LWSLIRP_DEBUG, ("dest = ")); ip_addr_debug_print(LWSLIRP_DEBUG, &pcb->remote_ip); LWIP_DEBUGF(LWSLIRP_DEBUG, ("\n")); /* Hack: domain name lookup will be used the most for UDP, * and since they'll only be used once there's no need * for the 4 minute (or whatever) timeout... So we time them * out much quicker (10 seconds for now...) */ LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_udp_input: pcb->local_port = %d. BEFORE pcb->slirp_expire = %d --- " "AFTER pcb->slirp_expire = (%ld + ", pcb->local_port, pcb->slirp_expire, time_now())); if (pcb->local_port == 53) { pcb->slirp_expire = time_now() + UDP_PCB_EXPIREFAST; LWIP_DEBUGF(LWSLIRP_DEBUG, ("%d", UDP_PCB_EXPIREFAST)); } else { pcb->slirp_expire = time_now() + UDP_PCB_EXPIRE; LWIP_DEBUGF(LWSLIRP_DEBUG, ("%d", UDP_PCB_EXPIRE)); } LWIP_DEBUGF(LWSLIRP_DEBUG, (") = %ld\n", pcb->slirp_expire)); /* I send the data read */ //udp_sendto(pcb, m, &pcb->remote_ip, pcb->remote_port); callback_to_udp_sendto(stack,pcb,m); } else pbuf_free(m); } } /*============ PORT FORWARDING ===================*/ struct slirp_listen { struct netif *slirpif; struct ip_addr destaddr; u16_t destport; u16_t srcport; union { struct ip_addr srcaddr; char srcpath[1]; } src; }; #define SLIRP_LISTEN_LEN(TYPE, SRC) \ (((TYPE) == SLIRP_LISTEN_UNIXSTREAM) ? \ sizeof(struct slirp_listen) - sizeof(struct ip_addr) + strlen(src) + 1 : \ sizeof(struct slirp_listen)) /* the stack received a connection request (or the first datagram from a new source) */ static void slirp_listen_cb(struct netif_fddata *fddata, short revents) { /* NETIF THREAD */ struct netif *netif = fddata->netif; struct slirp_listen *sl = fddata->opaque; struct stack *stack=netif->stack; int ret; int slirp_fd=fddata->fd; PRINTTHREAD("slirp_listen_cb"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_cb: new data on %d\n", slirp_fd)); if (fddata->flags & SLIRP_LISTEN_UDP) { /*DGRAM*/ int n; struct pbuf *m; struct sockaddr_in6 srcaddr; struct udp_pcb *udp_pcb=NULL; int srclen = sizeof(struct sockaddr_in6); ioctl(slirp_fd, FIONREAD, &n); m = pbuf_alloc(PBUF_TRANSPORT, n, PBUF_RAM); if (m==NULL) return; ret = recvfrom(slirp_fd, m->payload, n, 0,(struct sockaddr *)&srcaddr, &srclen); if(ret == -1 || ret == 0) goto udp_err; LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_cb: udp packet on %d\n", slirp_fd)); /* create a new unconnected socket for new udp sequence from a different source/port */ if (!(fddata->flags & SLIRP_LISTEN_ONCE)) lwip_slirp_listen_add(sl->slirpif, &sl->destaddr, sl->destport, &sl->src.srcaddr, sl->srcport, fddata->flags); /* connect the current socket to the source of the first packet */ ret = connect(slirp_fd,(struct sockaddr *)&srcaddr,srclen); udp_pcb=callback_to_udp_new_forwarding(stack, sl->slirpif, slirp_fd, (struct ip_addr *)&(srcaddr.sin6_addr), ntohs(srcaddr.sin6_port), &sl->destaddr, sl->destport); /* remove the old listening item from the main loop */ //netif_delfd(stack, pos); ??? XXX mem_free(sl); /* forward the first packet */ if (udp_pcb != NULL) callback_to_udp_sendto(stack, udp_pcb, m); udp_err: return; } else { /*STREAM*/ int conn; struct sockaddr_in6 srcaddr; int srclen = sizeof(srcaddr); struct tcp_pcb *pcb; LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_cb: tcp/unixsream packet on %d\n", slirp_fd)); memset(&srcaddr,0,srclen); /* accept: unfortunately we have to accept the connection request to read the address/port of the client end */ conn=accept(slirp_fd, (struct sockaddr *)&srcaddr, &srclen); if (conn < 0) goto tcp_err; #if LWSLIRP_DEBUG { char str_addr6[INET6_ADDRSTRLEN]; LWIP_DEBUGF(LWSLIRP_DEBUG, ("ACCEPT: connect()ing, addr.sin_port = %d, " "addr.sin_addr.s_addr = %s\n", ntohs(srcaddr.sin6_port), inet_ntop(AF_INET6, &srcaddr.sin6_addr, str_addr6, sizeof(str_addr6)))); } #endif pcb=callback_to_tcp_new_forwarding(stack, sl->slirpif, conn, (struct ip_addr *)&(srcaddr.sin6_addr), ntohs(srcaddr.sin6_port), &sl->destaddr, sl->destport); if (fddata->flags & SLIRP_LISTEN_ONCE) { close(slirp_fd); /* remove the old listening item from the main loop */ //netif_delfd(stack, pos); mem_free(sl); } return; tcp_err: close(conn); return; } } /* add a port forwarding rule. src/srcport is the local address/port (in the native stack) dest/destport is the virtual address/port where all the traffic to src/srcport must be forwarded */ int lwip_slirp_listen_add(struct netif *slirpif, struct ip_addr *dest, int destport, void *src, int srcport, int flags) { /* APP THREAD */ int s; int conntype=flags & SLIRP_LISTEN_TYPEMASK; struct slirp_listen *sl_item; struct stack *stack=slirpif->stack;; int ret; int one=1; PRINTTHREAD("lwip_slirp_listen_add"); LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_add: srcport %d flags %x\n", srcport, flags)); if (conntype == SLIRP_LISTEN_UNIXSTREAM && src==NULL) return ERR_VAL; sl_item=mem_malloc(SLIRP_LISTEN_LEN(conntype, src)); if (sl_item==NULL) return ERR_MEM; ip_addr_set(&sl_item->destaddr,dest); sl_item->destport=destport; sl_item->srcport=srcport; sl_item->slirpif=slirpif; /* TCP-IP port forwarding */ if (conntype == SLIRP_LISTEN_TCP || conntype == SLIRP_LISTEN_UDP) { struct sockaddr_in6 srcsockaddr; memset(&srcsockaddr,0,sizeof(srcsockaddr)); ip_addr_set(&sl_item->src.srcaddr,src); /* create the socket */ s=slirpif->netifctl(slirpif, (conntype == SLIRP_LISTEN_UDP)?NETIFCTL_SLIRPSOCK_DGRAM:NETIFCTL_SLIRPSOCK_STREAM, NULL); if (s < 0) { ret=ERR_CONN; goto err_free; } LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_add: new tcp/udp socket %d\n", s)); setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); srcsockaddr.sin6_family=AF_INET6; srcsockaddr.sin6_port=htons(srcport); memcpy(&srcsockaddr.sin6_addr,src,sizeof(struct ip_addr)); /* bind it to the right address/port */ if(bind(s, (struct sockaddr *) &srcsockaddr, sizeof(srcsockaddr)) < 0) { ret=ERR_CONN; goto err_close; } LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_add: socket %d bound to the local address/port %d\n", s, srcport)); } else if (conntype == SLIRP_LISTEN_UNIXSTREAM) { struct sockaddr_un srcsockaddr; /* Unix stream create */ memset(&srcsockaddr,0,sizeof(srcsockaddr)); if (strlen(src) + 1 > sizeof(srcsockaddr.sun_path)) { ret=ERR_VAL; goto err_free; } sl_item->srcport=srcport; strcpy(sl_item->src.srcpath,src); s=socket(AF_UNIX, SOCK_STREAM, 0); if (s < 0) { ret=ERR_CONN; goto err_free; } LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_add: new unix socket %d\n", s)); srcsockaddr.sun_family=AF_UNIX; strcpy(srcsockaddr.sun_path,src); /* Unix stream bind */ if(bind(s, (struct sockaddr *) &srcsockaddr, sizeof(srcsockaddr)) < 0) { ret=ERR_CONN; goto err_close; } LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_add: unix socket %d bound to the local address/port %d\n", s, srcport)); } else { ret=ERR_ARG; goto err_free; } /* connection oriented forwarding services need listen */ if ((conntype == SLIRP_LISTEN_TCP || conntype == SLIRP_LISTEN_UNIXSTREAM)) { if (listen(s,5) < 0) { ret=ERR_CONN; goto err_close; } LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_add: stream socket %d listen ok\n", s)); } /* add the fd descriptor */ if (netif_addfd(slirpif, s, slirp_listen_cb, sl_item, flags, POLLIN) < 0) { ret=ERR_CONN; goto err_close; } LWIP_DEBUGF(LWSLIRP_DEBUG, ("slirp_listen_add: stream socket %d listen ok\n", s)); return ERR_OK; err_close: close(s); err_free: mem_free(sl_item); return ERR_CONN; } #if 0 /* to be updated */ static inline int slirp_listen_delpos(struct stack *stack, int pos) { close(stack->netif_pfd[pos].fd); if (stack->netif_pfd_args[pos].funarg != NULL) mem_free(stack->netif_pfd_args[pos].funarg); netif_delfd(stack,pos); return 0; } int lwip_slirp_listen_del(struct netif *slirpif, struct ip_addr *dest, int destport, void *src, int srcport, int flags) { /* APP THREAD */ struct stack *stack=slirpif->stack; int n; int ret; PRINTTHREAD("lwip_slirp_listen_del"); for (n=0; nnetif_npfd && stack->netif_pfd[n].fd >= 0; n++) { struct slirp_listen *sl=stack->netif_pfd_args[n].funarg; int conntype=stack->netif_pfd_args[n].flags & SLIRP_LISTEN_TYPEMASK; if ((flags & SLIRP_LISTEN_TYPEMASK) == (conntype & SLIRP_LISTEN_TYPEMASK) && (ip_addr_cmp(dest,&sl->destaddr)==0) && destport == sl->destport && srcport == sl->srcport && (conntype == SLIRP_LISTEN_UNIXSTREAM) ? (strcmp(src,sl->src.srcpath)==0) : (memcmp(src,&sl->src.srcaddr,sizeof(struct ip_addr))==0)) { return slirp_listen_delpos(stack,n); } } return ERR_VAL; } #endif #if LWSLIRP_DEBUG void slirp_debug_print_state(int debk, struct tcp_pcb *pcb) { int i = 0; LWIP_DEBUGF(debk, ("Socket States: ")); if ((pcb->slirp_state & SS_NOFDREF) == SS_NOFDREF) LWIP_DEBUGF(debk, ("%sSS_NOFDREF", i++ > 0 ? ", " : "")); if ((pcb->slirp_state & SS_ISFCONNECTING) == SS_ISFCONNECTING) LWIP_DEBUGF(debk, ("SS_ISFCONNECTING%s", i++ > 0 ? ", " : "")); if ((pcb->slirp_state & SS_ISFCONNECTED) == SS_ISFCONNECTED) LWIP_DEBUGF(debk, ("SS_ISFCONNECTED%s", i++ > 0 ? ", " : "")); if ((pcb->slirp_state & SS_FCANTRCVMORE) == SS_FCANTRCVMORE) LWIP_DEBUGF(debk, ("SS_FCANTRCVMORE%s", i++ > 0 ? ", " : "")); if ((pcb->slirp_state & SS_FCANTSENDMORE) == SS_FCANTSENDMORE) LWIP_DEBUGF(debk, ("SS_FCANTSENDMORE%s", i++ > 0 ? ", " : "")); if ((pcb->slirp_state & SS_FWDRAIN) == SS_FWDRAIN) LWIP_DEBUGF(debk, ("SS_FWDRAIN%s", i++ > 0 ? ", " : "")); if ((pcb->slirp_state & SS_CTL) == SS_CTL) LWIP_DEBUGF(debk, ("SS_CTL%s", i++ > 0 ? ", " : "")); if ((pcb->slirp_state & SS_FACCEPTCONN) == SS_FACCEPTCONN) LWIP_DEBUGF(debk, ("SS_FACCEPTCONN%s", i++ > 0 ? ", " : "")); if ((pcb->slirp_state & SS_FACCEPTONCE) == SS_FACCEPTONCE) LWIP_DEBUGF(debk, ("SS_FACCEPTONCE%s", i++ > 0 ? ", " : "")); if(i == 0) LWIP_DEBUGF(debk, ("NO FLAG SET")); } #endif /* LWSLIRP_DEBUG */ #endif lwipv6-1.5a/lwip-v6/src/core/memp_dynmalloc.c0000644000175000017500000001432511671615010020215 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/opt.h" #include "lwip/memp.h" #include "lwip/pbuf.h" #include "lwip/udp.h" #include "lwip/raw.h" #include "lwip/tcp.h" #include "lwip/api.h" #include "lwip/tcpip.h" #include "lwip/sys.h" #include "lwip/stats.h" /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT #include "lwip/nat/nat.h" #endif struct memp { struct memp *next; }; static struct memp *memp_tab[MEMP_MAX]; static const u16_t memp_sizes[MEMP_MAX] = { MEM_ALIGN_SIZE(sizeof(struct pbuf)), MEM_ALIGN_SIZE(sizeof(struct raw_pcb)), MEM_ALIGN_SIZE(sizeof(struct udp_pcb)), MEM_ALIGN_SIZE(sizeof(struct tcp_pcb)), MEM_ALIGN_SIZE(sizeof(struct tcp_pcb_listen)), MEM_ALIGN_SIZE(sizeof(struct tcp_seg)), MEM_ALIGN_SIZE(sizeof(struct netbuf)), MEM_ALIGN_SIZE(sizeof(struct netconn)), MEM_ALIGN_SIZE(sizeof(struct tcpip_msg)), MEM_ALIGN_SIZE(sizeof(struct sys_timeout)), MEM_ALIGN_SIZE(sizeof(struct ip_route_list)), MEM_ALIGN_SIZE(sizeof(struct ip_addr_list)), MEM_ALIGN_SIZE(sizeof(struct netif_fddata)), #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION , MEM_ALIGN_SIZE(sizeof(struct ip_reassbuf)) #endif /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT , MEM_ALIGN_SIZE(sizeof(struct nat_pcb)), MEM_ALIGN_SIZE(sizeof(struct nat_rule)) #endif }; static const u16_t memp_num[MEMP_MAX] = { MEMP_NUM_PBUF, MEMP_NUM_RAW_PCB, MEMP_NUM_UDP_PCB, MEMP_NUM_TCP_PCB, MEMP_NUM_TCP_PCB_LISTEN, MEMP_NUM_TCP_SEG, MEMP_NUM_NETBUF, MEMP_NUM_NETCONN, MEMP_NUM_TCPIP_MSG, MEMP_NUM_SYS_TIMEOUT, MEMP_NUM_ROUTES, MEMP_NUM_ADDRS, MEMP_NUM_REASS /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT , MEMP_NUM_NAT_PCB, MEMP_NUM_NAT_RULE #endif }; #if !SYS_LIGHTWEIGHT_PROT static sys_sem_t mutex; #endif static struct memp *memp_newpool(int type) { LWIP_DEBUGF(MEMP_DEBUG, ("memp_malloc: newpool %d\n", type)); LWIP_ASSERT("memp_newpool: size < sizeof(*)", memp_sizes[type] >= sizeof (void *)); char *newpool=(char *)malloc(memp_sizes[type]*memp_num[type]); if (newpool == NULL) return NULL; else { char *p=newpool; int i; for (i=0;inext)=(struct memp *)(p+memp_sizes[type])); ((struct memp *)p)->next = NULL; return (struct memp *) newpool; } } void memp_init(void) { u16_t i; #if MEMP_STATS for(i = 0; i < MEMP_MAX; ++i) { lwip_stats.memp[i].used = lwip_stats.memp[i].max = lwip_stats.memp[i].err = 0; lwip_stats.memp[i].avail = memp_num[i]; } #endif /* MEMP_STATS */ for (i=0; inext; #if MEMP_STATS ++lwip_stats.memp[type].used; if (lwip_stats.memp[type].used > lwip_stats.memp[type].max) { lwip_stats.memp[type].max = lwip_stats.memp[type].used; } #endif /* MEMP_STATS */ #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ LWIP_DEBUGF(MEMP_DEBUG, ("memp_malloc: malloc %d %p\n", type,memp)); return (void *) memp; } else { LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type)); #if MEMP_STATS ++lwip_stats.memp[type].err; #endif /* MEMP_STATS */ #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ return NULL; } } void memp_free(memp_t type, void *mem) { struct memp *memp; LWIP_DEBUGF(MEMP_DEBUG, ("memp_free: free %d %p\n", type, mem)); #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_DECL_PROTECT(old_level); #endif /* SYS_LIGHTWEIGHT_PROT */ if (mem == NULL) { return; } memp = (struct memp *)(mem); #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_PROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_wait(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ #if MEMP_STATS lwip_stats.memp[type].used--; #endif /* MEMP_STATS */ memp->next = memp_tab[type]; memp_tab[type] = memp; #if MEMP_SANITY_CHECK LWIP_ASSERT("memp sanity", memp_sanity()); #endif #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ } lwipv6-1.5a/lwip-v6/src/core/tcp_out.c0000644000175000017500000005736611671615010016706 0ustar renzorenzo/** * @file * * Transmission Control Protocol, outgoing traffic */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2010,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include /* tcp_output.c * * The output functions of TCP. * */ #include "lwip/def.h" #include "lwip/opt.h" #include "lwip/mem.h" #include "lwip/memp.h" #include "lwip/sys.h" #include "lwip/netif.h" #include "lwip/inet.h" #include "lwip/tcp.h" #include "lwip/stats.h" #if LWIP_TCP /* Forward declarations.*/ static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb); err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags) { /* no data, no length, flags, copy=1, no optdata, no optdatalen */ return tcp_enqueue(pcb, NULL, 0, flags, 1, NULL, 0); } /** * Write data for sending (but does not send it immediately). * * It waits in the expectation of more data being sent soon (as * it can send them more efficiently by combining them together). * To prompt the system to send data now, call tcp_output() after * calling tcp_write(). * * @arg pcb Protocol control block of the TCP connection to enqueue data for. * * @see tcp_write() */ err_t tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, arg=%p, len=%u, copy=%d)\n", (void *)pcb, arg, len, (unsigned int)copy)); /* connection is in valid state for data transmission? */ if (pcb->state == ESTABLISHED || pcb->state == CLOSE_WAIT || pcb->state == SYN_SENT || pcb->state == SYN_RCVD) { if (len > 0) { return tcp_enqueue(pcb, (void *)arg, len, 0, copy, NULL, 0); } return ERR_OK; } else { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_STATE | 3, ("tcp_write() called in invalid state\n")); return ERR_CONN; } } /** * Enqueue either data or TCP options (but not both) for tranmission * * * * @arg pcb Protocol control block for the TCP connection to enqueue data for. * @arg arg Pointer to the data to be enqueued for sending. * @arg len Data length in bytes * @arg flags * @arg copy 1 if data must be copied, 0 if data is non-volatile and can be * referenced. * @arg optdata * @arg optlen */ err_t tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len, u8_t flags, u8_t copy, u8_t *optdata, u8_t optlen) { struct pbuf *p; struct tcp_seg *seg, *useg, *queue; u32_t left, seqno; u16_t seglen; void *ptr; u8_t queuelen; LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue(pcb=%p, arg=%p, len=%u, flags=%x, copy=%u)\n", (void *)pcb, arg, len, (unsigned int)flags, (unsigned int)copy)); LWIP_ASSERT("tcp_enqueue: len == 0 || optlen == 0 (programmer violates API)", len == 0 || optlen == 0); LWIP_ASSERT("tcp_enqueue: arg == NULL || optdata == NULL (programmer violates API)", arg == NULL || optdata == NULL); /* fail on too much data */ if (len > pcb->snd_buf) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too much data (len=%u > snd_buf=%u)\n", len, pcb->snd_buf)); return ERR_MEM; } left = len; ptr = arg; /* seqno will be the sequence number of the first segment enqueued * by the call to this function. */ seqno = pcb->snd_lbb; LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: queuelen: %u\n", (unsigned int)pcb->snd_queuelen)); /* If total number of pbufs on the unsent/unacked queues exceeds the * configured maximum, return an error */ queuelen = pcb->snd_queuelen; if (queuelen >= TCP_SND_QUEUELEN) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too long queue %u (max %u)\n", queuelen, TCP_SND_QUEUELEN)); TCP_STATS_INC(tcp.memerr); return ERR_MEM; } if (queuelen != 0) { LWIP_ASSERT("tcp_enqueue: pbufs on queue => at least one queue non-empty", pcb->unacked != NULL || pcb->unsent != NULL); } else { LWIP_ASSERT("tcp_enqueue: no pbufs on queue => both queues empty", pcb->unacked == NULL && pcb->unsent == NULL); } /* First, break up the data into segments and tuck them together in * the local "queue" variable. */ useg = queue = seg = NULL; seglen = 0; while (queue == NULL || left > 0) { /* The segment length should be the MSS if the data to be enqueued * is larger than the MSS. */ seglen = left > pcb->mss? pcb->mss: left; /* Allocate memory for tcp_seg, and fill in fields. */ seg = memp_malloc(MEMP_TCP_SEG); if (seg == NULL) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for tcp_seg\n")); goto memerr; } seg->next = NULL; seg->p = NULL; /* first segment of to-be-queued data? */ if (queue == NULL) { queue = seg; } /* subsequent segments of to-be-queued data */ else { /* Attach the segment to the end of the queued segments */ LWIP_ASSERT("useg != NULL", useg != NULL); useg->next = seg; } /* remember last segment of to-be-queued data for next iteration */ useg = seg; /* If copy is set, memory should be allocated * and data copied into pbuf, otherwise data comes from * ROM or other static memory, and need not be copied. If * optdata is != NULL, we have options instead of data. */ /* options? */ if (optdata != NULL) { if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, optlen, PBUF_RAM)) == NULL) { goto memerr; } ++queuelen; seg->dataptr = seg->p->payload; } /* copy from volatile memory? */ else if (copy) { if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue : could not allocate memory for pbuf copy size %u\n", seglen)); goto memerr; } ++queuelen; if (arg != NULL) { memcpy(seg->p->payload, ptr, seglen); } seg->dataptr = seg->p->payload; } /* do not copy data */ else { /* First, allocate a pbuf for holding the data. * since the referenced data is available at least until it is sent out on the * link (as it has to be ACKed by the remote party) we can safely use PBUF_ROM * instead of PBUF_REF here. */ if ((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for zero-copy pbuf\n")); goto memerr; } ++queuelen; /* reference the non-volatile payload data */ p->payload = ptr; seg->dataptr = ptr; /* Second, allocate a pbuf for the headers. */ if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_RAM)) == NULL) { /* If allocation fails, we have to deallocate the data pbuf as * well. */ pbuf_free(p); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for header pbuf\n")); goto memerr; } ++queuelen; /* Concatenate the headers and data pbufs together. */ pbuf_cat(seg->p/*header*/, p/*data*/); p = NULL; } /* Now that there are more segments queued, we check again if the length of the queue exceeds the configured maximum. */ if (queuelen > TCP_SND_QUEUELEN) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: queue too long %u (%u)\n", queuelen, TCP_SND_QUEUELEN)); goto memerr; } seg->len = seglen; /* build TCP header */ if (pbuf_header(seg->p, TCP_HLEN)) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: no room for TCP header in pbuf.\n")); TCP_STATS_INC(tcp.err); goto memerr; } seg->tcphdr = seg->p->payload; seg->tcphdr->src = htons(pcb->local_port); seg->tcphdr->dest = htons(pcb->remote_port); seg->tcphdr->seqno = htonl(seqno); seg->tcphdr->urgp = 0; TCPH_FLAGS_SET(seg->tcphdr, flags); /* don't fill in tcphdr->ackno and tcphdr->wnd until later */ /* Copy the options into the header, if they are present. */ if (optdata == NULL) { TCPH_HDRLEN_SET(seg->tcphdr, 5); } else { TCPH_HDRLEN_SET(seg->tcphdr, (5 + optlen / 4)); /* Copy options into data portion of segment. Options can thus only be sent in non data carrying segments such as SYN|ACK. */ memcpy(seg->dataptr, optdata, optlen); } LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE, ("tcp_enqueue: queueing %lu:%lu (0x%x)\n", ntohl(seg->tcphdr->seqno), ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg), flags)); left -= seglen; seqno += seglen; ptr = (void *)((char *)ptr + seglen); } /* Now that the data to be enqueued has been broken up into TCP segments in the queue variable, we add them to the end of the pcb->unsent queue. */ if (pcb->unsent == NULL) { useg = NULL; } else { for (useg = pcb->unsent; useg->next != NULL; useg = useg->next); } /* { useg is last segment on the unsent queue, NULL if list is empty } */ /* If there is room in the last pbuf on the unsent queue, chain the first pbuf on the queue together with that. */ if (useg != NULL && TCP_TCPLEN(useg) != 0 && !(TCPH_FLAGS(useg->tcphdr) & (TCP_SYN | TCP_FIN)) && !(flags & (TCP_SYN | TCP_FIN)) && /* fit within max seg size */ useg->len + queue->len <= pcb->mss) { /* Remove TCP header from first segment of our to-be-queued list */ pbuf_header(queue->p, -TCP_HLEN); pbuf_cat(useg->p, queue->p); useg->len += queue->len; useg->next = queue->next; LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE | DBG_STATE, ("tcp_enqueue: chaining segments, new len %u\n", useg->len)); if (seg == queue) { seg = NULL; } memp_free(MEMP_TCP_SEG, queue); } else { /* empty list */ if (useg == NULL) { /* initialize list with this segment */ pcb->unsent = queue; } /* enqueue segment */ else { useg->next = queue; } } if ((flags & TCP_SYN) || (flags & TCP_FIN)) { ++len; } pcb->snd_lbb += len; /* FIX: Data split over odd boundaries */ pcb->snd_buf -= ((len+1) & ~0x1); /* Even the send buffer */ /* update number of segments on the queues */ pcb->snd_queuelen = queuelen; LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: %d (after enqueued)\n", pcb->snd_queuelen)); if (pcb->snd_queuelen != 0) { LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL || pcb->unsent != NULL); } /* Set the PSH flag in the last segment that we enqueued, but only if the segment has data (indicated by seglen > 0). */ if (seg != NULL && seglen > 0 && seg->tcphdr != NULL) { TCPH_SET_FLAG(seg->tcphdr, TCP_PSH); } return ERR_OK; memerr: TCP_STATS_INC(tcp.memerr); if (queue != NULL) { tcp_segs_free(queue); } if (pcb->snd_queuelen != 0) { LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL || pcb->unsent != NULL); } LWIP_DEBUGF(TCP_QLEN_DEBUG | DBG_STATE, ("tcp_enqueue: %d (with mem err)\n", pcb->snd_queuelen)); return ERR_MEM; } /* find out what we can send and send it */ err_t tcp_output(struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; struct pbuf *p; struct tcp_hdr *tcphdr; struct tcp_seg *seg, *useg; u32_t wnd; #if TCP_CWND_DEBUG int i = 0; #endif /* TCP_CWND_DEBUG */ /* First, check if we are invoked by the TCP input processing code. If so, we do not output anything. Instead, we rely on the input processing code to call us when input processing is done with. */ if (stack->tcp_input_pcb == pcb) { return ERR_OK; } wnd = LWIP_MIN(pcb->snd_wnd, pcb->cwnd); seg = pcb->unsent; /* useg should point to last segment on unacked queue */ useg = pcb->unacked; if (useg != NULL) { for (; useg->next != NULL; useg = useg->next); } /* If the TF_ACK_NOW flag is set and no data will be sent (either * because the ->unsent queue is empty or because the window does * not allow it), construct an empty ACK segment and send it. * * If data is to be sent, we will just piggyback the ACK (see below). */ if (pcb->flags & TF_ACK_NOW && (seg == NULL || ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len > wnd)) { p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); if (p == NULL) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n")); return ERR_BUF; } LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: sending ACK for %lu\n", pcb->rcv_nxt)); /* remove ACK flags from the PCB, as we send an empty ACK now */ pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); tcphdr = p->payload; tcphdr->src = htons(pcb->local_port); tcphdr->dest = htons(pcb->remote_port); tcphdr->seqno = htonl(pcb->snd_nxt); tcphdr->ackno = htonl(pcb->rcv_nxt); TCPH_FLAGS_SET(tcphdr, TCP_ACK); tcphdr->wnd = htons(pcb->rcv_wnd); tcphdr->urgp = 0; TCPH_HDRLEN_SET(tcphdr, 5); tcphdr->chksum = 0; tcphdr->chksum = inet6_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip), IP_PROTO_TCP, p->tot_len); ip_output(stack, p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, IP_PROTO_TCP); pbuf_free(p); return ERR_OK; } #if TCP_OUTPUT_DEBUG if (seg == NULL) { LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", pcb->unsent)); } #endif /* TCP_OUTPUT_DEBUG */ #if TCP_CWND_DEBUG if (seg == NULL) { LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, seg == NULL, ack %lu\n", pcb->snd_wnd, pcb->cwnd, wnd, pcb->lastack)); } else { LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu\n", pcb->snd_wnd, pcb->cwnd, wnd, ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len, ntohl(seg->tcphdr->seqno), pcb->lastack)); } #endif /* TCP_CWND_DEBUG */ /* data available and window allows it to be sent? */ while (seg != NULL && ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { #if TCP_CWND_DEBUG LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu, i%d\n", pcb->snd_wnd, pcb->cwnd, wnd, ntohl(seg->tcphdr->seqno) + seg->len - pcb->lastack, ntohl(seg->tcphdr->seqno), pcb->lastack, i)); ++i; #endif /* TCP_CWND_DEBUG */ pcb->unsent = seg->next; if (pcb->state != SYN_SENT) { TCPH_SET_FLAG(seg->tcphdr, TCP_ACK); pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); } tcp_output_segment(seg, pcb); pcb->snd_nxt = ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg); if (TCP_SEQ_LT(pcb->snd_max, pcb->snd_nxt)) { pcb->snd_max = pcb->snd_nxt; } /* put segment on unacknowledged list if length > 0 */ if (TCP_TCPLEN(seg) > 0) { seg->next = NULL; /* unacked list is empty? */ if (pcb->unacked == NULL) { pcb->unacked = seg; useg = seg; /* unacked list is not empty? */ } else { /********** XXX XXX *********/ if (useg == NULL) printf("??????? race condition error ??? seg useg %p %p\n",seg,useg); /* In the case of fast retransmit, the packet should not go to the tail * of the unacked queue, but rather at the head. We need to check for * this case. -STJ Jul 27, 2004 */ if (TCP_SEQ_LT(ntohl(seg->tcphdr->seqno), ntohl(useg->tcphdr->seqno))){ /* add segment to head of unacked list */ seg->next = pcb->unacked; pcb->unacked = seg; } else { /* add segment to tail of unacked list */ useg->next = seg; useg = useg->next; } } /* do not queue empty segments on the unacked list */ } else { tcp_seg_free(seg); } seg = pcb->unsent; } return ERR_OK; } /** * Actually send a TCP segment over IP */ static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; u16_t len; struct netif *netif; /* The TCP header has already been constructed, but the ackno and wnd fields remain. */ seg->tcphdr->ackno = htonl(pcb->rcv_nxt); /* silly window avoidance */ if (pcb->rcv_wnd < pcb->mss) { seg->tcphdr->wnd = 0; } else { /* advertise our receive window size in this TCP segment */ seg->tcphdr->wnd = htons(pcb->rcv_wnd); } /* If we don't have a local IP address, we get one by calling ip_route(). */ if (ip_addr_isany(&(pcb->local_ip))) { struct ip_addr_list *el; struct ip_addr *nexthop; int flags; /* Get outgoing interface and next hop */ if (ip_route_findpath(stack, &(pcb->remote_ip), &nexthop, &netif, &flags) != ERR_OK) return; /* Get source IP address */ if ((el = ip_route_select_source_ip(netif, &pcb->remote_ip, nexthop)) == NULL) return; ip_addr_set(&(pcb->local_ip), &(el->ipaddr)); } pcb->rtime = 0; if (pcb->rttest == 0) { pcb->rttest = stack->tcp_ticks; pcb->rtseq = ntohl(seg->tcphdr->seqno); LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %lu\n", pcb->rtseq)); } LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %lu:%lu\n", htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) + seg->len)); len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload); seg->p->len -= len; seg->p->tot_len -= len; seg->p->payload = seg->tcphdr; seg->tcphdr->chksum = 0; seg->tcphdr->chksum = inet6_chksum_pseudo(seg->p, &(pcb->local_ip), &(pcb->remote_ip), IP_PROTO_TCP, seg->p->tot_len); TCP_STATS_INC(tcp.xmit); ip_output(stack, seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos, IP_PROTO_TCP); } void tcp_rst(struct stack *stack, u32_t seqno, u32_t ackno, struct ip_addr *local_ip, struct ip_addr *remote_ip, u16_t local_port, u16_t remote_port) { struct pbuf *p; struct tcp_hdr *tcphdr; p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); if (p == NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n")); return; } #if 0 fprintf(stderr, "RESET! %x %x %x %x:%d %x %x %x %x %d\n", local_ip->addr[0], local_ip->addr[1], local_ip->addr[2], local_ip->addr[3], local_port, remote_ip->addr[0], remote_ip->addr[1], remote_ip->addr[2], remote_ip->addr[3], remote_port); #endif tcphdr = p->payload; tcphdr->src = htons(local_port); tcphdr->dest = htons(remote_port); tcphdr->seqno = htonl(seqno); tcphdr->ackno = htonl(ackno); TCPH_FLAGS_SET(tcphdr, TCP_RST | TCP_ACK); tcphdr->wnd = htons(TCP_WND); tcphdr->urgp = 0; TCPH_HDRLEN_SET(tcphdr, 5); tcphdr->chksum = 0; tcphdr->chksum = inet6_chksum_pseudo(p, local_ip, remote_ip, IP_PROTO_TCP, p->tot_len); TCP_STATS_INC(tcp.xmit); /* Send output with hardcoded TTL since we have no access to the pcb */ ip_output(stack, p, local_ip, remote_ip, TCP_TTL, 0, IP_PROTO_TCP); pbuf_free(p); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %lu ackno %lu.\n", seqno, ackno)); } /* requeue all unacked segments for retransmission */ void tcp_rexmit_rto(struct tcp_pcb *pcb) { struct tcp_seg *seg; if (pcb->unacked == NULL) { return; } /* Move all unacked segments to the head of the unsent queue */ for (seg = pcb->unacked; seg->next != NULL; seg = seg->next); /* concatenate unsent queue after unacked queue */ seg->next = pcb->unsent; /* unsent queue is the concatenated queue (of unacked, unsent) */ pcb->unsent = pcb->unacked; /* unacked queue is now empty */ pcb->unacked = NULL; pcb->snd_nxt = ntohl(pcb->unsent->tcphdr->seqno); /* increment number of retransmissions */ ++pcb->nrtx; /* Don't take any RTT measurements after retransmitting. */ pcb->rttest = 0; /* Do the actual retransmission */ tcp_output(pcb); } void tcp_rexmit(struct tcp_pcb *pcb) { struct tcp_seg *seg; if (pcb->unacked == NULL) { return; } /* Move the first unacked segment to the unsent queue */ seg = pcb->unacked->next; pcb->unacked->next = pcb->unsent; pcb->unsent = pcb->unacked; pcb->unacked = seg; pcb->snd_nxt = ntohl(pcb->unsent->tcphdr->seqno); ++pcb->nrtx; /* Don't take any rtt measurements after retransmitting. */ pcb->rttest = 0; /* Do the actual retransmission. */ tcp_output(pcb); } void tcp_keepalive(struct tcp_pcb *pcb) { struct stack *stack = pcb->stack; struct pbuf *p; struct tcp_hdr *tcphdr; #ifndef IPv6 LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: sending KEEPALIVE probe to %u.%u.%u.%u\n", ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip))); #endif LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: tcp_ticks %lu pcb->tmr %lu pcb->keep_cnt %u\n", stack->tcp_ticks, pcb->tmr, pcb->keep_cnt)); p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); if(p == NULL) { LWIP_DEBUGF(TCP_DEBUG, ("tcp_keepalive: could not allocate memory for pbuf\n")); return; } tcphdr = p->payload; tcphdr->src = htons(pcb->local_port); tcphdr->dest = htons(pcb->remote_port); tcphdr->seqno = htonl(pcb->snd_nxt - 1); tcphdr->ackno = htonl(pcb->rcv_nxt); tcphdr->wnd = htons(pcb->rcv_wnd); tcphdr->urgp = 0; TCPH_HDRLEN_SET(tcphdr, 5); tcphdr->chksum = 0; tcphdr->chksum = inet6_chksum_pseudo(p, &pcb->local_ip, &pcb->remote_ip, IP_PROTO_TCP, p->tot_len); TCP_STATS_INC(tcp.xmit); /* Send output to IP */ ip_output(stack, p, &pcb->local_ip, &pcb->remote_ip, pcb->ttl, 0, IP_PROTO_TCP); pbuf_free(p); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_keepalive: seqno %lu ackno %lu.\n", pcb->snd_nxt - 1, pcb->rcv_nxt)); } #endif /* LWIP_TCP */ lwipv6-1.5a/lwip-v6/src/core/stats.c0000644000175000017500000001013711671615007016356 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/stats.h" #include "lwip/mem.h" #if LWIP_STATS struct stats_ lwip_stats; void stats_init(void) { memset(&lwip_stats, 0, sizeof(struct stats_)); } #if LWIP_STATS_DISPLAY void stats_display_proto(struct stats_proto *proto, char *name) { LWIP_PLATFORM_DIAG(("\n%s\n\t", name)); LWIP_PLATFORM_DIAG(("xmit: %d\n\t", proto->xmit)); LWIP_PLATFORM_DIAG(("rexmit: %d\n\t", proto->rexmit)); LWIP_PLATFORM_DIAG(("recv: %d\n\t", proto->recv)); LWIP_PLATFORM_DIAG(("fw: %d\n\t", proto->fw)); LWIP_PLATFORM_DIAG(("drop: %d\n\t", proto->drop)); LWIP_PLATFORM_DIAG(("chkerr: %d\n\t", proto->chkerr)); LWIP_PLATFORM_DIAG(("lenerr: %d\n\t", proto->lenerr)); LWIP_PLATFORM_DIAG(("memerr: %d\n\t", proto->memerr)); LWIP_PLATFORM_DIAG(("rterr: %d\n\t", proto->rterr)); LWIP_PLATFORM_DIAG(("proterr: %d\n\t", proto->proterr)); LWIP_PLATFORM_DIAG(("opterr: %d\n\t", proto->opterr)); LWIP_PLATFORM_DIAG(("err: %d\n\t", proto->err)); LWIP_PLATFORM_DIAG(("cachehit: %d\n", proto->cachehit)); } void stats_display_pbuf(struct stats_pbuf *pbuf) { LWIP_PLATFORM_DIAG(("\nPBUF\n\t")); LWIP_PLATFORM_DIAG(("avail: %d\n\t", pbuf->avail)); LWIP_PLATFORM_DIAG(("used: %d\n\t", pbuf->used)); LWIP_PLATFORM_DIAG(("max: %d\n\t", pbuf->max)); LWIP_PLATFORM_DIAG(("err: %d\n\t", pbuf->err)); LWIP_PLATFORM_DIAG(("alloc_locked: %d\n\t", pbuf->alloc_locked)); LWIP_PLATFORM_DIAG(("refresh_locked: %d\n", pbuf->refresh_locked)); } void stats_display_mem(struct stats_mem *mem, char *name) { LWIP_PLATFORM_DIAG(("\n MEM %s\n\t", name)); LWIP_PLATFORM_DIAG(("avail: %d\n\t", mem->avail)); LWIP_PLATFORM_DIAG(("used: %d\n\t", mem->used)); LWIP_PLATFORM_DIAG(("max: %d\n\t", mem->max)); LWIP_PLATFORM_DIAG(("err: %d\n", mem->err)); } void stats_display(void) { int i; char * memp_names[] = {"PBUF", "RAW_PCB", "UDP_PCB", "TCP_PCB", "TCP_PCB_LISTEN", "TCP_SEG", "NETBUF", "NETCONN", "API_MSG", "TCP_MSG", "TIMEOUT"}; stats_display_proto(&lwip_stats.link, "LINK"); stats_display_proto(&lwip_stats.ip_frag, "IP_FRAG"); stats_display_proto(&lwip_stats.ip, "IP"); stats_display_proto(&lwip_stats.icmp, "ICMP"); stats_display_proto(&lwip_stats.udp, "UDP"); stats_display_proto(&lwip_stats.tcp, "TCP"); stats_display_pbuf(&lwip_stats.pbuf); stats_display_mem(&lwip_stats.mem, "HEAP"); for (i = 0; i < MEMP_MAX; i++) { stats_display_mem(&lwip_stats.memp[i], memp_names[i]); } } #endif /* LWIP_STATS_DISPLAY */ #endif /* LWIP_STATS */ lwipv6-1.5a/lwip-v6/src/core/mem_malloc.c0000644000175000017500000001702411671615010017321 0ustar renzorenzo/** @file * * Dynamic memory manager * */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include #include "lwip/arch.h" #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/mem.h" #include "lwip/sys.h" #include "lwip/stats.h" /* * FIX: If you want to use these functions malloc() and free() * implementation MUST be thread safe. */ #ifndef DEBUGMEM void mem_init(void) { } void mem_free(void *rmem) { free(rmem); } void * mem_reallocm(void *rmem, mem_size_t newsize) { return (realloc(rmem,newsize)); } void * mem_realloc(void *rmem, mem_size_t newsize) { return (realloc(rmem,newsize)); } void * mem_malloc(mem_size_t size) { return (malloc(size)); } #else struct mem_check { void *addr; mem_size_t size; char *file; int line; /*positive if allocated */ }; struct mem_stat { int count; char *file; int line; /*positive if allocated */ }; #define MEMCHECKSIZE 32768 #define STATSIZE 1024 struct mem_check table[MEMCHECKSIZE]; struct mem_stat stat[STATSIZE]; void mem_d_init(char *__file,int __line) { } void mem_d_free(void *rmem,char *__file,int __line) { int i; for (i=0; i 0) { fprintf(stderr, "MALLOC DOUBLE ALLOCATION %s %d and %s %d\n",__file,__line, table[i].file, table[i].line); } table[i].file=__file; table[i].line=__line; break; } if (rv >= table[i].addr && rv < table[i].addr + table[i].size) { if (table[i].line > 0) { fprintf(stderr, "MALLOC OVERLAP %s %d and %s %d\n",__file,__line, table[i].file, table[i].line); } } if (table[i].addr >= rv && table[i].addr < rv + size) { if (table[i].line > 0) { fprintf(stderr, "MALLOC OVERLAP2 %s %d and %s %d\n",__file,__line, table[i].file, table[i].line); } } if (table[i].addr == 0) { table[i].addr=rv; table[i].file=__file; table[i].line=__line; if ((i % 1024) == 1023) { int allocated, freed; int j; for (i=0; i 0) { for (j=0; j0 ;j++) fprintf(stderr, " count %d file %s line %d\n",stat[j].count,stat[j].file,stat[j].line); } break; } } } return rv; } void * mem_d_realloc(void *rmem, mem_size_t newsize,char *__file,int __line) { if (rmem == NULL) return mem_d_malloc(newsize, __file, __line); else { int i; int matchi=-1; void *rv=realloc(rmem,newsize); for (i=0; i 0) { fprintf(stderr, "REALLOC DOUBLE ALLOCATION %s %d and %s %d\n",__file,__line, table[i].file, table[i].line); } table[i].file=__file; table[i].line=__line; break; } if (rv >= table[i].addr && rv < table[i].addr + table[i].size) { if (table[i].line > 0) { fprintf(stderr, "REALLOC OVERLAPS %s %d and %s %d\n",__file,__line, table[i].file, table[i].line); } } if (table[i].addr >= rv && table[i].addr < rv + newsize) { if (table[i].line > 0) { fprintf(stderr, "MALLOC OVERLAP2 %s %d and %s %d\n",__file,__line, table[i].file, table[i].line); } } if (table[i].addr == rmem) { if (table[i].line < 0) { fprintf(stderr, "REALLOC FREED ADDR %s %d and %s %d\n",__file,__line, table[i].file, -table[i].line); } table[i].file=__file; table[i].line=__line; table[i].size=newsize; table[i].addr=rv; matchi=i; } if (table[i].addr == 0) { if (matchi < 0) fprintf(stderr, "REALLOC not allocated addr %s %d\n",__file,__line); break; } } return rv; } } void * mem_d_reallocm(void *rmem, mem_size_t newsize,char *__file,int __line) { return mem_d_realloc(rmem,newsize,__file,__line); } #endif lwipv6-1.5a/lwip-v6/src/core/pbufnopool.c0000644000175000017500000006577311671615010017415 0ustar renzorenzo/** * @file * Packet buffer management * * Packets are built from the pbuf data structure. It supports dynamic * memory allocation for packet contents or can reference externally * managed packet contents both in RAM and ROM. Quick allocation for * incoming packets is provided through pools with fixed sized pbufs. * * A packet may span over multiple pbufs, chained as a singly linked * list. This is called a "pbuf chain". * * Multiple packets may be queued, also using this singly linked list. * This is called a "packet queue". * * So, a packet queue consists of one or more pbuf chains, each of * which consist of one or more pbufs. Currently, queues are only * supported in a limited section of lwIP, this is the etharp queueing * code. Outside of this section no packet queues are supported yet. * * The differences between a pbuf chain and a packet queue are very * precise but subtle. * * The last pbuf of a packet has a ->tot_len field that equals the * ->len field. It can be found by traversing the list. If the last * pbuf of a packet has a ->next field other than NULL, more packets * are on the queue. * * Therefore, looping through a pbuf of a single packet, has an * loop end condition (tot_len == p->len), NOT (next == NULL). */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include "lwip/opt.h" #include "lwip/stats.h" #include "lwip/def.h" #include "lwip/mem.h" #include "lwip/memp.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include "arch/perf.h" #if LWIP_USERFILTER && LWIP_NAT #include "lwip/netif.h" #include "lwip/ip.h" #include "lwip/nat/nat.h" #endif /** * Initializes the pbuf module. * * A large part of memory is allocated for holding the pool of pbufs. * The size of the individual pbufs in the pool is given by the size * parameter, and the number of pbufs in the pool by the num parameter. * * After the memory has been allocated, the pbufs are set up. The * ->next pointer in each pbuf is set up to point to the next pbuf in * the pool. * */ void pbuf_init(void) { } /** * Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). * * The actual memory allocated for the pbuf is determined by the * layer at which the pbuf is allocated and the requested size * (from the size parameter). * * @param flag this parameter decides how and where the pbuf * should be allocated as follows: * * - PBUF_RAM: buffer memory for pbuf is allocated as one large * chunk. This includes protocol headers as well. * - PBUF_ROM: no buffer memory is allocated for the pbuf, even for * protocol headers. Additional headers must be prepended * by allocating another pbuf and chain in to the front of * the ROM pbuf. It is assumed that the memory used is really * similar to ROM in that it is immutable and will not be * changed. Memory which is dynamic should generally not * be attached to PBUF_ROM pbufs. Use PBUF_REF instead. * - PBUF_REF: no buffer memory is allocated for the pbuf, even for * protocol headers. It is assumed that the pbuf is only * being used in a single thread. If the pbuf gets queued, * then pbuf_take should be called to copy the buffer. * - PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from * the pbuf pool that is allocated during pbuf_init(). * (CONVERTED TO PBUF_RAM) * * @return the allocated pbuf. If multiple pbufs where allocated, this * is the first pbuf of a pbuf chain. */ struct pbuf * pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag) { struct pbuf *p; u16_t offset; LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u)\n", length)); /* determine header offset */ offset = 0; switch (l) { case PBUF_TRANSPORT: /* add room for transport (often TCP) layer header */ offset += PBUF_TRANSPORT_HLEN; /* FALLTHROUGH */ case PBUF_IP: /* add room for IP layer header */ offset += PBUF_IP_HLEN; /* FALLTHROUGH */ case PBUF_LINK: /* add room for link layer header */ offset += PBUF_LINK_HLEN; break; case PBUF_RAW: break; default: LWIP_ASSERT("pbuf_alloc: bad pbuf layer", 0); return NULL; } switch (flag) { case PBUF_POOL: case PBUF_RAM: /* If pbuf is to be allocated in RAM, allocate memory for it. */ p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + offset) + MEM_ALIGN_SIZE(length)); if (p == NULL) { return NULL; } /* Set up internal structure of the pbuf. */ p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf) + offset)); p->len = p->tot_len = length; p->next = NULL; p->flags = PBUF_FLAG_RAM; LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); break; /* pbuf references existing (non-volatile static constant) ROM payload? */ case PBUF_ROM: /* pbuf references existing (externally allocated) RAM payload? */ case PBUF_REF: /* only allocate memory for the pbuf structure */ p = memp_malloc(MEMP_PBUF); if (p == NULL) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", flag == PBUF_ROM?"ROM":"REF")); return NULL; } /* caller must set this field properly, afterwards */ p->payload = NULL; p->len = p->tot_len = length; p->next = NULL; p->flags = (flag == PBUF_ROM? PBUF_FLAG_ROM: PBUF_FLAG_REF); break; default: LWIP_ASSERT("pbuf_alloc: erroneous flag", 0); return NULL; } /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT nat_pbuf_init(p); #endif /* set reference count */ p->ref = 1; LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u) == %p\n", length, (void *)p)); return p; } #if PBUF_STATS #define DEC_PBUF_STATS do { --lwip_stats.pbuf.used; } while (0) #else /* PBUF_STATS */ #define DEC_PBUF_STATS #endif /* PBUF_STATS */ /** * Shrink a pbuf chain to a desired length. * * @param p pbuf to shrink. * @param new_len desired new length of pbuf chain * * Depending on the desired length, the first few pbufs in a chain might * be skipped and left unchanged. The new last pbuf in the chain will be * resized, and any remaining pbufs will be freed. * * @note If the pbuf is ROM/REF, only the ->tot_len and ->len fields are adjusted. * @note May not be called on a packet queue. * * @bug Cannot grow the size of a pbuf (chain) (yet). */ void pbuf_realloc(struct pbuf *p, u16_t new_len) { struct pbuf *q; u16_t rem_len; /* remaining length */ s16_t grow; LWIP_ASSERT("pbuf_realloc: sane p->flags", p->flags == PBUF_FLAG_POOL || p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_RAM || p->flags == PBUF_FLAG_REF); /* desired length larger than current length? */ if (new_len >= p->tot_len) { /* enlarging not yet supported */ return; } /* the pbuf chain grows by (new_len - p->tot_len) bytes * (which may be negative in case of shrinking) */ grow = new_len - p->tot_len; /* first, step over any pbufs that should remain in the chain */ rem_len = new_len; q = p; /* should this pbuf be kept? */ while (rem_len > q->len) { /* decrease remaining length by pbuf length */ rem_len -= q->len; /* decrease total length indicator */ q->tot_len += grow; /* proceed to next pbuf in chain */ q = q->next; } /* we have now reached the new last pbuf (in q) */ /* rem_len == desired length for pbuf q */ /* shrink allocated memory for PBUF_RAM */ /* (other types merely adjust their length fields */ if ((q->flags == PBUF_FLAG_RAM) && (rem_len != q->len)) { /* reallocate and adjust the length of the pbuf that will be split */ mem_realloc(q, (u8_t *)q->payload - (u8_t *)q + rem_len); } /* adjust length fields for new last pbuf */ q->len = rem_len; q->tot_len = q->len; /* any remaining pbufs in chain? */ if (q->next != NULL) { /* free remaining pbufs in chain */ pbuf_free(q->next); } /* q is last packet in chain */ q->next = NULL; } /** * Adjusts the payload pointer to hide or reveal headers in the payload. * * Adjusts the ->payload pointer so that space for a header * (dis)appears in the pbuf payload. * * The ->payload, ->tot_len and ->len fields are adjusted. * * @param hdr_size_inc Number of bytes to increment header size which * increases the size of the pbuf. New space is on the front. * (Using a negative value decreases the header size.) * If hdr_size_inc is 0, this function does nothing and returns succesful. * * PBUF_ROM and PBUF_REF type buffers cannot have their sizes increased, so * the call will fail. A check is made that the increase in header size does * not move the payload pointer in front of the start of the buffer. * @return non-zero on failure, zero on success. * */ u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment) { void *payload; LWIP_ASSERT("p != NULL", p != NULL); if ((header_size_increment == 0) || (p == NULL)) return 0; /* remember current payload pointer */ payload = p->payload; /* pbuf types containing payloads? */ if (p->flags == PBUF_FLAG_RAM || p->flags == PBUF_FLAG_POOL) { /* set new payload pointer */ p->payload = (u8_t *)p->payload - header_size_increment; /* boundary check fails? */ if ((u8_t *)p->payload < (u8_t *)p + sizeof(struct pbuf)) { LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_header: failed as %p < %p (not enough space for new header size)\n", (void *)p->payload, (void *)(p + 1)));\ /* restore old payload pointer */ p->payload = payload; /* bail out unsuccesfully */ return 1; } /* pbuf types refering to external payloads? */ } else if (p->flags == PBUF_FLAG_REF || p->flags == PBUF_FLAG_ROM) { /* hide a header in the payload? */ if ((header_size_increment < 0) && (header_size_increment - p->len <= 0)) { /* increase payload pointer */ p->payload = (u8_t *)p->payload - header_size_increment; } else { /* cannot expand payload to front (yet!) * bail out unsuccesfully */ return 1; } } /* modify pbuf length fields */ p->len += header_size_increment; p->tot_len += header_size_increment; LWIP_DEBUGF( PBUF_DEBUG, ("pbuf_header: old %p new %p (%d)\n", (void *)payload, (void *)p->payload, header_size_increment)); return 0; } /** * Dereference a pbuf chain or queue and deallocate any no-longer-used * pbufs at the head of this chain or queue. * * Decrements the pbuf reference count. If it reaches zero, the pbuf is * deallocated. * * For a pbuf chain, this is repeated for each pbuf in the chain, * up to the first pbuf which has a non-zero reference count after * decrementing. So, when all reference counts are one, the whole * chain is free'd. * * @param pbuf The pbuf (chain) to be dereferenced. * * @return the number of pbufs that were de-allocated * from the head of the chain. * * @note MUST NOT be called on a packet queue (Not verified to work yet). * @note the reference counter of a pbuf equals the number of pointers * that refer to the pbuf (or into the pbuf). * * @internal examples: * * Assuming existing chains a->b->c with the following reference * counts, calling pbuf_free(a) results in: * * 1->2->3 becomes ...1->3 * 3->3->3 becomes 2->3->3 * 1->1->2 becomes ......1 * 2->1->1 becomes 1->1->1 * 1->1->1 becomes ....... * */ u8_t pbuf_free(struct pbuf *p) { struct pbuf *q; u8_t count; SYS_ARCH_DECL_PROTECT(old_level); LWIP_ASSERT("p != NULL", p != NULL); /* if assertions are disabled, proceed with debug output */ if (p == NULL) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_free(p == NULL) was called.\n")); return 0; } LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_free(%p)\n", (void *)p)); PERF_START; LWIP_ASSERT("pbuf_free: sane flags", p->flags == PBUF_FLAG_RAM || p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_REF || p->flags == PBUF_FLAG_POOL); count = 0; /* Since decrementing ref cannot be guaranteed to be a single machine operation * we must protect it. Also, the later test of ref must be protected. */ SYS_ARCH_PROTECT(old_level); /* de-allocate all consecutive pbufs from the head of the chain that * obtain a zero reference count after decrementing*/ while (p != NULL) { /* all pbufs in a chain are referenced at least once */ LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0); /* decrease reference count (number of pointers to pbuf) */ p->ref--; /* this pbuf is no longer referenced to? */ if (p->ref == 0) { /* remember next pbuf in chain for next iteration */ q = p->next; /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT nat_pbuf_put(p); #endif LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: deallocating %p\n", (void *)p)); if (p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_REF) { memp_free(MEMP_PBUF, p); /* p->flags == PBUF_FLAG_RAM */ } else { mem_free(p); } count++; /* proceed to next pbuf */ p = q; /* p->ref > 0, this pbuf is still referenced to */ /* (and so the remaining pbufs in chain as well) */ } else { LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: %p has ref %u, ending here.\n", (void *)p, (unsigned int)p->ref)); /* stop walking through the chain */ p = NULL; } } SYS_ARCH_UNPROTECT(old_level); PERF_STOP("pbuf_free"); /* return number of de-allocated pbufs */ return count; } /** * Count number of pbufs in a chain * * @param p first pbuf of chain * @return the number of pbufs in a chain */ u8_t pbuf_clen(struct pbuf *p) { u8_t len; len = 0; while (p != NULL) { ++len; p = p->next; } return len; } /** * Increment the reference count of the pbuf. * * @param p pbuf to increase reference counter of * */ void pbuf_ref(struct pbuf *p) { SYS_ARCH_DECL_PROTECT(old_level); /* pbuf given? */ if (p != NULL) { SYS_ARCH_PROTECT(old_level); ++(p->ref); SYS_ARCH_UNPROTECT(old_level); } } /** * Concatenate two pbufs (each may be a pbuf chain) and take over * the caller's reference of the tail pbuf. * * @note The caller MAY NOT reference the tail pbuf afterwards. * Use pbuf_chain() for that purpose. * * @see pbuf_chain() */ void pbuf_cat(struct pbuf *h, struct pbuf *t) { struct pbuf *p; LWIP_ASSERT("h != NULL (programmer violates API)", h != NULL); LWIP_ASSERT("t != NULL (programmer violates API)", t != NULL); if ((h == NULL) || (t == NULL)) return; /* proceed to last pbuf of chain */ for (p = h; p->next != NULL; p = p->next) { /* add total length of second chain to all totals of first chain */ p->tot_len += t->tot_len; } /* { p is last pbuf of first h chain, p->next == NULL } */ LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); LWIP_ASSERT("p->next == NULL", p->next == NULL); /* add total length of second chain to last pbuf total of first chain */ p->tot_len += t->tot_len; /* chain last pbuf of head (p) with first of tail (t) */ p->next = t; /* p->next now references t, but the caller will drop its reference to t, * so netto there is no change to the reference count of t. */ } /** * Chain two pbufs (or pbuf chains) together. * * The caller MUST call pbuf_free(t) once it has stopped * using it. Use pbuf_cat() instead if you no longer use t. * * @param h head pbuf (chain) * @param t tail pbuf (chain) * @note The pbufs MUST belong to the same packet. * @note MAY NOT be called on a packet queue. * * The ->tot_len fields of all pbufs of the head chain are adjusted. * The ->next field of the last pbuf of the head chain is adjusted. * The ->ref field of the first pbuf of the tail chain is adjusted. * */ void pbuf_chain(struct pbuf *h, struct pbuf *t) { pbuf_cat(h, t); /* t is now referenced by h */ pbuf_ref(t); LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: %p references %p\n", (void *)h, (void *)t)); } /* For packet queueing. Note that queued packets MUST be dequeued first * using pbuf_dequeue() before calling other pbuf_() functions. */ #if ARP_QUEUEING /** * Add a packet to the end of a queue. * * @param q pointer to first packet on the queue * @param n packet to be queued * * Both packets MUST be given, and must be different. */ void pbuf_queue(struct pbuf *p, struct pbuf *n) { #if PBUF_DEBUG /* remember head of queue */ struct pbuf *q = p; #endif /* programmer stupidity checks */ LWIP_ASSERT("p == NULL in pbuf_queue: this indicates a programmer error\n", p != NULL); LWIP_ASSERT("n == NULL in pbuf_queue: this indicates a programmer error\n", n != NULL); LWIP_ASSERT("p == n in pbuf_queue: this indicates a programmer error\n", p != n); if ((p == NULL) || (n == NULL) || (p == n)){ LWIP_DEBUGF(PBUF_DEBUG | DBG_HALT | 3, ("pbuf_queue: programmer argument error\n")); return; } /* iterate through all packets on queue */ while (p->next != NULL) { /* be very picky about pbuf chain correctness */ #if PBUF_DEBUG /* iterate through all pbufs in packet */ while (p->tot_len != p->len) { /* make sure invariant condition holds */ LWIP_ASSERT("p->len < p->tot_len", p->len < p->tot_len); /* make sure each packet is complete */ LWIP_ASSERT("p->next != NULL", p->next != NULL); p = p->next; /* { p->tot_len == p->len => p is last pbuf of a packet } */ } /* { p is last pbuf of a packet } */ /* proceed to next packet on queue */ #endif /* proceed to next pbuf */ if (p->next != NULL) p = p->next; } /* { p->tot_len == p->len and p->next == NULL } ==> * { p is last pbuf of last packet on queue } */ /* chain last pbuf of queue with n */ p->next = n; /* n is now referenced to by the (packet p in the) queue */ pbuf_ref(n); #if PBUF_DEBUG LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_queue: newly queued packet %p sits after packet %p in queue %p\n", (void *)n, (void *)p, (void *)q)); #endif } /** * Remove a packet from the head of a queue. * * The caller MUST reference the remainder of the queue (as returned). The * caller MUST NOT call pbuf_ref() as it implicitly takes over the reference * from p. * * @param p pointer to first packet on the queue which will be dequeued. * @return first packet on the remaining queue (NULL if no further packets). * */ struct pbuf * pbuf_dequeue(struct pbuf *p) { struct pbuf *q; LWIP_ASSERT("p != NULL", p != NULL); /* iterate through all pbufs in packet p */ while (p->tot_len != p->len) { /* make sure invariant condition holds */ LWIP_ASSERT("p->len < p->tot_len", p->len < p->tot_len); /* make sure each packet is complete */ LWIP_ASSERT("p->next != NULL", p->next != NULL); p = p->next; } /* { p->tot_len == p->len } => p is the last pbuf of the first packet */ /* remember next packet on queue in q */ q = p->next; /* dequeue packet p from queue */ p->next = NULL; /* any next packet on queue? */ if (q != NULL) { /* although q is no longer referenced by p, it MUST be referenced by * the caller, who is maintaining this packet queue. So, we do not call * pbuf_free(q) here, resulting in an implicit pbuf_ref(q) for the caller. */ LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: first remaining packet on queue is %p\n", (void *)q)); } else { LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: no further packets on queue\n")); } return q; } #endif /** * * Create PBUF_RAM copies of PBUF_REF pbufs. * * Used to queue packets on behalf of the lwIP stack, such as * ARP based queueing. * * Go through a pbuf chain and replace any PBUF_REF buffers * with PBUF_RAM pbufs, each taking a copy of * the referenced data. * * @note You MUST explicitly use p = pbuf_take(p); * The pbuf you give as argument, may have been replaced * by a (differently located) copy through pbuf_take()! * * @note Any replaced pbufs will be freed through pbuf_free(). * This may deallocate them if they become no longer referenced. * * @param p Head of pbuf chain to process * * @return Pointer to head of pbuf chain */ struct pbuf * pbuf_take(struct pbuf *p) { struct pbuf *q , *prev, *head; LWIP_ASSERT("pbuf_take: p != NULL\n", p != NULL); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)p)); prev = NULL; head = p; /* iterate through pbuf chain */ do { /* pbuf is of type PBUF_REF? */ if (p->flags == PBUF_FLAG_REF) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p)); /* allocate a pbuf (w/ payload) fully in RAM */ q = pbuf_alloc(PBUF_RAW, p->len, PBUF_RAM); if (q == NULL) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_RAM\n")); } /* replacement pbuf could be allocated? */ if (q != NULL) { /* copy p to q */ /* copy successor */ q->next = p->next; /* remove linkage from original pbuf */ p->next = NULL; /* remove linkage to original pbuf */ if (prev != NULL) { /* prev->next == p at this point */ LWIP_ASSERT("prev->next == p", prev->next == p); /* break chain and insert new pbuf instead */ prev->next = q; /* prev == NULL, so we replaced the head pbuf of the chain */ } else { head = q; } /* copy pbuf payload */ memcpy(q->payload, p->payload, p->len); q->tot_len = p->tot_len; q->len = p->len; /* in case p was the first pbuf, it is no longer refered to by * our caller, as the caller MUST do p = pbuf_take(p); * in case p was not the first pbuf, it is no longer refered to * by prev. we can safely free the pbuf here. * (note that we have set p->next to NULL already so that * we will not free the rest of the chain by accident.) */ pbuf_free(p); /* do not copy ref, since someone else might be using the old buffer */ LWIP_DEBUGF(PBUF_DEBUG, ("pbuf_take: replaced PBUF_REF %p with %p\n", (void *)p, (void *)q)); p = q; } else { /* deallocate chain */ pbuf_free(head); LWIP_DEBUGF(PBUF_DEBUG | 2, ("pbuf_take: failed to allocate replacement pbuf for %p\n", (void *)p)); return NULL; } /* p->flags != PBUF_FLAG_REF */ } else { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: skipping pbuf not of type PBUF_REF\n")); } /* remember this pbuf */ prev = p; /* proceed to next pbuf in original chain */ p = p->next; } while (p); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n")); return head; } /** * Dechains the first pbuf from its succeeding pbufs in the chain. * * Makes p->tot_len field equal to p->len. * @param p pbuf to dechain * @return remainder of the pbuf chain, or NULL if it was de-allocated. * @note May not be called on a packet queue. */ struct pbuf * pbuf_dechain(struct pbuf *p) { struct pbuf *q; u8_t tail_gone = 1; /* tail */ q = p->next; /* pbuf has successor in chain? */ if (q != NULL) { /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ LWIP_ASSERT("p->tot_len == p->len + q->tot_len", q->tot_len == p->tot_len - p->len); /* enforce invariant if assertion is disabled */ q->tot_len = p->tot_len - p->len; /* decouple pbuf from remainder */ p->next = NULL; /* total length of pbuf p is its own length only */ p->tot_len = p->len; /* q is no longer referenced by p, free it */ LWIP_DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: unreferencing %p\n", (void *)q)); tail_gone = pbuf_free(q); if (tail_gone > 0) { LWIP_DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *)q)); } /* return remaining tail or NULL if deallocated */ } /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ LWIP_ASSERT("p->tot_len == p->len", p->tot_len == p->len); return (tail_gone > 0? NULL: q); } /* added by Diego Billi */ struct pbuf * pbuf_clone(pbuf_layer l, struct pbuf *p, pbuf_flag flag) { struct pbuf *q, *r; u8_t *ptr; r = pbuf_alloc(l, p->tot_len, PBUF_RAM); if (r != NULL) { ptr = r->payload; for(q = p; q != NULL; q = q->next) { memcpy(ptr, q->payload, q->len); ptr += q->len; } #if LWIP_USERFILTER && LWIP_NAT nat_pbuf_clone(r, p); #endif } return r ; } /* added by Diego Billi */ struct pbuf * pbuf_make_writable(struct pbuf *p) { struct pbuf *r = NULL; if (p->len < p->tot_len) { r = pbuf_clone(PBUF_LINK, p, PBUF_RAM); if (r != NULL) pbuf_free(p); } else r = p; return r; } lwipv6-1.5a/lwip-v6/src/core/packet.c0000644000175000017500000002370011671615010016461 0ustar renzorenzo/** * @file * * Implementation of packet protocol PCBs for low-level handling of * different types of LEVEL 2 protocols besides (or overriding) those * already available in lwIP. * * 2005.06.04 * Send is not complete. * RAW-DGRAM mgmt still missing. * */ /* This is part of LWIPv6 * * Copyright 2005 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Some of the code is still inhrited from the origina LWIP code: * * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/memp.h" #include "lwip/inet.h" #include "lwip/ip_addr.h" #include "lwip/netif.h" #include "lwip/packet.h" #include "netif/etharp.h" #include "lwip/stats.h" #include "arch/perf.h" #include "lwip/snmp.h" #if LWIP_PACKET #define TOS_DGRAM 1 #define TOS_RAW 0 void packet_init(struct stack *stack) { stack->active_pfpacket = 0; stack->packet_pcbs = NULL; } /** * Determine if in incoming IP packet is covered by a PACKET PCB * and if so, pass it to a user-provided receive callback function. * * Given an incoming IP datagram (as a chain of pbufs) this function * finds a corresponding PACKET PCB and calls the corresponding receive * callback function. * * @param pbuf pbuf to be demultiplexed to a PACKET PCB. * @param netif network interface on which the datagram was received. * @Return - 1 if the packet has been eaten by a PACKET PCB receive * callback function. The caller MAY NOT not reference the * packet any longer, and MAY NOT call pbuf_free(). * @return - 0 if packet is not eaten (pbuf is still referenced by the * caller). * */ u8_t packet_input(struct stack *stack, struct pbuf *p,struct sockaddr_ll *sll,u16_t link_header_size) { struct packet_pcb *pcb; u8_t eaten = 0; struct ip_addr ipsll; LWIP_DEBUGF(PACKET_DEBUG, ("packet_input\n")); pcb = stack->packet_pcbs; /* loop through all packet pcbs until the packet is eaten by one */ /* this allows multiple pcbs to match against the packet by design */ while (pcb != NULL) { if ( (IPSADDR_IFINDEX(pcb->local_ip) == 0 || IPSADDR_IFINDEX(pcb->local_ip) == sll->sll_ifindex) && (pcb->in_protocol == ETH_P_ALL || pcb->in_protocol == sll->sll_protocol) ) { /* receive callback function available? */ if (pcb->recv != NULL) { struct pbuf *r, *q; char *ptr; r = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); if (r != NULL) { ptr = r->payload; for(q = p; q != NULL; q = q->next) { memcpy(ptr, q->payload, q->len); ptr += q->len; } SALL2IPADDR(*sll,ipsll); if (pcb->tos == TOS_DGRAM) pbuf_header(r, -link_header_size); pcb->recv(pcb->recv_arg, pcb, r, &ipsll, sll->sll_protocol); } } } pcb = pcb->next; } LWIP_DEBUGF(PACKET_DEBUG, ("packet_input leave\n")); return eaten; } /** * Bind a PACKET PCB. * * @param pcb PACKET PCB to be bound with a local address ipaddr. * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to * bind to all local interfaces. * * @return lwIP error code. * - ERR_OK. Successful. No error occured. * - ERR_USE. The specified IP address is already bound to by * another PACKET PCB. * * @see packet_disconnect() */ err_t packet_bind(struct packet_pcb *pcb, struct ip_addr *ipaddr,u16_t protocol) { ip_addr_set(&pcb->local_ip, ipaddr); pcb->in_protocol=protocol; return ERR_OK; } /** * Connect an PACKET PCB. This function is required by upper layers * of lwip. Using the packet api you could use packet_sendto() instead * * This will associate the PACKET PCB with the remote address. * * @param pcb PACKET PCB to be connected with remote address ipaddr and port. * @param ipaddr remote IP address to connect with. * * @return lwIP error code * * @see packet_disconnect() and packet_sendto() */ err_t packet_connect(struct packet_pcb *pcb, struct ip_addr *ipaddr, u16_t protocol) { ip_addr_set(&pcb->remote_ip, ipaddr); pcb->out_protocol=protocol; return ERR_OK; } /** * Set the callback function for received packets that match the * packet PCB's protocol and binding. * * The callback function MUST either * - eat the packet by calling pbuf_free() and returning non-zero. The * packet will not be passed to other packet PCBs or other protocol layers. * - not free the packet, and return zero. The packet will be matched * against further PCBs and/or forwarded to another protocol layers. * * @return non-zero if the packet was free()d, zero if the packet remains * available for others. */ void packet_recv(struct packet_pcb *pcb, void (* recv)(void *arg, struct packet_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t proto), void *recv_arg) { /* remember recv() callback and user data */ pcb->recv = (void *) recv; pcb->recv_arg = recv_arg; } /** * Send the packet IP packet to the given address. Note that actually you cannot * modify the IP headers (this is inconsistent with the receive callback where * you actually get the IP headers), you can only specify the IP payload here. * It requires some more changes in lwIP. (there will be a packet_send() function * then.) * * @param pcb the packet pcb which to send * @param p the IP payload to send * @param ipaddr the destination address of the IP packet * */ err_t packet_sendto(struct packet_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr, u16_t protocol) { struct stack *stack = pcb->stack; struct sockaddr_ll sll; IPADDR2SALL(*ipaddr, sll); struct netif *netif; /*netif search*/ if ((netif = netif_find_id(stack, IPSADDR_IFINDEX(*ipaddr))) != NULL) return eth_packet_out (netif, p, &sll, protocol, pcb->tos); else return ERR_IF; } /** * Send the raw IP packet to the address given by raw_connect() * * @param pcb the raw pcb which to send * @param p the IP payload to send * @param ipaddr the destination address of the IP packet * */ err_t packet_send(struct packet_pcb *pcb, struct pbuf *p) { return packet_sendto(pcb, p, &pcb->remote_ip, pcb->out_protocol); } /** * Remove an PACKET PCB. * * @param pcb PACKET PCB to be removed. The PCB is removed from the list of * PACKET PCB's and the data structure is freed from memory. * * @see packet_new() */ void packet_remove(struct packet_pcb *pcb) { struct stack *stack = pcb->stack; struct packet_pcb *pcb2; /* pcb to be removed is first in list? */ if (stack->packet_pcbs == pcb) { /* make list start at 2nd pcb */ stack->packet_pcbs = stack->packet_pcbs->next; /* pcb not 1st in list */ } else for(pcb2 = stack->packet_pcbs; pcb2 != NULL; pcb2 = pcb2->next) { /* find pcb in packet_pcbs list */ if (pcb2->next != NULL && pcb2->next == pcb) { /* remove pcb from list */ pcb2->next = pcb->next; } } memp_free(MEMP_PACKET_PCB, pcb); stack->active_pfpacket = (stack->packet_pcbs != NULL); } /** * Create a PACKET PCB. * * @return The PACKET PCB which was created. NULL if the PCB data structure * could not be allocated. * * @param proto the protocol number of the IPs payload (e.g. IP_PROTO_ICMP) * * @see packet_remove() */ struct packet_pcb * packet_new(struct stack *stack, u16_t proto,u16_t dgramflag) { struct packet_pcb *pcb; LWIP_DEBUGF(PACKET_DEBUG | DBG_TRACE | 3, ("packet_new\n")); pcb = memp_malloc(MEMP_PACKET_PCB); /* could allocate PACKET PCB? */ if (pcb != NULL) { /* initialize PCB to all zeroes */ memset(pcb, 0, sizeof(struct packet_pcb)); pcb->stack = stack; #ifdef LWSLIRP pcb->slirp_fddata = NULL; #endif pcb->in_protocol = proto; pcb->next = stack->packet_pcbs; pcb->tos = dgramflag; /* override type of service dgram (1) or raw (0) */ stack->packet_pcbs = pcb; stack->active_pfpacket=1; } return pcb; } #endif /* LWIP_PACKET */ lwipv6-1.5a/lwip-v6/src/core/udp.c0000644000175000017500000007324011671615010016006 0ustar renzorenzo/** * @file * User Datagram Protocol module * */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2010,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* udp.c * * The code for the User Datagram Protocol UDP. * */ #include #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/memp.h" #include "lwip/inet.h" #include "lwip/netif.h" #include "lwip/udp.h" #include "lwip/icmp.h" #include "lwip/ip_addr.h" #include "lwip/stats.h" #include "arch/perf.h" #include "lwip/snmp.h" #include "lwip/lwslirp.h" /* The list of UDP PCBs */ #if LWIP_UDP void udp_init(struct stack *stack) { stack->udp_pcbs = stack->pcb_cache = NULL; } void udp_shutdown(struct stack *stack) { /* FIX: TODO */ } /** * Process an incoming UDP datagram. * * Given an incoming UDP datagram (as a chain of pbufs) this function * finds a corresponding UDP PCB and * * @param pbuf pbuf to be demultiplexed to a UDP PCB. * @param netif network interface on which the datagram was received. * */ void udp_input(struct pbuf *p, struct ip_addr_list *inad,struct pseudo_iphdr *piphdr #ifdef LWSLIRP , struct netif *slirpif #endif ) { struct udp_hdr *udphdr; struct udp_pcb *pcb; struct netif *netif = inad->netif; struct stack *stack = netif->stack; /*struct ip_hdr *iphdr;*/ // struct netif *inp=inad->netif; /* UNUSED? */ u16_t src, dest; void *payloadrestore; #if SO_REUSE struct udp_pcb *pcb_temp; int reuse = 0; int reuse_port_1 = 0; int reuse_port_2 = 0; #endif /* SO_REUSE */ PERF_START; UDP_STATS_INC(udp.recv); payloadrestore=p->payload; /*iphdr = p->payload;*/ /*if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) {*/ if (pbuf_header(p, -((s16_t)(UDP_HLEN + piphdr->iphdrlen)))) { /* drop short packets */ LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len)); UDP_STATS_INC(udp.lenerr); UDP_STATS_INC(udp.drop); snmp_inc_udpinerrors(); pbuf_free(p); goto end; } udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN); LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %u\n", p->tot_len)); src = ntohs(udphdr->src); dest = ntohs(udphdr->dest); udp_debug_print(udphdr); /* print the UDP source and destination */ #if 0 printf("C%d %d %d - %d %d -%x:%x:%x:%x %d %x:%x:%x:%x - %x:%x:%x:%x %d %x:%x:%x:%x\n", (pcb->flags & UDP_FLAGS_CONNECTED), pcb->remote_port,src,pcb->local_port,dest, pcb->remote_ip.addr[0], pcb->remote_ip.addr[1], pcb->remote_ip.addr[2], pcb->remote_ip.addr[3], ip_addr_isany(&pcb->remote_ip), piphdr->src->addr[0], piphdr->src->addr[1], piphdr->src->addr[2], piphdr->src->addr[3], pcb->local_ip.addr[0], pcb->local_ip.addr[1], pcb->local_ip.addr[2], pcb->local_ip.addr[3], ip_addr_isany(&pcb->local_ip), piphdr->dest->addr[0], piphdr->dest->addr[1], piphdr->dest->addr[2], piphdr->dest->addr[3]); #endif #if SO_REUSE pcb_temp = stack->udp_pcbs; again_1: /* Iterate through the UDP pcb list for a fully matching pcb */ for (pcb = pcb_temp; pcb != NULL; pcb = pcb->next) #else /* SO_REUSE */ /* Iterate through the UDP pcb list for a fully matching pcb */ for (pcb = stack->udp_pcbs; pcb != NULL; pcb = pcb->next) #endif /* SO_REUSE */ { /* print the PCB local and remote address */ #ifdef IPv6 /* XXX */ #else LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n", ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port)); #endif /* PCB remote port matches UDP source port? */ if ((pcb->remote_port == src) && /* PCB local port matches UDP destination port? */ (pcb->local_port == dest) && /* accepting from any remote (source) IP address? or... */ (ip_addr_isany(&pcb->remote_ip) || /* PCB remote IP address matches UDP source IP address? */ ip_addr_cmp(&(pcb->remote_ip), piphdr->src) /* or the socket wants broadcasts */ /*|| (pcb->so_options & SOF_BROADCAST)*/) && /* accepting on any local (netif) IP address? or... */ (ip_addr_isany(&pcb->local_ip) || /* PCB local IP address matches UDP destination IP address? */ ip_addr_cmp(&(pcb->local_ip), piphdr->dest))) { #if SO_REUSE if (pcb->so_options & SOF_REUSEPORT) { if(reuse) { /* We processed one PCB already */ LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB and SOF_REUSEPORT set.\n")); } else { /* First PCB with this address */ LWIP_DEBUGF(UDP_DEBUG, ("udp_input: first PCB and SOF_REUSEPORT set.\n")); reuse = 1; } reuse_port_1 = 1; p->ref++; LWIP_DEBUGF(UDP_DEBUG, ("udp_input: reference counter on PBUF set to %i\n", p->ref)); } else { if (reuse) { /* We processed one PCB already */ LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB but SOF_REUSEPORT not set !\n")); } } #endif /* SO_REUSE */ break; } } /* no fully matching pcb found? then look for an unconnected pcb */ if (pcb == NULL) { /* Iterate through the UDP PCB list for a pcb that matches the local address. */ #if SO_REUSE pcb_temp = stack->udp_pcbs; again_2: for (pcb = pcb_temp; pcb != NULL; pcb = pcb->next) #else /* SO_REUSE */ for (pcb = stack->udp_pcbs; pcb != NULL; pcb = pcb->next) #endif /* SO_REUSE */ { #ifdef IPv6 /* XXX */ #else LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n", ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port)); #endif /* unconnected? */ if (((pcb->flags & UDP_FLAGS_CONNECTED) == 0) && /* destination port matches? */ (pcb->local_port == dest) && /* not bound to a specific (local) interface address? or... */ (ip_addr_isany(&pcb->local_ip) || /* ...matching interface address? */ ip_addr_cmp(&(pcb->local_ip), piphdr->dest) /* or the socket wants broadcasts */ || (pcb->so_options & SOF_BROADCAST)) #ifdef LWSLIRP /* X1008 */ && slirpif==NULL #endif ) { #if SO_REUSE if (pcb->so_options & SOF_REUSEPORT) { if (reuse) { /* We processed one PCB already */ LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB and SOF_REUSEPORT set.\n")); } else { /* First PCB with this address */ LWIP_DEBUGF(UDP_DEBUG, ("udp_input: first PCB and SOF_REUSEPORT set.\n")); reuse = 1; } reuse_port_2 = 1; p->ref++; LWIP_DEBUGF(UDP_DEBUG, ("udp_input: reference counter on PBUF set to %i\n", p->ref)); } else { if (reuse) { /* We processed one PCB already */ LWIP_DEBUGF(UDP_DEBUG, ("udp_input: second or later PCB but SOF_REUSEPORT not set !\n")); } } #endif /* SO_REUSE */ break; } } } /* Check checksum if this is a match or if it was directed at us. */ if (pcb != NULL || ( #ifdef LWSLIRP slirpif==NULL && #endif ip_addr_cmp(&inad->ipaddr, piphdr->dest))) { LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: calculating checksum\n")); pbuf_header(p, UDP_HLEN); if (piphdr->proto == IP_PROTO_UDPLITE) { /* Do the UDP Lite checksum */ if (inet6_chksum_pseudo(p, (struct ip_addr *)piphdr->src, (struct ip_addr *)piphdr->dest, IP_PROTO_UDPLITE, ntohs(udphdr->len)) != 0) { LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP Lite datagram discarded due to failing checksum\n")); UDP_STATS_INC(udp.chkerr); UDP_STATS_INC(udp.drop); snmp_inc_udpinerrors(); pbuf_free(p); goto end; } } else { if (udphdr->chksum != 0) { if (inet6_chksum_pseudo(p, (struct ip_addr *)piphdr->src, (struct ip_addr *)piphdr->dest, IP_PROTO_UDP, p->tot_len) != 0) { LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP datagram discarded due to failing checksum\n")); UDP_STATS_INC(udp.chkerr); UDP_STATS_INC(udp.drop); snmp_inc_udpinerrors(); pbuf_free(p); goto end; } } } pbuf_header(p, -UDP_HLEN); if (pcb != NULL) { snmp_inc_udpindatagrams(); /* callback */ LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: delivery\n")); if (pcb->recv != NULL) { pcb->recv(pcb->recv_arg, pcb, p, piphdr->src, src); } #if SO_REUSE /* First socket should receive now */ if (reuse_port_1 || reuse_port_2) { /* We want to search on next socket after receiving */ pcb_temp = pcb->next; #ifdef LWSLIRP if (slirpif!=NULL) slirpif=NULL; #endif if (reuse_port_1) { /* We are searching connected sockets */ reuse_port_1 = 0; reuse_port_2 = 0; goto again_1; } else { /* We are searching unconnected sockets */ reuse_port_1 = 0; reuse_port_2 = 0; goto again_2; } } #endif /* SO_REUSE */ } else { #if SO_REUSE if(reuse) { LWIP_DEBUGF(UDP_DEBUG, ("udp_input: freeing PBUF with reference counter set to %i\n", p->ref)); pbuf_free(p); goto end; } #endif /* SO_REUSE */ LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: not for us.\n")); /* No match was found, send ICMP destination port unreachable unless destination address was broadcast/multicast. */ if (!(ip_addr_ismulticast(piphdr->dest) || ip_addr_is_v4broadcast(piphdr->dest,&(inad->ipaddr),&(inad->netmask)) || ip_addr_is_v4multicast(piphdr->dest))) { /* adjust pbuf pointer */ /*p->payload = iphdr; */ p->payload = payloadrestore; icmp_dest_unreach(stack, p, ICMP_DUR_PORT); } UDP_STATS_INC(udp.proterr); UDP_STATS_INC(udp.drop); snmp_inc_udpnoports(); pbuf_free(p); } #ifdef LWSLIRP } else if (slirpif != NULL) { int ret; struct udp_pcb *udp_pcb; /* LWSLIRP TEST */ if ((udp_pcb = udp_new(stack)) == NULL) goto err_out; udp_recv(udp_pcb, slirp_udp_recv, slirpif); /* Set the reuse port options */ udp_pcb->so_options |= SOF_REUSEPORT; /* equal to the old udp_attach() */ ret = udp_bind(udp_pcb, piphdr->dest, ntohs(udphdr->dest), slirpif); /* If there were some errors or the socket() call failed */ if(ret != ERR_OK || udp_pcb->slirp_fddata == NULL) { LWIP_DEBUGF(UDP_DEBUG, ("udp_input: udp_bind() error.\n")); udp_remove(udp_pcb); goto err_out; } LWIP_DEBUGF(UDP_DEBUG, ("udp_input: pcb %p udp_bind()ed\n", udp_pcb)); if(udp_connect(udp_pcb, piphdr->src, ntohs(udphdr->src)) != ERR_OK) { LWIP_DEBUGF(UDP_DEBUG, ("udp_input: udp_connect() error.\n")); udp_remove(udp_pcb); goto err_out; } LWIP_DEBUGF(UDP_DEBUG, ("udp_input: pcb %p udp_connect()ed, run " "again the search to menage the data of the packet\n", udp_pcb)); /* I have created the udp pcb, so now I call again udp_input() to * menage the packet, but before I have to restore the ->payload * of the pbuf to include IP and UDP header.*/ pbuf_header(p, ((s16_t)(UDP_HLEN + piphdr->iphdrlen))); udp_input(p, inad, piphdr, NULL); #endif } else goto err_out; end: PERF_STOP("udp_input"); return; err_out: pbuf_free(p); return; } /** * Send data to a specified address using UDP. * * @param pcb UDP PCB used to send the data. * @param pbuf chain of pbuf's to be sent. * @param dst_ip Destination IP address. * @param dst_port Destination UDP port. * * If the PCB already has a remote address association, it will * be restored after the data is sent. * * @return lwIP error code. * - ERR_OK. Successful. No error occured. * - ERR_MEM. Out of memory. * - ERR_RTE. Could not find route to destination address. * * @see udp_disconnect() udp_send() */ err_t udp_sendto(struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port) { err_t err; /* temporary space for current PCB remote address */ struct ip_addr pcb_remote_ip; u16_t pcb_remote_port; /* remember current remote peer address of PCB */ memcpy(&(pcb_remote_ip.addr),&(pcb->remote_ip.addr),sizeof(struct ip_addr)); pcb_remote_port = pcb->remote_port; /* copy packet destination address to PCB remote peer address */ memcpy(&(pcb->remote_ip.addr),&(dst_ip->addr),sizeof(struct ip_addr)); pcb->remote_port = dst_port; /* send to the packet destination address */ err = udp_send(pcb, p); /* restore PCB remote peer address */ memcpy(&(pcb->remote_ip.addr),&(pcb_remote_ip.addr),sizeof(struct ip_addr)); pcb->remote_port = pcb_remote_port; return err; } /** * Send data using UDP. * * @param pcb UDP PCB used to send the data. * @param pbuf chain of pbuf's to be sent. * * @return lwIP error code. * - ERR_OK. Successful. No error occured. * - ERR_MEM. Out of memory. * - ERR_RTE. Could not find route to destination address. * * @see udp_disconnect() udp_sendto() */ err_t udp_send(struct udp_pcb *pcb, struct pbuf *p) { struct stack *stack = pcb->stack; struct udp_hdr *udphdr; struct netif *netif; struct ip_addr *src_ip; err_t err; struct pbuf *q; /* q will be sent down the stack */ struct ip_addr *nexthop; int flags; LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_send\n")); /* if the PCB is not yet bound to a port, bind it here */ if (pcb->local_port == 0) { LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: not yet bound to a port, binding now\n")); err = udp_bind(pcb, &pcb->local_ip, pcb->local_port #ifdef LWSLIRP ,NULL #endif ); if (err != ERR_OK) { LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: forced port bind failed\n")); return err; } } /* find the outgoing network interface for this packet */ /* no outgoing network interface could be found? */ if (ip_route_findpath(stack, &(pcb->remote_ip), &nexthop, &netif, &flags) != ERR_OK) { LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", 0L /*pcb->remote_ip.addr*/)); UDP_STATS_INC(udp.rterr); return ERR_RTE; } /* not enough space to add an UDP header to first pbuf in given p chain? */ if (pbuf_header(p, UDP_HLEN)) { /* allocate header in a seperate new pbuf */ q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM); /* new header pbuf could not be allocated? */ if (q == NULL) { LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: could not allocate header\n")); return ERR_MEM; } /* chain header q in front of given pbuf p */ pbuf_chain(q, p); /* { first pbuf q points to header pbuf } */ LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); /* adding a header within p succeeded */ } else { /* first pbuf q equals given pbuf */ q = p; LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header in given pbuf %p\n", (void *)p)); } /* { q now represents the packet to be sent } */ udphdr = q->payload; udphdr->src = htons(pcb->local_port); udphdr->dest = htons(pcb->remote_port); /* in UDP, 0 checksum means 'no checksum' */ udphdr->chksum = 0x0000; /* PCB local address is IP_ANY_ADDR? */ if (ip_addr_isany(&pcb->local_ip)) { /* use outgoing network interface IP address as source address */ struct ip_addr_list *el; if ((el=ip_route_select_source_ip(netif, &pcb->remote_ip, nexthop)) == NULL) return err; src_ip = &(el->ipaddr); } else { /* use UDP PCB local IP address as source address */ src_ip = &(pcb->local_ip); } LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len)); /* UDP Lite protocol? */ if (pcb->flags & UDP_FLAGS_UDPLITE) { LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len)); /* set UDP message length in UDP header */ udphdr->len = htons(pcb->chksum_len); /* calculate checksum */ udphdr->chksum = inet6_chksum_pseudo(q, src_ip, &(pcb->remote_ip), IP_PROTO_UDP, pcb->chksum_len); /* chksum zero must become 0xffff, as zero means 'no checksum' */ if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff; /* output to IP */ LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n")); err = ip_output_if (stack, q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif, nexthop, flags); /* UDP */ } else { LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len)); udphdr->len = htons(q->tot_len); /* calculate checksum */ if ((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) { udphdr->chksum = inet6_chksum_pseudo(q, src_ip, &pcb->remote_ip, IP_PROTO_UDP, q->tot_len); /* chksum zero must become 0xffff, as zero means 'no checksum' */ if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff; } LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); /* output to IP */ err = ip_output_if(stack, q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif, nexthop, flags); } /* TODO: must this be increased even if error occured? */ snmp_inc_udpoutdatagrams(); /* did we chain a seperate header pbuf earlier? */ if (q != p) { /* free the header pbuf */ pbuf_free(q); q = NULL; /* { p is still referenced by the caller, and will live on } */ } UDP_STATS_INC(udp.xmit); return err; } /** * Bind an UDP PCB. * * @param pcb UDP PCB to be bound with a local address ipaddr and port. * @param ipaddr local IP address to bind with. Use IP_ADDR_ANY to * bind to all local interfaces. * @param port local UDP port to bind with. * * @return lwIP error code. * - ERR_OK. Successful. No error occured. * - ERR_USE. The specified ipaddr and port are already bound to by * another UDP PCB. * * @see udp_disconnect() */ err_t udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port #ifdef LWSLIRP , struct netif *slirpif #endif ) { struct stack *stack = pcb->stack; struct udp_pcb *ipcb; u8_t rebind; #if SO_REUSE int reuse_port_all_set = 1; #endif /* SO_REUSE */ LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = ")); ip_addr_debug_print(UDP_DEBUG, ipaddr); LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, (", port = %u)\n", port)); rebind = 0; /* Check for double bind and rebind of the same pcb */ for (ipcb = stack->udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { /* is this UDP PCB already on active list? */ if (pcb == ipcb) { /* pcb may occur at most once in active list */ LWIP_ASSERT("rebind == 0", rebind == 0); /* pcb already in list, just rebind */ rebind = 1; } #if SO_REUSE == 0 /* this code does not allow upper layer to share a UDP port for listening to broadcast or multicast traffic (See SO_REUSE_ADDR and SO_REUSE_PORT under *BSD). TODO: See where it fits instead, OR combine with implementation of UDP PCB flags. Leon Woestenberg. */ #ifdef LWIP_UDP_TODO /* port matches that of PCB in list? */ else if ((ipcb->local_port == port) && /* IP address matches, or one is IP_ADDR_ANY? */ (ip_addr_isany(&(ipcb->local_ip)) || ip_addr_isany(ipaddr) || ip_addr_cmp(&(ipcb->local_ip), ipaddr))) { /* other PCB already binds to this local IP and port */ LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: local port %u already bound by another pcb\n", port)); return ERR_USE; } #endif #else /* SO_REUSE */ /* Search through list of PCB's. If there is a PCB bound to specified port and IP_ADDR_ANY another PCB can be bound to the interface IP or to the loopback address on the same port if SOF_REUSEADDR is set. Any combination of PCB's bound to the same local port, but to one address out of {IP_ADDR_ANY, 127.0.0.1, interface IP} at a time is valid. But no two PCB's bound to same local port and same local address is valid. If SOF_REUSEPORT is set several PCB's can be bound to same local port and same local address also. But then all PCB's must have the SOF_REUSEPORT option set. When the two options aren't set and specified port is already bound, ERR_USE is returned saying that address is already in use. */ else if (ipcb->local_port == port) { if(ip_addr_cmp(&(ipcb->local_ip), ipaddr)) { if(pcb->so_options & SOF_REUSEPORT) { LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT set and same address.\n")); reuse_port_all_set = (reuse_port_all_set && (ipcb->so_options & SOF_REUSEPORT)); } else { LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT not set and same address.\n")); return ERR_USE; } } else if((ip_addr_isany(ipaddr) && !ip_addr_isany(&(ipcb->local_ip))) || (!ip_addr_isany(ipaddr) && ip_addr_isany(&(ipcb->local_ip)))) { if(!(pcb->so_options & SOF_REUSEADDR) && !(pcb->so_options & SOF_REUSEPORT)) { LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: in UDP PCB's SO_REUSEPORT or SO_REUSEADDR not set and not the same address.\n")); return ERR_USE; } } } #endif /* SO_REUSE */ } #if SO_REUSE /* If SOF_REUSEPORT isn't set in all PCB's bound to specified port and local address specified then {IP, port} can't be reused. */ if(!reuse_port_all_set) { LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: not all sockets have SO_REUSEPORT set.\n")); return ERR_USE; } #endif /* SO_REUSE */ ip_addr_set(&pcb->local_ip, ipaddr); /* no port specified? */ if (port == 0) { #ifndef UDP_LOCAL_PORT_RANGE_START #define UDP_LOCAL_PORT_RANGE_START 4096 #define UDP_LOCAL_PORT_RANGE_END 0x7fff #endif port = UDP_LOCAL_PORT_RANGE_START; ipcb = stack->udp_pcbs; while ((ipcb != NULL) && (port != UDP_LOCAL_PORT_RANGE_END)) { if (ipcb->local_port == port) { port++; ipcb = stack->udp_pcbs; } else ipcb = ipcb->next; } if (ipcb != NULL) { /* no more ports available in local range */ LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: out of free UDP ports\n")); return ERR_USE; } } pcb->local_port = port; #ifdef LWSLIRP if (slirpif) slirp_udp_bind(pcb, slirpif, 0); #endif /* pcb not active yet? */ if (rebind == 0) { /* place the PCB on the active list if not already there */ pcb->next = stack->udp_pcbs; stack->udp_pcbs = pcb; } LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_bind: bound to %u.%u.%u.%u, port %u\n", 0,0,0,0, /*(unsigned int)(ntohl(pcb->local_ip.addr) >> 24 & 0xff), (unsigned int)(ntohl(pcb->local_ip.addr) >> 16 & 0xff), (unsigned int)(ntohl(pcb->local_ip.addr) >> 8 & 0xff), (unsigned int)(ntohl(pcb->local_ip.addr) & 0xff), */ pcb->local_port)); return ERR_OK; } /** * Connect an UDP PCB. * * This will associate the UDP PCB with the remote address. * * @param pcb UDP PCB to be connected with remote address ipaddr and port. * @param ipaddr remote IP address to connect with. * @param port remote UDP port to connect with. * * @return lwIP error code * * @see udp_disconnect() */ err_t udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port) { struct stack *stack = pcb->stack; struct udp_pcb *ipcb; if (pcb->local_port == 0) { err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port #ifdef LWSLIRP ,NULL #endif ); if (err != ERR_OK) return err; } ip_addr_set(&pcb->remote_ip, ipaddr); pcb->remote_port = port; pcb->flags |= UDP_FLAGS_CONNECTED; /** TODO: this functionality belongs in upper layers */ #ifdef LWIP_UDP_TODO /* Nail down local IP for netconn_addr()/getsockname() */ if (ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) { struct netif *netif; if ((netif = ip_route(&(pcb->remote_ip))) == NULL) { LWIP_DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", 0 /*pcb->remote_ip.addr*/)); UDP_STATS_INC(udp.rterr); return ERR_RTE; } /** TODO: this will bind the udp pcb locally, to the interface which is used to route output packets to the remote address. However, we might want to accept incoming packets on any interface! */ pcb->local_ip = netif->ip_addr; } else if (ip_addr_isany(&pcb->remote_ip)) { pcb->local_ip.addr = 0; } #endif LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_connect: connected to %u.%u.%u.%u, port %u\n", 0,0,0,0, /*(unsigned int)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff), (unsigned int)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff), (unsigned int)(ntohl(pcb->remote_ip.addr) >> 8 & 0xff), (unsigned int)(ntohl(pcb->remote_ip.addr) & 0xff), */ pcb->remote_port)); /* Insert UDP PCB into the list of active UDP PCBs. */ for(ipcb = stack->udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { if (pcb == ipcb) { /* already on the list, just return */ return ERR_OK; } } /* PCB not yet on the list, add PCB now */ pcb->next = stack->udp_pcbs; stack->udp_pcbs = pcb; return ERR_OK; } void udp_disconnect(struct udp_pcb *pcb) { /* reset remote address association */ ip_addr_set(&pcb->remote_ip, IP_ADDR_ANY); pcb->remote_port = 0; /* mark PCB as unconnected */ pcb->flags &= ~UDP_FLAGS_CONNECTED; } void udp_recv(struct udp_pcb *pcb, void (* recv)(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port), void *recv_arg) { /* remember recv() callback and user data */ pcb->recv = recv; pcb->recv_arg = recv_arg; } /** * Remove an UDP PCB. * * @param pcb UDP PCB to be removed. The PCB is removed from the list of * UDP PCB's and the data structure is freed from memory. * * @see udp_new() */ void udp_remove(struct udp_pcb *pcb) { struct stack *stack = pcb->stack; struct udp_pcb *pcb2; /* pcb to be removed is first in list? */ if (stack->udp_pcbs == pcb) { /* make list start at 2nd pcb */ stack->udp_pcbs = stack->udp_pcbs->next; /* pcb not 1st in list */ } else for(pcb2 = stack->udp_pcbs; pcb2 != NULL; pcb2 = pcb2->next) { /* find pcb in udp_pcbs list */ if (pcb2->next != NULL && pcb2->next == pcb) { /* remove pcb from list */ pcb2->next = pcb->next; } } memp_free(MEMP_UDP_PCB, pcb); } /** * Create a UDP PCB. * * @return The UDP PCB which was created. NULL if the PCB data structure * could not be allocated. * * @see udp_remove() */ struct udp_pcb * udp_new(struct stack *stack) { struct udp_pcb *pcb; pcb = memp_malloc(MEMP_UDP_PCB); /* could allocate UDP PCB? */ if (pcb != NULL) { /* initialize PCB to all zeroes */ memset(pcb, 0, sizeof(struct udp_pcb)); pcb->ttl = UDP_TTL; pcb->stack = stack; #ifdef LWSLIRP pcb->slirp_fddata = NULL; #endif } return pcb; } #if UDP_DEBUG int udp_debug_print(struct udp_hdr *udphdr) { LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n")); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(UDP_DEBUG, ("| %5u | %5u | (src port, dest port)\n", ntohs(udphdr->src), ntohs(udphdr->dest))); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(UDP_DEBUG, ("| %5u | 0x%04x | (len, chksum)\n", ntohs(udphdr->len), ntohs(udphdr->chksum))); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); return 0; } #endif /* UDP_DEBUG */ #endif /* LWIP_UDP */ lwipv6-1.5a/lwip-v6/src/core/memp.c0000644000175000017500000002115011671615007016153 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/opt.h" #include "lwip/memp.h" #include "lwip/pbuf.h" #include "lwip/udp.h" #include "lwip/raw.h" #include "lwip/tcp.h" #include "lwip/api.h" #include "lwip/tcpip.h" #include "lwip/sys.h" #include "lwip/stats.h" /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT #include "lwip/nat/nat.h" #endif struct memp { struct memp *next; }; static struct memp *memp_tab[MEMP_MAX]; static const u16_t memp_sizes[MEMP_MAX] = { sizeof(struct pbuf), sizeof(struct raw_pcb), sizeof(struct udp_pcb), sizeof(struct tcp_pcb), sizeof(struct tcp_pcb_listen), sizeof(struct tcp_seg), sizeof(struct netbuf), sizeof(struct netconn), sizeof(struct tcpip_msg), sizeof(struct sys_timeout) sizeof(struct ip_route_list), sizeof(struct ip_addr_list), sizeof(struct netif_fddata) #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION , sizeof(struct ip_reassbuf) #endif /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT , sizeof(struct nat_pcb), sizeof(struct nat_rule) #endif }; static const u16_t memp_num[MEMP_MAX] = { MEMP_NUM_PBUF, MEMP_NUM_RAW_PCB, MEMP_NUM_UDP_PCB, MEMP_NUM_TCP_PCB, MEMP_NUM_TCP_PCB_LISTEN, MEMP_NUM_TCP_SEG, MEMP_NUM_NETBUF, MEMP_NUM_NETCONN, MEMP_NUM_API_MSG, MEMP_NUM_TCPIP_MSG, MEMP_NUM_SYS_TIMEOUT, MEMP_NUM_ROUTES, MEMP_NUM_ADDRS, MEMP_NUM_REASS /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT , MEMP_NUM_NAT_PCB, MEMP_NUM_NAT_RULE #endif }; static u8_t memp_memory[(MEMP_NUM_PBUF * MEM_ALIGN_SIZE(sizeof(struct pbuf) + sizeof(struct memp)) + MEMP_NUM_RAW_PCB * MEM_ALIGN_SIZE(sizeof(struct raw_pcb) + sizeof(struct memp)) + MEMP_NUM_UDP_PCB * MEM_ALIGN_SIZE(sizeof(struct udp_pcb) + sizeof(struct memp)) + MEMP_NUM_TCP_PCB * MEM_ALIGN_SIZE(sizeof(struct tcp_pcb) + sizeof(struct memp)) + MEMP_NUM_TCP_PCB_LISTEN * MEM_ALIGN_SIZE(sizeof(struct tcp_pcb_listen) + sizeof(struct memp)) + MEMP_NUM_TCP_SEG * MEM_ALIGN_SIZE(sizeof(struct tcp_seg) + sizeof(struct memp)) + MEMP_NUM_NETBUF * MEM_ALIGN_SIZE(sizeof(struct netbuf) + sizeof(struct memp)) + MEMP_NUM_NETCONN * MEM_ALIGN_SIZE(sizeof(struct netconn) + sizeof(struct memp)) + MEMP_NUM_TCPIP_MSG * MEM_ALIGN_SIZE(sizeof(struct tcpip_msg) + sizeof(struct memp)) + MEMP_NUM_SYS_TIMEOUT * MEM_ALIGN_SIZE(sizeof(struct sys_timeout) + sizeof(struct memp)) /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT + MEMP_NUM_NAT_PCB * MEM_ALIGN_SIZE(sizeof(struct nat_pcb) + sizeof(struct memp)) + MEMP_NUM_NAT_RULE * MEM_ALIGN_SIZE(sizeof(struct nat_rule) + sizeof(struct memp)) #endif )]; #if !SYS_LIGHTWEIGHT_PROT static sys_sem_t mutex; #endif #if MEMP_SANITY_CHECK static int memp_sanity(void) { int i, c; struct memp *m, *n; for(i = 0; i < MEMP_MAX; i++) { for(m = memp_tab[i]; m != NULL; m = m->next) { c = 1; for(n = memp_tab[i]; n != NULL; n = n->next) { if (n == m) { --c; } if (c < 0) return 0; /* LW was: abort(); */ } } } return 1; } #endif /* MEMP_SANITY_CHECK*/ void memp_init(void) { struct memp *m, *memp; u16_t i, j; u16_t size; #if MEMP_STATS for(i = 0; i < MEMP_MAX; ++i) { lwip_stats.memp[i].used = lwip_stats.memp[i].max = lwip_stats.memp[i].err = 0; lwip_stats.memp[i].avail = memp_num[i]; } #endif /* MEMP_STATS */ memp = (struct memp *)&memp_memory[0]; for(i = 0; i < MEMP_MAX; ++i) { size = MEM_ALIGN_SIZE(memp_sizes[i] + sizeof(struct memp)); if (memp_num[i] > 0) { memp_tab[i] = memp; m = memp; for(j = 0; j < memp_num[i]; ++j) { m->next = (struct memp *)MEM_ALIGN((u8_t *)m + size); memp = m; m = m->next; } memp->next = NULL; memp = m; } else { memp_tab[i] = NULL; } } #if !SYS_LIGHTWEIGHT_PROT mutex = sys_sem_new(1); #endif } void * memp_malloc(memp_t type) { struct memp *memp; void *mem; #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_DECL_PROTECT(old_level); #endif LWIP_ASSERT("memp_malloc: type < MEMP_MAX", type < MEMP_MAX); #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_PROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_wait(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ memp = memp_tab[type]; if (memp != NULL) { memp_tab[type] = memp->next; memp->next = NULL; #if MEMP_STATS ++lwip_stats.memp[type].used; if (lwip_stats.memp[type].used > lwip_stats.memp[type].max) { lwip_stats.memp[type].max = lwip_stats.memp[type].used; } #endif /* MEMP_STATS */ #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ LWIP_ASSERT("memp_malloc: memp properly aligned", ((mem_ptr_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0); mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp)); return mem; } else { LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type)); #if MEMP_STATS ++lwip_stats.memp[type].err; #endif /* MEMP_STATS */ #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ return NULL; } } void memp_free(memp_t type, void *mem) { struct memp *memp; #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_DECL_PROTECT(old_level); #endif /* SYS_LIGHTWEIGHT_PROT */ if (mem == NULL) { return; } memp = (struct memp *)((u8_t *)mem - sizeof(struct memp)); #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_PROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_wait(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ #if MEMP_STATS lwip_stats.memp[type].used--; #endif /* MEMP_STATS */ memp->next = memp_tab[type]; memp_tab[type] = memp; #if MEMP_SANITY_CHECK LWIP_ASSERT("memp sanity", memp_sanity()); #endif #if SYS_LIGHTWEIGHT_PROT SYS_ARCH_UNPROTECT(old_level); #else /* SYS_LIGHTWEIGHT_PROT */ sys_sem_signal(mutex); #endif /* SYS_LIGHTWEIGHT_PROT */ } lwipv6-1.5a/lwip-v6/src/core/memp_malloc.c0000644000175000017500000001205311671615010017476 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include "lwip/opt.h" #include "lwip/mem.h" #include "lwip/memp.h" #include "lwip/pbuf.h" #include "lwip/udp.h" #include "lwip/raw.h" #include "lwip/tcp.h" #include "lwip/api.h" #include "lwip/tcpip.h" #include "lwip/netif.h" #include "lwip/sys.h" #include "lwip/stats.h" /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT #include "lwip/nat/nat.h" #endif /* * FIX: This implementation uses malloc() and free() functions. * These functions MUST be thread safe. */ static const u32_t memp_sizes[MEMP_MAX] = { sizeof(struct pbuf), sizeof(struct raw_pcb), sizeof(struct udp_pcb), sizeof(struct tcp_pcb), sizeof(struct tcp_pcb_listen), sizeof(struct tcp_seg), sizeof(struct netbuf), sizeof(struct netconn), sizeof(struct tcpip_msg), sizeof(struct sys_timeout), sizeof(struct ip_route_list), sizeof(struct ip_addr_list), sizeof(struct netif_fddata) #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION , sizeof(struct ip_reassbuf) #endif /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT , sizeof(struct nat_pcb), sizeof(struct nat_rule) #endif }; #ifndef DEBUGMEM void memp_init(void) { } void * memp_malloc(memp_t type) { return (malloc(memp_sizes[type])); } void memp_free(memp_t type, void *mem) { free(mem); } #else #include static char *stypes[] = { "PBUF", "RAW_PCB", "UDP_PCB", "TCP_PCB", "TCP_PCB_LISTEN", "TCP_SEG", "NETBUF", "NETCONN", "TCPIP_MSG", "SYS_TIMEOUT", "ROUTE", "ADDR", "NETIF_FDDATA", #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION "REASS", #endif #if LWIP_USERFILTER && LWIP_NAT "NAT_PCB", "NAT_RULE", #endif "MAX" }; int mempcount[MEMP_MAX]; static void memstat(int signo) { int i; for (i=0; i %d\n",stypes[i],mempcount[i]); } void memp_d_init(char *__file, int __line) { signal(SIGUSR2, memstat); } void * memp_d_malloc(memp_t type, char *__file, int __line) { void *rv=(mem_d_malloc(memp_sizes[type], __file, __line)); mempcount[type]++; //if (type == MEMP_TCP_PCB) fprintf(stderr, "memp_d_malloc MEMP_TCP_PCB %s %d %p\n",__file,__line,rv); //if (type == MEMP_TCP_PCB_LISTEN) fprintf(stderr, "memp_d_malloc MEMP_TCP_PCB_LISTEN %s %d\ %pn",__file,__line,rv); return rv; } void memp_d_free(memp_t type, void *mem, char *__file, int __line) { mempcount[type]--; //if (type == MEMP_TCP_PCB) fprintf(stderr, "memp_d_free MEMP_TCP_PCB %s %d %p\n",__file,__line,mem); ////if (type == MEMP_TCP_PCB_LISTEN) fprintf(stderr, "memp_d_free MEMP_TCP_PCB_LISTEN %s %d %p\n",__file,__line,mem); mem_d_free(mem, __file, __line); } #endif lwipv6-1.5a/lwip-v6/src/core/ipv6/0000755000175000017500000000000011671615111015732 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/core/ipv6/ip6_frag.c0000644000175000017500000007212711671615007017610 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* @file * * This is the IP packet segmentation and reassembly implementation. * */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Jani Monoses * original reassembly code by Adam Dunkels * */ /* TODO ip_reassembly_pools using memp_alloc */ #include "lwip/opt.h" #if IPv6_FRAGMENTATION || IPv4_FRAGMENTATION #include "lwip/debug.h" #include "lwip/stats.h" #include "lwip/sys.h" #include "lwip/netif.h" #include "lwip/ip.h" #include "lwip/ip_frag.h" #include "lwip/stack.h" /*---------------------------------------------------------------------------*/ //#ifndef IP_REASS_DEBUG //#define IP_REASS_DEBUG DBG_OFF //#endif /* FIX: used only for printf warning */ #ifdef IP_REASS_DEBUG #define UINT (unsigned int) #endif /*---------------------------------------------------------------------------*/ /* * Copy len bytes from offset in pbuf to buffer * * helper used by both ip_reass and ip_frag */ INLINE static struct pbuf * copy_from_pbuf(struct pbuf *p, u16_t * offset, u8_t * buffer, u16_t len) { u16_t l; p->payload = (u8_t *) p->payload + *offset; p->len -= *offset; while (len) { l = len < p->len ? len : p->len; memcpy(buffer, p->payload, l); buffer += l; len -= l; if (len) p = p->next; else *offset = l; } return p; } /*---------------------------------------------------------------------------*/ /* Macro and costants */ /*---------------------------------------------------------------------------*/ static const u8_t bitmap_bits[8] = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 }; /* IPv4 reassembly timer timeout */ #define IP_REASS_TIMER_TIMEOUT 1000 /* Expire time of a fragmented packet */ #define IP4_REASS_MAX_AGE 5 #define IP4_REASS_FLAG_USED 0x40 #define IP4_REASS_FLAG_LASTFRAG 0x01 #define CLEAR_ENTRY(e) \ do { \ (e)->ipv = 0; \ (e)->id = 0; \ (e)->age = 0; \ (e)->flags = 0; \ (e)->len = 0; \ bzero((e)->bitmap, IP4_REASS_BITMAP_SIZE); \ } while (0) #define fill_bitmap(bit, off, len) \ do { \ int ___i; \ bit[(off)/(8*8)] |= bitmap_bits[((off)/8)&7]; \ for (___i = 1 + (off)/(8*8); ___i < ((off)+(len))/(8*8); ++___i) \ bit[___i] = 0xff; \ bit[((off)+(len))/(8*8)] |= ~bitmap_bits[(((off)+(len))/8)&7]; \ } while (0); /* Costants for fragmentation buffers */ #define MAX_MTU 1500 /* Reassembly timer */ INLINE static void ip_reass_tmr(void *arg) { int i; struct stack *stack = (struct stack *) arg; struct ip_reassbuf *ip_reassembly_pool = stack->ip_reassembly_pools; for (i=0; i < IP_REASS_POOL_SIZE; i++) { /* If this entry is used increment entry age */ if (ip_reassembly_pool[i].flags & IP4_REASS_FLAG_USED) { ip_reassembly_pool[i].age++; /* This entry is too old */ if (ip_reassembly_pool[i].age >= IP4_REASS_MAX_AGE) { CLEAR_ENTRY(& ip_reassembly_pool[i] ); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass_tmr: free entry %d (IPv%d, id=%u)\n", i, ip_reassembly_pool[i].ipv, UINT ip_reassembly_pool[i].id)); } } } sys_timeout(IP_REASS_TIMER_TIMEOUT, ip_reass_tmr, arg); } #if 0 #define IP_REASS_EXPIRE_TIMEOUT 5000 static void ip_reass_expire_tm(void *arg) { struct ip_reassbuf * entry = (struct ip_reassbuf *) arg; CLEAR_ENTRY( entry ); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: free entry (IPv%d, id=%u)\n", entry->ipv, UINT entry->id)); } #endif /*---------------------------------------------------------------------------*/ /* Module functions */ /*---------------------------------------------------------------------------*/ /* Initialize IPv4 Reassembly cache */ void ip_frag_reass_init(struct stack *stack) { /* FIX: rough init, change it? */ bzero(stack->ip_reassembly_pools, IP_REASS_POOL_SIZE * sizeof(struct ip_reassbuf)); #if IPv4_FRAGMENTATION LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: IPv4 fragmentation enabled.\n", __func__)); #endif #if IPv6_FRAGMENTATION LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: IPv6 fragmentation enabled.\n", __func__)); #endif sys_timeout(IP_REASS_TIMER_TIMEOUT, (sys_timeout_handler) ip_reass_tmr, (void*)stack); } void ip_frag_reass_shutdown(struct stack *stack) { /* FIX: TODO */ sys_untimeout((sys_timeout_handler) ip_reass_tmr, (void*)stack); } /*---------------------------------------------------------------------------*/ /* IPv4 */ /*---------------------------------------------------------------------------*/ #if IPv4_FRAGMENTATION struct pbuf *ip4_reass(struct stack *stack, struct pbuf *p) { struct pbuf *q; struct ip4_hdr *fragment_hdr, *entry_iphdr; u32_t offset, len; u16_t i; u16_t pos; struct ip_reassbuf *ip_reassembly_pool = stack->ip_reassembly_pools; IPFRAG_STATS_INC(ip_frag.recv); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: start\n")); fragment_hdr = (struct ip4_hdr *) p->payload; /* Search in the pool for matching fragments */ for (pos=0; pos < IP_REASS_POOL_SIZE; pos++) { /* Lookup for IPv4 entries, If this entry is used check it */ if (ip_reassembly_pool[pos].ipv == 4) if (ip_reassembly_pool[pos].flags & IP4_REASS_FLAG_USED) { entry_iphdr = (struct ip4_hdr *) ip_reassembly_pool[pos].buf; /* cached fragment matches receivd fragment? */ if (ip_reassembly_pool[pos].id == IPH4_ID(fragment_hdr) && ip4_addr_cmp(&entry_iphdr->src, &fragment_hdr->src) && ip4_addr_cmp(&entry_iphdr->dest, &fragment_hdr->dest) ) break; } } /* No match found. Try Create new one. */ if (pos >= IP_REASS_POOL_SIZE) { /* Search empty entry for this new fragment */ for (pos=0; pos < IP_REASS_POOL_SIZE; pos++) /* This entry is empty. Let's use it */ if (ip_reassembly_pool[pos].ipv == 0) if (!(ip_reassembly_pool[pos].flags & IP4_REASS_FLAG_USED)) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: new packet (pos=%d)\n", pos)); /* Reset entry data */ ip_reassembly_pool[pos].flags = IP4_REASS_FLAG_USED; ip_reassembly_pool[pos].age = 0; #if 0 sys_timeout(IP_REASS_EXPIRE_TIMEOUT, ip_reass_expire_tm, &ip_reassembly_pool[pos]); #endif ip_reassembly_pool[pos].ipv = 4; ip_reassembly_pool[pos].id = IPH4_ID(fragment_hdr); ip_reassembly_pool[pos].len = IP4_HLEN; /* Clean bitmap */ bzero(ip_reassembly_pool[pos].bitmap, IP4_REASS_BITMAP_SIZE); /* Save fragment in the entry */ entry_iphdr = (struct ip4_hdr *) ip_reassembly_pool[pos].buf; memcpy(entry_iphdr, fragment_hdr, IP4_HLEN); /* update bitmap */ fill_bitmap(ip_reassembly_pool[pos].bitmap, 0, IP4_HLEN); break; } } /* Entry found */ if (pos < IP_REASS_POOL_SIZE) { entry_iphdr = (struct ip4_hdr *) ip_reassembly_pool[pos].buf; LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: matching old packet (pos=%d)\n", pos)); IPFRAG_STATS_INC(ip_frag.cachehit); /* Find out the offset in the reassembly buffer where we should copy the fragment. */ len = ntohs(IPH4_LEN(fragment_hdr)) - IPH4_HL(fragment_hdr) * 4; offset = IP4_HLEN + (ntohs(IPH4_OFFSET(fragment_hdr)) & IP_OFFMASK) * 8; /* If the offset or the offset + fragment length overflows the reassembly buffer, we discard the entire packet. */ if (offset > IP_REASS_BUFSIZE || offset + len > IP_REASS_BUFSIZE) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: fragment outside of buffer (%d:%d/%d).\n", UINT offset, UINT (offset + len), UINT IP_REASS_BUFSIZE)); /* Make this entry empty */ CLEAR_ENTRY( & ip_reassembly_pool[pos] ); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: remove entry %d.\n", pos)); goto nullreturn; } /* Copy the fragment into the reassembly buffer, at the right offset. */ LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: copying with offset %d into %d:%d\n", UINT offset, UINT (IP4_HLEN + offset), UINT (IP4_HLEN + offset + len))); i = IPH4_HL(fragment_hdr) * 4; copy_from_pbuf(p, &i, &ip_reassembly_pool[pos].buf[offset], len); /* Update the bitmap. */ if (offset / (8 * 8) == (offset + len) / (8 * 8)) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: updating single byte in bitmap.\n")); /* If the two endpoints are in the same byte, we only update that byte. */ ip_reassembly_pool[pos].bitmap[offset / (8 * 8)] |= bitmap_bits[(offset / 8) & 7] & ~bitmap_bits[((offset + len) / 8) & 7]; } else { /* If the two endpoints are in different bytes, we update the bytes in the endpoints and fill the stuff inbetween with 0xff. */ fill_bitmap(ip_reassembly_pool[pos].bitmap, offset, len); } /* If this fragment has the More Fragments flag set to zero, we know that this is the last fragment, so we can calculate the size of the entire packet. We also set the IP_REASS_FLAG_LASTFRAG flag to indicate that we have received the final fragment. */ if ((ntohs(IPH4_OFFSET(fragment_hdr)) & IP_MF) == 0) { ip_reassembly_pool[pos].flags |= IP4_REASS_FLAG_LASTFRAG; ip_reassembly_pool[pos].len = offset + len; LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: last fragment seen, total len %d\n", UINT ip_reassembly_pool[pos].len)); } /* Finally, we check if we have a full packet in the buffer. We do this by checking if we have the last fragment and if all bits in the bitmap are set. */ if (ip_reassembly_pool[pos].flags & IP4_REASS_FLAG_LASTFRAG) { /* Check all bytes up to and including all but the last byte in the bitmap. */ for (i = 0; i < ip_reassembly_pool[pos].len / (8 * 8) - 1; ++i) { if (ip_reassembly_pool[pos].bitmap[i] != 0xff) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: last fragment seen, bitmap %d/%d failed (%x)\n", i, UINT ip_reassembly_pool[pos].len / (8 * 8) - 1, UINT ip_reassembly_pool[pos].bitmap[i])); goto nullreturn; } } /* Check the last byte in the bitmap. It should contain just the right amount of bits. */ if (ip_reassembly_pool[pos].bitmap[ip_reassembly_pool[pos].len / (8 * 8)] != (u8_t) ~ bitmap_bits[ip_reassembly_pool[pos].len / 8 & 7]) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: last fragment seen, bitmap %d didn't contain %x (%x)\n", UINT ip_reassembly_pool[pos].len / (8 * 8), UINT ~bitmap_bits[ip_reassembly_pool[pos].len / 8 & 7], UINT ip_reassembly_pool[pos].bitmap[ip_reassembly_pool[pos].len / (8 * 8)])); goto nullreturn; } /* Pretend to be a "normal" (i.e., not fragmented) IP packet from now on. */ IPH4_LEN_SET(entry_iphdr, htons(ip_reassembly_pool[pos].len)); IPH4_OFFSET_SET(entry_iphdr, 0); IPH4_CHKSUM_SET(entry_iphdr, 0); IPH4_CHKSUM_SET(entry_iphdr, inet_chksum(entry_iphdr, IP4_HLEN)); /* If we have come this far, we have a full packet in the buffer, so we allocate a pbuf and copy the packet into it. We also reset the timer. */ pbuf_free(p); p = pbuf_alloc(PBUF_LINK, ip_reassembly_pool[pos].len, PBUF_POOL); if (p != NULL) { i = 0; for (q = p; q != NULL; q = q->next) { /* Copy enough bytes to fill this pbuf in the chain. The available data in the pbuf is given by the q->len variable. */ LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: memcpy from %p (%d) to %p, %ld bytes\n", (void *) &ip_reassembly_pool[pos].buf[i], i, q->payload, q->len > (ip_reassembly_pool[pos].len - i) ? ip_reassembly_pool[pos].len - i : q->len)); memcpy(q->payload, &ip_reassembly_pool[pos].buf[i], q->len > ip_reassembly_pool[pos].len - i ? ip_reassembly_pool[pos].len - i : q->len); i += q->len; } IPFRAG_STATS_INC(ip_frag.fw); } else { IPFRAG_STATS_INC(ip_frag.memerr); } CLEAR_ENTRY( & ip_reassembly_pool[pos] ); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: p %p\n", (void *) p)); return p; } } nullreturn: IPFRAG_STATS_INC(ip_frag.drop); pbuf_free(p); return NULL; } /** * Fragment an IP packet if too large * * Chop the packet in mtu sized chunks and send them in order * by using a fixed size static memory buffer (PBUF_ROM) */ err_t ip4_frag(struct stack *stack, struct pbuf *p, struct netif *netif, struct ip_addr *dest) { u8_t buf[MAX_MTU]; struct pbuf *rambuf; struct pbuf *header; struct ip4_hdr *iphdr; u16_t nfb = 0; u16_t left, cop; u16_t mtu; u16_t ofo, omf; u16_t last; u16_t poff = IP4_HLEN; u16_t tmp; mtu = netif->mtu; LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: start\n", __func__)); /* Get a RAM based MTU sized pbuf */ rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF); rambuf->tot_len = rambuf->len = mtu; rambuf->payload = MEM_ALIGN((void *) buf); /* Copy the IP header in it */ iphdr = rambuf->payload; memcpy(iphdr, p->payload, IP4_HLEN); /* Save original offset */ tmp = ntohs(IPH4_OFFSET(iphdr)); ofo = tmp & IP_OFFMASK; omf = tmp & IP_MF; left = p->tot_len - IP4_HLEN; while (left) { last = (left <= mtu - IP4_HLEN); /* Set new offset and MF flag */ ofo += nfb; tmp = omf | (IP_OFFMASK & (ofo)); if (!last) tmp = tmp | IP_MF; IPH4_OFFSET_SET(iphdr, htons(tmp)); /* Fill this fragment */ nfb = (mtu - IP4_HLEN) / 8; cop = last ? left : nfb * 8; p = copy_from_pbuf(p, &poff, (u8_t *) iphdr + IP4_HLEN, cop); /* Correct header */ IPH4_LEN_SET(iphdr, htons(cop + IP4_HLEN)); IPH4_CHKSUM_SET(iphdr, 0); IPH4_CHKSUM_SET(iphdr, inet_chksum(iphdr, IP4_HLEN)); if (last) pbuf_realloc(rambuf, left + IP4_HLEN); /* This part is ugly: we alloc a RAM based pbuf for * the link level header for each chunk and then * free it.A PBUF_ROM style pbuf for which pbuf_header * worked would make things simpler. */ header = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM); pbuf_chain(header, rambuf); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: netif->output\n", __func__)); netif->output(netif, header, dest); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: netif->output finish\n", __func__)); IPFRAG_STATS_INC(ip_frag.xmit); pbuf_free(header); left -= cop; } pbuf_free(rambuf); return ERR_OK; } #endif /*---------------------------------------------------------------------------*/ /* IPv6 */ /*---------------------------------------------------------------------------*/ #if IPv6_FRAGMENTATION struct pbuf * ip6_reass(struct stack *stack, struct pbuf *p, struct ip6_fraghdr *fragext, struct ip_exthdr *lastext) { struct pbuf *q; struct ip_hdr *entry_iphdr; struct ip_hdr *fragment_hdr; u32_t offset, len; u16_t i; u16_t pos; u16_t unfragpart_len; /* length of unfragmentable part */ struct ip_reassbuf *ip_reassembly_pool = stack->ip_reassembly_pools; IPFRAG_STATS_INC(ip_frag.recv); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: start\n")); LWIP_DEBUGF(IP_REASS_DEBUG, ("Next : %d\n", UINT IP6_NEXTHDR(fragext) )); LWIP_DEBUGF(IP_REASS_DEBUG, ("ID : %d\n", UINT IP6_ID(fragext) )); LWIP_DEBUGF(IP_REASS_DEBUG, ("Offset: %d\n", UINT IP6_OFFSET(fragext) )); LWIP_DEBUGF(IP_REASS_DEBUG, ("M : %d\n", UINT IP6_M(fragext) )); fragment_hdr = (struct ip_hdr *) p->payload; /* Search in the pool for matching fragments */ for (pos=0; pos < IP_REASS_POOL_SIZE; pos++) { /* If this entry is used */ if (ip_reassembly_pool[pos].ipv == 6) if (ip_reassembly_pool[pos].flags & IP4_REASS_FLAG_USED) { entry_iphdr = (struct ip_hdr *) ip_reassembly_pool[pos].buf; /* cached fragment matches receivd fragment? */ if (ip_reassembly_pool[pos].id == IP6_ID(fragext) && ip_addr_cmp(&entry_iphdr->src , &fragment_hdr->src ) && ip_addr_cmp(&entry_iphdr->dest, &fragment_hdr->dest) ) break; } } /* No match found. Try Create new one. */ if (pos >= IP_REASS_POOL_SIZE) { /* Search empty entry for this new fragment */ for (pos=0; pos < IP_REASS_POOL_SIZE; pos++) if (ip_reassembly_pool[pos].ipv == 0) /* This entry is empty. Let's use it */ if (!(ip_reassembly_pool[pos].flags & IP4_REASS_FLAG_USED)) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: new packet (pos=%d)\n", pos)); /* Reset entry data */ ip_reassembly_pool[pos].ipv = 6; ip_reassembly_pool[pos].id = IP6_ID(fragext); ip_reassembly_pool[pos].age = 0; ip_reassembly_pool[pos].flags = IP4_REASS_FLAG_USED; ip_reassembly_pool[pos].len = unfragpart_len; /* Clean bitmap */ bzero(ip_reassembly_pool[pos].bitmap, IP4_REASS_BITMAP_SIZE); /* Save fragment in the entry */ entry_iphdr = (struct ip_hdr *) ip_reassembly_pool[pos].buf; /* Copy the whole Unfragmentable Part */ unfragpart_len = ((long)fragext) - ((long)fragment_hdr); memcpy(entry_iphdr, fragment_hdr, unfragpart_len); fill_bitmap(ip_reassembly_pool[pos].bitmap, 0, unfragpart_len); break; } } /* Entry found */ if (pos < IP_REASS_POOL_SIZE) { unfragpart_len = ((long)fragext) - ((long)fragment_hdr); entry_iphdr = (struct ip_hdr *) ip_reassembly_pool[pos].buf; LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: matching old packet (pos=%d)\n", pos)); IPFRAG_STATS_INC(ip_frag.cachehit); /* Find out the offset in the reassembly buffer where we should copy the fragment. */ /* Payload Length of the IPv6 header contains the length of this fragment packet only (excluding the length of the IPv6 header itself) */ len = ntohs(IPH_PAYLOADLEN(fragment_hdr)) + IP_HLEN - unfragpart_len - sizeof(struct ip6_fraghdr); offset = unfragpart_len + IP6_OFFSET(fragext); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: Len = %d.\n", UINT len)); /* If the offset or the offset + fragment length overflows the reassembly buffer, we discard the entire packet. */ if (offset > IP_REASS_BUFSIZE || offset + len > IP_REASS_BUFSIZE) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: fragment outside of buffer (%d:%d/%d).\n", UINT offset, UINT (offset + len), UINT IP_REASS_BUFSIZE)); /* Make this entry empty */ LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: remove entry %d.\n", pos)); CLEAR_ENTRY( & ip_reassembly_pool[pos] ); goto nullreturn; } /* Copy the fragment into the reassembly buffer, at the right offset. */ LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: copying with offset %d into %d:%d\n",UINT offset, UINT (unfragpart_len + offset), UINT (unfragpart_len + offset + len))); i = unfragpart_len + sizeof(struct ip6_fraghdr); copy_from_pbuf(p, &i, &ip_reassembly_pool[pos].buf[offset], len); /* Update the bitmap. */ if (offset / (8 * 8) == (offset + len) / (8 * 8)) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: updating single byte in bitmap.\n")); /* If the two endpoints are in the same byte, we only update that byte. */ ip_reassembly_pool[pos].bitmap[offset / (8 * 8)] |= bitmap_bits[(offset / 8) & 7] & ~bitmap_bits[((offset + len) / 8) & 7]; } else { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip4_reass: updating many bytes in bitmap (%ld:%ld).\n", 1 + offset / (8 * 8), (offset + len) / (8 * 8))); /* If the two endpoints are in different bytes, we update the bytes in the endpoints and fill the stuff inbetween with 0xff. */ fill_bitmap(ip_reassembly_pool[pos].bitmap, offset, len); } /* If this fragment has the More Fragments flag set to zero, we know that this is the last fragment, so we can calculate the size of the entire packet. We also set the IP_REASS_FLAG_LASTFRAG flag to indicate that we have received the final fragment. */ if (IP6_M(fragext) == 0) { ip_reassembly_pool[pos].flags |= IP4_REASS_FLAG_LASTFRAG; ip_reassembly_pool[pos].len = offset + len; LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: last fragment seen, total len %d\n", UINT ip_reassembly_pool[pos].len)); } else { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: NOT last fragment.\n")); } /* Finally, we check if we have a full packet in the buffer. We do this by checking if we have the last fragment and if all bits in the bitmap are set. */ if (ip_reassembly_pool[pos].flags & IP4_REASS_FLAG_LASTFRAG) { /* Check all bytes up to and including all but the last byte in the bitmap. */ for (i = 0; i < ip_reassembly_pool[pos].len / (8 * 8) - 1; ++i) { if (ip_reassembly_pool[pos].bitmap[i] != 0xff) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: last fragment seen, bitmap %d/%ld failed (%x)\n", i, ip_reassembly_pool[pos].len / (8 * 8) - 1, ip_reassembly_pool[pos].bitmap[i])); goto nullreturn; } } /* Check the last byte in the bitmap. It should contain just the right amount of bits. */ if (ip_reassembly_pool[pos].bitmap[ip_reassembly_pool[pos].len / (8 * 8)] != (u8_t) ~ bitmap_bits[ip_reassembly_pool[pos].len / 8 & 7]) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: last fragment seen, bitmap %ld didn't contain %x (%x)\n", ip_reassembly_pool[pos].len / (8 * 8), ~bitmap_bits[ip_reassembly_pool[pos].len / 8 & 7], ip_reassembly_pool[pos].bitmap[ip_reassembly_pool[pos].len / (8 * 8)])); goto nullreturn; } /* Pretend to be a "normal" (i.e., not fragmented) IP packet from now on. */ IPH_PAYLOADLEN_SET(entry_iphdr, ip_reassembly_pool[pos].len); //lastext = ip_last_exthdr_before_fraghdr(p); if (lastext != NULL) { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: memcpy from %p (%d) to %p, %ld bytes\n", (void *) &ip_reassembly_pool[pos].buf[i], i, q->payload, q->len > ip_reassembly_pool[pos].len - i ? ip_reassembly_pool[pos].len - i : q->len)); /* FIX FIX FIX */ } else { LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: no extension headers before fragment\n")); /* No extension header. Modify NextHdr field in IPv6 Header */ IPH_NEXTHDR_SET(entry_iphdr, fragext->nexthdr); } /* If we have come this far, we have a full packet in the buffer, so we allocate a pbuf and copy the packet into it. We also reset the timer. */ pbuf_free(p); p = pbuf_alloc(PBUF_LINK, ip_reassembly_pool[pos].len, PBUF_POOL); if (p != NULL) { i = 0; for (q = p; q != NULL; q = q->next) { /* Copy enough bytes to fill this pbuf in the chain. The available data in the pbuf is given by the q->len variable. */ LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: memcpy from %p (%d) to %p, %ld bytes\n", (void *) &ip_reassembly_pool[pos].buf[i], i, q->payload, q->len > ip_reassembly_pool[pos].len - i ? ip_reassembly_pool[pos].len - i : q->len)); memcpy(q->payload, &ip_reassembly_pool[pos].buf[i], q->len > ip_reassembly_pool[pos].len - i ? ip_reassembly_pool[pos].len - i : q->len); i += q->len; } IPFRAG_STATS_INC(ip_frag.fw); } else { IPFRAG_STATS_INC(ip_frag.memerr); } CLEAR_ENTRY( & ip_reassembly_pool[pos] ); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip6_reass: p %p\n", (void *) p)); return p; } } nullreturn: IPFRAG_STATS_INC(ip_frag.drop); pbuf_free(p); return NULL; } /** * Fragment an IP packet if too large * * Chop the packet in mtu sized chunks and send them in order * by using a fixed size static memory buffer (PBUF_ROM) */ err_t ip6_frag(struct stack *stack, struct pbuf *p, struct netif *netif, struct ip_addr *dest) { u8_t buf6[MAX_MTU]; struct pbuf *rambuf; struct pbuf *linkheader; struct ip_hdr *iphdr; struct ip6_fraghdr *fraghdr; u16_t mtu; u8_t last; /* last fragment, yes=1, no=0 */ u16_t left; u16_t frag_maxlen; /* Len of fragment payload to create */ u16_t offset; /* offset of current frag */ u16_t poffset; /* used for copy_from_pbuf() */ u16_t offset_m; /* offset + M bit field value */ u16_t ncopy; u16_t unfragpart_len; /* len of the Unfragmentable part */ u8_t nexthdr; u16_t destext_num; struct ip_exthdr *exthdr, *last_exthdr; iphdr = (struct ip_hdr *) p->payload; LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: start\n", __func__)); mtu = netif->mtu; /* Calculate len of Ipv6 Unfragmentable part */ unfragpart_len = IP_HLEN; nexthdr = IPH_NEXTHDR(iphdr); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: search next header %d\n", __func__, nexthdr)); exthdr = NULL; destext_num = 0; /* Destination header can occour two times. We include the first */ do { last_exthdr = exthdr; exthdr = (struct ip_exthdr *) ((char*)p->payload + unfragpart_len); if (nexthdr == IP6_NEXTHDR_HOP) { nexthdr = exthdr->nexthdr; } else if (nexthdr == IP6_NEXTHDR_DEST && destext_num < 1) { nexthdr = exthdr->nexthdr; destext_num++; } else if (nexthdr == IP6_NEXTHDR_ROUTING) { nexthdr = exthdr->nexthdr; } else { break; } } while (1); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: next header = %d\n", __func__, nexthdr)); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: unfrag part len = %d\n", __func__, unfragpart_len)); /* The Fragmentable Part of the original packet is divided into * fragments, each, except possibly the last ("rightmost") one, * being an integer multiple of 8 octets long. */ frag_maxlen = ((mtu - unfragpart_len - IP_EXTFRAG_LEN) >> 3) << 3; LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: frag maxlen = %d\n", __func__, frag_maxlen)); /* Get a RAM based sized pbuf for Unfragmentable part + Frag hdr*/ rambuf = pbuf_alloc(PBUF_LINK, 0, PBUF_REF); rambuf->tot_len = rambuf->len = unfragpart_len + IP_EXTFRAG_LEN + frag_maxlen; rambuf->payload = MEM_ALIGN((void *) buf6); /* Copy Unfragmentable part (IP hdr + Ext hdrs) */ iphdr = rambuf->payload; memcpy(iphdr, p->payload, unfragpart_len); /* Set NextHeader field in the IP header or the last Extension header */ if (last_exthdr == NULL) IPH_NEXTHDR_SET(iphdr, IP6_NEXTHDR_FRAGMENT); else last_exthdr->nexthdr = IP6_NEXTHDR_FRAGMENT; /* Fill Frag header's fields common to all fragments */ fraghdr = (struct ip6_fraghdr *) (((char *)iphdr) + unfragpart_len); fraghdr->nexthdr = nexthdr; fraghdr->id = htonl(stack->ip_id++); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: id = %d\n", __func__, UINT fraghdr->id)); /* Create fragments */ offset = 0; poffset = unfragpart_len; left = p->tot_len - unfragpart_len; LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: left = %d\n", __func__, left)); while (left) { last = (left <= frag_maxlen) ? 1 : 0; /* Set offset and M bit*/ offset_m = (offset>>3)<<3 ; if (!last) offset_m |= IP6_MF; fraghdr->offset_res_m = htons(offset_m); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: offset = %d\n", __func__, offset)); /* Fill this fragment*/ ncopy = last ? left : frag_maxlen; /* Payload Length of the original IPv6 header changed to contain the length of this fragment packet only (excluding the length * of the IPv6 header itself), */ IPH_PAYLOADLEN_SET(iphdr, (unfragpart_len - IP_HLEN) + IP_EXTFRAG_LEN + ncopy); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: offset = %d (%4x) (last=%d) copy=%d\n", __func__, offset, offset_m, last, ncopy)); p = copy_from_pbuf(p, &poffset, ((u8_t *) iphdr) + unfragpart_len + IP_EXTFRAG_LEN, ncopy); if (last) pbuf_realloc(rambuf, unfragpart_len + IP_EXTFRAG_LEN + left); /* This part is ugly: we alloc a RAM based pbuf for * the link level header for each chunk and then * free it.A PBUF_ROM style pbuf for which pbuf_header * worked would make things simpler. */ linkheader = pbuf_alloc(PBUF_LINK, 0, PBUF_RAM); pbuf_chain(linkheader, rambuf); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: netif->output (pbuf len/tot=%d/%d)\n", __func__, linkheader->len, linkheader->tot_len )); netif->output(netif, linkheader, dest); LWIP_DEBUGF(IP_REASS_DEBUG, ("%s: netif->output finish\n", __func__)); IPFRAG_STATS_INC(ip_frag.xmit); pbuf_free(linkheader); left -= ncopy; offset += ncopy; } pbuf_free(rambuf); return ERR_OK; } #endif #endif /* IPv6_FRAGMENTATION || IPv4_FRAGMENTATION */ lwipv6-1.5a/lwip-v6/src/core/ipv6/icmp6.c0000644000175000017500000004621111671615007017124 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2010,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* Some ICMP messages should be passed to the transport protocols. This is not implemented. */ #include "lwip/opt.h" #include "lwip/debug.h" #include "lwip/ip.h" #include "lwip/icmp.h" #include "lwip/inet.h" #include "lwip/def.h" #include "lwip/stats.h" #include "netif/etharp.h" #if IPv6_AUTO_CONFIGURATION #include "lwip/ip_autoconf.h" #endif /*--------------------------------------------------------------------------*/ /* * Handle ICMP input packets. * p = ICMP packet * inad = Interface destination Address * piphdr = IP pseudo header */ void icmp_input(struct stack *stack, struct pbuf *p, struct ip_addr_list *inad, struct pseudo_iphdr *piphdr) { struct ip_hdr *iphdr; struct ip4_hdr *ip4hdr; unsigned char type; struct icmp_echo_hdr *iecho; struct icmp_ns_hdr *ins; struct icmp_na_hdr *ina; struct icmp_opt_addr *opt; struct ip_addr tmpdest; struct netif *inp = inad->netif; /* FIX: remove 'stack' and use only inp->stack */ LWIP_ASSERT("STACK != NETIFSTACK \n", stack == inp->stack); ICMP_STATS_INC(icmp.recv); /* TODO: check length before accessing payload! */ if (pbuf_header(p, -(piphdr->iphdrlen)) || (p->tot_len < sizeof(u16_t)*2)) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%u bytes) received\n", p->tot_len)); pbuf_free(p); return; } type = ((char *)p->payload)[0]; switch (type | (piphdr->version << 8)) { case ICMP6_ECHO | (6 << 8): LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: icmp6 ping\n")); if (p->tot_len < sizeof(struct icmp_echo_hdr)) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); pbuf_free(p); ICMP_STATS_INC(icmp.lenerr); return; } iecho = p->payload; iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN); LWIP_DEBUGF(ICMP_DEBUG, ("from ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src)); LWIP_DEBUGF(ICMP_DEBUG, (" to ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest)); LWIP_DEBUGF(ICMP_DEBUG, ("\n")); if (inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len) != 0) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%x)\n", inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); ICMP_STATS_INC(icmp.chkerr); return; } LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %d p->tot_len %d\n", p->len, p->tot_len)); /* Reuse packet and set up echo response */ ip_addr_set(&tmpdest, piphdr->src); iecho->type = ICMP6_ER; /*compute the new checksum*/ iecho->chksum = 0; iecho->chksum = inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len); ICMP_STATS_INC(icmp.xmit); /* XXX ECHO must be routed */ ip_output (stack, p, &(inad->ipaddr), &tmpdest, IPH_HOPLIMIT(iphdr), 0, IP_PROTO_ICMP); break; /* * Neighbor Solicitation protocol */ case ICMP6_NS | (6 << 8): LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: icmp6 neighbor solicitation\n")); if (p->tot_len < sizeof(struct icmp_ns_hdr)) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP neighbor solicitation received\n")); pbuf_free(p); ICMP_STATS_INC(icmp.lenerr); return; } ins = p->payload; iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN); if (inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len) != 0) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP NS (%x)\n", inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); ICMP_STATS_INC(icmp.chkerr); pbuf_free(p); return; } LWIP_DEBUGF(ICMP_DEBUG, ("FROM ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src)); LWIP_DEBUGF(ICMP_DEBUG, (" TO ")); ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest)); LWIP_DEBUGF(ICMP_DEBUG, (" LOCALADDR ")); ip_addr_debug_print(ICMP_DEBUG, &(inad->ipaddr)); LWIP_DEBUGF(ICMP_DEBUG, ("\n")); LWIP_DEBUGF(ICMP_DEBUG, ("TARGETIP ")); ip_addr_debug_print(ICMP_DEBUG, (struct ip_addr *) &ins->targetip ); LWIP_DEBUGF(ICMP_DEBUG, ("\n")); if (ip_addr_list_deliveryfind(inad->netif->addrs, (struct ip_addr *) &ins->targetip, &(iphdr->src)) == NULL) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: not for us\n")); pbuf_free(p); return; } /* Reuse packet and create response */ ina = p->payload; opt = p->payload + sizeof(struct icmp_na_hdr); if (pbuf_header(p, IP_HLEN)) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: NA alloc ERR\n")); pbuf_free(p); return; } iphdr = (struct ip_hdr *)(p->payload); /* Set IP header */ ip_addr_set(&(iphdr->dest), &(iphdr->src)); ip_addr_set(&(iphdr->src), &(inad->ipaddr)); /* Set ICMP NA fields */ ina->type = ICMP6_NA; ina->icode = 0; /* FIX: why R bit set ? */ ina->rso_flags = (ICMP6_NA_S | ICMP6_NA_O | ICMP6_NA_R); bzero(ina->reserved, 3); /* ina->targetip Don't touch this field. For solicited advertisements, the Target Address field in the Neighbor Solicitation message that prompted this advertisement. */ /* Set Target link-layer address */ opt->type = ICMP6_OPT_DESTADDR; opt->len = ICMP6_OPT_LEN_ETHER; memcpy( &opt->addr, &(inp->hwaddr), inp->hwaddr_len); pbuf_header(p, - IP_HLEN); /* Calculate checksum */ ins->chksum = 0; ins->chksum = inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len); pbuf_header(p, IP_HLEN); LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %u p->tot_len %u\n", p->len, p->tot_len)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp: send Neighbor Advertisement\n")); ip_output_if (stack, p, &(iphdr->src), IP_LWHDRINCL, IPH_HOPLIMIT(iphdr), 0, IP_PROTO_ICMP, inp, &(iphdr->dest), 0); break; case ICMP6_NA | (6 << 8): LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: icmp6 neighbor advertisement\n")); if (p->tot_len < sizeof(struct icmp_na_hdr)) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP neighbor advertisement received\n")); pbuf_free(p); ICMP_STATS_INC(icmp.lenerr); return; } ina = p->payload; opt = p->payload + sizeof(struct icmp_na_hdr); iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN); if (inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len) != 0) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP NS (%x)\n", inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); ICMP_STATS_INC(icmp.chkerr); return; } /* The sender is a router? */ if (ina->rso_flags & ICMP6_NA_R) { /* TODO: */ } /* override an existing cache entry and update the cached link-layer address? */ if (ina->rso_flags & ICMP6_NA_O) { /* TODO */ } #if IPv6_AUTO_CONFIGURATION /* FIX: add MULTISTACK */ /* Check Target IP for Duplicate Address Detection protocol */ ip_autoconf_handle_na(inad->netif, p, iphdr, ina); #endif update_arp_entry(inp, (struct ip_addr *)&ina->targetip, (struct eth_addr *)&opt->addr, 0); break; /* * Router Advertisement Protocol */ case ICMP6_RS | (6 << 8): #if IPv6_ROUTER_ADVERTISEMENT { struct icmp_rs_hdr *irs; LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: icmp6 Route Solicitation \n")); if (p->tot_len < sizeof(struct icmp_rs_hdr)) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP Router solicitation received\n")); pbuf_free(p); ICMP_STATS_INC(icmp.lenerr); return; } iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN); irs = p->payload; if (inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len) != 0) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP RS (%x)\n", inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); ICMP_STATS_INC(icmp.chkerr); return; } /* FIX: add MULTISTACK */ ip_radv_handle_rs(inad->netif, p, iphdr, irs); } #else LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: icmp6 router Solicitation. Not supported!\n")); #endif break; case ICMP6_RA | (6 << 8): #if IPv6_AUTO_CONFIGURATION { struct icmp_ra_hdr *ira; LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: icmp6 Route Advertisement \n")); if (p->tot_len < sizeof(struct icmp_ra_hdr)) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP Router advertisement received\n")); pbuf_free(p); ICMP_STATS_INC(icmp.lenerr); return; } iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN); ira = p->payload; if (inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len) != 0) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP NS (%x)\n", inet6_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); ICMP_STATS_INC(icmp.chkerr); return; } /* Try autoconfiguration */ ip_autoconf_handle_ra(inad->netif, p, iphdr, ira); } #else LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: icmp6 Route Advertisement. Not supported \n")); #endif break; /* * IPv4 */ case ICMP4_ECHO | (4 << 8): LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: icmp4 echo\n")); if (ip_addr_is_v4broadcast(piphdr->dest, &(inad->ipaddr), &(inad->netmask)) || ip_addr_ismulticast(piphdr->dest)) { LWIP_DEBUGF(ICMP_DEBUG, ("Smurf.\n")); ICMP_STATS_INC(icmp.err); pbuf_free(p); return; } if (p->tot_len < sizeof(struct icmp_echo_hdr)) { LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); ICMP_STATS_INC(icmp.lenerr); pbuf_free(p); return; } /* Set up echo response */ iecho = p->payload; ip4hdr = (struct ip4_hdr *)((char *)p->payload - piphdr->iphdrlen); ip_addr_set(&tmpdest, piphdr->src); iecho->type=ICMP4_ER; if (iecho->chksum >= htons(0xffff - (ICMP4_ECHO << 8))) { iecho->chksum += htons(ICMP4_ECHO << 8) + 1; } else { iecho->chksum += htons(ICMP4_ECHO << 8); } ICMP_STATS_INC(icmp.xmit); ip_output(stack, p, &(inad->ipaddr), &tmpdest, IPH4_TTL(ip4hdr), 0, IP_PROTO_ICMP4); break; default: LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d not supported.\n", (int)type)); ICMP_STATS_INC(icmp.proterr); ICMP_STATS_INC(icmp.drop); } pbuf_free(p); } /* * Send a Duplicate Address Detection message * See seciont 4.3. of RFC 2461. */ void icmp_send_dad(struct stack *stack, struct ip_addr_list *targetip, struct netif *srcnetif) { struct ip_addr_list src; LWIP_DEBUGF(ICMP_DEBUG, ("icmp_send_dad: sending DAD\n")); /* Setup source interface and address for this packet.*/ IP6_ADDR_UNSPECIFIED(&(src.ipaddr)); src.netif = srcnetif; icmp_neighbor_solicitation(stack, &(targetip->ipaddr), &src); } /* * Send a Neighbor Solicitation message. * - ipaddr = target ip * - inad = outgoing netif + ip * * FIX: See seciont 4.3. of RFC 2461. Must use unicast address * when the node seeks to verify the reachability of a neighbor (not yet implemented). */ void icmp_neighbor_solicitation(struct stack *stack, struct ip_addr *ipaddr, struct ip_addr_list *inad) { struct pbuf *q; struct icmp_ns_hdr *ins; struct icmp_opt_addr *iopt; struct ip_addr targetaddr; struct netif *inp = inad->netif; LWIP_DEBUGF(ICMP_DEBUG, ("icmp_neighbor_solicitation: sending NS\n")); /* Setup a Solicited-Node Address multicast address */ IP6_ADDR_SOLICITED(&targetaddr, ipaddr); /* ICMP header + [SrcAddr option+Ethernet address] */ q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_ns_hdr) + sizeof(struct icmp_opt_addr) + 6, PBUF_RAM); /* Fill icmp header */ ins = q->payload; ins->type = ICMP6_NS; ins->icode = 0; ins->reserved = 0; /* The IP address of the target of the solicitation. It MUST NOT be a multicast address. */ memcpy(&ins->targetip, ipaddr, sizeof(struct ip_addr)); LWIP_DEBUGF(ICMP_DEBUG, ("\ttargetip: ")); ip_addr_debug_print(ICMP_DEBUG, (struct ip_addr *) &ins->targetip); LWIP_DEBUGF(ICMP_DEBUG, ("\n")); /* Fill option header with interface's link-layer address */ iopt = q->payload + sizeof(struct icmp_ns_hdr); iopt->type = ICMP6_OPT_SRCADDR; iopt->len = ICMP6_OPT_LEN_ETHER; memcpy(&iopt->addr, &(inp->hwaddr), inp->hwaddr_len); /* Calculate checksum */ ins->chksum = 0; ins->chksum = inet6_chksum_pseudo(q, &(inad->ipaddr), &(targetaddr), IP_PROTO_ICMP, q->tot_len); ip_output_if(stack, q, &(inad->ipaddr), &targetaddr, 255, 0, IP_PROTO_ICMP, inp, &(targetaddr), 0); pbuf_free(q); } /* * Send a Neighbor Solicitation message. * See seciont 4.3. of RFC 2461. */ void icmp_router_solicitation(struct stack *stack, struct ip_addr *ipaddr, struct ip_addr_list *inad) { struct pbuf *q; struct icmp_rs_hdr *irs; struct icmp_opt_addr *iopt; struct ip_addr targetaddr; struct netif *inp = inad->netif; LWIP_DEBUGF(ICMP_DEBUG, ("icmp_router_solicitation: sending RS\n")); /* Setup a All-router multicast address */ IP6_ADDR_ALLROUTER(&targetaddr, IP6_LINKLOCAL); /* ICMP header + [SrcAddr option+Ethernet address] */ q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_rs_hdr) + sizeof(struct icmp_opt_addr) + 6, PBUF_RAM); /* Fill icmp header */ irs = q->payload; irs->type = ICMP6_RS; irs->icode = 0; irs->reserved = 0; /* Fill option header with our link-layer address */ iopt = q->payload + sizeof(struct icmp_rs_hdr); iopt->type = ICMP6_OPT_SRCADDR; iopt->len = ICMP6_OPT_LEN_ETHER; memcpy(&iopt->addr, &(inp->hwaddr), inp->hwaddr_len); /* Calculate checksum */ irs->chksum = 0; irs->chksum = inet6_chksum_pseudo(q, &(inad->ipaddr), &(targetaddr), IP_PROTO_ICMP, q->tot_len); ip_output_if (stack, q, &(inad->ipaddr), &targetaddr, 255, 0, IP_PROTO_ICMP, inp, &(targetaddr), 0); pbuf_free(q); } /* ipv4 mgmt added by Diego Billi */ void icmp_dest_unreach(struct stack *stack, struct pbuf *p, enum icmp_dur_type t) { struct pbuf *q; struct ip_hdr *iphdr=p->payload; struct icmp_dur_hdr *idur; if (IPH_V(iphdr) == 4) { struct ip4_hdr *ip4hdr=p->payload; struct ip_addr tmpdest; q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_dur_hdr) + IP4_HLEN + 8, PBUF_RAM); idur = q->payload; idur->type = (char)ICMP4_DUR; idur->icode = (char)t; memcpy((char *)q->payload + sizeof(struct icmp_dur_hdr), p->payload, IP4_HLEN + 8); /* calculate checksum */ idur->chksum = 0; idur->chksum = inet_chksum(idur, q->len); ICMP_STATS_INC(icmp.xmit); IP64_CONV(&tmpdest, &ip4hdr->src); ip_output(stack, q, NULL, &tmpdest, ICMP_TTL, 0, IP_PROTO_ICMP4); } else { /* ICMP header + IP header + 8 bytes of data */ q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_dur_hdr) + IP_HLEN + 8, PBUF_RAM); idur = q->payload; idur->type = (char)ICMP6_DUR; idur->icode = (char)t; memcpy((char *)q->payload + sizeof(struct icmp_dur_hdr), p->payload, IP_HLEN + 8); /* calculate checksum */ idur->chksum = 0; idur->chksum = inet_chksum(idur, q->len); ICMP_STATS_INC(icmp.xmit); ip_output(stack, q, NULL, (struct ip_addr *)&(iphdr->src), ICMP_TTL, 0, IP_PROTO_ICMP); } pbuf_free(q); } void icmp_time_exceeded(struct stack *stack, struct pbuf *p, enum icmp_te_type t) { struct pbuf *q; struct ip_hdr *iphdr=p->payload; struct icmp_te_hdr *tehdr; if (IPH_V(iphdr) == 4) { struct ip4_hdr *ip4hdr=p->payload; struct ip_addr tmpdest; q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_te_hdr) + IP4_HLEN + 8, PBUF_RAM); tehdr = q->payload; tehdr->type = (char)ICMP4_TE; tehdr->icode = (char)t; /* copy fields from original packet */ memcpy((char *)q->payload + sizeof(struct icmp_te_hdr), (char *)p->payload, IP4_HLEN + 8); /* calculate checksum */ tehdr->chksum = 0; tehdr->chksum = inet_chksum(tehdr, q->len); ICMP_STATS_INC(icmp.xmit); IP64_CONV(&tmpdest, &ip4hdr->src); ip_output(stack, q, NULL, &tmpdest, ICMP_TTL, 0, IP_PROTO_ICMP4); } else { q = pbuf_alloc(PBUF_IP, sizeof(struct icmp_te_hdr) + IP_HLEN + 8, PBUF_RAM); tehdr = q->payload; tehdr->type = (char)ICMP6_TE; tehdr->icode = (char)t; /* copy fields from original packet */ memcpy((char *)q->payload + sizeof(struct icmp_te_hdr), (char *)p->payload, IP_HLEN + 8); /* calculate checksum */ tehdr->chksum = 0; tehdr->chksum = inet_chksum(tehdr, q->len); ICMP_STATS_INC(icmp.xmit); ip_output(stack, q, NULL, (struct ip_addr *)&(iphdr->src), ICMP_TTL, 0, IP_PROTO_ICMP); } pbuf_free(q); } void icmp_packet_too_big(struct stack *stack, struct pbuf *p, u16_t mtu) { struct pbuf *q; struct ip_hdr *iphdr; struct icmp_ptb_hdr *ptbhdr; q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM); /* Fill ICMP header */ ptbhdr = q->payload; ptbhdr->type = (char)ICMP6_PTB; ptbhdr->icode = 0; ptbhdr->mtu = htons(mtu); /* copy fields from original packet */ iphdr = p->payload; memcpy((char *)q->payload + 8, (char *)p->payload, IP_HLEN + 8); /* calculate ICMP checksum */ ptbhdr->chksum = 0; ptbhdr->chksum = inet_chksum(ptbhdr, q->len); ICMP_STATS_INC(icmp.xmit); /* Send */ ip_output(stack, q, NULL, (struct ip_addr *)&(iphdr->src), ICMP_TTL, 0, IP_PROTO_ICMP); pbuf_free(q); } lwipv6-1.5a/lwip-v6/src/core/ipv6/README0000644000175000017500000000026611671615007016622 0ustar renzorenzo/* This is LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy */ lwipv6-1.5a/lwip-v6/src/core/ipv6/ip6_radv.c0000644000175000017500000004646311671615007017631 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * Updated and integrated with the rest of the code * Copyright 2010 Renzo Davoli - University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if IPv6_ROUTER_ADVERTISEMENT #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/stats.h" #include "lwip/netif.h" #include "lwip/ip.h" #include "lwip/ip_addr.h" #include "lwip/icmp.h" #include "lwip/ip_radv.h" #include "lwip/radvconf.h" #include "lwip/netlinkdefs.h" #include "lwip/mem.h" /*---------------------------------------------------------------------------*/ #ifndef IP_RADV_DEBUG #define IP_RADV_DEBUG DBG_OFF #endif #define U_INT (unsigned int) /*--------------------------------------------------------------------------*/ #if 0 #define PREFIX_POOL_SIZE 10 static struct radv_prefix prefix_pool[PREFIX_POOL_SIZE]; static struct radv_prefix *prefix_freelist; void radv_prefix_list_init(void) { int i; for (i=0; inext; ip_radv_prefix_init(el); return el; } } void radv_prefix_list_free(struct radv_prefix *el) { el->next = prefix_freelist; prefix_freelist = el; } #endif void radv_prefix_list_init(void) {} void ip_radv_prefix_init(struct radv_prefix *prefix); struct radv_prefix * radv_prefix_list_alloc() { struct radv_prefix *el=mem_malloc(sizeof(struct radv_prefix)); if (el != NULL) ip_radv_prefix_init(el); return el; } void radv_prefix_list_free(struct radv_prefix *el) { mem_free(el); } void ip_radv_prefix_init(struct radv_prefix *prefix) { memset(prefix, 0, sizeof(struct radv_prefix)); //prefix->Prefix, prefix->PrefixLen prefix->AdvOnLinkFlag = DFLT_AdvOnLinkFlag; prefix->AdvAutonomousFlag = DFLT_AdvAutonomousFlag; prefix->AdvValidLifetime = DFLT_AdvValidLifetime; prefix->AdvPreferredLifetime = DFLT_AdvPreferredLifetime; } /*--------------------------------------------------------------------------*/ void ip_radv_data_init(struct radv *rinfo) { bzero((char*)rinfo, sizeof(struct radv)); rinfo->AdvSendAdvert = DFLT_AdvSendAdv; rinfo->AdvManagedFlag = DFLT_AdvManagedFlag; rinfo->AdvOtherConfigFlag = DFLT_AdvOtherConfigFlag; rinfo->MaxRtrAdvInterval = DFLT_MaxRtrAdvInterval; rinfo->MinDelayBetweenRAs = DFLT_MinDelayBetweenRAs; rinfo->MinRtrAdvInterval = DFLT_MinRtrAdvInterval(rinfo); rinfo->AdvLinkMTU = DFLT_AdvLinkMTU; rinfo->AdvSourceLLAddress = DFLT_AdvSourceLLAddress; rinfo->AdvReachableTime = DFLT_AdvReachableTime; rinfo->AdvRetransTimer = DFLT_AdvRetransTimer; rinfo->AdvCurHopLimit = DFLT_AdvCurHopLimit; rinfo->AdvSourceLLAddress = DFLT_AdvSourceLLAddress; rinfo->AdvDefaultLifetime = DFLT_AdvDefaultLifetime(rinfo); rinfo->UnicastOnly = DFLT_UnicastOnly; } void ip_radv_data_reset(struct radv *rinfo) { struct radv_prefix *el, *next; el = rinfo->prefix_list; while (el) { next = el->next; radv_prefix_list_free(el); el = next; } ip_radv_data_init(rinfo); } void ip_radv_netif_init(struct netif *netif) { netif->radv = mem_malloc(sizeof(struct radv)); LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: init '%c%c%d'.\n", __func__, netif->name[0], netif->name[1], netif->num) ); if (netif->radv != NULL) ip_radv_data_init(netif->radv); } void ip_radv_netif_reset(struct netif *netif) { struct radv *rinfo; LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: reset '%c%c%d'.\n", __func__, netif->name[0], netif->name[1], netif->num) ); rinfo = netif->radv; if (netif->radv != NULL) ip_radv_data_reset(rinfo); } /*--------------------------------------------------------------------------*/ static double rand_between(double lower, double upper) { return ((upper - lower) / (RAND_MAX + 1.0) * rand() + lower); } static int ip_forwarding_enabled(void) { #if IP_FORWARD return 1; #else return 0; #endif } static void send_ra(struct netif *netif, struct ip_addr *rs_ipsrc) { int totlen; struct stack *stack = netif->stack; struct radv_prefix *list; struct pbuf *p; struct icmp_ra_hdr *rahdr; struct icmp_opt_prefix *opt_prefix; struct icmp_opt_mtu *opt_mtu; struct icmp_opt_addr *opt_addr; struct ip_addr srcip; struct ip_addr dstip; LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: start \n", __func__) ); /* * Set IP addresses */ if (rs_ipsrc != NULL && !ip_addr_isunspecified(rs_ipsrc)) { ip_addr_set (&dstip, rs_ipsrc); } else IP6_ADDR_ALLNODE(&dstip, IP6_LINKLOCAL); IP6_ADDR_LINKSCOPE(&srcip, netif->hwaddr); /* * Calculate ICMP packet size */ totlen = sizeof(struct icmp_ra_hdr); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tLenght = RA(%d)", totlen) ); list = netif->radv->prefix_list; while (list != NULL) { totlen += sizeof(struct icmp_opt_prefix); LWIP_DEBUGF(IP_RADV_DEBUG, ("+Prefix(%d)", totlen) ); list = list->next; } if (netif->radv->AdvLinkMTU != 0) { totlen += sizeof(struct icmp_opt_mtu); LWIP_DEBUGF(IP_RADV_DEBUG, ("+MTU(%d)", totlen) ); } if (netif->radv->AdvSourceLLAddress == TRUE) { totlen += sizeof(struct icmp_opt_addr) + netif->hwaddr_len; LWIP_DEBUGF(IP_RADV_DEBUG, ("+LLAddr(%d)", totlen) ); } LWIP_DEBUGF(IP_RADV_DEBUG, ("\n") ); /* * Create ICMP packet */ p = pbuf_alloc(PBUF_IP, totlen , PBUF_RAM); if (p == NULL) { LWIP_DEBUGF(IP_RADV_DEBUG, ("\t*** Unable to create new packet")); return; } LWIP_DEBUGF(IP_RADV_DEBUG, ("\tSetting: RA") ); bzero(p->payload, p->tot_len); rahdr = p->payload; rahdr->type = ICMP6_RA; rahdr->icode = 0; rahdr->hoplimit = netif->radv->AdvCurHopLimit; rahdr->m_o_flag = netif->radv->AdvManagedFlag ? ICMP6_RA_M : 0; rahdr->m_o_flag |= netif->radv->AdvOtherConfigFlag ? ICMP6_RA_O : 0; rahdr->life = ip_forwarding_enabled() ? htons(netif->radv->AdvDefaultLifetime) : 0; rahdr->reach = htonl(netif->radv->AdvReachableTime); rahdr->retran = htonl(netif->radv->AdvRetransTimer); /* Add MTU option */ opt_mtu = (struct icmp_opt_mtu *) (rahdr + 1); if (netif->radv->AdvLinkMTU != 0) { LWIP_DEBUGF(IP_RADV_DEBUG, ("+MTU") ); opt_mtu->type = ICMP6_OPT_MTU; opt_mtu->len = 1; opt_mtu->reserved = 0; opt_mtu->mtu = htonl(netif->radv->AdvLinkMTU); opt_mtu++; } /* Add prefix options */ opt_prefix = (struct icmp_opt_prefix *) (opt_mtu); list = netif->radv->prefix_list; while (list != NULL) { LWIP_DEBUGF(IP_RADV_DEBUG, ("+Prefix") ); bzero(opt_prefix, sizeof(struct icmp_opt_prefix)); opt_prefix->type = ICMP6_OPT_PREFIX; opt_prefix->len = 4; opt_prefix->flags = 0; if (list->AdvOnLinkFlag) opt_prefix->flags |= ICMP6_OPT_PREF_L; if (list->AdvAutonomousFlag) opt_prefix->flags |= ICMP6_OPT_PREF_A; opt_prefix->flags |= ICMP6_OPT_PREF_R; opt_prefix->preflen = (u8_t) list->PrefixLen; opt_prefix->valid = htonl(list->AdvValidLifetime); opt_prefix->prefered = htonl(list->AdvPreferredLifetime); opt_prefix->reserved = 0; ip_addr_set((struct ip_addr *) &opt_prefix->prefix, &list->Prefix); list = list->next; opt_prefix++; } /* Add Link-level source addr */ opt_addr = (struct icmp_opt_addr *) (opt_prefix); if (netif->radv->AdvSourceLLAddress == TRUE) { LWIP_DEBUGF(IP_RADV_DEBUG, ("+LLAddr") ); opt_addr->type = ICMP6_OPT_SRCADDR; opt_addr->len = (u8_t) ((2 + netif->hwaddr_len) / 8 ) ; memcpy(&opt_addr->addr, netif->hwaddr, netif->hwaddr_len); } LWIP_DEBUGF(IP_RADV_DEBUG, ("\n") ); /* * Send packet */ rahdr->chksum = 0; rahdr->chksum = inet6_chksum_pseudo(p, &srcip, &dstip, IP_PROTO_ICMP, p->tot_len); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tReady to send!! \n") ); ICMP_STATS_INC(icmp.xmit); ip_output_if(stack, p, &srcip, &dstip, 255, 0, IP_PROTO_ICMP , netif, &dstip, 0); pbuf_free(p); } /* Timeouts schema: * * last RA DT Min next RA Max * |-------|-------------|--------ST---------|--------> TIME LINE * Case 1: | |---|+++| * | RS ST * | * Case 2: | |+++| * | RS ST * | * Case 3: | ST * | * * DT = min_delay_RA_timeout() (netif->MinDelayBetweenRAs) * ST = send_multicast_ra_timeout() * * Min = netif->MinRtrAdvInterval * Max = netif->MaxRtrAdvInterval * * RS = Router Solicitation * * (1) - Solicited RS message received -> netif->solicitation_received = 1 * - MinDelayBetweenRA reached -> RA will be sent after a random delay ( [0, MAX_RA_DELAY_TIME] ) * - RA sent * * (2) RS message received and RA sent after a random delay [0, MAX_RA_DELAY_TIME] * * (3) No RS -> Unsolicited multicast RA */ static void min_delay_RA_timeout(void *data); static void send_multicast_ra_timeout(void *data); static void remove_ra_timers(struct netif *netif) { sys_untimeout(min_delay_RA_timeout, netif); sys_untimeout(send_multicast_ra_timeout, netif); } /* Resets RA timers. If waitmax == 1 then next RA will be sent after MaxRtrAdvInterval seconds */ static void ip_radv_reset_timers(struct netif *netif, int waitmax) { u32_t next_send; LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: reset RA timers for %c%c%d\n", __func__, netif->name[0], netif->name[1], netif->num)); netif->radv->solicited_received = 0; netif->radv->min_delay_RA_reached = 0; remove_ra_timers(netif); /* Calculate next multicast RA timeout */ if (waitmax) { next_send = netif->radv->MaxRtrAdvInterval; } else next_send = rand_between(netif->radv->MinRtrAdvInterval, netif->radv->MaxRtrAdvInterval); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tNext Multicast RA at %d s (%ld ms)\n", U_INT next_send, next_send * 1000)); sys_timeout(next_send * 1000, send_multicast_ra_timeout, netif); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tMinDelayBetweenRAs = %d s (%ld ms)\n", U_INT netif->radv->MinDelayBetweenRAs, netif->radv->MinDelayBetweenRAs * 1000)); sys_timeout(netif->radv->MinDelayBetweenRAs * 1000, min_delay_RA_timeout , netif); } /* Send multicast RA and reset timers */ static void send_multicast_ra(struct netif *netif) { send_ra(netif, NULL); ip_radv_reset_timers(netif, 0); } /* Called when the unsolicited multicas RA have to be sent */ static void send_multicast_ra_timeout(void *data) { struct netif *netif = (struct netif *) data; LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: It's time to send a multicast RA\n", __func__)); send_multicast_ra(netif); } /* Called when we need to send a RA in response to a RS */ static void send_multicast_ra_with_delay(struct netif *netif) { u32_t delay; /* Router Advertisements sent in response to a Router Solicitation MUST be delayed by a random time between 0 and MAX_RA_DELAY_TIME seconds. */ delay = (u32_t) (MAX_RA_DELAY_TIME * rand() / (RAND_MAX + 1.0)); LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: Send RA with delay %d s (%ld ms).\n ", __func__, U_INT delay, delay * 1000)); sys_timeout(delay, send_multicast_ra_timeout, netif); } /* Called when the Mininum RAd interval is reached */ static void min_delay_RA_timeout(void *data) { struct netif *netif = (struct netif *) data; LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: reached! \n", __func__)); netif->radv->min_delay_RA_reached = 1; /* If we received a RS, now we must send a RA */ if (netif->radv->solicited_received == 1) { send_multicast_ra_with_delay(netif); } } static void remember_rs(struct netif *netif) { netif->radv->solicited_received = 1; /* We received a solicitation, unset the next RA timeout. We are going to send it at the next min_delay_RA_timeout() */ sys_untimeout(send_multicast_ra_timeout, netif); } /*--------------------------------------------------------------------------*/ /* Functions for unicast RA only */ /*--------------------------------------------------------------------------*/ struct send_unicast_data { struct netif *netif; struct ip_addr src; }; static void send_unicast_timeout(void *arg) { struct send_unicast_data *data = (struct send_unicast_data *) arg; LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: start\n", __func__)); send_ra(data->netif, &data->src); mem_free(data); } static void send_unicast_ra_with_delay(struct netif *netif, struct ip_addr *src) { struct unicast_data *data; u32_t delay; data = mem_malloc(sizeof(struct send_unicast_data)); if (data == NULL) return; delay = (u32_t) (MAX_RA_DELAY_TIME * rand() / (RAND_MAX + 1.0)); LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: Send Unicast RA widh %d delay\n", __func__, U_INT delay)); sys_timeout(delay, send_unicast_timeout, data); } /*--------------------------------------------------------------------------*/ /* Public functions */ /*--------------------------------------------------------------------------*/ void ip_radv_init(struct stack *stack) { #if 0 LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: init Routing Advertising tables.\n", __func__) ); radv_prefix_list_init(); #endif } void ip_radv_start(struct netif *netif) { LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: Routing Advertising enabled.\n", __func__) ); if (netif->radv == NULL) return; if (netif-> radv && netif->radv->AdvSendAdvert == TRUE) { LWIP_DEBUGF(IP_RADV_DEBUG, ("\tSending first RA\n")); send_ra(netif, NULL); ip_radv_reset_timers(netif, 1); } } void ip_radv_stop(struct netif *netif) { if (netif->radv) { LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: Routing Advertising disabled.\n", __func__) ); remove_ra_timers(netif); } } void ip_radv_shutdown(struct netif *netif) { if (netif->radv) { netif->radv->AdvDefaultLifetime = 0; send_ra(netif, NULL); remove_ra_timers(netif); } } int ip_radv_check_options(struct netif *netif) { struct radv_prefix *prefix; int res = 1; if (netif->radv == NULL) return -1; if ((netif->radv->MinRtrAdvInterval < MIN_MinRtrAdvInterval) || (netif->radv->MinRtrAdvInterval > MAX_MinRtrAdvInterval(netif))) { res = -1; } if ((netif->radv->MaxRtrAdvInterval < MIN_MaxRtrAdvInterval) || (netif->radv->MaxRtrAdvInterval > MAX_MaxRtrAdvInterval)) { res = -1; } if (netif->radv->MinDelayBetweenRAs < MIN_DELAY_BETWEEN_RAS) { res = -1; } if ( (netif->radv->AdvLinkMTU != 0) && ((netif->radv->AdvLinkMTU < MIN_AdvLinkMTU) || (netif->radv->AdvLinkMTU > netif->mtu)) ) { res = -1; } if (netif->radv->AdvReachableTime > MAX_AdvReachableTime) { res = -1; } if (netif->radv->AdvCurHopLimit > MAX_AdvCurHopLimit) { /* FIX: always true due to limited range of data type */ res = -1; } if ((netif->radv->AdvDefaultLifetime != 0) && ((netif->radv->AdvDefaultLifetime > MAX_AdvDefaultLifetime) || (netif->radv->AdvDefaultLifetime < MIN_AdvDefaultLifetime(netif))) ) { res = -1; } prefix = netif->radv->prefix_list; while (prefix) { if (prefix->PrefixLen > MAX_PrefixLen) { res = -1; } if (prefix->AdvPreferredLifetime > prefix->AdvValidLifetime) { res = -1; } prefix = prefix->next; } if (res <= 0) { LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: RA disabled on '%c%c%d'.\n", __func__, netif->name[0], netif->name[1], netif->num) ); netif->radv->AdvSendAdvert = FALSE; } return res; } void ip_radv_handle_rs(struct netif *netif, struct pbuf *p, struct ip_hdr *iphdr, struct icmp_rs_hdr *irs) { if (netif->radv == NULL) return; LWIP_DEBUGF(IP_RADV_DEBUG, ("%s: Processing received RS \n", __func__) ); if (irs->icode != 0) { LWIP_DEBUGF(IP_RADV_DEBUG, ("\tinvalide ICMP code: %d\n", (int) irs->icode)); return; } if (IPH_HOPLIMIT(iphdr) != 255) { LWIP_DEBUGF(IP_RADV_DEBUG, ("\tinvalide HOP LIMIT: %d\n", (int) IPH_HOPLIMIT(iphdr))); return; } if (netif->radv->AdvSendAdvert == FALSE) { LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvSendAdvert is off.\n")); return; } /* FIX: check valid ICMP options: * - NO Link-layer Address option with unspecified IP source address! * - others? */ if (netif->radv->UnicastOnly) { send_unicast_ra_with_delay(netif, &iphdr->src); } else { /* Have we reached the Mininum RA interval? */ if (netif->radv->min_delay_RA_reached == 0) { LWIP_DEBUGF(IP_RADV_DEBUG, ("\tRS received before Mininum RA . wait!\n")); remember_rs(netif); } else { LWIP_DEBUGF(IP_RADV_DEBUG, ("\tWe can respond to the RS.\n")); send_multicast_ra_with_delay(netif); } } } /*--------------------------------------------------------------------------*/ /* Debug functions */ /*--------------------------------------------------------------------------*/ void ip_radv_prefix_dump(struct radv_prefix *prefix) { LWIP_DEBUGF(IP_RADV_DEBUG, ("\t")); ip_addr_debug_print(IP_RADV_DEBUG, &prefix->Prefix); LWIP_DEBUGF(IP_RADV_DEBUG, (" / %d \n", prefix->PrefixLen)); LWIP_DEBUGF(IP_RADV_DEBUG, ("\t\tAdvOnLinkFlag = %d\n", prefix->AdvOnLinkFlag )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\t\tAdvAutonomousFlag = %d\n", prefix->AdvAutonomousFlag )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\t\tAdvValidLifetime = %d\n", U_INT prefix->AdvValidLifetime )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\t\tAdvPreferredLifetime = %d\n", U_INT prefix->AdvPreferredLifetime )); } void ip_radv_data_dump(struct radv *rinfo) { struct radv_prefix *prefix; LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvSendAdvert = %d\n", rinfo->AdvSendAdvert )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tUnicastOnly = %d\n", rinfo->UnicastOnly )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvManagedFlag = %d\n", U_INT rinfo->AdvManagedFlag )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvOtherConfigFlag = %d\n", U_INT rinfo->AdvOtherConfigFlag )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tMaxRtrAdvInterval = %d\n", U_INT rinfo->MaxRtrAdvInterval )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tMinRtrAdvInterval = %d\n", U_INT rinfo->MinRtrAdvInterval )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tMinDelayBetweenRAs = %d\n", U_INT rinfo->MinDelayBetweenRAs )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvRetransTimer = %d\n", U_INT rinfo->AdvRetransTimer )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvReachableTime = %d\n", U_INT rinfo->AdvReachableTime )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvDefaultLifetime = %d\n", U_INT rinfo->AdvDefaultLifetime )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvCurHopLimit = %d\n", rinfo->AdvCurHopLimit )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvLinkMTU = %d\n", U_INT rinfo->AdvLinkMTU )); LWIP_DEBUGF(IP_RADV_DEBUG, ("\tAdvSourceLLAddress = %d\n", rinfo->AdvSourceLLAddress )); prefix = rinfo->prefix_list; while (prefix) { ip_radv_prefix_dump(prefix); prefix = prefix->next; } } #endif /* IPv6_ROUTER_ADVERTISEMENT */ lwipv6-1.5a/lwip-v6/src/core/ipv6/ip6_autoconf.c0000644000175000017500000005550111671615007020504 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if IPv6_AUTO_CONFIGURATION #include "lwip/debug.h" #include "lwip/def.h" #include "lwip/sys.h" #include "lwip/netif.h" #include "lwip/ip.h" #include "lwip/ip_addr.h" #include "lwip/stack.h" #include "lwip/icmp.h" #include "lwip/ip_autoconf.h" #include "lwip/netlinkdefs.h" #include "lwip/mem.h" /*--------------------------------------------------------------------------*/ #ifndef IP_AUTOCONF_DEBUG #define IP_AUTOCONF_DEBUG DBG_OFF #endif void dad_timeout(void *arg); void dad_remove_timer(struct ip_addr_list *addr); void start_dad_on_addr(struct ip_addr_list *addr, struct netif *netif); /*--------------------------------------------------------------------------*/ /* Functions */ /*--------------------------------------------------------------------------*/ void ip_autoconf_init(struct stack *stack) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: IPv6 Address Autoconfiguration Enabled.\n", __func__)); } void ip_autoconf_shutdown(struct stack *stack) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: IPv6 Address Autoconfiguration stopped.\n", __func__)); } /* Initialize interface data for autoconfiguration protocol */ void ip_autoconf_netif_init(struct netif *netif) { netif->autoconf = NULL; LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: Init interface %c%c%d.\n", __func__, netif->name[0],netif->name[1],netif->num)); } static inline void ip_autoconf_netif_init_values(struct netif *netif) { netif->autoconf->status = AUTOCONF_INIT; netif->autoconf->flag_M = 0; netif->autoconf->flag_O = 0; netif->autoconf->dad_duptrans = DUP_ADDR_DETECT_TRANSMITS; netif->autoconf->retrans_timer = RETRANS_TIMER; /* milliseconds */ netif->autoconf->rtr_sol_counter = 0; netif->autoconf->max_rtr_solicitation_delay = MAX_RTR_SOLICITATION_DELAY; netif->autoconf->rtr_solicitation_interval = RTR_SOLICITATION_INTERVAL; netif->autoconf->max_rtr_solicitations = MAX_RTR_SOLICITATIONS; netif->autoconf->addrs_tentative = NULL; } int create_address_from_prefix(struct ip_addr *ip, struct ip_addr *netmask, struct ip_addr *prefix, int prefixlen, struct netif *netif) { /* FIX FIX FIX FIX: very bad way to create address XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX*/ IP6_ADDR_LINKSCOPE(ip, netif->hwaddr); memcpy(ip, prefix, prefixlen / 8); SET_ADDR_MASK((char*)netmask, prefixlen); return 1; } /* * TODO: read better: RFC 2461 - 6.3.4. Processing Received Router Advertisements */ void ip_autoconf_handle_ra(struct netif *netif, struct pbuf *p, struct ip_hdr *iphdr, struct icmp_ra_hdr *ira) { u16_t icmp_len; struct icmp_opt *opt; struct icmp_opt_addr *oaddr = NULL; struct icmp_opt_prefix *oprefix = NULL; struct icmp_opt_mtu *omtu = NULL; struct ip_addr prefix; struct ip_addr ipaddr; struct ip_addr netmask; struct ip_addr_list *confaddr; struct stack *stack = netif->stack; if (netif->autoconf == NULL) return; LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: Processing received RA \n", __func__) ); if (ira->icode != 0) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: invalide ICMP code: %d",__func__, ira->icode)); return; } if (IPH_HOPLIMIT(iphdr) != 255) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: invalide HOP LIMIT: %d", __func__, IPH_HOPLIMIT(iphdr))); return; } /* Scan for options */ icmp_len = sizeof(struct icmp_ra_hdr); while (p->tot_len > icmp_len) { opt = (struct icmp_opt *) (p->payload + icmp_len); switch (opt->type) { case ICMP6_OPT_SRCADDR: /* Found SourceAdd option */ oaddr = (struct icmp_opt_addr *) opt; break; case ICMP6_OPT_PREFIX: /* Found Prefix option */ oprefix = (struct icmp_opt_prefix *) opt; break; case ICMP6_OPT_MTU: /* Fount Link MTU Option */ omtu = (struct icmp_opt_mtu *) opt; break; default: LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tICMP: *** BUG (unknow type %d)***. SKIP\n", opt->type) ); break; } icmp_len += opt->len * 8; } /* Handle router informations */ /* if Lifetime == 0 the router is not a default router and SHOULD NOT appear on the default router list. */ if (ira->life != 0) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tThis is default router: ")); ip_addr_debug_print(IP_AUTOCONF_DEBUG, &iphdr->src); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); /* TODO: check if the entry already exists and implement route lifetime */ IP6_ADDR_UNSPECIFIED(&ipaddr); IP6_ADDR_UNSPECIFIED(&netmask); ip_route_list_add(stack, &ipaddr,&netmask, &iphdr->src, netif, 0); } LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tHop-Lim:%u ", ira->hoplimit)); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("[M:%d O:%u] " , (ira->m_o_flag & ICMP6_RA_M)?1:0 , (ira->m_o_flag & ICMP6_RA_O)?1:0 )); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("Life:%d " , ntohs(ira->life) )); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("Reach:%d " , (unsigned int)ntohl(ira->reach) )); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("Retrans:%u\n" , (unsigned int)ntohl(ira->retran) )); if (ira->hoplimit != UNSPECIFIED) { /* TODO: up to now, HOPLIMIT values for TCP/UPD/ICMP are fixed (TCP_TTL, UDP_TTL, ICMP_TTL). :-/ */ } if (ira->m_o_flag & ICMP6_RA_M) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("Stateful or Stateless+DHCP configuration not supported!\n")); /* TODO */ return; } if (ira->reach != UNSPECIFIED) { /* TODO: reachability detection non implemented yet */ } if (ira->retran != UNSPECIFIED) { netif->autoconf->retrans_timer = ntohl(ira->retran); } /* Handle options */ if (oaddr != NULL) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tSrcAddr: %02x:%02x:%02x:%02x:%02x:%02x (len=%d)\n", oaddr->addr[0],oaddr->addr[1],oaddr->addr[2], oaddr->addr[3],oaddr->addr[4],oaddr->addr[5], oaddr->len * 8)); /* TODO: update or refresh ARP table? */ } if (omtu != NULL) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tLink MTU: %u (len=%u)\n", (unsigned int) ntohl(omtu->mtu), omtu->len * 8)); /* FIX: !!!!!!!!!!!!! very bad thing to change net->mtu */ //netif->mtu = ntohl(omtu->mtu); } if (oprefix != NULL) { /* Save prefix */ memcpy(&prefix, &oprefix->prefix, sizeof(struct ip_addr) ); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tPrefix: ")); ip_addr_debug_print(IP_AUTOCONF_DEBUG, &prefix); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("/%d ", oprefix->preflen)); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("[L:%d A:%d] Valid=%u Prefered=%u\n", (oprefix->flags & ICMP6_OPT_PREF_L)?1:0, (oprefix->flags & ICMP6_OPT_PREF_A)?1:0, (unsigned int) ntohl(oprefix->valid), (unsigned int) ntohl(oprefix->prefered))); /* We can use this prefix for autoconfiguration */ if (oprefix->flags & ICMP6_OPT_PREF_A) { confaddr = ip_addr_list_alloc(stack); if (confaddr != NULL) { confaddr->flags = IFA_F_TENTATIVE; confaddr->netif = netif; //FIX FIX: prefered time is relative to the prefix! confaddr->info.prefered = ntohl(oprefix->prefered); confaddr->info.valid = ntohl(oprefix->valid); create_address_from_prefix(&confaddr->ipaddr, &confaddr->netmask, &prefix, oprefix->preflen, netif); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tNetif IP: ")); ip_addr_debug_print(IP_AUTOCONF_DEBUG, &confaddr->ipaddr); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tNetmask : ")); ip_addr_debug_print(IP_AUTOCONF_DEBUG, &confaddr->netmask); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); /* This is a new autogenerated address ? */ if (ip_addr_list_find(netif->addrs, &confaddr->ipaddr, &confaddr->netmask) == NULL) { /* Add address to interface */ LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tAdding configured address...\n")); /* Store it in tentative addresses */ ip_addr_list_add(&(netif->autoconf->addrs_tentative), confaddr); /* this prefix can be used for on-link determination. */ if (oprefix->flags & ICMP6_OPT_PREF_L) { /* Add routing rule to reach onlink */ LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tAdding routing informations...\n")); ip_addr_set(&ipaddr, &(confaddr->ipaddr)); ip_addr_set(&netmask, &(confaddr->netmask)); ip_route_list_add(stack, &ipaddr, &netmask, NULL, netif, 0); } netif->autoconf->status = AUTOCONF_SUCC; /* Start DAD on new address */ start_dad_on_addr(confaddr, netif); } else { /* Discard autogenerated packet */ LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tAddress already added.\n")); ip_addr_list_free(stack, confaddr); /* TODO: update (address|route entry)'s life-time information? */ } } else { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("*** NO MORE MEMORY FOR ADDRESS!***\n")); } } } } void ip_autoconf_handle_na(struct netif *netif, struct pbuf *p, struct ip_hdr *iphdr, struct icmp_na_hdr *ina) { struct ip_addr_list * ip; struct stack *stack = netif->stack; if (netif->autoconf == NULL) return; LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: Processing received NA \n", __func__) ); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: [S=%d,R=%d,O=%d] ", __func__, ina->rso_flags & ICMP6_NA_S, ina->rso_flags & ICMP6_NA_R, ina->rso_flags & ICMP6_NA_O) ); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tTarget IP: ")); ip_addr_debug_print(IP_AUTOCONF_DEBUG, (struct ip_addr *) &ina->targetip); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); /* Is this a response to a Neighbor Solicitation from the Destination address? */ if (ina->rso_flags & ICMP6_NA_S) { /* If this advertisment is a response to a DAD message, the IP source address have to be a all-nodes multicast address. */ if (ip_addr_isallnode(&iphdr->dest)) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tMaybe a DAD response for us.\n") ); /* Check for tentative addresses! */ ip = ip_addr_list_maskfind(netif->autoconf->addrs_tentative, (struct ip_addr *) &ina->targetip); if (ip != NULL) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tAddress found!\n")); if (ip->info.flag == IPADDR_TENTATIVE) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\tIs TENTATIVE, remove it!\n")); /* Remove DAD timeout */ dad_remove_timer(ip); /* This address is duplicated, remove it */ ip_addr_list_del(&netif->autoconf->addrs_tentative, ip); ip_addr_list_free(stack, ip); /* FIX: remove any routing table's entries ???? */ /* If address was Link-local, disable interface */ if (ip_addr_islinkscope(&ip->ipaddr)) { netif->autoconf->status = AUTOCONF_FAIL; //netif->flags &= ~NETIF_FLAG_UP; ip_notify(netif, NETIF_CHANGE_DOWN); netif_set_down_low(netif); } } } else { /* what to do? */ LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("*** Received NS, but we don't have tentative addresses!\n")); } } else { /* TODO: simple NS*/ } } else { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("*** Received NS, but not solicited!\n")); /* TODO: */ } LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: stop \n", __func__) ); } /*--------------------------------------------------------------------------*/ /* Duplicate Address Detection (DAD) functions */ /*--------------------------------------------------------------------------*/ void dad_timeout(void *arg) { struct ip_addr_list *addr = (struct ip_addr_list *) arg; struct netif * netif = addr->netif; struct stack *stack = netif->stack; /* FIX: LOCK netif->addr */ //LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: start on ", __func__)); //ip_addr_debug_print(IP_AUTOCONF_DEBUG, &(addr->ipaddr)); //LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); /* If address still is TENTATIVE */ if (addr->info.flag == IPADDR_TENTATIVE) { /* More probes to send? */ if (addr->info.dad_counter < addr->netif->autoconf->dad_duptrans) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: still TENTATIVE (probes %d/%d)\n", __func__, addr->info.dad_counter, addr->netif->autoconf->dad_duptrans)); icmp_send_dad(stack, addr, netif); addr->info.dad_counter++; /* Set next timeout */ sys_timeout(netif->autoconf->retrans_timer, (sys_timeout_handler)dad_timeout, addr); } else { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: now PERMANENT\n", __func__)); addr->flags = IFA_F_PERMANENT; addr->info.flag = IPADDR_PREFERRED; /* Move from tenative to permanent */ ip_addr_list_del(&netif->autoconf->addrs_tentative, addr); /* FIX FIX: LOCK netif->addrs */ ip_addr_list_add(&netif->addrs, addr); /* FIX FIX: UNLOCK netif->addrs */ } } /* FIX: UNLOCK netif->addr */ } void dad_remove_timer(struct ip_addr_list *addr) { sys_untimeout((sys_timeout_handler)dad_timeout, addr); } /* Start Duplicate Address Detection in the address "addr" */ void start_dad_on_addr(struct ip_addr_list *addr, struct netif *netif) { struct stack *stack = netif->stack; LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: start on ", __func__)); ip_addr_debug_print(IP_AUTOCONF_DEBUG, &(addr->ipaddr)); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); addr->flags = IFA_F_TENTATIVE; addr->info.flag = IPADDR_TENTATIVE; addr->info.dad_counter = 0; icmp_send_dad(stack, addr, netif); /* Set DAD timeout for this entry. */ addr->info.dad_counter++; sys_timeout(netif->autoconf->retrans_timer, (sys_timeout_handler)dad_timeout, addr); } /*--------------------------------------------------------------------------*/ /* Router Solicitation functions */ /*--------------------------------------------------------------------------*/ /* * See RFC 2461: 6.3.7. Sending Router Solicitations */ void rtr_sol_timeout(void *arg) { struct netif *netif = (struct netif *) arg; struct ip_addr_list unspecified; struct ip_addr linkscope; struct ip_addr_list *srcaddr; struct stack *stack = netif->stack; /* If we received a Router Advertisment then netif->autoconf->status != INIT and stop protocol */ if (netif->autoconf->status != AUTOCONF_INIT) return; /* More probe to send? */ if (netif->autoconf->rtr_sol_counter < netif->autoconf->max_rtr_solicitations) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: sending RS (%d/%d).\n", __func__, netif->autoconf->rtr_sol_counter, netif->autoconf->max_rtr_solicitations)); /* Have we got a valid (not tentative) link-scope address? */ IP6_ADDR_LINKSCOPE(&linkscope, netif->hwaddr); srcaddr = ip_addr_list_maskfind(netif->addrs, &linkscope); if (srcaddr == NULL) { /* If we don't have link-scope address yet, use unspecified address */ IP6_ADDR_UNSPECIFIED(&(unspecified.ipaddr)); unspecified.netif = netif; srcaddr = &unspecified; } /* Send RS */ icmp_router_solicitation(stack, NULL, srcaddr); netif->autoconf->rtr_sol_counter++; /* Set next timeout */ sys_timeout( netif->autoconf->rtr_solicitation_interval * 1000, (sys_timeout_handler)rtr_sol_timeout, netif); } else { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: no routers on the link.\n", __func__)); netif->autoconf->status = AUTOCONF_FAIL; } } /* Start Duplicate Address Detection in the address "addr" */ void start_router_solicitation(struct netif *netif) { unsigned int r; u32_t delay; /* Before a host sends an initial solicitation, it SHOULD delay the transmission for a random amount of time between 0 and MAX_RTR_SOLICITATION_DELAY */ delay = ( ((float)rand_r(&r)) / RAND_MAX ) * (netif->autoconf->max_rtr_solicitation_delay * 1000) ; LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: start initial delay (%d/%d).\n", __func__, (unsigned int) delay, (int) netif->autoconf->max_rtr_solicitation_delay)); netif->autoconf->rtr_sol_counter = 0; sys_timeout(delay, (sys_timeout_handler)rtr_sol_timeout, netif); } /*--------------------------------------------------------------------------*/ /* Autoconfiguration timer */ /*--------------------------------------------------------------------------*/ /* Update lifetime and returns 1 if there is a valid (or tentative) link-scope address in the list */ INLINE static int addr_update_lifetime(struct stack *stack, struct ip_addr_list **addrs, u32_t time) { struct ip_addr_list *cur, *next; struct ip_addr_list *list, *new_list; int r = 0; if (*addrs == NULL) return 0; /* * Save in "new_list" the valid addresses and free the others. */ /* FIX: LOCK addrs */ list = *addrs; new_list = NULL; cur = list; do { next = cur->next; /* Skip IPV4 and not autoconfigured!!! */ if (cur->info.flag == IPADDR_NONE) { ip_addr_list_add(&new_list, cur); } else { /* Update address lifetime */ if (cur->info.prefered != INFINITE_LIFETIME) cur->info.prefered -= time; if (cur->info.valid != INFINITE_LIFETIME) cur->info.valid -= time; /* Update address status */ if (cur->info.flag & IPADDR_VALID) { if (cur->info.prefered == 0) { cur->info.flag = IPADDR_DEPRECATED; cur->flags = IFA_F_DEPRECATED; } if (cur->info.valid == 0) cur->info.flag = IPADDR_INVALID; } if (cur->info.flag != IPADDR_INVALID) { ip_addr_list_add(&new_list, cur); r = 1; } else { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: address expired! ", __func__)); ip_addr_debug_print(IP_AUTOCONF_DEBUG, &(cur->ipaddr)); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); /* TODO: Remove this address, close connections, ecc... */ ip_addr_list_free(stack, cur); } } cur = next; } while (cur != list); *addrs = new_list; /* FIX: UNLOCK addrs */ return r; } static struct ip_addr_list * create_link_scope_addr(struct netif *netif) { struct stack *stack = netif->stack; struct ip_addr_list *add = NULL; add = ip_addr_list_alloc(stack); if (add != NULL) { IP6_ADDR_LINKSCOPE(&(add->ipaddr), netif->hwaddr); IP6_ADDR(&(add->netmask), 0xffff,0xffff,0xffff,0xffff,0x0,0x0,0x0,0x0); add->netif = netif; add->flags = IFA_F_TENTATIVE; /* Now add Autoconfigurations info */ add->info.flag = IPADDR_TENTATIVE; add->info.dad_counter = 0; /* A link-local address has an infinite preferred and valid lifetime; it is never timed out. */ add->info.prefered = INFINITE_LIFETIME; add->info.valid = INFINITE_LIFETIME; } return add; } static void remove_autoconf_data(struct netif *netif) { struct stack *stack = netif->stack; struct ip_addr_list *cur, *next; struct ip_addr_list *list, *new_list; /* FIX: UNLOCK netif->addr */ /* Remove assigned addresses */ if (netif->addrs != NULL) { /* Save in "new_list" the valid addresses and free the others. */ list = netif->addrs; new_list = NULL; cur = list; do { next = cur->next; /* Skip IPV4 and not autoconfigured IPV6 !!! */ if (cur->info.flag == IPADDR_NONE) { ip_addr_list_add(&new_list, cur); } else { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: removing: ", __func__)); ip_addr_debug_print(IP_AUTOCONF_DEBUG, &(cur->ipaddr)); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); /* FIX: ABORT TCP,UDP,ICMP connections */ //ip_addr_close(&(cur->ipaddr)); ip_addr_list_free(stack, cur); } cur = next; } while (cur != list); netif->addrs = new_list; } /* FIX: UNLOCK netif->addr */ /* Remove tentative addresses */ while (netif->autoconf->addrs_tentative != NULL) { cur = ip_addr_list_first(netif->autoconf->addrs_tentative); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: tentative removing: ", __func__)); ip_addr_debug_print(IP_AUTOCONF_DEBUG, &(cur->ipaddr)); LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("\n")); dad_remove_timer(cur); ip_addr_list_del(&(netif->autoconf->addrs_tentative), cur); } /* * FIX: REMOVE ROUTING TABLE ENTRIES */ } /*--------------------------------------------------------------------------*/ static void ip_autoconf_timer(void *arg) { int have_linkaddr = 0; struct netif *netif = (struct netif *) arg; struct stack *stack = netif->stack; LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: start on %c%c%d \n", __func__, netif->name[0], netif->name[1], netif->num)); /* Update addresses status (and remove invalid addresses) */ have_linkaddr = addr_update_lifetime(stack, &netif->autoconf->addrs_tentative, (AUTOCONF_TMR_INTERVAL/1000)); /* FIX: LOCK netif->addrs */ have_linkaddr |= addr_update_lifetime(stack, &netif->addrs, (AUTOCONF_TMR_INTERVAL/1000)); /* FIX: UNLOCK netif->addrs */ sys_timeout(AUTOCONF_TMR_INTERVAL, ip_autoconf_timer , netif); } void ip_autoconf_start(struct netif *netif) { struct stack *stack = netif->stack; struct ip_addr_list *linkadd; LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: start.\n", __func__) ); netif->autoconf = mem_malloc(sizeof(struct autoconf)); if (netif->autoconf == NULL) return; ip_autoconf_netif_init_values(netif); /* If autoconfiguration has not started yet */ /*if (netif->autoconf->status == AUTOCONF_INIT) */{ LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: creating link-scope address.\n", __func__)); linkadd = create_link_scope_addr(netif); if (linkadd != NULL) { /* Add link-scope address as tentative */ ip_addr_list_add(&(netif->autoconf->addrs_tentative),linkadd); /* Add routing entry for link-scope addresses */ ip_route_list_add(stack, &(linkadd->ipaddr),&(linkadd->netmask), NULL, netif, 0); /* Start DAD on link-scope address */ start_dad_on_addr(linkadd, netif); sys_timeout(AUTOCONF_TMR_INTERVAL, ip_autoconf_timer , netif); } else { LWIP_DEBUGF( IP_AUTOCONF_DEBUG, ("%s: unable to create link-scop address. No more memory.\n", __func__) ); free(netif->autoconf); netif->autoconf = NULL; /* Disable interface */ //netif->flags &= ~NETIF_FLAG_UP; ip_notify(netif, NETIF_CHANGE_DOWN); netif_set_down_low(netif); //netif->autoconf->status = AUTOCONF_FAIL; } /* Router solicitation starts concurrently with Autoconfiguration to save time. */ start_router_solicitation(netif); } } void ip_autoconf_stop(struct netif *netif) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: start.\n", __func__) ); if (netif->autoconf) { if (netif->autoconf->status != AUTOCONF_INIT) { LWIP_DEBUGF(IP_AUTOCONF_DEBUG, ("%s: %c%c%d set down. reset data\n", __func__, netif->name[0],netif->name[1],netif->num)); remove_autoconf_data(netif); netif->autoconf->status = AUTOCONF_INIT; } sys_untimeout(ip_autoconf_timer, netif); free(netif->autoconf); netif->autoconf = NULL; } } #endif lwipv6-1.5a/lwip-v6/src/core/ipv6/ip6_addr.c0000644000175000017500000002762111671615007017602 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2010 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/ip_addr.h" #include "lwip/inet.h" #include "lwip/stack.h" #include "lwip/memp.h" /* Added by Diego Billi */ #define IP4_ADDR_BROADCAST_VALUE 0xffffffffUL const struct ip4_addr ip4_addr_broadcast = { IP4_ADDR_BROADCAST_VALUE }; const struct ip_addr ip_addr_any = {{0,0,0,0}}; #if BYTE_ORDER == LITTLE_ENDIAN const struct ip_addr ip4_addr_any = {{0,0,0xffff0000,0}}; #else const struct ip_addr ip4_addr_any = {{0,0,0x0000ffff,0}}; #endif int ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2, struct ip_addr *mask) { return((addr1->addr[0] & mask->addr[0]) == (addr2->addr[0] & mask->addr[0]) && (addr1->addr[1] & mask->addr[1]) == (addr2->addr[1] & mask->addr[1]) && (addr1->addr[2] & mask->addr[2]) == (addr2->addr[2] & mask->addr[2]) && (addr1->addr[3] & mask->addr[3]) == (addr2->addr[3] & mask->addr[3])); } int ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2) { return(addr1->addr[0] == addr2->addr[0] && addr1->addr[1] == addr2->addr[1] && addr1->addr[2] == addr2->addr[2] && addr1->addr[3] == addr2->addr[3]); } static inline int ip_addr_is_dhcp_broadcast(struct ip_addr *from, struct ip_addr *to) { return (from->addr[3]==0 && to->addr[3]==0xffffffff && from->addr[2]==IP64_PREFIX && to->addr[2]==IP64_PREFIX && (from->addr[0] | from->addr[1] | to->addr[0] | to->addr[1]) == 0); } void ip_addr_set(struct ip_addr *dest, struct ip_addr *src) { if (src == NULL) memcpy(dest, &ip_addr_any, sizeof(struct ip_addr)); else memcpy(dest, src, sizeof(struct ip_addr)); } void ip_addr_set_mask(struct ip_addr *dest, struct ip_addr *src, struct ip_addr *mask) { if (src == NULL) memcpy(dest, &ip_addr_any, sizeof(struct ip_addr)); else { register int i; for (i=0;i<4;i++) dest->addr[i]=src->addr[i] & mask->addr[i]; } } void ip64_addr_set(struct ip4_addr *dest, struct ip_addr *src) { if (src == NULL) memcpy(dest, &ip_addr_any.addr[3], sizeof(struct ip4_addr)); else memcpy(dest, &(src->addr[3]), sizeof(struct ip4_addr)); } void ip4_addr_set(struct ip4_addr *dest, struct ip4_addr *src) { if (src == NULL) memcpy(dest, &ip_addr_any.addr[3], sizeof(struct ip4_addr)); else memcpy(dest, src, sizeof(struct ip4_addr)); } /* #if IP_DEBUG*/ void ip_addr_debug_print(int debk, struct ip_addr *addr) { if (addr != NULL) { /* added by Diego Billi */ if(ip_addr_is_v4comp(addr)) { LWIP_DEBUGF(debk,("%ld.%ld.%ld.%ld", ntohl(addr->addr[3]) >> 24 & 0xff, ntohl(addr->addr[3]) >> 16 & 0xff, ntohl(addr->addr[3]) >> 8 & 0xff, ntohl(addr->addr[3]) & 0xff)); } else { LWIP_DEBUGF(debk,("%lx:%lx:%lx:%lx:%lx:%lx:%lx:%lx", ntohl(addr->addr[0]) >> 16 & 0xffff, ntohl(addr->addr[0]) & 0xffff, ntohl(addr->addr[1]) >> 16 & 0xffff, ntohl(addr->addr[1]) & 0xffff, ntohl(addr->addr[2]) >> 16 & 0xffff, ntohl(addr->addr[2]) & 0xffff, ntohl(addr->addr[3]) >> 16 & 0xffff, ntohl(addr->addr[3]) & 0xffff)); } } else LWIP_DEBUGF(debk,("IPv6 NULL ADDR")); } /*#endif*/ /* IP_DEBUG */ /*---------------------------------------------------------------------------*/ void ip_addr_list_init(struct stack *stack) { #if 0 register int i; struct ip_addr_list *ip_addr_pool = stack->ip_addr_pools; for (i = 0; i < IP_ADDR_POOL_SIZE-1; i++) ip_addr_pool[i].next = ip_addr_pool+(i+1); ip_addr_pool[i].next = NULL; stack->ip_addr_freelist = ip_addr_pool; #endif } void ip_addr_list_shutdown(struct stack *stack) { } /*---------------------------------------------------------------------------*/ struct ip_addr_list *ip_addr_list_alloc(struct stack *stack) { struct ip_addr_list *el; #if 0 if (stack->ip_addr_freelist == NULL) return NULL; else { el = stack->ip_addr_freelist; stack->ip_addr_freelist = stack->ip_addr_freelist->next; /* Added by Diego Billi */ bzero(el, sizeof (struct ip_addr_list)); #endif el=memp_malloc(MEMP_ADDR); if (el) memset(el,0,sizeof(struct ip_addr_list)); return el; } void ip_addr_list_free(struct stack *stack, struct ip_addr_list *el) { memp_free(MEMP_ADDR,el); /* el->next = stack->ip_addr_freelist; stack->ip_addr_freelist = el; */ } void ip_addr_list_freelist(struct stack *stack, struct ip_addr_list *tail) { /* if (tail == NULL) return; else { struct ip_addr_list *tail = tail->next; tail->next = stack->ip_addr_freelist; stack->ip_addr_freelist = tail; } */ if (tail != NULL) { struct ip_addr_list *next=tail->next; tail->next=NULL; while (tail != NULL) { next=tail->next; ip_addr_list_free(stack,tail); tail=next; } } } #define mask_wider(x,y) \ (((y)->addr[0] & ~((x)->addr[0])) | \ ((y)->addr[1] & ~((x)->addr[1])) | \ ((y)->addr[2] & ~((x)->addr[2])) | \ ((y)->addr[3] & ~((x)->addr[3]))) void ip_addr_list_add(struct ip_addr_list **ptail, struct ip_addr_list *el) { LWIP_ASSERT("ip_addr_list_add NULL handle",ptail != NULL); if (*ptail == NULL) *ptail=el->next=el; else { el->next=(*ptail)->next; *ptail=(*ptail)->next=el; } } void ip_addr_list_del(struct ip_addr_list **ptail, struct ip_addr_list *el) { LWIP_ASSERT("ip_addr_list_del NULL handle",ptail != NULL); if (*ptail == NULL) return; else { struct ip_addr_list *prev=*ptail; struct ip_addr_list *p; for (p=prev->next;p != el && p != *ptail; prev=p,p=p->next) ; if (p == el) { if (p == prev) *ptail = NULL; else { prev->next=p->next; if (*ptail==p) *ptail=prev; } } } } struct ip_addr_list *ip_addr_list_find(struct ip_addr_list *tail, struct ip_addr *addr, struct ip_addr *netmask) { struct ip_addr_list *el; if (tail == NULL) return NULL; el=tail=tail->next; do { if (ip_addr_cmp(&(el->ipaddr),addr) && (netmask == NULL || ip_addr_cmp(&(el->netmask),netmask))) return el; el=el->next; } while (el != tail); return NULL; } struct ip_addr_list *ip_addr_list_maskfind(struct ip_addr_list *tail, struct ip_addr *addr) { struct ip_addr_list *el; if (tail==NULL) return NULL; el=tail=tail->next; do { /*printf("ip_addr_list_maskfind "); ip_addr_debug_print(IP_DEBUG,&(el->ipaddr)); printf(" - "); ip_addr_debug_print(IP_DEBUG,addr); printf(" - "); ip_addr_debug_print(IP_DEBUG,&(el->netmask)); printf("\n"); */ if (ip_addr_maskcmp(&(el->ipaddr),addr,&(el->netmask))) if ((ip_addr_islinkscope(&(el->ipaddr)) && ip_addr_islinkscope(addr)) || (!ip_addr_islinkscope(&(el->ipaddr)) && !ip_addr_islinkscope(addr))) return el; el=el->next; } while (el != tail); return NULL; } struct ip_addr_list *ip_addr_list_deliveryfind(struct ip_addr_list *tail, struct ip_addr *addr, struct ip_addr *sender) { struct ip_addr_list *el; if (tail == NULL) return NULL; el=tail=tail->next; do { /* printf("ip_addr_list_deliveryfind "); ip_addr_debug_print(DBG_ON,&(el->ipaddr)); printf(" - "); ip_addr_debug_print(DBG_ON,addr); printf(" - "); ip_addr_debug_print(DBG_ON,&(el->netmask)); printf(" -from "); ip_addr_debug_print(DBG_ON,sender); printf("\n"); */ /* local address */ if (ip_addr_cmp(&(el->ipaddr),addr)) return el; /* bradcast only from local nodes */ if (ip_addr_maskcmp(sender,&(el->ipaddr),&(el->netmask))) { /*printf("%x %x\n",(addr)->addr[3],((&(el->ipaddr))->addr[3] | 0xff000000));*/ if (ip_addr_isallnode(addr)) { /*printf("direct\n");*/ return el; } if (ip_addr_issolicited(addr,&(el->ipaddr))) { /*printf("solicited\n");*/ return el; } if (ip_addr_is_v4comp(&(el->ipaddr)) && ip_addr_is_v4broadcast(addr,&el->ipaddr,&(el->netmask))) { /*printf("v4comp\n");*/ return el; } } if (ip_addr_is_dhcp_broadcast(sender,addr)) { return el; } el=el->next; } while (el != tail); return NULL; } struct ip_addr_list *ip_addr_list_masquarade_addr(struct ip_addr_list *tail, u8_t ipv) { struct ip_addr_list *el; if (tail==NULL) return NULL; /* FIX: we have ip_route_ipv6_select_source() and we should use it */ if (ipv != 4 && ipv != 6) return NULL; el=tail=tail->next; do { if (ipv == 4) { if (ip_addr_is_v4comp(&el->ipaddr)) return el; } else if (!(ip_addr_ismulticast(&el->ipaddr)) && !(ip_addr_islinkscope(&el->ipaddr))) return el; el=el->next; } while (el != tail); return NULL; } #ifdef LWSLIRP /** * Added for slirp: * It search in the list "tail" an address that has its triling 24 bits * equal to the trailing 24 bits of the multicast solicited IPv6 address "addr". * The four address of slirpvde have the last 24 bit each one different from the other, * so the ip_addr returned is unique. */ struct ip_addr *ip_addr_find_unicast_from_solicited(struct ip_addr_list *tail, struct ip_addr *addr) { struct ip_addr netmask; struct ip_addr_list *el; IP6_ADDR(&netmask, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00ff, 0xffff); if (tail == NULL) return NULL; el=tail=tail->next; do { LWIP_DEBUGF(IP_DEBUG, ("ip_addr_find_unicast_from_solicited: el->ipaddr = ")); ip_addr_debug_print(IP_DEBUG, &(el->ipaddr)); LWIP_DEBUGF(IP_DEBUG, (" addr = ")); ip_addr_debug_print(IP_DEBUG, addr); LWIP_DEBUGF(IP_DEBUG, (" netmask = ")); ip_addr_debug_print(IP_DEBUG, &netmask); LWIP_DEBUGF(IP_DEBUG, (" !ip_addr_is_v4comp(&(el->ipaddr)) = %d\n", !ip_addr_is_v4comp(&(el->ipaddr)))); /* I search only in the IPv6 addresses, not IPv4. */ if (!ip_addr_is_v4comp(&(el->ipaddr)) && ip_addr_maskcmp(&(el->ipaddr), addr, &netmask)) return &(el->ipaddr); el=el->next; } while (el != tail); return NULL; } #endif /* SLIRPVDE */ lwipv6-1.5a/lwip-v6/src/core/ipv6/ip6.c0000644000175000017500000010152511671615007016604 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2010,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ /* ip.c * * This is the code for the IP layer for IPv6. * */ #include "lwip/opt.h" #include "lwip/debug.h" #include "lwip/stats.h" #include "arch/perf.h" #include "lwip/def.h" #include "lwip/mem.h" #include "lwip/netif.h" #include "lwip/ip.h" #include "lwip/ip_addr.h" #include "lwip/ip_frag.h" #include "lwip/icmp.h" #include "lwip/raw.h" #include "lwip/udp.h" #include "lwip/tcp.h" #include "lwip/inet.h" #if LWIP_DHCP #include "lwip/dhcp.h" #endif #if IPv6_AUTO_CONFIGURATION #include "lwip/ip_autoconf.h" #endif #if IPv6_ROUTER_ADVERTISEMENT #include "lwip/ip_radv.h" #endif #if LWIP_USERFILTER #include "lwip/userfilter.h" #endif #if LWIP_NAT #include "lwip/nat/nat.h" #endif //#ifndef IP_DEBUG //#define IP_DEBUG DBG_ON //#endif #ifdef LWSLIRP #define NOSLIRP ,NULL #else #define NOSLIRP #endif /*--------------------------------------------------------------------------*/ /* IPv4 ID counter */ /* FIX: race condition with fragmentation code */ INLINE static int ip_process_exthdr(struct stack *stack, u8_t hdr, char *exthdr, u8_t hpos, struct pbuf **p, struct pseudo_iphdr *piphdr); /*--------------------------------------------------------------------------*/ /* ip_init: * * Initializes the IP layer. */ void ip_init(struct stack *stack) { ip_route_list_init(stack); #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION ip_frag_reass_init(stack); #endif #if IPv6_AUTO_CONFIGURATION ip_autoconf_init(stack); #endif #if IPv6_ROUTER_ADVERTISEMENT ip_radv_init(stack); #endif #if LWIP_USERFILTER /* init UserFilter's internal tables */ if (stack->stack_flags & LWIP_STACK_FLAG_USERFILTER) { userfilter_init(stack); #if LWIP_NAT if (stack->stack_flags & LWIP_STACK_FLAG_UF_NAT) nat_init(stack); else stack->stack_nat = NULL; #endif } else { stack->stack_userfilter = NULL; #if LWIP_NAT stack->stack_nat = NULL; #endif } #endif } void ip_shutdown(struct stack *stack) { #if LWIP_USERFILTER #if LWIP_NAT if (stack->stack_nat != NULL) nat_shutdown(stack); #endif if (stack->stack_userfilter != NULL) userfilter_shutdown(stack); #endif #if IPv6_AUTO_CONFIGURATION ip_autoconf_shutdown(stack); #endif #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION ip_frag_reass_shutdown(stack); #endif ip_route_list_shutdown(stack); } /*--------------------------------------------------------------------------*/ /* ip_input: * * This function is called by the network interface device driver when an IP packet is * received. The function does the basic checks of the IP header such as packet size * being at least larger than the header size etc. If the packet was not destined for * us, the packet is forwarded (using ip_forward). The IP checksum is always checked. * * Finally, the packet is sent to the upper layer protocol input function. */ static void ip_inpacket(struct stack *stack, struct ip_addr_list *addr, struct pbuf *p, struct pseudo_iphdr *piphdr #ifdef LWSLIRP , struct netif *slirpif #endif ) { #if LWIP_USERFILTER if (UF_HOOK(stack, UF_IP_LOCAL_IN, &p, addr->netif, NULL, UF_FREE_BUF) <= 0) { return; } #endif /* Check for particular options/operations */ if (piphdr->version == 4) { struct ip4_hdr *ip4hdr = (struct ip4_hdr *) p->payload; /* See if this is a fragment */ if ((IPH4_OFFSET(ip4hdr) & htons(IP_OFFMASK | IP_MF)) != 0) { #if IPv4_FRAGMENTATION struct ip_addr src4, dest4; LWIP_DEBUGF(IP_DEBUG, ("IPv4 packet is a fragment (id=0x%04x tot_len=%u len=%u MF=%u offset=%u), calling ip_reass()\n",ntohs(IPH4_ID(ip4hdr)), p->tot_len, ntohs(IPH4_LEN(ip4hdr)), !!(IPH4_OFFSET(ip4hdr) & htons(IP_MF)), (ntohs(IPH4_OFFSET(ip4hdr)) & IP_OFFMASK)*8)); /* reassemble the packet*/ p = ip4_reass(stack, p); /* packet not fully reassembled yet? */ if (p == NULL) { LWIP_DEBUGF(IP_DEBUG,("%s: packet cached p=%p\n", __func__, p)); return; } /* We reassembled the original IP header. Rebuild pseudo header! */ if ( ip_build_piphdr(piphdr, p, &src4, &dest4) < 0) { LWIP_DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n")); ip_debug_print(IP_DEBUG, p); pbuf_free(p); IP_STATS_INC(ip.err); IP_STATS_INC(ip.drop); return; } #else LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented\n")); pbuf_free(p); IP_STATS_INC(ip.opterr); IP_STATS_INC(ip.drop); return; #endif } } else if (piphdr->version == 6) { /* Process extension headers before upper-layers protocols */ if (is_ipv6_exthdr(piphdr->proto)) { char *ehp = ((char *) p->payload) + piphdr->iphdrlen; if (ip_process_exthdr(stack, piphdr->proto, ehp, 0, &p, piphdr) < 0) /* an error occurred. Stop */ return; } } #if LWIP_RAW raw_input(p, addr, piphdr); #endif /* LWIP_RAW */ #if LWIP_USERFILTER && LWIP_NAT /* Reset NAT+tracking information before sending to the upper layer */ nat_pbuf_reset(p); #endif switch (piphdr->proto + (piphdr->version << 8)) { #if LWIP_UDP case IP_PROTO_UDP + (4 << 8): case IP_PROTO_UDP + (6 << 8): LWIP_DEBUGF(IP_DEBUG,("->UDP\n")); udp_input(p, addr, piphdr #ifdef LWSLIRP , slirpif #endif ); break; #endif #if LWIP_TCP case IP_PROTO_TCP + (4 << 8): case IP_PROTO_TCP + (6 << 8): LWIP_DEBUGF(IP_DEBUG,("->TCP\n")); tcp_input(p, addr, piphdr #ifdef LWSLIRP , slirpif #endif ); break; #endif case IP_PROTO_ICMP + (6 << 8): case IP_PROTO_ICMP4 + (4 << 8): LWIP_DEBUGF(IP_DEBUG,("->ICMP\n")); icmp_input(stack, p, addr, piphdr); break; default: LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %u\n", piphdr->proto)); /* send ICMP destination protocol unreachable */ icmp_dest_unreach(stack, p, ICMP_DUR_PROTO); /*discard*/ IP_STATS_INC(ip.proterr); IP_STATS_INC(ip.drop); pbuf_free(p); } } /*--------------------------------------------------------------------------*/ /* ip_forward: * * Forwards an IP packet. It finds an appropriate route for the packet, decrements * the TTL value of the packet, adjusts the checksum and outputs the packet on the * appropriate interface. */ INLINE static void ip_forward(struct stack *stack, struct pbuf *p, struct ip_hdr *iphdr, struct netif *inif, struct netif *netif, struct ip_addr *nexthop, struct pseudo_iphdr *piphdr) { struct ip4_hdr *ip4hdr; PERF_START; #if LWIP_USERFILTER if (UF_HOOK(stack, UF_IP_FORWARD, &p, NULL, netif, UF_FREE_BUF) <= 0) { return; } #endif /* * Check TimeToLive (Ipv4) or Hop-Limit Field (Ipv6) */ if (IPH_V(iphdr) == 4) { ip4hdr = (struct ip4_hdr *) iphdr; IPH4_TTL_SET(ip4hdr, IPH4_TTL(ip4hdr) - 1); if (IPH4_TTL(ip4hdr) <= 0) { LWIP_DEBUGF(IP_DEBUG, ("ip_forward: dropped packet! TTL <= 0 ")); /* Don't send ICMP messages in response to ICMP messages */ if (piphdr->proto != IP_PROTO_ICMP4) icmp_time_exceeded(stack, p, ICMP_TE_TTL); pbuf_free(p); return; } /* Incrementally update the IP checksum. */ if (IPH4_CHKSUM(ip4hdr) >= htons(0xffff - 0x100)) { IPH4_CHKSUM_SET(ip4hdr, IPH4_CHKSUM(ip4hdr) + htons(0x100) + 1); } else { IPH4_CHKSUM_SET(ip4hdr, IPH4_CHKSUM(ip4hdr) + htons(0x100)); } } else if (IPH_V(iphdr) == 6) { /* Decrement TTL and send ICMP if ttl == 0. */ IPH_HOPLIMIT_SET(iphdr, IPH_HOPLIMIT(iphdr) -1); if (IPH_HOPLIMIT(iphdr) <= 0) { LWIP_DEBUGF(IP_DEBUG, ("ip_forward: dropped packet! HOPLIMIT <= 0 ")); /* Don't send ICMP messages in response to ICMP messages */ if (IPH_NEXTHDR(iphdr) != IP_PROTO_ICMP) icmp_time_exceeded(stack, p, ICMP_TE_TTL); pbuf_free(p); return; } } LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to ")); ip_addr_debug_print(IP_DEBUG, piphdr->dest); LWIP_DEBUGF(IP_DEBUG, (" via %c%c%d\n",netif->name[0], netif->name[1], netif->num)); #if LWIP_USERFILTER /* pbuf_free() is called by Caller */ if (UF_HOOK(stack, UF_IP_POST_ROUTING, &p, NULL, netif, UF_FREE_BUF) <= 0) { return; } #endif /* * Check IP Fragmentation. Packet Size > Next Hop's MTU? */ if (p->tot_len > netif->mtu) { if (IPH_V(iphdr) == 4) { #if IPv4_FRAGMENTATION ip4hdr = (struct ip4_hdr *) iphdr; if (IPH4_OFFSET(ip4hdr) & htons(IP_MF)) { LWIP_DEBUGF(IP_DEBUG, ("ip_forward: IPv4 DF bit set. Don't fragment!")); icmp_dest_unreach(stack, p, ICMP_DUR_FRAG /*, netif->mtu*/); pbuf_free(p); return; } else { /* we can frag the packet */ IP_STATS_INC(ip.fw); IP_STATS_INC(ip.xmit); ip4_frag(stack, p , netif, nexthop); } #else LWIP_DEBUGF(IP_DEBUG, ("ip_forward: fragmentation on forwarded packets not implemented!")); pbuf_free(p); return; #endif } else if (IPH_V(iphdr) == 6) { /* IPv6 doesn't fragment forwarded packets */ icmp_packet_too_big(stack, p, netif->mtu); pbuf_free(p); return; } } IP_STATS_INC(ip.fw); IP_STATS_INC(ip.xmit); /* LWSLIRP TEST */ #ifdef LWSLIRP if (netif->link_type == NETIF_SLIRPIF) { struct ip_addr_list *addr; LWIP_DEBUGF(IP_DEBUG, ("ip_forward: slirp")); if (piphdr->version == 6) /* in ipv6 the length field conatins only the legnth of the payload * (the length of the ipv6 haeder is costant) */ pbuf_realloc(p, IP_HLEN + ntohs(iphdr->len)); else /* in ipv4 the legnth filed contains also the length of the header * (the length of the ipv4 header isn't costant) */ pbuf_realloc(p, ntohs(IPH4_LEN(ip4hdr))); addr = ip_addr_list_alloc(stack); if(addr == NULL) { LWIP_DEBUGF(IP_DEBUG, ("ip_forward: ip_addr_list_alloc() failed, I abort\n")); /* There aren't no more ip_addr_list avaible, so I abort.*/ abort(); } addr->next = NULL; /* I control if the destination address is a multicast-solicited address, * in this case I find the right unicast address and I copy it in addr->ipaddr. * Otherwise the dest address is copied in addr->ipaddr */ if(piphdr->version == 6 && ip_addr_is_addr_solicited(piphdr->dest)) { struct ip_addr *unicast_addr; LWIP_DEBUGF(IP_DEBUG, ("ip_input: destination address(")); ip_addr_debug_print(IP_DEBUG, piphdr->dest); LWIP_DEBUGF(IP_DEBUG, (") is a solicited IPv6 address\n")); unicast_addr = ip_addr_find_unicast_from_solicited(inif->addrs, piphdr->dest); /* If unicast_addr is NULL, the pachet is not for us */ if(unicast_addr == NULL) { LWIP_DEBUGF(IP_DEBUG, ("ip_input: multicast packet not for us\n")); pbuf_free(p); ip_addr_list_free(stack,addr); return; } LWIP_DEBUGF(IP_DEBUG, ("ip_input: after ip_addr_find_unicast_from_solicited(), unicast_addr = ")); ip_addr_debug_print(IP_DEBUG, unicast_addr); LWIP_DEBUGF(IP_DEBUG, ("\n")); memcpy(&addr->ipaddr, unicast_addr, sizeof(struct ip_addr)); } else { memcpy(&addr->ipaddr, piphdr->dest, sizeof(struct ip_addr)); } /* addr->netmask; unused? */ addr->netif = inif; /* addr->flags; unused?*/ /* I test if is not a solicited dest address and * the packet is a ICMP packet. If it so, I discard * it, because it's not for us, and I return */ if(!ip_addr_is_addr_solicited(piphdr->dest) && (piphdr->proto == IP_PROTO_ICMP4 || piphdr->proto == IP_PROTO_ICMP)) { LWIP_DEBUGF(IP_DEBUG, ("ip_input: ICMP packet, I discard it.\n")); pbuf_free(p); ip_addr_list_free(stack,addr); return; } /* Then I can pass the packet to an higher level of the stack */ ip_inpacket(stack,addr, p, piphdr, netif); /* I free "addr"*/ ip_addr_list_free(stack,addr); return; } else #endif { PERF_STOP("ip_forward"); netif->output(netif, p, nexthop); pbuf_free(p); } } /*--------------------------------------------------------------------------*/ void ip_input(struct pbuf *p, struct netif *inp) { struct ip_hdr *iphdr; struct ip4_hdr *ip4hdr; struct netif *netif; struct ip_addr_list *addrel; #if IP_FORWARD struct ip_addr *nexthop; int fwflags; #endif struct pseudo_iphdr piphdr; struct ip_addr src4,dest4; /* Get stack id from network interface */ struct stack *stack = inp->stack; PERF_START; LWIP_DEBUGF(IP_DEBUG,("%s: new IP packet\n", __func__)); ip_debug_print(IP_DEBUG, p); IP_STATS_INC(ip.recv); /* identify the IP header */ iphdr = p->payload; ip4hdr = p->payload; /* Create a pseudo header used by the stack */ if ( ip_build_piphdr(&piphdr, p, &src4, &dest4) < 0) { LWIP_DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n")); ip_debug_print(IP_DEBUG, p); pbuf_free(p); IP_STATS_INC(ip.err); IP_STATS_INC(ip.drop); return; } #if IPv4_CHECK_CHECKSUM if (IPH_V(iphdr) == 4) { /* Only IPv4 has checksum field */ u16_t sum = inet_chksum(ip4hdr, piphdr.iphdrlen); if (sum != 0) { pbuf_free(p); LWIP_DEBUGF(IP_DEBUG | 2, ("Checksum (0x%x, len=%d) failed, IP packet dropped.\n", sum, piphdr.iphdrlen)); IP_STATS_INC(ip.chkerr); IP_STATS_INC(ip.drop); return; } } #endif #if LWIP_USERFILTER if (UF_HOOK(stack, UF_IP_PRE_ROUTING, &p, inp, NULL, UF_FREE_BUF) <= 0) { return; } /* NATed packets need a new pseudo header used by the stack */ if ( ip_build_piphdr(&piphdr, p, &src4, &dest4) < 0) { LWIP_DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n")); ip_debug_print(IP_DEBUG, p); pbuf_free(p); IP_STATS_INC(ip.err); IP_STATS_INC(ip.drop); return; } #endif /* Find packet destination */ if ((addrel = ip_addr_list_deliveryfind(inp->addrs, piphdr.dest, piphdr.src)) != NULL) { /* local address */ if (piphdr.version == 6) pbuf_realloc(p, IP_HLEN + ntohs(iphdr->len)); else pbuf_realloc(p, ntohs(IPH4_LEN(ip4hdr))); ip_inpacket(stack, addrel, p, &piphdr NOSLIRP); goto ip_input_end; } /* FIX: handle IPv6 Multicast in this way? */ if (ip_addr_ismulticast(piphdr.dest)) { struct ip_addr_list tmpaddr; LWIP_DEBUGF(IP_DEBUG | 2, ("ip_input: multicast!\n")); tmpaddr.netif = inp; tmpaddr.flags = 0; IP6_ADDR_LINKSCOPE(&tmpaddr.ipaddr, inp->hwaddr); ip_inpacket(stack, &tmpaddr, p, &piphdr NOSLIRP); goto ip_input_end; } #if LWIP_DHCP /* Pass DHCP messages regardless of destination address. DHCP traffic is addressed * using link layer addressing (such as Ethernet MAC) so we must not filter on IP. * According to RFC 1542 section 3.1.1, referred by RFC 2131). */ if (piphdr.version == 4 && IPH4_PROTO(ip4hdr) == IP_PROTO_UDP) { struct udp_hdr *udphdr = (struct udp_hdr *)((u8_t *)ip4hdr + piphdr.iphdrlen); /* remote port is DHCP server? */ LWIP_DEBUGF(IP_DEBUG, ("ip_input: UDP packet to DHCP client port %u\n", ntohs(udphdr->dest))); if (ntohs(udphdr->dest) == DHCP_CLIENT_PORT) { LWIP_DEBUGF(IP_DEBUG, ("ip_input: DHCP packet accepted.\n")); struct ip_addr_list tmpaddr; memset(&tmpaddr, 0, sizeof(struct ip_addr_list)); tmpaddr.netif = inp; tmpaddr.flags = 0; ip_inpacket(stack, &tmpaddr, p, &piphdr NOSLIRP); goto ip_input_end; } } #endif /* LWIP_DHCP */ #if IP_FORWARD if ((stack->stack_flags & LWIP_STACK_FLAG_FORWARDING) && ip_route_findpath(stack, piphdr.dest, &nexthop, &netif, &fwflags) == ERR_OK && netif != inp) { /* forwarding */ ip_forward(stack, p, iphdr, inp, netif, nexthop, &piphdr); goto ip_input_end; } #endif /* LWSLIRP TEST */ LWIP_DEBUGF(IP_DEBUG | 2, ("ip_input: unable to route IP packet. Droped\n")); pbuf_free(p); ip_input_end: PERF_STOP("ip_input"); } /*--------------------------------------------------------------------------*/ /* ip_output_if: * * Sends an IP packet on a network interface. This function constructs the IP header * and calculates the IP header checksum. If the source IP address is NULL, * the IP address of the outgoing network interface is filled in as source address. */ err_t ip_output_if (struct stack *stack, struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t tos, u8_t proto, struct netif *netif, struct ip_addr *nexthop, int flags) { err_t ret = ERR_OK; /* default return value */ struct ip_hdr *iphdr; struct ip4_hdr *ip4hdr; u8_t version; struct ip_addr addrfromhdr; #if LWIP_USERFILTER struct pbuf *caller_p; #endif /*fprintf(stderr, "ip_output_if %p\n", src);*/ if (src == NULL) { fprintf(stderr, "*^*^*^ ip_output_if NULL!\n"); return ERR_BUF; } PERF_START; if (ip_addr_isany(src)) version = ip_addr_is_v4comp(dest) ? 4 : 6; else version = (ip_addr_is_v4comp(src) && ip_addr_is_v4comp(dest)) ? 4 : 6; /* Get size for the IP header */ if (dest != IP_LWHDRINCL && pbuf_header(p, version==6?IP_HLEN:IP4_HLEN)) { LWIP_DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n")); IP_STATS_INC(ip.err); return ERR_BUF; } /* Create IP header */ if(version == 6) { iphdr = p->payload; if (dest != IP_LWHDRINCL) { iphdr->_v_cl_fl = 0; IPH_NEXT_HOP_SET(iphdr, proto, ttl); iphdr->len = htons(p->tot_len - IP_HLEN); IPH_V_SET(iphdr, 6); ip_addr_set(&(iphdr->dest), dest); ip_addr_set(&(iphdr->src), src); } else { dest = &(iphdr->dest); } } else { /* IPv4 */ ip4hdr = p->payload; if (dest != IP_LWHDRINCL) { IPH4_TTL_SET(ip4hdr, ttl); IPH4_PROTO_SET(ip4hdr, proto); ip64_addr_set(&(ip4hdr->dest), dest); IPH4_VHLTOS_SET(ip4hdr, 4, IP4_HLEN / 4, tos); IPH4_LEN_SET(ip4hdr, htons(p->tot_len)); IPH4_OFFSET_SET(ip4hdr, htons(IP_DF)); IPH4_ID_SET(ip4hdr, htons(stack->ip_id)); ++stack->ip_id; ip64_addr_set(&(ip4hdr->src), src); IPH4_CHKSUM_SET(ip4hdr, 0); IPH4_CHKSUM_SET(ip4hdr, inet_chksum(ip4hdr, IP4_HLEN)); } else { IPH4_LEN_SET(ip4hdr, htons(p->tot_len)); /* from raw(7) man page: but it is not true! Linux kernel * does not clean src and ID */ /* ip64_addr_set(&(ip4hdr->src), 0); IPH4_ID_SET(ip4hdr, 0); */ IPH4_CHKSUM_SET(ip4hdr, 0); IPH4_CHKSUM_SET(ip4hdr, inet_chksum(ip4hdr, IP4_HLEN)); IP64_CONV(&addrfromhdr,&(ip4hdr->dest)); dest = &addrfromhdr; } } #if LWIP_USERFILTER /* The Caller of ip_output_if() will call pbuf_free() on buffer pointed by 'p' after return. Hooks could call pbuf_free() on 'p' too, so we need to increase reference. IF hooks replace buffer pointed by 'p' with an other, we have to free the new buffer before return. */ caller_p = p; /* this allocation must be undone in end_ip_output_if when the buffer does not change */ pbuf_ref(caller_p); #endif #if LWIP_USERFILTER /* FIX: LOCAL_OUT after routing decisions? It this the right place */ if (UF_HOOK(stack, UF_IP_LOCAL_OUT, &p, NULL, netif, UF_DONTFREE_BUF) <= 0) { goto end_ip_output_if; } #endif #ifdef IP_DEBUG LWIP_DEBUGF(IP_DEBUG, ("\nip_output_if: %c%c (len %u)\n", netif->name[0], netif->name[1], p->tot_len)); ip_debug_print(IP_DEBUG, p); #endif /* IP_DEBUG */ IP_STATS_INC(ip.xmit); PERF_STOP("ip_output_if"); /* The packet is for us? */ if (ip_addr_cmp(src,dest)) { struct pbuf *r; LWIP_DEBUGF(IP_DEBUG, ("\t PACKET FOR US\n")); if (! (netif->flags & NETIF_FLAG_UP)) { goto end_ip_output_if; } /* The caller will destroy 'p' after return. We need to create a clone! */ r = pbuf_clone(PBUF_RAW, p, PBUF_RAM); if (r != NULL) { #if LWIP_USERFILTER if (UF_HOOK(stack, UF_IP_POST_ROUTING, &r, NULL, netif, UF_DONTFREE_BUF) <= 0) { goto end_ip_output_if; } #if LWIP_NAT /* Reset NAT+tracking information before sending packet back to us */ nat_pbuf_reset(r); #endif #endif netif->input( r, netif ); //ip_input(r, netif); } goto end_ip_output_if; } /* packet for remote host */ else { LWIP_DEBUGF(IP_DEBUG, ("SENDING OUT %c%c%d\n", netif->name[0],netif->name[1],netif->num)); #if LWIP_USERFILTER if (UF_HOOK(stack, UF_IP_POST_ROUTING, &p, NULL, netif, UF_DONTFREE_BUF) <= 0) { goto end_ip_output_if; } #endif /* Handle fragmentation */ if (netif->mtu && (p->tot_len > netif->mtu)) { LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: packet need fragmentation (len=%d, mtu=%d)\n",p->tot_len,netif->mtu)); #if IPv4_FRAGMENTATION if (version == 4) { ret = ip4_frag(stack, p , netif, nexthop); goto end_ip_output_if; } #endif #if IPv6_FRAGMENTATION if (version == 6) { ret = ip6_frag(stack, p , netif, nexthop); goto end_ip_output_if; } #endif LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: fragmentation not supported. Dropped!\n")); /* FIX: error code? */ } else { LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: nettif->output()\n")); ret = netif->output(netif, p, nexthop); } } end_ip_output_if: #if LWIP_USERFILTER if (caller_p != p) { /* Somewhere, inside a hook, we've changed packet's buffer. In this case we have to free it because Caller will call pbuf_free() only on buffer pointed by caller_p */ pbuf_free(p); } else { /* the buffer did not change so we must undo the pbuf_ref above */ pbuf_free(caller_p); } #endif return ret; } /*--------------------------------------------------------------------------*/ /* ip_output: * * Simple interface to ip_output_if. It finds the outgoing network interface and * calls upon ip_output_if to do the actual work. */ err_t ip_output(struct stack *stack, struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t ttl, u8_t tos, u8_t proto) { struct netif *netif; struct ip_addr *nexthop; int flags; LWIP_DEBUGF(IP_DEBUG, ("%s: start\n", __func__)); LWIP_DEBUGF(IP_DEBUG, ("src=")); ip_addr_debug_print(IP_DEBUG, src); LWIP_DEBUGF(IP_DEBUG, (" dest=")); ip_addr_debug_print(IP_DEBUG, dest); LWIP_DEBUGF(IP_DEBUG, (" ttl=%d", ttl)); LWIP_DEBUGF(IP_DEBUG, (" proto=%d\n", proto)); if (ip_route_findpath(stack, dest, &nexthop, &netif, &flags) != ERR_OK) { LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to XXX \n" )); IP_STATS_INC(ip.rterr); return ERR_RTE; } else { if (src==NULL) { struct ip_addr_list *el; if ((el=ip_route_select_source_ip(netif, dest, nexthop)) == NULL) return ERR_RTE; src = &(el->ipaddr); } return ip_output_if (stack, p, src, dest, ttl, tos, proto, netif, nexthop, flags); } } /*--------------------------------------------------------------------------*/ /* This function inform the IP Layer that interface's properties have been changed. */ void ip_notify(struct netif *netif, u32_t type) { struct stack *stack = netif->stack; switch(type) { case NETIF_CHANGE_UP: LWIP_DEBUGF(IP_DEBUG, ("%s: netif %c%c%d now UP!\n", __func__, netif->name[0], netif->name[1], netif->num)); #if LWIP_DHCP if (netif->flags & NETIF_FLAG_DHCP) dhcp_start(netif); #endif #if IPv6_AUTO_CONFIGURATION if (netif->flags & NETIF_FLAG_AUTOCONF) ip_autoconf_start(netif); #endif #if IPv6_ROUTER_ADVERTISEMENT if (netif->flags & NETIF_FLAG_RADV) ip_radv_start(netif); #endif break; case NETIF_CHANGE_DOWN: LWIP_DEBUGF(IP_DEBUG, ("%s: netif %c%c%d now DOWN!\n", __func__, netif->name[0], netif->name[1], netif->num)); #if LWIP_DHCP if (netif->flags & NETIF_FLAG_DHCP) { dhcp_release(netif); dhcp_stop(netif); } #endif #if IPv6_ROUTER_ADVERTISEMENT if (netif->flags & NETIF_FLAG_RADV) ip_radv_stop(netif); #endif #if IPv6_AUTO_CONFIGURATION if (netif->flags & NETIF_FLAG_AUTOCONF) ip_autoconf_stop(netif); #endif break; case NETIF_CHANGE_MTU: LWIP_DEBUGF(IP_DEBUG, ("%s: netif %c%c%d changed MTU, now %d!\n", __func__, netif->name[0], netif->name[1], netif->num, netif->mtu)); #if IPv6_ROUTER_ADVERTISEMENT /* todo? */ #endif break; default: LWIP_DEBUGF(IP_DEBUG, ("%s: unknown change *** BUG ***\n", __func__)); break; } } /*--------------------------------------------------------------------------*/ #ifdef IP_DEBUG INLINE static void ip_debug_print_transport(u8_t proto, void *hdr) { struct icmp_echo_hdr *icmph = NULL; struct tcp_hdr *tcphdr = NULL; struct udp_hdr *udphdr = NULL; switch (proto) { case IP_PROTO_TCP: tcphdr = hdr; LWIP_DEBUGF(IP_DEBUG, ("TCP [%d,%d]", ntohs(tcphdr->src), ntohs(tcphdr->dest))); break; case IP_PROTO_UDP: udphdr = hdr; LWIP_DEBUGF(IP_DEBUG, ("UDP [%d,%d]", ntohs(udphdr->src), ntohs(udphdr->dest))); break; case IP_PROTO_ICMP4: icmph = hdr; LWIP_DEBUGF(IP_DEBUG, ("Icmp4 id=%d type=%d code=%d", ntohs(icmph->id), (char)ICMPH_TYPE(icmph), (char)icmph->icode)); break; case IP_PROTO_ICMP: icmph = hdr; LWIP_DEBUGF(IP_DEBUG, ("Icmp6 id=%d type=%d code=%d", ntohs(icmph->id), (unsigned char)ICMPH_TYPE(icmph), (unsigned char)icmph->icode)); break; default: LWIP_DEBUGF(IP_DEBUG, ("%s: strange protocol", __func__ )); break; } LWIP_DEBUGF(IP_DEBUG, ("\n")); } INLINE static void ip4_debug_print(struct pbuf *p) { struct ip_addr tempsrc, tempdest; struct ip4_hdr *iphdr = p->payload; u8_t *payload; payload = (u8_t *)iphdr + IP4_HLEN; LWIP_DEBUGF(IP_DEBUG, ("IPv4 Packet: ")); IP64_CONV(&tempsrc, &(iphdr->src)); IP64_CONV(&tempdest, &(iphdr->dest)); LWIP_DEBUGF(IP_DEBUG, ("src=")); ip_addr_debug_print(IP_DEBUG, &tempsrc); LWIP_DEBUGF(IP_DEBUG, (" dest=")); ip_addr_debug_print(IP_DEBUG, &tempdest); LWIP_DEBUGF(IP_DEBUG, (" proto=%u ttl=%u chksum=0x%04x", IPH4_PROTO(iphdr), IPH4_TTL(iphdr), ntohs(IPH4_CHKSUM(iphdr)))); LWIP_DEBUGF(IP_DEBUG, (" id=%u flags=%u%u%u offset=%u\n", ntohs(IPH4_ID(iphdr)), ntohs(IPH4_OFFSET(iphdr)) >> 15 & 1, ntohs(IPH4_OFFSET(iphdr)) >> 14 & 1, ntohs(IPH4_OFFSET(iphdr)) >> 13 & 1, ntohs(IPH4_OFFSET(iphdr)) & IP_OFFMASK)); ip_debug_print_transport(IPH4_PROTO(iphdr), payload); } INLINE static void ip6_debug_print(int how, struct pbuf *p) { struct ip_hdr *iphdr = p->payload; char *payload; payload = (char *)iphdr + IP_HLEN; LWIP_DEBUGF(how, ("IPv6 packet:\n")); LWIP_DEBUGF(how, ("src=")); ip_addr_debug_print(how, &iphdr->src); LWIP_DEBUGF(how, (" dest=")); ip_addr_debug_print(how, &iphdr->dest); LWIP_DEBUGF(how, (" nexthdr=%2u hoplim=%2u\n", IPH_NEXTHDR(iphdr), IPH_HOPLIMIT(iphdr))); ip_debug_print_transport( IPH_NEXTHDR(iphdr), payload); } void ip_debug_print(int how, struct pbuf *p) { struct ip_hdr *iphdr = p->payload; if (IPH_V(iphdr) == 4) ip4_debug_print(p); else ip6_debug_print(how,p); } #endif /* IP_DEBUG */ /*--------------------------------------------------------------------------*/ /** * Build the pseudo header. * It takes in input the pseudo header to fill and, pbuf * with the IP packet from where take the information, and * the two IPv4 addresses fill with the IPv4 addresses if * the packet in IPv4. * It returns 1 if the pseudo header is fill without error, * 0 if the the packet contains a bad IP version number. */ int ip_build_piphdr(struct pseudo_iphdr *piphdr, struct pbuf *p, struct ip_addr *src4, struct ip_addr *dest4) { struct ip_hdr *iphdr; struct ip4_hdr *ip4hdr; iphdr = p->payload; /* I identify the IP header */ piphdr->version=IPH_V(iphdr); if (piphdr->version == 6) { /* it's a ipv6 packet, I fill the pseudo header */ piphdr->proto = IPH_NEXTHDR(iphdr); piphdr->iphdrlen = IP_HLEN; piphdr->src = &(iphdr->src); piphdr->dest = &(iphdr->dest); return 1; /* All ok*/ } else if (piphdr->version == 4) { /* it's a ipv4 packet, I fill the pseudo header */ ip4hdr = p->payload; piphdr->proto = IPH4_PROTO(ip4hdr); piphdr->iphdrlen = IPH4_HL(ip4hdr) * 4; /* coversion of the source and destination addresses * from ipv4 to "ipv4-mapped ipv6 address". * This kind of address is used in device that understand * only ipv4. */ IP64_CONV(src4,&(ip4hdr->src)); IP64_CONV(dest4,&(ip4hdr->dest)); piphdr->src = src4; piphdr->dest = dest4; return 1; /* All ok*/ } else { /* bad version number */ return -1; /* error */ } } /* * Process Extension headers of IPv6. */ INLINE static int ip_process_exthdr(struct stack *stack, u8_t hdr, char *exthdr, u8_t hpos, struct pbuf **p, struct pseudo_iphdr *piphdr) { struct ip_exthdr *prevhdr; /* previous ext header */ u8_t loop = 1; int r = -1; LWIP_DEBUGF(IP_DEBUG, ("%s: Start processing extension headers.\n", __func__)); /* It loops while there are extension headers */ prevhdr = NULL; do { /* FIX: check p->tot_len and "hdr" position to avoid bufferoverflows */ switch (hdr) { case IP6_NEXTHDR_HOP: case IP6_NEXTHDR_DEST: case IP6_NEXTHDR_ROUTING: /* Drop packet */ LWIP_DEBUGF(IP_DEBUG, ("Extension header %d not yet supported\n", hdr)); pbuf_free(*p); *p=NULL; loop = 0; break; case IP6_NEXTHDR_FRAGMENT: #if IPv6_FRAGMENTATION { struct ip6_fraghdr *fhdr = (struct ip6_fraghdr *) exthdr; LWIP_DEBUGF(IP_DEBUG, ("Fragment Header\n")); *p = ip6_reass(stack, *p, fhdr, prevhdr); if (*p == NULL) { /* Don't free 'p'. Fragmentation code has "stolen" the packet */ LWIP_DEBUGF(IP_DEBUG,("\tpacket cached p=%p\n", *p)); } else { LWIP_DEBUGF(IP_DEBUG,("\tNew pseudo header p=%p\n", *p)); ip_build_piphdr(piphdr, *p, piphdr->src, piphdr->dest); r = 1; } /* Go to the next header */ hdr = fhdr->nexthdr; exthdr = exthdr + sizeof(struct ip6_fraghdr); break; } #endif case IP6_NEXTHDR_ESP: case IP6_NEXTHDR_AUTH: case IP6_NEXTHDR_NONE: /* NOTE: this is useful only on forwarded packets? */ /* Drop packet */ LWIP_DEBUGF(IP_DEBUG, ("Extension header %d not yet supported\n", hdr)); pbuf_free(*p); *p=NULL; loop = 0; break; default: /* We found the first non-extention header. We can exit */ LWIP_DEBUGF(IP_DEBUG, ("Protocol %d is not an extension headers.\n", hdr)); loop = 0; break; } } while (loop); LWIP_DEBUGF(IP_DEBUG, ("ip_process_exthdr: Stop\n")); return r; } lwipv6-1.5a/lwip-v6/src/core/ipv6/ip6_route.c0000644000175000017500000010545311671615007020026 0ustar renzorenzo/* * ip6_route.c routing table management IPv6 * (IPv4 compatible using IPv4 prefixes). * * This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright (c) 2004 Renzo Davoli * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * */ #include "lwip/debug.h" #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/ip_route.h" #include "lwip/inet.h" #include "lwip/netlink.h" #include "lwip/stack.h" #include "lwip/memp.h" /*--------------------------------------------------------------------------*/ //#ifndef ROUTE_DEBUG //#define ROUTE_DEBUG DBG_OFF //#endif /* added by Diego Billi */ #if 0 #ifdef IPv6_PMTU_DISCOVERY static void ip_pmtu_init(); static void ip_pmtu_free_list(struct pmtu_info *head); #define IP_PMTU_FREELIST(list) \ do { if ((list) != NULL) { \ ip_pmtu_free_list( (list) ); \ (list) = NULL; \ } } while (0); #endif #endif /*---------------------------------------------------------------------------*/ #if ROUTE_DEBUG == DBG_ON INLINE static void sprintf_ip(char *str, struct ip_addr *addr) { if (addr != NULL) { sprintf(str, "%lx:%lx:%lx:%lx:%lx:%lx:", ntohl(addr->addr[0]) >> 16 & 0xffff, ntohl(addr->addr[0]) & 0xffff, ntohl(addr->addr[1]) >> 16 & 0xffff, ntohl(addr->addr[1]) & 0xffff, ntohl(addr->addr[2]) >> 16 & 0xffff, ntohl(addr->addr[2]) & 0xffff); str += strlen(str); if(ip_addr_is_v4comp(addr)) sprintf(str, "%ld.%ld.%ld.%ld", ntohl(addr->addr[3]) >> 24 & 0xff, ntohl(addr->addr[3]) >> 16 & 0xff, ntohl(addr->addr[3]) >> 8 & 0xff, ntohl(addr->addr[3]) & 0xff); else { sprintf(str, "%lx:%lx", ntohl(addr->addr[3]) >> 16 & 0xffff, ntohl(addr->addr[3]) & 0xffff); } } } void ip_route_debug_list(struct stack *stack) { char ip_tmp[40]; struct ip_route_list *r = stack->ip_route_head; if (r != NULL) LWIP_DEBUGF(ROUTE_DEBUG, ("Destination Gateway Genmask Iface\n")); while (r != NULL) { sprintf_ip(ip_tmp, &r->addr); LWIP_DEBUGF(ROUTE_DEBUG, ("%-40s", ip_tmp)); sprintf_ip(ip_tmp, &r->nexthop); LWIP_DEBUGF(ROUTE_DEBUG, ("%-40s", ip_tmp)); sprintf_ip(ip_tmp, &r->netmask); LWIP_DEBUGF(ROUTE_DEBUG, ("%-40s", ip_tmp)); LWIP_DEBUGF(ROUTE_DEBUG, ("%d (%c%c%d)", r->netif->id, r->netif->name[0],r->netif->name[1],r->netif->num)); LWIP_DEBUGF(ROUTE_DEBUG, ("\n")); r = r->next; } } #else #define ip_route_debug_list(A) #endif /*---------------------------------------------------------------------------*/ void ip_route_policy_table_init(void); void ip_route_list_init(struct stack *stack) { #if 0 #ifdef IPv6_PMTU_DISCOVERY ip_pmtu_init(); #endif #endif ip_route_policy_table_init(); } void ip_route_list_shutdown(struct stack *stack) { /* FIX: TODO */ LWIP_DEBUGF(ROUTE_DEBUG, ("ip_route_list_shutdown: done!\n")); } /*---------------------------------------------------------------------------*/ #define mask_wider(x,y) \ (((y)->addr[0] & ~((x)->addr[0])) | \ ((y)->addr[1] & ~((x)->addr[1])) | \ ((y)->addr[2] & ~((x)->addr[2])) | \ ((y)->addr[3] & ~((x)->addr[3]))) err_t ip_route_list_add(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags) { struct ip_route_list *el = memp_malloc(MEMP_ROUTE); LWIP_ASSERT("ip_route_list_add NULL addr",addr != NULL); LWIP_ASSERT("ip_route_list_add NULL netmask",netmask != NULL); LWIP_ASSERT("ip_route_list_add NULL netif",netif != NULL); if(el == NULL) return ERR_MEM; else { struct ip_route_list **dp = (&stack->ip_route_head); /* Find duplicate */ while (*dp != NULL && ((!ip_addr_cmp(&((*dp)->addr),addr)) || (!ip_addr_cmp(&((*dp)->netmask),netmask)) || (!ip_addr_cmp(&((*dp)->nexthop),nexthop) && (*dp)->netif != netif)) ) dp = &((*dp)->next); if (*dp != NULL) return ERR_CONN; dp=(&stack->ip_route_head); ip_addr_set_mask(&(el->addr),addr,netmask); ip_addr_set(&(el->netmask), netmask); ip_addr_set(&(el->nexthop), nexthop); el->netif = netif; el->flags = flags; /* ordered insert */ while (*dp != NULL && !mask_wider(&((*dp)->netmask),netmask)) { dp = &((*dp)->next); } el->next= *dp; *dp=el; ip_route_debug_list(stack); return ERR_OK; } } err_t ip_route_list_del(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags) { struct ip_route_list **dp=(&stack->ip_route_head); LWIP_ASSERT("ip_route_list_del NULL addr",addr != NULL); /*LWIP_ASSERT("ip_route_list_del NULL netmask",netmask != NULL);*/ if (nexthop == NULL) nexthop = IP_ADDR_ANY; while (*dp != NULL && ( /* addr and mask must be compared separately because * netmask can be NULL */ !ip_addr_cmp(&((*dp)->addr),addr) || (netmask != NULL && !ip_addr_cmp(&((*dp)->netmask),netmask)) || ( !ip_addr_cmp(&((*dp)->nexthop),nexthop) && (*dp)->netif != netif ) )) dp = &((*dp)->next); if (*dp == NULL) { return ERR_CONN; } else { struct ip_route_list *el=*dp; *dp = el->next; #if 0 #ifdef IPv6_PMTU_DISCOVERY IP_PMTU_FREELIST( el->pmtu_list ); #endif #endif memp_free(MEMP_ROUTE,el); ip_route_debug_list(stack); return ERR_OK; } } err_t ip_route_list_delnetif(struct stack *stack, struct netif *netif) { struct ip_route_list **dp=(&stack->ip_route_head); if (netif == NULL) return ERR_OK; else { while (*dp != NULL) { if ((*dp)->netif == netif) { struct ip_route_list *el = *dp; *dp = el->next; #if 0 #ifdef IPv6_PMTU_DISCOVERY IP_PMTU_FREELIST( el->pmtu_list ); #endif #endif memp_free(MEMP_ROUTE,el); } else dp = &((*dp)->next); } ip_route_debug_list(stack); } return ERR_OK; } err_t ip_route_findpath(struct stack *stack, struct ip_addr *addr, struct ip_addr **pnexthop, struct netif **pnetif, int *flags) { struct ip_route_list *dp = stack->ip_route_head; LWIP_ASSERT("ip_route_findpath NULL addr",addr != NULL); LWIP_ASSERT("ip_route_findpath NULL pnetif",pnetif != NULL); LWIP_ASSERT("ip_route_findpath NULL pnexthop",pnexthop != NULL); while (dp != NULL && !ip_addr_maskcmp(addr,&(dp->addr),&(dp->netmask))) dp = dp->next; if (dp==NULL) { *pnetif=NULL; *pnexthop=NULL; return ERR_RTE; } else { *pnetif = dp->netif; if (ip_addr_isany(&(dp->nexthop))) { //LWIP_DEBUGF(ROUTE_DEBUG, ("DIRECTLY CONNECTED %x\n",(*pnexthop)->addr[3])); *pnexthop=addr; } else { //LWIP_DEBUGF(ROUTE_DEBUG, ("VIA %x\n",(*pnexthop)->addr[3])); *pnexthop=&(dp->nexthop); } return ERR_OK; } } #if LWIP_NL /*---------------------------------------------------------------------------------*/ /* Netlink functions (iproute2 tools) */ /*---------------------------------------------------------------------------------*/ INLINE static struct ip_addr_list * ip_route_ipv6_select_source(struct netif *outif, struct ip_addr *dst); #include "lwip/netlink.h" static int isdefault (struct ip_addr *addr) { return ((addr->addr[0] | addr->addr[1] | addr->addr[2] | addr->addr[3] ) ==0) || (ip_addr_is_v4comp(addr) && addr->addr[3] ==0); } void ip_route_out_route_dst(int index,struct ip_route_list *irl,struct ip_addr *address,void * buf,int *offset) { struct rtattr x; int isv4=ip_addr_is_v4comp(&(irl->addr)); if (!address) address=&(irl->addr); if (! isdefault(address)) { x.rta_len=sizeof(struct rtattr)+((isv4)?sizeof(u32_t):sizeof(struct ip_addr)); x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); if (isv4) netlink_addanswer(buf,offset,&(address->addr[3]),sizeof(u32_t)); else netlink_addanswer(buf,offset,address,sizeof(struct ip_addr)); } } void ip_route_out_route_prefsrc(int index,struct ip_route_list *irl,struct ip_addr *address,void * buf,int *offset) { struct rtattr x; int isv4=ip_addr_is_v4comp(&(irl->addr)); struct ip_addr *directaddr; if (address) { if (! isdefault(&(irl->addr))) directaddr= &(irl->addr); else directaddr= &(irl->nexthop); if (directaddr) { struct ip_addr_list *srclist; if (isv4) srclist=ip_addr_list_maskfind(irl->netif->addrs,directaddr); else srclist=ip_route_ipv6_select_source(irl->netif,directaddr); if(srclist) { x.rta_len=sizeof(struct rtattr)+((isv4)?sizeof(u32_t):sizeof(struct ip_addr)); x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); if (isv4) netlink_addanswer(buf,offset,&(srclist->ipaddr.addr[3]),sizeof(u32_t)); else netlink_addanswer(buf,offset,&(srclist->ipaddr),sizeof(struct ip_addr)); } } } } void ip_route_out_route_gateway(int index,struct ip_route_list *irl,struct ip_addr *address,void * buf,int *offset) { struct rtattr x; int isv4=ip_addr_is_v4comp(&(irl->addr)); if (! isdefault(&(irl->nexthop))) { x.rta_len=sizeof(struct rtattr)+((isv4)?sizeof(u32_t):sizeof(struct ip_addr)); x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); if (isv4) netlink_addanswer(buf,offset,&(irl->nexthop.addr[3]),sizeof(u32_t)); else netlink_addanswer(buf,offset,&(irl->nexthop),sizeof(struct ip_addr)); } } void ip_route_out_route_oif(int index,struct ip_route_list *irl,struct ip_addr *address,void * buf,int *offset) { struct rtattr x; u32_t id=irl->netif->id; x.rta_len=sizeof(struct rtattr)+sizeof(int); x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); netlink_addanswer(buf,offset,&(id),sizeof(u32_t)); } typedef void (*opt_out_route)(int,struct ip_route_list *,struct ip_addr *,void *,int *); static opt_out_route ip_route_route_out_table[]={ NULL, ip_route_out_route_dst, NULL, NULL, /* IIF */ ip_route_out_route_oif, ip_route_out_route_gateway, NULL, ip_route_out_route_prefsrc}; #define IP_ROUTE_ROUTE_OUT_TABLE_SIZE (sizeof(ip_route_route_out_table)/sizeof(opt_out_route)) static void ip_route_netlink_out_route(struct nlmsghdr *msg,struct ip_route_list *irl,char family,struct ip_addr *address,struct ip_addr *netmask, void * buf,int *offset) { register int i; int myoffset=*offset; if (family == 0 || family == (ip_addr_is_v4comp(&(irl->addr))?PF_INET:PF_INET6)) { (*offset) += sizeof (struct nlmsghdr); /*printf("UNO route %x\n",irl->addr.addr[3]);*/ struct rtmsg rtm; rtm.rtm_family= ip_addr_is_v4comp(&(irl->addr))?PF_INET:PF_INET6; if (netmask) rtm.rtm_dst_len=mask2prefix(netmask)-(ip_addr_is_v4comp(&(irl->addr))?(32*3):0); else rtm.rtm_dst_len=mask2prefix(&(irl->netmask))-(ip_addr_is_v4comp(&(irl->addr))?(32*3):0); rtm.rtm_src_len=0; rtm.rtm_tos=0; rtm.rtm_table=RT_TABLE_MAIN; rtm.rtm_protocol=RTPROT_KERNEL; rtm.rtm_scope=RT_SCOPE_UNIVERSE; rtm.rtm_type=RTN_UNICAST; /*rtm.rtm_flags=irl->flags; */ rtm.rtm_flags=0; netlink_addanswer(buf,offset,&rtm,sizeof (struct rtmsg)); for (i=0; i< IP_ROUTE_ROUTE_OUT_TABLE_SIZE;i++) if (ip_route_route_out_table[i] != NULL) ip_route_route_out_table[i](i,irl,address,buf,offset); msg->nlmsg_flags = NLM_F_MULTI; msg->nlmsg_type = RTM_NEWROUTE; msg->nlmsg_len = *offset - myoffset; netlink_addanswer(buf,&myoffset,msg,sizeof (struct nlmsghdr)); } } void ip_route_netlink_getroute(struct stack *stack, struct nlmsghdr *msg,void * buf,int *offset) { struct rtmsg *rtm=(struct rtmsg *)(msg+1); struct rtattr *opt=(struct rtattr *)(rtm+1); int size=msg->nlmsg_len - sizeof(struct nlmsghdr) - sizeof(struct rtmsg); int lenrestore=msg->nlmsg_len; int flag=msg->nlmsg_flags; char family=0; /*printf("ip_route_netlink_getrotue %x\n",flag);*/ if (msg->nlmsg_len < sizeof (struct nlmsghdr)) { fprintf(stderr,"Netlink getlink error\n"); /* XXX error packet */ return; } if (msg->nlmsg_len > sizeof (struct nlmsghdr)) family=rtm->rtm_family; if ((flag & NLM_F_DUMP) == NLM_F_DUMP) { struct ip_route_list *dp = stack->ip_route_head; while (dp != NULL) { ip_route_netlink_out_route(msg,dp,family,NULL,NULL,buf,offset); dp=dp->next; } } else if (size > 0){ struct ip_addr ipaddr,netmask; struct ip_route_list *dp = stack->ip_route_head; memcpy(&ipaddr,IP_ADDR_ANY,sizeof(struct ip_addr)); prefix2mask((int)(rtm->rtm_dst_len)+(rtm->rtm_family == PF_INET?(32*3):0),&netmask); while (RTA_OK(opt,size)) { switch(opt->rta_type) { case RTA_DST: if (rtm->rtm_family == PF_INET && opt->rta_len == 8) { ipaddr.addr[2]=IP64_PREFIX; ipaddr.addr[3]=(*((int *)(opt+1))); } else if (rtm->rtm_family == PF_INET6 && opt->rta_len == 20) { register int i; for (i=0;i<4;i++) ipaddr.addr[i]=(*(((int *)(opt+1))+i)); } else { netlink_ackerror(msg,-EINVAL,buf,offset); return; } break; default: printf("Netlink: Unsupported RTA opt %d\n",opt->rta_type); break; } opt=RTA_NEXT(opt,size); } while (dp != NULL && !ip_addr_maskcmp(&ipaddr,&(dp->addr),&(dp->netmask))) dp = dp->next; if (dp != NULL) ip_route_netlink_out_route(msg,dp,family,&ipaddr,&netmask,buf,offset); } msg->nlmsg_type = NLMSG_DONE; msg->nlmsg_flags = 0; msg->nlmsg_len = sizeof (struct nlmsghdr); netlink_addanswer(buf,offset,msg,sizeof (struct nlmsghdr)); msg->nlmsg_len=lenrestore; /* ip_route_list_debug();*/ /*printf("FAMILY=%d\n",family);*/ } void ip_route_netlink_adddelroute(struct stack *stack, struct nlmsghdr *msg,void * buf,int *offset) { struct rtmsg *rtm=(struct rtmsg *)(msg+1); struct rtattr *opt=(struct rtattr *)(rtm+1); int size=msg->nlmsg_len - sizeof(struct nlmsghdr) - sizeof(struct rtmsg); struct ip_addr ipaddr,netmask,nexthop; int netid; struct netif *nip=NULL; int family; int err; int flags=0; /*printf("netif_netlink_adddelroute\n");*/ if (msg->nlmsg_len < sizeof (struct nlmsghdr)) { fprintf(stderr,"Netlink add/deladdr error\n"); netlink_ackerror(msg,-ENXIO,buf,offset); return; } /* XXX controls TABLE_MAIN TYPE_UNICAST */ family=rtm->rtm_family; memcpy(&ipaddr,IP_ADDR_ANY,sizeof(struct ip_addr)); memcpy(&nexthop,IP_ADDR_ANY,sizeof(struct ip_addr)); prefix2mask((int)(rtm->rtm_dst_len)+(rtm->rtm_family == PF_INET?(32*3):0),&netmask); if (family==PF_INET) ipaddr.addr[2]=nexthop.addr[2]=IP64_PREFIX; while (RTA_OK(opt,size)) { switch(opt->rta_type) { case RTA_DST: /*printf("RTN_DST\n");*/ if (rtm->rtm_family == PF_INET && opt->rta_len == 8) { ipaddr.addr[2]=IP64_PREFIX; ipaddr.addr[3]=(*((int *)(opt+1))); } else if (rtm->rtm_family == PF_INET6 && opt->rta_len == 20) { register int i; for (i=0;i<4;i++) ipaddr.addr[i]=(*(((int *)(opt+1))+i)); } else { netlink_ackerror(msg,-EINVAL,buf,offset); return; } break; case RTA_GATEWAY: /*printf("RTN_GATEWAY\n");*/ if (rtm->rtm_family == PF_INET && opt->rta_len == 8) { nexthop.addr[2]=IP64_PREFIX; nexthop.addr[3]=(*((int *)(opt+1))); } else if (rtm->rtm_family == PF_INET6 && opt->rta_len == 20) { register int i; for (i=0;i<4;i++) nexthop.addr[i]=(*(((int *)(opt+1))+i)); } else { netlink_ackerror(msg,-EINVAL,buf,offset); return; } break; case RTA_OIF: /*printf("RTA_OIF\n");*/ if ( opt->rta_len != 8) { netlink_ackerror(msg,-EINVAL,buf,offset); return; } else { netid=(*((int *)(opt+1))); nip=netif_find_id(stack, netid); if (nip == NULL) { fprintf(stderr,"Route add/deladdr id error %d \n",netid); netlink_ackerror(msg,-ENODEV,buf,offset); return; } } break; default: printf("Netlink: Unsupported RTA opt %d\n",opt->rta_type); break; } opt=RTA_NEXT(opt,size); } if (nip==NULL) { /* XXX search the interface */ nip=netif_find_direct_destination(stack, &nexthop); } if (nip == NULL) { fprintf(stderr,"Gateway unreachable\n"); netlink_ackerror(msg,-ENETUNREACH,buf,offset); return; } if (msg->nlmsg_type == RTM_NEWROUTE) { err=ip_route_list_add(stack, &ipaddr,&netmask,&nexthop,nip,flags); } else { err=ip_route_list_del(stack, &ipaddr,&netmask,&nexthop,nip,flags); } /* XXX convert error */ netlink_ackerror(msg,err,buf,offset); } #endif /*---------------------------------------------------------------------------------*/ /* IPv6 Default Address Selection (RFC 3484) */ /*---------------------------------------------------------------------------------*/ //#ifndef IPv6_ADDRSELECT_DBG //#define IPv6_ADDRSELECT_DBG DBG_OFF //#endif struct ip_policy { struct ip_addr ip; struct ip_addr prefix; u16_t precedence; u16_t label; }; #define IP_SELECT_SRC_TABLE_SIZE 5 struct ip_policy ip_policy_table[IP_SELECT_SRC_TABLE_SIZE]; /* FIX: now the table is read only, make it writable! */ /* FIX: add destination address selection */ void ip_route_policy_table_init(void) { /* From RFC Prefix Precedence Label ::1/128 50 0 ::/0 40 1 2002::/16 30 2 ::/96 20 3 ::ffff:0:0/96 10 4 */ IP6_ADDR( &ip_policy_table[0].ip , 0,0,0,0,0,0,0,1); IP6_ADDR( &ip_policy_table[0].prefix , 0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff); ip_policy_table[0].precedence = 50; ip_policy_table[0].label = 0; IP6_ADDR( &ip_policy_table[1].ip , 0,0,0,0,0,0,0,0); IP6_ADDR( &ip_policy_table[1].prefix , 0,0,0,0,0,0,0,0); ip_policy_table[1].precedence = 40; ip_policy_table[1].label = 1; IP6_ADDR( &ip_policy_table[2].ip , 0x2002,0,0,0,0,0,0,0); IP6_ADDR( &ip_policy_table[2].prefix , 0xffff,0,0,0,0,0,0,0); ip_policy_table[2].precedence = 30; ip_policy_table[2].label = 2; IP6_ADDR( &ip_policy_table[3].ip , 0,0,0,0,0,0,0,0); IP6_ADDR( &ip_policy_table[3].prefix , 0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0,0); ip_policy_table[3].precedence = 20; ip_policy_table[3].label = 3; IP6_ADDR( &ip_policy_table[4].ip , 0,0,0,0,0,0xffff,0,0); IP6_ADDR( &ip_policy_table[4].prefix , 0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0,0); ip_policy_table[4].precedence = 10; ip_policy_table[4].label = 4; LWIP_DEBUGF(ROUTE_DEBUG, ("%s: done\n", __func__)); } u16_t ip_policy_get_label(struct ip_addr *ip) { int i; for (i=0; i < IP_SELECT_SRC_TABLE_SIZE; i++) { if (ip_addr_maskcmp(ip, &ip_policy_table[i].ip, &ip_policy_table[i].prefix)) { return ip_policy_table[i].label; } } return 0; } #define SCOPE_NODE 0x1 #define SCOPE_LINK 0x2 #define SCOPE_SUBNET 0x3 #define SCOPE_ADMIN 0x4 #define SCOPE_SITE 0x5 #define SCOPE_ORG 0x8 #define SCOPE_GLOBAL 0xE #define ismulticast(addr1,scope) ( (ntohl((addr1)->addr[0]) & 0x000f) == (scope) ) #define isunicast_link(addr1) (ntohl((addr1)->addr[0]) & 0xFE80) #define isunicast_site(addr1) (ntohl((addr1)->addr[0]) & 0xFEC0) #define isunicast_global(addr1) (ntohl((addr1)->addr[0]) & 0x2000) INLINE static int ip_policy_get_scope(struct ip_addr *ip) { /* FIX: do this better */ if (ip_addr_ismulticast(ip)) { if (ismulticast(ip,SCOPE_NODE)) return 0; if (ismulticast(ip,SCOPE_LINK)) return 1; if (ismulticast(ip,SCOPE_SUBNET)) return 2; if (ismulticast(ip,SCOPE_ADMIN)) return 3; if (ismulticast(ip,SCOPE_SITE)) return 4; if (ismulticast(ip,SCOPE_ORG)) return 5; if (ismulticast(ip,SCOPE_GLOBAL)) return 6; } else { if (isunicast_link(ip)) return 1; if (isunicast_site(ip)) return 4; if (isunicast_global(ip)) return 6; } /* Strange, return the smallest scope */ LWIP_DEBUGF(ROUTE_DEBUG, ("%s: unable to get address scope. BUG?\n", __func__)); return 0; } INLINE static struct ip_addr_list * select_prefer_source(struct ip_addr_list *sa, struct ip_addr_list *sb, struct ip_addr *dst, struct netif *outif) { int scope_sa, scope_sb, scope_d; int label_sa, label_sb, label_d; /* FIX: implement all checks */ /* Rule 1: Prefer same address. If SA = D, then prefer SA. Similarly, if SB = D, then prefer SB. */ if (ip_addr_cmp(&(sa->ipaddr), dst)) return sa; else if (ip_addr_cmp(&(sb->ipaddr), dst)) return sb; /* Rule 2: Prefer appropriate scope. If Scope(SA) < Scope(SB): If Scope(SA) < Scope(D), then prefer SB and otherwise prefer SA. Similarly, if Scope(SB) < Scope(SA): If Scope(SB) < Scope(D), then prefer SA and otherwise prefer SB. */ scope_sa = ip_policy_get_scope(&sa->ipaddr); scope_sb = ip_policy_get_scope(&sb->ipaddr); scope_d = ip_policy_get_scope(dst); if (scope_sa < scope_sb) { if (scope_sa < scope_d) return sb; else return sa; } else if (scope_sb < scope_sa) { if (scope_sb < scope_d) return sa; else return sb; } /* Rule 3: Avoid deprecated addresses. The addresses SA and SB have the same scope. If one of the two source addresses is "preferred" and one of them is "deprecated" (in the RFC 2462 sense), then prefer the one that is "preferred." */ #if IPv6_AUTO_CONFIGURATION if (sa->info.flag != IPADDR_PREFERRED) if (sb->info.flag == IPADDR_PREFERRED) return sb; if (sb->info.flag != IPADDR_PREFERRED) if (sa->info.flag == IPADDR_PREFERRED) return sa; #endif /* Rule 4: Prefer home addresses. If SA is simultaneously a home address and care-of address and SB is not, then prefer SA. Similarly, if SB is simultaneously a home address and care-of address and SA is not, then prefer SB. If SA is just a home address and SB is just a care-of address, then prefer SA. Similarly, if SB is just a home address and SA is just a care-of address, then prefer SB. */ /* Implementations should provide a mechanism allowing an application to reverse the sense of this preference and prefer care-of addresses over home addresses (e.g., via appropriate API extensions). Use of the mechanism should only affect the selection rules for the invoking application. */ /* TODO */ /* Rule 5: Prefer outgoing interface. If SA is assigned to the interface that will be used to send to D and SB is assigned to a different interface, then prefer SA. Similarly, if SB is assigned to the interface that will be used to send to D and SA is assigned to a different interface, then prefer SB. */ /* TODO: up to now, selected SA and SB are both assigned to the interface */ /* Rule 6: Prefer matching label. If Label(SA) = Label(D) and Label(SB) <> Label(D), then prefer SA. Similarly, if Label(SB) = Label(D) and Label(SA) <> Label(D), then prefer SB. */ label_sa = ip_policy_get_label(&sa->ipaddr); label_sb = ip_policy_get_label(&sb->ipaddr); label_d = ip_policy_get_label(dst); if (label_sa == label_d && label_sb != label_d) { return sa; } if (label_sb == label_d && label_sa != label_d) { return sb; } /* Rule 7: Prefer public addresses. If SA is a public address and SB is a temporary address, then prefer SA. Similarly, if SB is a public address and SA is a temporary address, then prefer SB. */ /* TODO */ /* Rule 8: Use longest matching prefix. If CommonPrefixLen(SA, D) > CommonPrefixLen(SB, D), then prefer SA. Similarly, if CommonPrefixLen(SB, D) > CommonPrefixLen(SA, D), then prefer SB. */ /* TODO */ /* Rule 8 may be superseded if the implementation has other means of choosing among source addresses. For example, if the implementation somehow knows which source address will result in the "best" communications performance. */ /* Rule 2 (prefer appropriate scope) MUST be implemented and given high priority because it can affect interoperability. */ /* Uhm... just choose one of them */ return sa; } INLINE static struct ip_addr_list * ip_route_ipv6_select_source(struct netif *outif, struct ip_addr *dst) { struct ip_addr_list *el, *tail; struct ip_addr_list *sa, *sb; struct ip_addr_list *prefer; LWIP_DEBUGF(IPv6_ADDRSELECT_DBG, ("%s: destination ip=", __func__)); ip_addr_debug_print(IPv6_ADDRSELECT_DBG, dst); LWIP_DEBUGF(IPv6_ADDRSELECT_DBG, ("\n")); /* RFC 3484 - 4. Candidate Source Addresses [...]It is RECOMMENDED that the candidate source addresses be the set of unicast addresses assigned to the interface that will be used to send to the destination. (The "outgoing" interface.) On routers, the candidate set MAY include unicast addresses assigned to any interface that forwards packets, subject to the restrictions described below[...] */ /* Visit interface's addresses and take the prefered one */ prefer = sa = sb = NULL; el = tail = outif->addrs->next; do { sa = prefer; /* Get SA (skip IPv4) */ if (sa == NULL) if (!ip_addr_is_v4comp(&el->ipaddr)) sa = el; /* Get SB (skip ipv4) */ if (!ip_addr_is_v4comp(&el->ipaddr)) sb = el; /* If sa != sb != NULL, they are IPv6 and i can compare them */ if (sa != NULL && sb != NULL) { if (sa != sb) prefer = select_prefer_source(sa, sb, dst, outif); else prefer = sa; } el=el->next; } while (el != tail); #if IPv6_ADDRSELECT_DBG == DBG_ON LWIP_DEBUGF(IPv6_ADDRSELECT_DBG, ("%s: ", __func__)); ip_addr_debug_print(IPv6_ADDRSELECT_DBG, &sa->ipaddr); LWIP_DEBUGF(IPv6_ADDRSELECT_DBG, (", ")); ip_addr_debug_print(IPv6_ADDRSELECT_DBG, &sb->ipaddr); LWIP_DEBUGF(IPv6_ADDRSELECT_DBG, (" -> ")); ip_addr_debug_print(IPv6_ADDRSELECT_DBG, &prefer->ipaddr); LWIP_DEBUGF(IPv6_ADDRSELECT_DBG, ("\n")); #endif return prefer; } struct ip_addr_list * ip_route_select_source_ip(struct netif *outif, struct ip_addr *dest, struct ip_addr *nexthop) { if (ip_addr_is_v4comp(dest)) return ip_addr_list_maskfind(outif->addrs, nexthop); else return ip_route_ipv6_select_source(outif, dest); } /* added by Diego Billi */ #if 0 /*---------------------------------------------------------------------------------*/ /* Path MTU Discovery - RFC 1191, 1981(ipv6) */ /*---------------------------------------------------------------------------------*/ err_t pmtu_find_route_entry(struct ip_addr *dest, struct ip_route_list **entry) { struct ip_route_list *r = ip_route_head; while (r != NULL) { if (ip_addr_maskcmp(dest, &(r->addr), &(r->netmask))) break; r = r->next; } if (r !=NULL) { *entry = r; return ERR_OK; } return ERR_RTE; } #ifdef IPv6_PMTU_DISCOVERY /* NOT TESTED YET, NOT TESTED YET, NOT TESTED YET, NOT TESTED YET */ /* * Here follows a simple implementation of Path MTU Discovery * protocol (RFC 1191). */ /* * This table contains commont internet MTUs used by the MTU Detection * algorithm described in the section 7.1. of RFC 1191 (where you can * also find the original table). */ #ifndef PMTU_DEBUG #define PMTU_DEBUG DBG_OFF #endif #define IP_COMMONS_MTUS 11 u16_t ip_pmtu_common_mtus[IP_COMMONS_MTUS] = { 68, 296, 508, 1006, 1492, 2002, 4352, 8166, 17914, 32000, 65535 }; #define IP_PMTU_DEST_POOL_SIZE 128 static struct pmtu_info ip_pmtu_pool[IP_PMTU_DEST_POOL_SIZE]; static struct pmtu_info *ip_pmtu_freelist; static struct pmtu_info *ip_pmtu_head; /* main list */ static void ip_pmtu_start_timer(void); static void ip_pmtu_init() { register int i; /* Clear table & lists */ for (i=0;inext != NULL) last = last->next; last->next = ip_pmtu_freelist; ip_pmtu_freelist = head; } /* Increase 'mtu' to the first greater internet's MTU */ void pmtu_increase(struct pmtu_info *p, u16_t defval) { int i; p->pmtu = defval; /* Find the first MTU greater than 'p->pmtu' */ for (i=0; i < IP_COMMONS_MTUS; i++) if ( p->pmtu < ip_pmtu_common_mtus[i]) { p->pmtu = ip_pmtu_common_mtus[i]; break; } } err_t ip_pmtu_add(struct ip_addr *src, struct ip_addr *dest, u8_t tos, u16_t mtu) { if (ip_pmtu_freelist == NULL) return ERR_MEM; else { struct ip_route_list *entry; struct pmtu_info **dp = (&ip_pmtu_head); struct pmtu_info *el = ip_pmtu_freelist; LWIP_DEBUGF(PMTU_DEBUG, ("ip_pmtu_add: new entry")); LWIP_DEBUGF(PMTU_DEBUG, ("[src=")); ip_addr_debug_print(PMTU_DEBUG, src); LWIP_DEBUGF(PMTU_DEBUG, (" dest=")); ip_addr_debug_print(PMTU_DEBUG, dest); LWIP_DEBUGF(PMTU_DEBUG, (" tos=%d", tos)); LWIP_DEBUGF(PMTU_DEBUG, (" mtu=%d]\n", mtu)); /* If we find a route entry in the routing which matches destination address */ if (pmtu_find_route_entry(dest, &entry) == ERR_OK) { /* Get new PMTU descriptor */ ip_pmtu_freelist = ip_pmtu_freelist->next; el->next = *dp; *dp = el; /* Save Path MTU informations */ ip_addr_set( &el->dest, dest ); ip_addr_set( &el->src , src ); el->tos = tos; el->pmtu = mtu; /* Just created. Start PMTU Increase later */ el->op_timeout = PMTU_INCREASE_TIMEOUT; el->flags = PMTU_FLAG_INCREASE; /* this entry is new */ el->expire_time = 0; /* Add PMTU informations in the route entry */ el->next = entry->pmtu_list; entry->pmtu_list = el; LWIP_DEBUGF(PMTU_DEBUG, ("ip_pmtu_add: added.\n")); return ERR_OK; } else { LWIP_DEBUGF(PMTU_DEBUG, ("ip_pmtu_add: not found route\n")); return ERR_RTE; } } } static inline err_t ip_pmtu_findinfo(struct ip_addr *dest, struct ip_addr *src, u8_t tos, struct pmtu_info **p) { struct ip_route_list *entry; if (pmtu_find_route_entry(dest, &entry) == ERR_OK) { /* Search */ struct pmtu_info *i = entry->pmtu_list; while (i != NULL) { if (ip_addr_cmp(&i->dest, dest) && ip_addr_cmp(&i->src, src) && (i->tos == tos)) break; i = i->next; } if (i != NULL) { *p = i; return ERR_OK; } LWIP_DEBUGF(PMTU_DEBUG, ("ip_pmtu_findinfo: entry not found ")); LWIP_DEBUGF(PMTU_DEBUG, ("[src=")); ip_addr_debug_print(PMTU_DEBUG, src); LWIP_DEBUGF(PMTU_DEBUG, (" dest=")); ip_addr_debug_print(PMTU_DEBUG, dest); LWIP_DEBUGF(PMTU_DEBUG, (" tos=%d]\n", tos)); *p = NULL; return ERR_RTE; } else { LWIP_DEBUGF(PMTU_DEBUG, ("ip_pmtu_findinfo: ______________ROUTE ENTRY NOT FOUND_______________ ")); } return ERR_RTE; } err_t ip_pmtu_getmtu(struct ip_addr *dest, struct ip_addr *src, u8_t tos, u16_t *mtu) { struct pmtu_info *i=NULL; /* find pmtu info */ if (ip_pmtu_findinfo(dest, src, tos, &i) == ERR_OK) { *mtu = i->pmtu; /* Reset expire time */ i->expire_time = 0; return ERR_OK; } return ERR_RTE; } err_t ip_pmtu_decrease(struct ip_addr *dest, struct ip_addr *src, u8_t tos, u16_t new_mtu) { struct pmtu_info *i=NULL; /* find pmtu info */ if (ip_pmtu_findinfo(dest, src, tos, &i) == ERR_OK) { LWIP_DEBUGF(PMTU_DEBUG, ("ip_pmtu_decrease: decreased ")); LWIP_DEBUGF(PMTU_DEBUG, ("[src=")); ip_addr_debug_print(PMTU_DEBUG, &i->src); LWIP_DEBUGF(PMTU_DEBUG, (" dest=")); ip_addr_debug_print(PMTU_DEBUG, &i->dest); LWIP_DEBUGF(PMTU_DEBUG, (" tos=%d", i->tos)); LWIP_DEBUGF(PMTU_DEBUG, (" mtu=%d] ", i->pmtu)); LWIP_DEBUGF(PMTU_DEBUG, ("downto %d\n", new_mtu )); if (i->pmtu < new_mtu) LWIP_DEBUGF(PMTU_DEBUG, ("ip_pmtu_decrease: ***WARNING*** pmtu(%d) > decremented mtu(%d) \n", i->pmtu, new_mtu )); i->pmtu = new_mtu; /* Reset expire time */ i->expire_time = 0; /* Wait a while before increase again Path MTU */ i->op_timeout = PMTU_INCREASE_TIMEOUT; i->flags = PMTU_FLAG_INCREASE; /* * TODO: notify Transport Level (TCP/UDP) */ return ERR_OK; } return ERR_RTE; } /* Called every minute. Visits routing table: * - remove unused pmtu_info * - increase Path MTU * - restore PathMTU to the next-hop's mtu */ static inline void pmtu_tmr(void) { struct ip_route_list *r; struct pmtu_info **i; struct pmtu_info *removed; r = ip_route_head; while (r != NULL) { /* Check all per-host destination for this route */ i = & r->pmtu_list; while (*i != NULL) { (*i)->expire_time++; /* First, clean garbage */ if ((*i)->expire_time != PMTU_NEVER_EXPIRE) if ((*i)->expire_time >= PMTU_EXPIRE_TIMEOUT) { LWIP_DEBUGF(PMTU_DEBUG, ("pmtu_timer: entry ")); LWIP_DEBUGF(PMTU_DEBUG, ("[src=")); ip_addr_debug_print(PMTU_DEBUG, & (*i)->src); LWIP_DEBUGF(PMTU_DEBUG, (" dest=")); ip_addr_debug_print(PMTU_DEBUG, & (*i)->dest); LWIP_DEBUGF(PMTU_DEBUG, (" tos=%d", (*i)->tos)); LWIP_DEBUGF(PMTU_DEBUG, (" mtu=%d] expired! \n", (*i)->pmtu)); /* Adjust list pointers */ removed = *i; *i = removed->next; /* TODO: notify Transport Layer (UDP/TCP) */ /* add pmtu_info to the free list */ removed->next = ip_pmtu_freelist; ip_pmtu_freelist = removed; continue; } /* Update operations timeout */ (*i)->op_timeout --; if ((*i)->op_timeout == 0) { LWIP_DEBUGF(PMTU_DEBUG, ("pmtu_timer: timeout on entry")); LWIP_DEBUGF(PMTU_DEBUG, ("[src=")); ip_addr_debug_print(PMTU_DEBUG, & (*i)->src); LWIP_DEBUGF(PMTU_DEBUG, (" dest=")); ip_addr_debug_print(PMTU_DEBUG, & (*i)->dest); LWIP_DEBUGF(PMTU_DEBUG, (" tos=%d", (*i)->tos)); LWIP_DEBUGF(PMTU_DEBUG, (" mtu=%d]\n", (*i)->pmtu)); if ((*i)->flags == PMTU_FLAG_INCREASE) { pmtu_increase( (*i) , r->netif->mtu ); LWIP_DEBUGF(PMTU_DEBUG, ("pmtu_timer: increased pmtu to %d >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n",(*i)->pmtu )); /* In the near future we could have to decrease mtu */ (*i)->op_timeout = PMTU_DECREASE_TIMEOUT; (*i)->flags = PMTU_FLAG_DECREASE; } else if ((*i)->flags == PMTU_FLAG_DECREASE) { /* Restore PathMTU to next-hop's mtu */ (*i)->pmtu = r->netif->mtu; LWIP_DEBUGF(PMTU_DEBUG, ("pmtu_timer: decreased pmtu downto %d <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",(*i)->pmtu )); /* Wait a while before increase again Path MTU */ (*i)->op_timeout = PMTU_INCREASE_TIMEOUT; (*i)->flags = PMTU_FLAG_INCREASE; } } i = &((*i)->next); } r = r->next; } } static void pmtu_timer_callback(void *arg) { pmtu_tmr(); sys_timeout(PMTU_TMR_INTERVAL, pmtu_timer_callback, NULL); } static void ip_pmtu_start_timer(void) { sys_timeout(PMTU_TMR_INTERVAL, pmtu_timer_callback, NULL); } #endif #endif /* IPv6_PMTU_DISCOVERY */ #if 0 void ip_route_list_debug() { struct ip_route_list *dp=ip_route_head; while (dp != NULL) { printf("addr %x:%x:%x:%x - msk %x:%x:%x:%x - nh %x:%x:%x:%x\n", dp->addr.addr[0], dp->addr.addr[1], dp->addr.addr[2], dp->addr.addr[3], dp->netmask.addr[0], dp->netmask.addr[1], dp->netmask.addr[2], dp->netmask.addr[3], dp->nexthop.addr[0], dp->nexthop.addr[1], dp->nexthop.addr[2], dp->nexthop.addr[3]); printf("addr%x- msk%x- nh%x\n", &(dp->addr), &(dp->netmask), &(dp->nexthop)); dp=dp->next; } } #endif lwipv6-1.5a/lwip-v6/src/core/dhcp.c0000644000175000017500000020231111671615010016125 0ustar renzorenzo/** * @file * * Dynamic Host Configuration Protocol client */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * * Copyright (c) 2001-2004 Leon Woestenberg * Copyright (c) 2001-2004 Axon Digital Design B.V., The Netherlands. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is a contribution to the lwIP TCP/IP stack. * The Swedish Institute of Computer Science and Adam Dunkels * are specifically granted permission to redistribute this * source code. * * Author: Leon Woestenberg * * This is a DHCP client for the lwIP TCP/IP stack. It aims to conform * with RFC 2131 and RFC 2132. * * TODO: * - Proper parsing of DHCP messages exploiting file/sname field overloading. * - Add JavaDoc style documentation (API, internals). * - Support for interfaces other than Ethernet (SLIP, PPP, ...) * * Please coordinate changes and requests with Leon Woestenberg * * * Integration with your code: * * In lwip/dhcp.h * #define DHCP_COARSE_TIMER_SECS (recommended 60 which is a minute) * #define DHCP_FINE_TIMER_MSECS (recommended 500 which equals TCP coarse timer) * * Then have your application call dhcp_coarse_tmr() and * dhcp_fine_tmr() on the defined intervals. * * dhcp_start(struct netif *netif); * starts a DHCP client instance which configures the interface by * obtaining an IP address lease and maintaining it. * * Use dhcp_release(netif) to end the lease and use dhcp_stop(netif) * to remove the DHCP client. * */ #include "lwip/opt.h" #if LWIP_DHCP #include "lwip/sys.h" #include "lwip/stats.h" #include "lwip/mem.h" #include "lwip/netif.h" #include "lwip/udp.h" #include "lwip/ip_addr.h" #include "netif/etharp.h" #include "lwip/sockets.h" #include "lwip/inet.h" #include "lwip/dhcp.h" /*---------------------------------------------------------------------------*/ //#ifndef DHCP_DEBUG //#define DHCP_DEBUG DBG_ON //#endif /*---------------------------------------------------------------------------*/ #define U16_F "hu" #define S16_F "hd" #define X16_F "hx" #define U32_F "lu" #define S32_F "ld" #define X32_F "lx" /*---------------------------------------------------------------------------*/ err_t udp_sendto_netif(struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port, struct netif *netif); err_t udp_send_netif(struct udp_pcb *pcb, struct pbuf *p, struct netif *netif); /*---------------------------------------------------------------------------*/ /** global transaction identifier, must be * unique for each DHCP request. We simply increment, starting * with this value (easy to match with a packet analyzer) */ static u32_t xid = 0xABCD0000; /** DHCP client state machine functions */ static void dhcp_handle_ack(struct netif *netif); static void dhcp_handle_nak(struct netif *netif); static void dhcp_handle_offer(struct netif *netif); static err_t dhcp_discover(struct netif *netif); static err_t dhcp_select(struct netif *netif); static void dhcp_check(struct netif *netif); static void dhcp_bind(struct netif *netif); static err_t dhcp_decline(struct netif *netif); static err_t dhcp_rebind(struct netif *netif); static void dhcp_set_state(struct dhcp *dhcp, u8_t new_state); /** receive, unfold, parse and free incoming messages */ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip4_addr *addr, u16_t port); static void dhcp_recv_wrapper(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port); static err_t dhcp_unfold_reply(struct dhcp *dhcp); static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type); static u8_t dhcp_get_option_byte(u8_t *ptr); #if 0 static u16_t dhcp_get_option_short(u8_t *ptr); #endif static u32_t dhcp_get_option_long(u8_t *ptr); static void dhcp_free_reply(struct dhcp *dhcp); /** set the DHCP timers */ static void dhcp_timeout(struct netif *netif); static void dhcp_t1_timeout(struct netif *netif); static void dhcp_t2_timeout(struct netif *netif); /** build outgoing messages */ /** create a DHCP request, fill in common headers */ static err_t dhcp_create_request(struct netif *netif); /** free a DHCP request */ static void dhcp_delete_request(struct netif *netif); /** add a DHCP option (type, then length in bytes) */ static void dhcp_option(struct dhcp *dhcp, u8_t option_type, u8_t option_len); /** add option values */ static void dhcp_option_byte(struct dhcp *dhcp, u8_t value); static void dhcp_option_short(struct dhcp *dhcp, u16_t value); static void dhcp_option_long(struct dhcp *dhcp, u32_t value); /** always add the DHCP options trailer to end and pad */ static void dhcp_option_trailer(struct dhcp *dhcp); /** * Back-off the DHCP client (because of a received NAK response). * * Back-off the DHCP client because of a received NAK. Receiving a * NAK means the client asked for something non-sensible, for * example when it tries to renew a lease obtained on another network. * * We back-off and will end up restarting a fresh DHCP negotiation later. * * @param state pointer to DHCP state structure */ static void dhcp_handle_nak(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; u16_t msecs = 10 * 1000; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_nak(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %"U16_F" msecs\n", msecs)); dhcp_set_state(dhcp, DHCP_BACKING_OFF); } /** * Checks if the offered IP address is already in use. * * It does so by sending an ARP request for the offered address and * entering CHECKING state. If no ARP reply is received within a small * interval, the address is assumed to be free for use by us. */ static void dhcp_check(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; err_t result; u16_t msecs; /* Added by Diego Billi */ struct ip_addr_list *al; struct ip_addr offered_addr; IP64_CONV (&offered_addr, &dhcp->offered_ip_addr ); if ((al=ip_addr_list_maskfind(netif->addrs, &offered_addr)) == NULL) // FIX: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX return; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_check(netif=%p) %c%c\n", (void *)netif, (s16_t)netif->name[0], (s16_t)netif->name[1])); /* create an ARP query for the offered IP address, expecting that no host responds, as the IP address should not be in use. */ ///CHANGED result = etharp_query(netif, &dhcp->offered_ip_addr, NULL); result = etharp_query(al, &offered_addr, NULL); if (result != ERR_OK) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_check: could not perform ARP query\n")); } dhcp->tries++; msecs = 500; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %"U16_F" msecs\n", msecs)); dhcp_set_state(dhcp, DHCP_CHECKING); } /** * Remember the configuration offered by a DHCP server. * * @param state pointer to DHCP state structure */ static void dhcp_handle_offer(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; /* obtain the server address */ u8_t *option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_SERVER_ID); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_offer(netif=%p) %c%c%d\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); if (option_ptr != NULL) { dhcp->server_ip_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2])); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08"X32_F"\n", dhcp->server_ip_addr.addr)); /* remember offered address */ ///CHANGED ip_addr_set(&dhcp->offered_ip_addr, (struct ip4_addr *)&dhcp->msg_in->yiaddr); ip4_addr_set(&dhcp->offered_ip_addr, (struct ip4_addr *)&dhcp->msg_in->yiaddr); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr)); dhcp_select(netif); } } /** * Select a DHCP server offer out of all offers. * * Simply select the first offer received. * * @param netif the netif under DHCP control * @return lwIP specific error (see error.h) */ static err_t dhcp_select(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; err_t result; u32_t msecs; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_select(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); /* create and initialize the DHCP message header */ result = dhcp_create_request(netif); if (result == ERR_OK) { dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); dhcp_option_byte(dhcp, DHCP_REQUEST); dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); dhcp_option_short(dhcp, 576); /* MUST request the offered IP address */ dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr)); dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr)); dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 4/*num options*/); dhcp_option_byte(dhcp, DHCP_OPTION_SUBNET_MASK); dhcp_option_byte(dhcp, DHCP_OPTION_ROUTER); dhcp_option_byte(dhcp, DHCP_OPTION_BROADCAST); dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER); dhcp_option_trailer(dhcp); /* shrink the pbuf to the actual content length */ pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); /* TODO: we really should bind to a specific local interface here but we cannot specify an unconfigured netif as it is addressless */ udp_bind(dhcp->pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT, NULL); /* send broadcast to any DHCP server */ { ///udp_connect(dhcp->pcb, IP4_ADDR_BROADCAST, DHCP_SERVER_PORT); struct ip_addr broadcast; IP64_CONV(&broadcast, IP4_ADDR_BROADCAST); udp_connect(dhcp->pcb, &broadcast, DHCP_SERVER_PORT); } udp_send_netif(dhcp->pcb, dhcp->p_out, netif); /* reconnect to any (or to server here?!) */ udp_connect(dhcp->pcb, IP4_ADDR_ANY, DHCP_SERVER_PORT); dhcp_delete_request(netif); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_select: REQUESTING\n")); dhcp_set_state(dhcp, DHCP_REQUESTING); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_select: could not allocate DHCP request\n")); } dhcp->tries++; msecs = dhcp->tries < 4 ? dhcp->tries * 1000 : 4 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %"U32_F" msecs\n", msecs)); return result; } /** * The DHCP timer that checks for lease renewal/rebind timeouts. * */ void dhcp_coarse_tmr(void *arg) { struct stack *stack = (struct stack *) arg; struct netif *netif = stack->netif_list; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_coarse_tmr()\n")); //printf("dhcp coarse\n"); /* iterate through all network interfaces */ while (netif != NULL) { /* only act on DHCP configured interfaces */ if (netif->dhcp != NULL) { /* timer is active (non zero), and triggers (zeroes) now? */ if (netif->dhcp->t2_timeout-- == 1) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n")); /* this clients' rebind timeout triggered */ dhcp_t2_timeout(netif); /* timer is active (non zero), and triggers (zeroes) now */ } else if (netif->dhcp->t1_timeout-- == 1) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n")); /* this clients' renewal timeout triggered */ dhcp_t1_timeout(netif); } } /* proceed to next netif */ netif = netif->next; } sys_timeout(DHCP_COARSE_TIMER_SECS * 1000, dhcp_coarse_tmr , stack); } /** * DHCP transaction timeout handling * * A DHCP server is expected to respond within a short period of time. * This timer checks whether an outstanding DHCP request is timed out. * */ void dhcp_fine_tmr(void *arg) { struct stack *stack = (struct stack *)arg; struct netif *netif = stack->netif_list; //printf("dhcp fine\n"); /* loop through netif's */ while (netif != NULL) { /* only act on DHCP configured interfaces */ if (netif->dhcp != NULL) { /* timer is active (non zero), and is about to trigger now */ if (netif->dhcp->request_timeout-- == 1) { /* { netif->dhcp->request_timeout == 0 } */ LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_fine_tmr(): request timeout\n")); /* this clients' request timeout triggered */ dhcp_timeout(netif); } } /* proceed to next network interface */ netif = netif->next; } sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_fine_tmr , stack); } #if 0 void dhcp_init(struct stack *stack) { sys_timeout(DHCP_FINE_TIMER_MSECS , dhcp_fine_tmr , (void*)stack); sys_timeout(DHCP_COARSE_TIMER_SECS * 1000, dhcp_coarse_tmr , (void*)stack); } #endif /* start timers if there are no interfaces requiring DHCP, call this just before assigning netif->dhcp */ static void dhcp_starttimers(struct stack *stack) { struct netif *netif; for(netif = stack->netif_list; netif != NULL; netif = netif->next) if (netif->dhcp != NULL) break; if (netif==NULL) { sys_timeout(DHCP_FINE_TIMER_MSECS , dhcp_fine_tmr , (void*)stack); sys_timeout(DHCP_COARSE_TIMER_SECS * 1000, dhcp_coarse_tmr , (void*)stack); } } /* stop timers if there are no interfaces requiring DHCP, call this just after assigning netif->dhcp=NULL */ static void dhcp_stoptimers(struct stack *stack) { struct netif *netif; for(netif = stack->netif_list; netif != NULL; netif = netif->next) if (netif->dhcp != NULL) break; if (netif==NULL) { sys_untimeout(dhcp_fine_tmr , (void*)stack); sys_untimeout(dhcp_coarse_tmr , (void*)stack); } } /** * A DHCP negotiation transaction, or ARP request, has timed out. * * The timer that was started with the DHCP or ARP request has * timed out, indicating no response was received in time. * * @param netif the netif under DHCP control * */ static void dhcp_timeout(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_timeout()\n")); /* back-off period has passed, or server selection timed out */ if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_timeout(): restarting discovery\n")); dhcp_discover(netif); /* receiving the requested lease timed out */ } else if (dhcp->state == DHCP_REQUESTING) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n")); if (dhcp->tries <= 5) { dhcp_select(netif); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n")); dhcp_release(netif); dhcp_discover(netif); } /* received no ARP reply for the offered address (which is good) */ } else if (dhcp->state == DHCP_CHECKING) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n")); if (dhcp->tries <= 1) { dhcp_check(netif); /* no ARP replies on the offered address, looks like the IP address is indeed free */ } else { /* bind the interface to the offered address */ dhcp_bind(netif); } } /* did not get response to renew request? */ else if (dhcp->state == DHCP_RENEWING) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out\n")); /* just retry renewal */ /* note that the rebind timer will eventually time-out if renew does not work */ dhcp_renew(netif); /* did not get response to rebind request? */ } else if (dhcp->state == DHCP_REBINDING) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out\n")); if (dhcp->tries <= 8) { dhcp_rebind(netif); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING\n")); dhcp_release(netif); dhcp_discover(netif); } } } /** * The renewal period has timed out. * * @param netif the netif under DHCP control */ static void dhcp_t1_timeout(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_t1_timeout()\n")); if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) { /* just retry to renew - note that the rebind timer (t2) will * eventually time-out if renew tries fail. */ LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t1_timeout(): must renew\n")); dhcp_renew(netif); } } /** * The rebind period has timed out. * */ static void dhcp_t2_timeout(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout()\n")); if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) { /* just retry to rebind */ LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout(): must rebind\n")); dhcp_rebind(netif); } } /** * * @param netif the netif under DHCP control */ static void dhcp_handle_ack(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; u8_t *option_ptr; /* clear options we might not get from the ACK */ dhcp->offered_sn_mask.addr = 0; dhcp->offered_gw_addr.addr = 0; dhcp->offered_bc_addr.addr = 0; /* lease time given? */ option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_LEASE_TIME); if (option_ptr != NULL) { /* remember offered lease time */ dhcp->offered_t0_lease = dhcp_get_option_long(option_ptr + 2); } /* renewal period given? */ option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_T1); if (option_ptr != NULL) { /* remember given renewal period */ dhcp->offered_t1_renew = dhcp_get_option_long(option_ptr + 2); } else { /* calculate safe periods for renewal */ dhcp->offered_t1_renew = dhcp->offered_t0_lease / 2; } /* renewal period given? */ option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_T2); if (option_ptr != NULL) { /* remember given rebind period */ dhcp->offered_t2_rebind = dhcp_get_option_long(option_ptr + 2); } else { /* calculate safe periods for rebinding */ dhcp->offered_t2_rebind = dhcp->offered_t0_lease; } /* (y)our internet address */ ///CHANGED ip_addr_set(&dhcp->offered_ip_addr, &dhcp->msg_in->yiaddr); ip4_addr_set(&dhcp->offered_ip_addr, &dhcp->msg_in->yiaddr); /** * Patch #1308 * TODO: we must check if the file field is not overloaded by DHCP options! */ #if 0 /* boot server address */ ip_addr_set(&dhcp->offered_si_addr, &dhcp->msg_in->siaddr); /* boot file name */ if (dhcp->msg_in->file[0]) { dhcp->boot_file_name = mem_malloc(strlen(dhcp->msg_in->file) + 1); strcpy(dhcp->boot_file_name, dhcp->msg_in->file); } #endif /* subnet mask */ option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_SUBNET_MASK); /* subnet mask given? */ if (option_ptr != NULL) { dhcp->offered_sn_mask.addr = htonl(dhcp_get_option_long(&option_ptr[2])); } /* gateway router */ option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_ROUTER); if (option_ptr != NULL) { dhcp->offered_gw_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2])); } /* broadcast address */ option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_BROADCAST); if (option_ptr != NULL) { dhcp->offered_bc_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2])); } /* DNS servers */ option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_DNS_SERVER); if (option_ptr != NULL) { u8_t n; dhcp->dns_count = dhcp_get_option_byte(&option_ptr[1]) / (u32_t)sizeof(struct ip4_addr); /* limit to at most DHCP_MAX_DNS DNS servers */ if (dhcp->dns_count > DHCP_MAX_DNS) dhcp->dns_count = DHCP_MAX_DNS; for (n = 0; n < dhcp->dns_count; n++) { dhcp->offered_dns_addr[n].addr = htonl(dhcp_get_option_long(&option_ptr[2 + n * 4])); } } } /** * Start DHCP negotiation for a network interface. * * If no DHCP client instance was attached to this interface, * a new client is created first. If a DHCP client instance * was already present, it restarts negotiation. * * @param netif The lwIP network interface * @return lwIP error code * - ERR_OK - No error * - ERR_MEM - Out of memory * */ err_t dhcp_start(struct netif *netif) { struct stack *stack = netif->stack; struct dhcp *dhcp = netif->dhcp; err_t result = ERR_OK; LWIP_ASSERT("netif != NULL", netif != NULL); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_start(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); netif->flags &= ~NETIF_FLAG_DHCP; /* no DHCP client attached yet? */ if (dhcp == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting new DHCP client\n")); dhcp = mem_malloc(sizeof(struct dhcp)); if (dhcp == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n")); return ERR_MEM; } dhcp_starttimers(stack); /* store this dhcp client in the netif */ netif->dhcp = dhcp; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): allocated dhcp")); } /* already has DHCP client attached */ else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 3, ("dhcp_start(): restarting DHCP configuration\n")); } /// /* FIX FIX FIX: I must give an address to the interface otherwise it does not work */ /// { /// struct ip_addr ip,netmask; /// IP64_ADDR(&ip, 0,0,0,0); /// IP64_MASKADDR(&netmask, 0,0,0,0); /// netif_add_addr(netif, &ip, &netmask); /// //ip_route_list_add(&ip, &netmask, &netmask, netif, 0); /// } /* clear data structure */ memset(dhcp, 0, sizeof(struct dhcp)); /* allocate UDP PCB */ dhcp->pcb = udp_new(stack); if (dhcp->pcb == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not obtain pcb\n")); mem_free((void *)dhcp); netif->dhcp = dhcp = NULL; dhcp_stoptimers(stack); return ERR_MEM; } LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting DHCP configuration\n")); /* (re)start the DHCP negotiation */ result = dhcp_discover(netif); if (result != ERR_OK) { /* free resources allocated above */ dhcp_stop(netif); return ERR_MEM; } netif->flags |= NETIF_FLAG_DHCP; return result; } /** * Inform a DHCP server of our manual configuration. * * This informs DHCP servers of our fixed IP address configuration * by sending an INFORM message. It does not involve DHCP address * configuration, it is just here to be nice to the network. * * @param netif The lwIP network interface * */ void dhcp_inform(struct netif *netif) { struct stack *stack = netif->stack; struct dhcp *dhcp; err_t result = ERR_OK; dhcp = mem_malloc(sizeof(struct dhcp)); if (dhcp == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not allocate dhcp\n")); return; } dhcp_starttimers(stack); netif->dhcp = dhcp; memset(dhcp, 0, sizeof(struct dhcp)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): allocated dhcp\n")); dhcp->pcb = udp_new(stack); if (dhcp->pcb == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not obtain pcb")); netif->dhcp=NULL; mem_free((void *)dhcp); dhcp_stoptimers(stack); return; } LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): created new udp pcb\n")); /* create and initialize the DHCP message header */ result = dhcp_create_request(netif); if (result == ERR_OK) { dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); dhcp_option_byte(dhcp, DHCP_INFORM); dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); /* TODO: use netif->mtu ?! */ dhcp_option_short(dhcp, 576); dhcp_option_trailer(dhcp); pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); udp_bind(dhcp->pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT, NULL); { ///udp_connect(dhcp->pcb, IP4_ADDR_BROADCAST, DHCP_SERVER_PORT); struct ip_addr broadcast; IP64_CONV(&broadcast, IP4_ADDR_BROADCAST); udp_connect(dhcp->pcb, &broadcast, DHCP_SERVER_PORT); } LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_inform: INFORMING\n")); udp_send_netif(dhcp->pcb, dhcp->p_out, netif); udp_connect(dhcp->pcb, IP4_ADDR_ANY, DHCP_SERVER_PORT); dhcp_delete_request(netif); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform: could not allocate DHCP request\n")); } if (dhcp != NULL) { if (dhcp->pcb != NULL) udp_remove(dhcp->pcb); dhcp->pcb = NULL; netif->dhcp = NULL; mem_free((void *)dhcp); dhcp_stoptimers(stack); } } #if DHCP_DOES_ARP_CHECK /** * Match an ARP reply with the offered IP address. * * @param addr The IP address we received a reply from * */ void dhcp_arp_reply(struct netif *netif, struct ip4_addr *addr) { LWIP_ASSERT("netif != NULL", netif != NULL); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()\n")); /* is a DHCP client doing an ARP check? */ if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08"X32_F"\n", addr->addr)); /* did a host respond with the address we were offered by the DHCP server? */ ///CHANGED if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) { if (ip4_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) { /* we will not accept the offered address */ LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 1, ("dhcp_arp_reply(): arp reply matched with offered address, declining\n")); dhcp_decline(netif); } } } /** * Decline an offered lease. * * Tell the DHCP server we do not accept the offered address. * One reason to decline the lease is when we find out the address * is already in use by another host (through ARP). */ static err_t dhcp_decline(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; err_t result = ERR_OK; u16_t msecs; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_decline()\n")); dhcp_set_state(dhcp, DHCP_BACKING_OFF); /* create and initialize the DHCP message header */ result = dhcp_create_request(netif); if (result == ERR_OK) { dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); dhcp_option_byte(dhcp, DHCP_DECLINE); dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); dhcp_option_short(dhcp, 576); dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr)); dhcp_option_trailer(dhcp); /* resize pbuf to reflect true size of options */ pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); udp_bind(dhcp->pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT, NULL); /* @todo: should we really connect here? we are performing sendto() */ udp_connect(dhcp->pcb, IP4_ADDR_ANY, DHCP_SERVER_PORT); /* per section 4.4.4, broadcast DECLINE messages */ { ///udp_sendto(dhcp->pcb, dhcp->p_out, IP4_ADDR_BROADCAST, DHCP_SERVER_PORT); struct ip_addr broadcast; IP64_CONV(&broadcast, IP4_ADDR_BROADCAST); udp_sendto_netif(dhcp->pcb, dhcp->p_out, &broadcast, DHCP_SERVER_PORT, netif); } dhcp_delete_request(netif); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_decline: BACKING OFF\n")); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_decline: could not allocate DHCP request\n")); } dhcp->tries++; msecs = 10*1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_decline(): set request timeout %"U16_F" msecs\n", msecs)); return result; } #endif /** * Start the DHCP process, discover a DHCP server. * */ static err_t dhcp_discover(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; err_t result = ERR_OK; u16_t msecs; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_discover()\n")); ///CHANGED ip_addr_set(&dhcp->offered_ip_addr, IP4_ADDR_ANY); ip64_addr_set(&dhcp->offered_ip_addr, IP4_ADDR_ANY); /* create and initialize the DHCP message header */ result = dhcp_create_request(netif); if (result == ERR_OK) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: making request\n")); dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); dhcp_option_byte(dhcp, DHCP_DISCOVER); dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); dhcp_option_short(dhcp, 576); dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 4/*num options*/); dhcp_option_byte(dhcp, DHCP_OPTION_SUBNET_MASK); dhcp_option_byte(dhcp, DHCP_OPTION_ROUTER); dhcp_option_byte(dhcp, DHCP_OPTION_BROADCAST); dhcp_option_byte(dhcp, DHCP_OPTION_DNS_SERVER); dhcp_option_trailer(dhcp); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: realloc()ing\n")); pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); /* set receive callback function with netif as user data */ ///CHANGED udp_recv(dhcp->pcb, dhcp_recv, netif); udp_recv(dhcp->pcb, dhcp_recv_wrapper, netif); udp_bind(dhcp->pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT, NULL); udp_connect(dhcp->pcb, IP4_ADDR_ANY, DHCP_SERVER_PORT); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: sendto(DISCOVER, IP4_ADDR_BROADCAST, DHCP_SERVER_PORT)\n")); { ///udp_sendto(dhcp->pcb, dhcp->p_out, IP4_ADDR_BROADCAST, DHCP_SERVER_PORT); struct ip_addr broadcast; IP64_CONV(&broadcast, IP4_ADDR_BROADCAST); udp_sendto_netif(dhcp->pcb, dhcp->p_out, &broadcast, DHCP_SERVER_PORT, netif); } LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: deleting()ing\n")); dhcp_delete_request(netif); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover: SELECTING\n")); dhcp_set_state(dhcp, DHCP_SELECTING); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_discover: could not allocate DHCP request\n")); } dhcp->tries++; msecs = dhcp->tries < 4 ? (dhcp->tries + 1) * 1000 : 10 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs)); return result; } /** * Bind the interface to the offered IP address. * * @param netif network interface to bind to the offered address */ static void dhcp_bind(struct netif *netif) { struct stack *stack = netif->stack; struct dhcp *dhcp = netif->dhcp; //struct ip4_addr sn_mask, gw_addr; struct ip_addr ip; struct ip_addr sn_mask, gw_addr; LWIP_ASSERT("dhcp_bind: netif != NULL", netif != NULL); LWIP_ASSERT("dhcp_bind: dhcp != NULL", dhcp != NULL); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_bind(netif=%p) %c%c%"U16_F"\n", (void*)netif, netif->name[0], netif->name[1], (u16_t)netif->num)); /* temporary DHCP lease? */ if (dhcp->offered_t1_renew != 0xffffffffUL) { /* set renewal period timer */ LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t1 renewal timer %"U32_F" secs\n", dhcp->offered_t1_renew)); dhcp->t1_timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; if (dhcp->t1_timeout == 0) dhcp->t1_timeout = 1; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t1_renew*1000)); } /* set renewal period timer */ if (dhcp->offered_t2_rebind != 0xffffffffUL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t2 rebind timer %"U32_F" secs\n", dhcp->offered_t2_rebind)); dhcp->t2_timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; if (dhcp->t2_timeout == 0) dhcp->t2_timeout = 1; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %"U32_F" msecs\n", dhcp->offered_t2_rebind*1000)); } /* copy offered network mask */ ///CHANGED ip_addr_set(&sn_mask, &dhcp->offered_sn_mask); IP64_MASKCONV(&sn_mask, &dhcp->offered_sn_mask); /* subnet mask not given? */ /* TODO: this is not a valid check. what if the network mask is 0? */ if (sn_mask.addr[3] == 0) { /* choose a safe subnet mask given the network class */ u8_t first_octet = ip4_addr1(&sn_mask); if (first_octet <= 127) sn_mask.addr[3] = htonl(0xff000000); else if (first_octet >= 192) sn_mask.addr[3] = htonl(0xffffff00); else sn_mask.addr[3] = htonl(0xffff0000); } /// CHANGED ip_addr_set(&gw_addr, &dhcp->offered_gw_addr); IP64_CONV(&gw_addr, &dhcp->offered_gw_addr); /* gateway address not given? */ if (gw_addr.addr[3] == 0) { /* copy network address */ gw_addr.addr[3] = (dhcp->offered_ip_addr.addr & sn_mask.addr[3]); /* use first host address on network as gateway */ gw_addr.addr[3] |= htonl(0x00000001); } ///LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): IP: 0x%08"X32_F"\n", dhcp->offered_ip_addr.addr)); ///netif_set_ipaddr(netif, &dhcp->offered_ip_addr); ///LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): SN: 0x%08"X32_F"\n", sn_mask.addr)); ///netif_set_netmask(netif, &sn_mask); ///LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08"X32_F"\n", gw_addr.addr)); ///netif_set_gw(netif, &gw_addr); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind()")); IP64_CONV(&ip, (struct ip4_addr*)&dhcp->offered_ip_addr.addr); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("\nIP: ")); ip_addr_debug_print(DHCP_DEBUG | DBG_STATE, &ip); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("\nSN: ")); ip_addr_debug_print(DHCP_DEBUG | DBG_STATE, &sn_mask); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("\nGW: ")); ip_addr_debug_print(DHCP_DEBUG | DBG_STATE, &gw_addr); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("\n")); /// /* FIX FIX FIX FIX: remove the fake address */ /// { /// struct ip_addr ip2,netmask2; /// IP64_ADDR(&ip2, 0,0,0,0); /// IP64_MASKADDR(&netmask2, 0,0,0,0); /// netif_del_addr(netif, &ip2, &netmask2); /// //ip_route_list_add(&ip, &netmask, &netmask, netif, 0); /// } netif_add_addr(netif, &ip, &sn_mask); IP64_ADDR(&ip, 0,0,0,0); IP64_MASKADDR(&sn_mask, 0,0,0,0); ip_route_list_add(stack, &ip, &sn_mask, &gw_addr, netif, 0); /* bring the interface up */ //netif_set_up_low(netif); /* netif is now bound to DHCP leased address */ dhcp_set_state(dhcp, DHCP_BOUND); } /** * Renew an existing DHCP lease at the involved DHCP server. * * @param netif network interface which must renew its lease */ err_t dhcp_renew(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; err_t result; u16_t msecs; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_renew()\n")); dhcp_set_state(dhcp, DHCP_RENEWING); /* create and initialize the DHCP message header */ result = dhcp_create_request(netif); if (result == ERR_OK) { dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); dhcp_option_byte(dhcp, DHCP_REQUEST); dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); /* TODO: use netif->mtu in some way */ dhcp_option_short(dhcp, 576); #if 0 dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr)); #endif #if 0 dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr)); #endif /* append DHCP message trailer */ dhcp_option_trailer(dhcp); pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); udp_bind(dhcp->pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT, NULL); { // struct ip_addr serverip; IP64_CONV(&serverip, &dhcp->server_ip_addr); ///CHANGED udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, &serverip, DHCP_SERVER_PORT); } udp_send_netif(dhcp->pcb, dhcp->p_out, netif); dhcp_delete_request(netif); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew: RENEWING\n")); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_renew: could not allocate DHCP request\n")); } dhcp->tries++; /* back-off on retries, but to a maximum of 20 seconds */ msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew(): set request timeout %"U16_F" msecs\n", msecs)); return result; } /** * Rebind with a DHCP server for an existing DHCP lease. * * @param netif network interface which must rebind with a DHCP server */ static err_t dhcp_rebind(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; err_t result; u16_t msecs; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind()\n")); dhcp_set_state(dhcp, DHCP_REBINDING); /* create and initialize the DHCP message header */ result = dhcp_create_request(netif); if (result == ERR_OK) { dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); dhcp_option_byte(dhcp, DHCP_REQUEST); dhcp_option(dhcp, DHCP_OPTION_MAX_MSG_SIZE, DHCP_OPTION_MAX_MSG_SIZE_LEN); dhcp_option_short(dhcp, 576); #if 0 dhcp_option(dhcp, DHCP_OPTION_REQUESTED_IP, 4); dhcp_option_long(dhcp, ntohl(dhcp->offered_ip_addr.addr)); dhcp_option(dhcp, DHCP_OPTION_SERVER_ID, 4); dhcp_option_long(dhcp, ntohl(dhcp->server_ip_addr.addr)); #endif dhcp_option_trailer(dhcp); pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); /* set remote IP association to any DHCP server */ udp_bind(dhcp->pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT, NULL); udp_connect(dhcp->pcb, IP4_ADDR_ANY, DHCP_SERVER_PORT); /* broadcast to server */ { ///udp_sendto(dhcp->pcb, dhcp->p_out, IP4_ADDR_BROADCAST, DHCP_SERVER_PORT); struct ip_addr broadcast; IP64_CONV(&broadcast, IP4_ADDR_BROADCAST); udp_sendto_netif(dhcp->pcb, dhcp->p_out, &broadcast, DHCP_SERVER_PORT, netif); } dhcp_delete_request(netif); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind: REBINDING\n")); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_rebind: could not allocate DHCP request\n")); } dhcp->tries++; msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind(): set request timeout %"U16_F" msecs\n", msecs)); return result; } /** * Release a DHCP lease. * * @param netif network interface which must release its lease */ err_t dhcp_release(struct netif *netif) { struct stack *stack = netif->stack; struct dhcp *dhcp = netif->dhcp; err_t result; u16_t msecs; if (dhcp == NULL) { /* FIX: should not append */ return ERR_OK; } struct ip_addr ip, netmask, gw; IP64_CONV( &ip, (struct ip4_addr *)&dhcp->offered_ip_addr.addr); IP64_MASKCONV( &netmask, (struct ip4_addr *)&dhcp->offered_sn_mask.addr); IP64_CONV( &gw, (struct ip4_addr *)&dhcp->offered_gw_addr.addr); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_release()\n")); /* idle DHCP client */ dhcp_set_state(dhcp, DHCP_OFF); /* clean old DHCP offer */ dhcp->server_ip_addr.addr = 0; dhcp->offered_ip_addr.addr = dhcp->offered_sn_mask.addr = 0; dhcp->offered_gw_addr.addr = dhcp->offered_bc_addr.addr = 0; dhcp->offered_t0_lease = dhcp->offered_t1_renew = dhcp->offered_t2_rebind = 0; dhcp->dns_count = 0; /* create and initialize the DHCP message header */ result = dhcp_create_request(netif); if (result == ERR_OK) { dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); dhcp_option_byte(dhcp, DHCP_RELEASE); dhcp_option_trailer(dhcp); pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); udp_bind(dhcp->pcb, IP4_ADDR_ANY, DHCP_CLIENT_PORT, NULL); { // struct ip_addr serverip; IP64_CONV(&serverip, &dhcp->server_ip_addr); ///CHANGED udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, &serverip, DHCP_SERVER_PORT); } udp_send_netif(dhcp->pcb, dhcp->p_out, netif); dhcp_delete_request(netif); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release: RELEASED, DHCP_OFF\n")); } else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_release: could not allocate DHCP request\n")); } dhcp->tries++; msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %"U16_F" msecs\n", msecs)); /* bring the interface down */ //netif_set_down(netif); /* remove IP address from interface */ ///netif_set_ipaddr(netif, IP_ADDR_ANY); ///netif_set_gw(netif, IP_ADDR_ANY); ///netif_set_netmask(netif, IP_ADDR_ANY); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_release()")); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("\n\tIP: ")); ip_addr_debug_print(DHCP_DEBUG | DBG_STATE, &ip); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("\n\tSN: ")); ip_addr_debug_print(DHCP_DEBUG | DBG_STATE, &netmask); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("\n\tGW: ")); ip_addr_debug_print(DHCP_DEBUG | DBG_STATE, &gw); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("\n")); { struct ip_addr ip2, netmask2; IP64_ADDR(&ip2, 0,0,0,0); IP64_MASKADDR(&netmask2, 0,0,0,0); ip_route_list_del(stack, &ip2, &netmask2, &gw, netif, 0); } netif_del_addr(netif, &ip, &netmask); /* TODO: netif_down(netif); */ return result; } /** * Remove the DHCP client from the interface. * * @param netif The network interface to stop DHCP on */ void dhcp_stop(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; LWIP_ASSERT("dhcp_stop: netif != NULL", netif != NULL); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_stop()\n")); /* netif is DHCP configured? */ if (dhcp != NULL) { if (dhcp->pcb != NULL) { udp_remove(dhcp->pcb); dhcp->pcb = NULL; } if (dhcp->p != NULL) { pbuf_free(dhcp->p); dhcp->p = NULL; } /* free unfolded reply */ dhcp_free_reply(dhcp); mem_free((void *)dhcp); netif->flags &= ~NETIF_FLAG_DHCP; netif->dhcp = NULL; dhcp_stoptimers(netif->stack); } } /* * Set the DHCP state of a DHCP client. * * If the state changed, reset the number of tries. * * TODO: we might also want to reset the timeout here? */ static void dhcp_set_state(struct dhcp *dhcp, u8_t new_state) { if (new_state != dhcp->state) { dhcp->state = new_state; dhcp->tries = 0; } } /* * Concatenate an option type and length field to the outgoing * DHCP message. * */ static void dhcp_option(struct dhcp *dhcp, u8_t option_type, u8_t option_len) { LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2 + option_len <= DHCP_OPTIONS_LEN); dhcp->msg_out->options[dhcp->options_out_len++] = option_type; dhcp->msg_out->options[dhcp->options_out_len++] = option_len; } /* * Concatenate a single byte to the outgoing DHCP message. * */ static void dhcp_option_byte(struct dhcp *dhcp, u8_t value) { LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len < DHCP_OPTIONS_LEN", dhcp->options_out_len < DHCP_OPTIONS_LEN); dhcp->msg_out->options[dhcp->options_out_len++] = value; } static void dhcp_option_short(struct dhcp *dhcp, u16_t value) { LWIP_ASSERT("dhcp_option_short: dhcp->options_out_len + 2 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 2 <= DHCP_OPTIONS_LEN); dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0xff00U) >> 8; dhcp->msg_out->options[dhcp->options_out_len++] = value & 0x00ffU; } static void dhcp_option_long(struct dhcp *dhcp, u32_t value) { LWIP_ASSERT("dhcp_option_long: dhcp->options_out_len + 4 <= DHCP_OPTIONS_LEN", dhcp->options_out_len + 4 <= DHCP_OPTIONS_LEN); dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0xff000000UL) >> 24; dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0x00ff0000UL) >> 16; dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0x0000ff00UL) >> 8; dhcp->msg_out->options[dhcp->options_out_len++] = (value & 0x000000ffUL); } /** * Extract the DHCP message and the DHCP options. * * Extract the DHCP message and the DHCP options, each into a contiguous * piece of memory. As a DHCP message is variable sized by its options, * and also allows overriding some fields for options, the easy approach * is to first unfold the options into a conitguous piece of memory, and * use that further on. * */ static err_t dhcp_unfold_reply(struct dhcp *dhcp) { struct pbuf *p = dhcp->p; u8_t *ptr; u16_t i; u16_t j = 0; LWIP_ASSERT("dhcp->p != NULL", dhcp->p != NULL); /* free any left-overs from previous unfolds */ dhcp_free_reply(dhcp); /* options present? */ if (dhcp->p->tot_len > (sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN)) { dhcp->options_in_len = dhcp->p->tot_len - (sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN); dhcp->options_in = mem_malloc(dhcp->options_in_len); if (dhcp->options_in == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->options\n")); return ERR_MEM; } } dhcp->msg_in = mem_malloc(sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN); if (dhcp->msg_in == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->msg_in\n")); mem_free((void *)dhcp->options_in); dhcp->options_in = NULL; return ERR_MEM; } ptr = (u8_t *)dhcp->msg_in; /* proceed through struct dhcp_msg */ for (i = 0; i < sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN; i++) { *ptr++ = ((u8_t *)p->payload)[j++]; /* reached end of pbuf? */ if (j == p->len) { /* proceed to next pbuf in chain */ p = p->next; j = 0; } } LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %"U16_F" bytes into dhcp->msg_in[]\n", i)); if (dhcp->options_in != NULL) { ptr = (u8_t *)dhcp->options_in; /* proceed through options */ for (i = 0; i < dhcp->options_in_len; i++) { *ptr++ = ((u8_t *)p->payload)[j++]; /* reached end of pbuf? */ if (j == p->len) { /* proceed to next pbuf in chain */ p = p->next; j = 0; } } LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %"U16_F" bytes to dhcp->options_in[]\n", i)); } return ERR_OK; } /** * Free the incoming DHCP message including contiguous copy of * its DHCP options. * */ static void dhcp_free_reply(struct dhcp *dhcp) { if (dhcp->msg_in != NULL) { mem_free((void *)dhcp->msg_in); dhcp->msg_in = NULL; } if (dhcp->options_in) { mem_free((void *)dhcp->options_in); dhcp->options_in = NULL; dhcp->options_in_len = 0; } LWIP_DEBUGF(DHCP_DEBUG, ("dhcp_free_reply(): free'd\n")); } /** * If an incoming DHCP message is in response to us, then trigger the state machine */ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip4_addr *addr, u16_t port) { struct netif *netif = (struct netif *)arg; struct dhcp *dhcp = netif->dhcp; struct dhcp_msg *reply_msg = (struct dhcp_msg *)p->payload; u8_t *options_ptr; u8_t msg_type; u8_t i; LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p, (u16_t)(ntohl(addr->addr) >> 24 & 0xff), (u16_t)(ntohl(addr->addr) >> 16 & 0xff), (u16_t)(ntohl(addr->addr) >> 8 & 0xff), (u16_t)(ntohl(addr->addr) & 0xff), port)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len)); /* prevent warnings about unused arguments */ (void)pcb; (void)addr; (void)port; dhcp->p = p; /* TODO: check packet length before reading them */ if (reply_msg->op != DHCP_BOOTREPLY) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %"U16_F"\n", (u16_t)reply_msg->op)); pbuf_free(p); dhcp->p = NULL; return; } /* iterate through hardware address and match against DHCP message */ for (i = 0; i < netif->hwaddr_len; i++) { if (netif->hwaddr[i] != reply_msg->chaddr[i]) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("netif->hwaddr[%"U16_F"]==%02"X16_F" != reply_msg->chaddr[%"U16_F"]==%02"X16_F"\n", (u16_t)i, (u16_t)netif->hwaddr[i], (u16_t)i, (u16_t)reply_msg->chaddr[i])); pbuf_free(p); dhcp->p = NULL; return; } } /* match transaction ID against what we expected */ if (ntohl(reply_msg->xid) != dhcp->xid) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("transaction id mismatch\n")); pbuf_free(p); dhcp->p = NULL; return; } /* option fields could be unfold? */ if (dhcp_unfold_reply(dhcp) != ERR_OK) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("problem unfolding DHCP message - too short on memory?\n")); pbuf_free(p); dhcp->p = NULL; return; } LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE\n")); /* obtain pointer to DHCP message type */ options_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_MESSAGE_TYPE); if (options_ptr == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OPTION_MESSAGE_TYPE option not found\n")); pbuf_free(p); dhcp->p = NULL; return; } /* read DHCP message type */ msg_type = dhcp_get_option_byte(options_ptr + 2); /* message type is DHCP ACK? */ if (msg_type == DHCP_ACK) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_ACK received\n")); /* in requesting state? */ if (dhcp->state == DHCP_REQUESTING) { dhcp_handle_ack(netif); dhcp->request_timeout = 0; #if DHCP_DOES_ARP_CHECK /* check if the acknowledged lease address is already in use */ dhcp_check(netif); #else /* bind interface to the acknowledged lease address */ dhcp_bind(netif); #endif } /* already bound to the given lease address? */ else if ((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING)) { dhcp->request_timeout = 0; dhcp_bind(netif); } } /* received a DHCP_NAK in appropriate state? */ else if ((msg_type == DHCP_NAK) && ((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING ))) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_NAK received\n")); dhcp->request_timeout = 0; dhcp_handle_nak(netif); } /* received a DHCP_OFFER in DHCP_SELECTING state? */ else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_SELECTING)) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OFFER received in DHCP_SELECTING state\n")); dhcp->request_timeout = 0; /* remember offered lease */ dhcp_handle_offer(netif); } pbuf_free(p); dhcp->p = NULL; } /* Work around for original dhcp_recv() */ static void dhcp_recv_wrapper(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port) { struct ip4_addr ip; ip64_addr_set(&ip, addr); dhcp_recv(arg, pcb, p, &ip, port); } static err_t dhcp_create_request(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; u16_t i; LWIP_ASSERT("dhcp_create_request: dhcp->p_out == NULL", dhcp->p_out == NULL); LWIP_ASSERT("dhcp_create_request: dhcp->msg_out == NULL", dhcp->msg_out == NULL); dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM); if (dhcp->p_out == NULL) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_create_request(): could not allocate pbuf\n")); return ERR_MEM; } /* give unique transaction identifier to this request */ dhcp->xid = xid++; dhcp->msg_out = (struct dhcp_msg *)dhcp->p_out->payload; dhcp->msg_out->op = DHCP_BOOTREQUEST; /* TODO: make link layer independent */ dhcp->msg_out->htype = DHCP_HTYPE_ETH; /* TODO: make link layer independent */ dhcp->msg_out->hlen = DHCP_HLEN_ETH; dhcp->msg_out->hops = 0; dhcp->msg_out->xid = htonl(dhcp->xid); dhcp->msg_out->secs = 0; dhcp->msg_out->flags = 0; { ///dhcp->msg_out->ciaddr.addr = netif->ip_addr.addr; struct ip_addr_list *al; struct ip_addr ip6_server; IP64_ADDR(&ip6_server, 0,0,0,0); // FIX: is this correct? if ((al=ip_addr_list_maskfind(netif->addrs, &ip6_server)) == NULL) ip64_addr_set( (struct ip4_addr *)(& dhcp->msg_out->ciaddr.addr), &ip6_server) ; else ip64_addr_set( (struct ip4_addr *)(& dhcp->msg_out->ciaddr.addr), &al->ipaddr ); } dhcp->msg_out->yiaddr.addr = 0; dhcp->msg_out->siaddr.addr = 0; dhcp->msg_out->giaddr.addr = 0; for (i = 0; i < DHCP_CHADDR_LEN; i++) { /* copy netif hardware address, pad with zeroes */ dhcp->msg_out->chaddr[i] = (i < netif->hwaddr_len) ? netif->hwaddr[i] : 0/* pad byte*/; } for (i = 0; i < DHCP_SNAME_LEN; i++) dhcp->msg_out->sname[i] = 0; for (i = 0; i < DHCP_FILE_LEN; i++) dhcp->msg_out->file[i] = 0; dhcp->msg_out->cookie = htonl(0x63825363UL); dhcp->options_out_len = 0; /* fill options field with an incrementing array (for debugging purposes) */ for (i = 0; i < DHCP_OPTIONS_LEN; i++) dhcp->msg_out->options[i] = i; return ERR_OK; } static void dhcp_delete_request(struct netif *netif) { struct dhcp *dhcp = netif->dhcp; LWIP_ASSERT("dhcp_free_msg: dhcp->p_out != NULL", dhcp->p_out != NULL); LWIP_ASSERT("dhcp_free_msg: dhcp->msg_out != NULL", dhcp->msg_out != NULL); pbuf_free(dhcp->p_out); dhcp->p_out = NULL; dhcp->msg_out = NULL; } /** * Add a DHCP message trailer * * Adds the END option to the DHCP message, and if * necessary, up to three padding bytes. */ static void dhcp_option_trailer(struct dhcp *dhcp) { LWIP_ASSERT("dhcp_option_trailer: dhcp->msg_out != NULL\n", dhcp->msg_out != NULL); LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN); dhcp->msg_out->options[dhcp->options_out_len++] = DHCP_OPTION_END; /* packet is too small, or not 4 byte aligned? */ while ((dhcp->options_out_len < DHCP_MIN_OPTIONS_LEN) || (dhcp->options_out_len & 3)) { /* LWIP_DEBUGF(DHCP_DEBUG,("dhcp_option_trailer:dhcp->options_out_len=%"U16_F", DHCP_OPTIONS_LEN=%"U16_F, dhcp->options_out_len, DHCP_OPTIONS_LEN)); */ LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN); /* add a fill/padding byte */ dhcp->msg_out->options[dhcp->options_out_len++] = 0; } } /** * Find the offset of a DHCP option inside the DHCP message. * * @param client DHCP client * @param option_type * * @return a byte offset into the UDP message where the option was found, or * zero if the given option was not found. */ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type) { u8_t overload = DHCP_OVERLOAD_NONE; /* options available? */ if ((dhcp->options_in != NULL) && (dhcp->options_in_len > 0)) { /* start with options field */ u8_t *options = (u8_t *)dhcp->options_in; u16_t offset = 0; /* at least 1 byte to read and no end marker, then at least 3 bytes to read? */ while ((offset < dhcp->options_in_len) && (options[offset] != DHCP_OPTION_END)) { /* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%"U16_F", q->len=%"U16_F, msg_offset, q->len)); */ /* are the sname and/or file field overloaded with options? */ if (options[offset] == DHCP_OPTION_OVERLOAD) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("overloaded message detected\n")); /* skip option type and length */ offset += 2; overload = options[offset++]; } /* requested option found */ else if (options[offset] == option_type) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset %"U16_F" in options\n", offset)); return &options[offset]; } /* skip option */ else { LWIP_DEBUGF(DHCP_DEBUG, ("skipping option %"U16_F" in options\n", options[offset])); /* skip option type */ offset++; /* skip option length, and then length bytes */ offset += 1 + options[offset]; } } /* is this an overloaded message? */ if (overload != DHCP_OVERLOAD_NONE) { u16_t field_len; if (overload == DHCP_OVERLOAD_FILE) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded file field\n")); options = (u8_t *)&dhcp->msg_in->file; field_len = DHCP_FILE_LEN; } else if (overload == DHCP_OVERLOAD_SNAME) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname field\n")); options = (u8_t *)&dhcp->msg_in->sname; field_len = DHCP_SNAME_LEN; } /* TODO: check if else if () is necessary */ else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname and file field\n")); options = (u8_t *)&dhcp->msg_in->sname; field_len = DHCP_FILE_LEN + DHCP_SNAME_LEN; } offset = 0; /* at least 1 byte to read and no end marker */ while ((offset < field_len) && (options[offset] != DHCP_OPTION_END)) { if (options[offset] == option_type) { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset=%"U16_F"\n", offset)); return &options[offset]; } /* skip option */ else { LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("skipping option %"U16_F"\n", options[offset])); /* skip option type */ offset++; offset += 1 + options[offset]; } } } } return NULL; } /** * Return the byte of DHCP option data. * * @param client DHCP client. * @param ptr pointer obtained by dhcp_get_option_ptr(). * * @return byte value at the given address. */ static u8_t dhcp_get_option_byte(u8_t *ptr) { LWIP_DEBUGF(DHCP_DEBUG, ("option byte value=%"U16_F"\n", (u16_t)(*ptr))); return *ptr; } #if 0 /** * Return the 16-bit value of DHCP option data. * * @param client DHCP client. * @param ptr pointer obtained by dhcp_get_option_ptr(). * * @return byte value at the given address. */ static u16_t dhcp_get_option_short(u8_t *ptr) { u16_t value; value = *ptr++ << 8; value |= *ptr; LWIP_DEBUGF(DHCP_DEBUG, ("option short value=%"U16_F"\n", value)); return value; } #endif /** * Return the 32-bit value of DHCP option data. * * @param client DHCP client. * @param ptr pointer obtained by dhcp_get_option_ptr(). * * @return byte value at the given address. */ static u32_t dhcp_get_option_long(u8_t *ptr) { u32_t value; value = (u32_t)(*ptr++) << 24; value |= (u32_t)(*ptr++) << 16; value |= (u32_t)(*ptr++) << 8; value |= (u32_t)(*ptr++); LWIP_DEBUGF(DHCP_DEBUG, ("option long value=%"U32_F"\n", value)); return value; } err_t udp_send_netif(struct udp_pcb *pcb, struct pbuf *p, struct netif *netif) { struct stack *stack = pcb->stack; struct udp_hdr *udphdr; struct ip_addr *src_ip; err_t err; struct pbuf *q; /* q will be sent down the stack */ //struct ip_addr *nexthop; int flags; LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_send\n")); /* if the PCB is not yet bound to a port, bind it here */ if (pcb->local_port == 0) { LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: not yet bound to a port, binding now\n")); err = udp_bind(pcb, &pcb->local_ip, pcb->local_port, NULL); if (err != ERR_OK) { LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: forced port bind failed\n")); return err; } } if (pbuf_header(p, UDP_HLEN)) { q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM); if (q == NULL) { LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: could not allocate header\n")); return ERR_MEM; } pbuf_chain(q, p); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); } else { q = p; LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header in given pbuf %p\n", (void *)p)); } /* { q now represents the packet to be sent } */ udphdr = q->payload; udphdr->src = htons(pcb->local_port); udphdr->dest = htons(pcb->remote_port); udphdr->chksum = 0x0000; #if 0 /* PCB local address is IP_ANY_ADDR? */ if (ip_addr_isany(&pcb->local_ip)) { /* use outgoing network interface IP address as source address */ /*src_ip = &(netif->ip_addr);*/ struct ip_addr_list *el; ///if ((el=ip_addr_list_maskfind(netif->addrs,nexthop)) == NULL) /// return err; ///src_ip = &(el->ipaddr); /* Added by Diego Billi */ /* Get source address */ if (ip_addr_is_v4comp(&pcb->remote_ip)) { if ((el=ip_addr_list_maskfind(netif->addrs, &pcb->remote_ip)) != NULL) src_ip = &(el->ipaddr); else src_ip = &pcb->local_ip; } else { if ((el=ip_route_ipv6_select_source(netif, &pcb->remote_ip)) != NULL) src_ip = &(el->ipaddr); else src_ip = &pcb->local_ip; } } else { /* use UDP PCB local IP address as source address */ src_ip = &(pcb->local_ip); } #endif src_ip = &(pcb->local_ip); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len)); if (pcb->flags & UDP_FLAGS_UDPLITE) { LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len)); udphdr->len = htons(pcb->chksum_len); udphdr->chksum = inet6_chksum_pseudo(q, src_ip, &(pcb->remote_ip), IP_PROTO_UDP, pcb->chksum_len); if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff; LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDPLITE,)\n")); err = ip_output_if (stack, q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDPLITE, netif, &pcb->remote_ip, flags); } else { LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len)); udphdr->len = htons(q->tot_len); if ((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) { udphdr->chksum = inet6_chksum_pseudo(q, src_ip, &pcb->remote_ip, IP_PROTO_UDP, q->tot_len); if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff; } LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); /* output to IP */ err = ip_output_if(stack, q, src_ip, &pcb->remote_ip, pcb->ttl, pcb->tos, IP_PROTO_UDP, netif, &pcb->remote_ip, flags); } /* did we chain a seperate header pbuf earlier? */ if (q != p) { /* free the header pbuf */ pbuf_free(q); q = NULL; /* { p is still referenced by the caller, and will live on } */ } UDP_STATS_INC(udp.xmit); return err; } err_t udp_sendto_netif(struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port, struct netif *netif) { err_t err; /* temporary space for current PCB remote address */ struct ip_addr pcb_remote_ip; u16_t pcb_remote_port; /* remember current remote peer address of PCB */ memcpy(&(pcb_remote_ip.addr), &(pcb->remote_ip.addr), sizeof(struct ip_addr)); pcb_remote_port = pcb->remote_port; /* copy packet destination address to PCB remote peer address */ memcpy(&(pcb->remote_ip.addr), &(dst_ip->addr), sizeof(struct ip_addr)); pcb->remote_port = dst_port; /* send to the packet destination address */ err = udp_send_netif(pcb, p, netif); /* restore PCB remote peer address */ memcpy(&(pcb->remote_ip.addr), &(pcb_remote_ip.addr), sizeof(struct ip_addr)); pcb->remote_port = pcb_remote_port; return err; } #endif /* LWIP_DHCP */ lwipv6-1.5a/lwip-v6/src/core/netif.c0000644000175000017500000007566011671615010016333 0ustar renzorenzo/** * @file * * lwIP network interface abstraction */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/ip_addr.h" #include "lwip/api.h" #include "lwip/sockets.h" #if LWIP_NL #include "lwip/netlink.h" #endif #include "lwip/if.h" #include "lwip/ip_route.h" #include "lwip/netif.h" #include "lwip/tcp.h" #include "lwip/stack.h" #include "lwip/memp.h" #ifndef NETIF_DEBUG #define NETIF_DEBUG DBG_OFF #endif /* increase the number of fd available for interfaces of NETIF_MAX_STEP units when there are less than NETIF_MIN_FREE available */ #define NETIF_MAX_STEP 8 #define NETIF_MIN_FREE 4 //#define NETIF_THREAD_DEBUG #ifdef NETIF_THREAD_DEBUG #define PRINTTHREAD(X) do {\ printf("thread %s: %p\n",(X),pthread_self());\ } while(0); #else #define PRINTTHREAD(X) #endif #define NETIF_UPDATE_FDLIST_WAKE 0 #define NETIF_UPDATE_FDLIST_ADDFD 1 struct netif_update_fdlist_data { int op; void *data; }; struct netif_fddata *netif_addfd(struct netif *netif, int fd, void (*fun)(struct netif_fddata *fddata, short revents), void *opaque, int flags, short events) { struct netif_fddata *new= memp_malloc(MEMP_NETIF_FDDATA); if (new) { struct netif_update_fdlist_data req = { .op = NETIF_UPDATE_FDLIST_ADDFD, .data = new }; new->fd = fd; new->netif = netif; new->fun = fun; new->opaque = opaque; new->flags = flags; new->events = events; new->refcnt = 1; int rv=write(netif->stack->netif_pipe[1], &req, sizeof(req)); //fprintf(stderr,"netif_addfd request! %d\n",rv); } return new; } void netif_thread_wake(struct stack *stack) { struct netif_update_fdlist_data req = { .op = NETIF_UPDATE_FDLIST_WAKE, .data = NULL }; write(stack->netif_pipe[1], &req, sizeof(req)); } static void netif_thread(void *arg) { struct stack *stack=arg; unsigned long time=time_now(); struct pollfd *pfd=mem_malloc(NETIF_MAX_STEP * sizeof(struct pollfd)); struct netif_fddata **pfddata=mem_malloc(NETIF_MAX_STEP * sizeof(struct netif_fddata *)); int pfdmax=NETIF_MAX_STEP; int pfdlen=1; int read_pipe_offset=0; struct netif_update_fdlist_data read_pipe_item; int i; if (pfd == NULL || pfddata == NULL) { fprintf(stderr,"netif_thread memory full: failed\n"); goto netif_thread_terminate; } pfd[0].fd = stack->netif_pipe[0]; pfd[0].events = POLLIN; pfddata[0] = NULL; PRINTTHREAD("NETIF_THREAD"); while(1) { /* stack active! This loop terminates when the pipe closes */ int ret; unsigned long newtime; /* eliminate closed files and copy events */ for (i=pfdlen-1; i>0; i--) { if (pfddata[i] == NULL) { //fprintf(stderr,"PFD #%d eliminated\n",i); if (i < pfdlen-1) { pfd[i] = pfd[pfdlen-1]; pfddata[i] = pfddata[pfdlen-1]; } pfdlen--; } else { pfd[i].events = pfddata[i]->events; } } #if 0 for (i=0; inetif_pipe[0], (((u8_t *)&read_pipe_item)+read_pipe_offset), remaining); if (n == 0) break; /* pipe closed means thread termination <--------- */ if (n != remaining) { read_pipe_offset += n; continue; } //fprintf(stderr, "netif request isi %d\n", read_pipe_item.op); switch (read_pipe_item.op) { case NETIF_UPDATE_FDLIST_ADDFD: { if (pfdlen == pfdmax) { int newmax = pfdmax + NETIF_MAX_STEP; struct pollfd *newpfd = mem_realloc(pfd, newmax * sizeof(struct pollfd)); struct netif_fddata **newpfddata=mem_realloc(pfddata, newmax * sizeof(struct netif_fddata *)); if (newpfd) pfd = newpfd; if (newpfddata) pfddata = newpfddata; if (newpfd && newpfddata) pfdmax = newmax; } if (pfdlen < pfdmax) { struct netif_fddata *data = pfddata[pfdlen] = read_pipe_item.data; pfd[pfdlen].fd = data->fd; pfd[pfdlen].events = data->events; pfdlen++; } } } } continue; } for (i=1; ret>0 && ifun, pfd[i].fd, pfd[i].revents); pfddata[i]->fun(pfddata[i], pfd[i].revents); } } } newtime=time_now(); if (newtime > time) { time=newtime; for (i=1; iflags & NETIF_ARGS_1SEC_POLL) pfddata[i]->fun(pfddata[i], 0); } } netif_thread_terminate: for (i=1; inetif_cleanup_mutex); } void netif_init(struct stack *stack) { /* FIX: move ip_addr_list_init() to ip6.c? */ ip_addr_list_init(stack); //ip_route_list_init(stack); stack->netif_list = NULL; /* add some fds for interfaces */ pipe(stack->netif_pipe); stack->netif_cleanup_mutex = sys_sem_new(0); sys_thread_new(netif_thread, stack, DEFAULT_THREAD_PRIO); } void netif_shutdown(struct stack *stack) { netif_cleanup(stack); LWIP_DEBUGF( NETIF_DEBUG, ("netif_shutdown!\n") ); close(stack->netif_pipe[1]); sys_sem_wait_timeout(stack->netif_cleanup_mutex, 0); sys_sem_free(stack->netif_cleanup_mutex); close(stack->netif_pipe[0]); LWIP_DEBUGF( NETIF_DEBUG, ("netif_shutdown: done!\n") ); } /** * Add a network interface to the list of lwIP netifs. * * @param netif a pre-allocated netif structure * @param ipaddr IP address for the new netif * @param netmask network mask for the new netif * @param state opaque data passed to the new netif * @param init callback function that initializes the interface * @param input callback function that is called to pass * ingress packets up in the protocol layer stack. * * @return netif, or NULL if failed. */ struct netif * netif_add( struct stack *stack, struct netif *netif, void *state, err_t (* init)(struct netif *netif), err_t (* input)(struct pbuf *p, struct netif *netif), void (* change)(struct netif *netif, u32_t type)) { struct netif *nip; struct netif *lastnip; for (nip=stack->netif_list; nip!=NULL; lastnip=nip,nip=nip->next) ; /* Link this new interface with the stack */ netif->stack = stack; #if LWIP_DHCP /* netif not under DHCP control by default */ netif->dhcp = NULL; #endif /* remember netif specific state information data */ netif->state = state; netif->num = 0; netif->addrs = NULL; netif->input = input; netif->netifctl = NULL; netif->change = change; netif->id = ++stack->uniqueid; netif->flags |= (NETIF_FLAG_LINK_UP | IFF_RUNNING); /* printf("netif_add %x netif->input %x\n",netif,netif->input); */ /* call user specified initialization function for netif */ if (init(netif) != ERR_OK) { ip_addr_list_freelist(stack, netif->addrs); return NULL; } #if IPv6_AUTO_CONFIGURATION if (netif->flags & NETIF_FLAG_AUTOCONF) ip_autoconf_netif_init(netif); else netif->autoconf = NULL; #endif #if IPv6_ROUTER_ADVERTISEMENT if (netif->flags & NETIF_FLAG_RADV) ip_radv_netif_init(netif); else netif->radv = NULL; #endif if (stack->netif_list == NULL) stack->netif_list = netif; else lastnip->next = netif; netif->next=NULL; LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c%d (stack %d) \n", netif->name[0], netif->name[1], netif->num, stack)); return netif; } u8_t netif_next_num(struct netif *netif,int netif_model) { return netif->stack->netif_num[netif_model]++; } int netif_add_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask) { struct stack *stack = netif->stack; /* XXX check if this address is compatible */ struct ip_addr_list *add; LWIP_ASSERT("netif_add_addr stack mismatch", stack == netif->stack); if (ip_addr_list_find(netif->addrs, ipaddr, netmask) != NULL) { LWIP_DEBUGF( NETIF_DEBUG, ("netif_add_addr: Address already exists\n") ); return -EADDRINUSE; } else { add=ip_addr_list_alloc(stack); if (add==NULL) { LWIP_DEBUGF( NETIF_DEBUG, ("netif_add_addr: NO more available addresses\n") ); return -ENOMEM; } else { #if IPv6_AUTO_CONFIGURATION /* FIX: start Duplicate Address Detection on all IPv6 Addresss: - use netif->addrs_tentative - Implement a tcpip_start_dad() to set a timeout in the main thread */ #endif ip_addr_set(&(add->ipaddr),ipaddr); ip_addr_set(&(add->netmask),netmask); #if LWIP_NL add->flags=IFA_F_PERMANENT; #endif add->netif=netif; ip_addr_list_add(&(netif->addrs),add); ip_route_list_add(stack, ipaddr, netmask, NULL, netif, 0); return 0; } } } static void ip_addr_close(struct stack *stack, struct ip_addr *ipaddr) { #if LWIP_TCP struct tcp_pcb *pcb; /* struct tcp_pcb_listen *lpcb; */ pcb = stack->tcp_active_pcbs; while (pcb != NULL) { /* PCB bound to current local interface address? */ if (ip_addr_cmp(&(pcb->local_ip), ipaddr)) { /* this connection must be aborted */ struct tcp_pcb *next = pcb->next; LWIP_DEBUGF(NETIF_DEBUG | 1, ("netif_addr_close: aborting TCP pcb %p\n", (void *)pcb)); tcp_abort(pcb); pcb = next; } else { pcb = pcb->next; } } #if 0 /* XXX TO BE managed */ for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = lpcb->next) { /* PCB bound to current local interface address? */ if (ip_addr_cmp(&(lpcb->local_ip), &(netif->ip_addr))) { /* The PCB is listening to the old ipaddr and * is set to listen to the new one instead */ ip_addr_set(&(lpcb->local_ip), ipaddr); } } #endif #endif } int netif_del_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask) { struct stack *stack = netif->stack; struct ip_addr_list *el; if ((el=ip_addr_list_find(netif->addrs, ipaddr, netmask)) == NULL) { LWIP_DEBUGF( NETIF_DEBUG, ("netif_del_addr: Address does not exist\n") ); return -EADDRNOTAVAIL; } else { #if IPv6_AUTO_CONFIGURATION /* FIX: what about if i remove link-local address needed for Autoconfiguration? */ #endif /*printf("netif_del_addr %p %x %x\n",netif, (ipaddr)?ipaddr->addr[3]:0, (netmask)?netmask->addr[3]:0);*/ ip_addr_close(stack, ipaddr); ip_route_list_del(stack, ipaddr,netmask,NULL,netif,0); ip_addr_list_del(&(netif->addrs),el); return 0; } } void netif_remove(struct netif * netif) { struct stack *stack; if ( netif == NULL ) return; stack = netif->stack; /* is it the first netif? */ if (stack->netif_list == netif) { stack->netif_list = netif->next; } else { /* look for netif further down the list */ struct netif * tmpNetif; for (tmpNetif = stack->netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) { if (tmpNetif->next == netif) { struct ip_addr_list *el; tmpNetif->next = netif->next; while (netif->addrs != NULL) { el = ip_addr_list_first(netif->addrs); ip_addr_close(stack, &(el->ipaddr)); ip_addr_list_del(&(netif->addrs),el); } break; } } if (tmpNetif == NULL) return; /* we didn't find any netif today */ } ip_route_list_delnetif(stack, netif); if(netif->netifctl) netif->netifctl(netif,NETIFCTL_CLEANUP,NULL); LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); } struct netif * netif_find(struct stack *stack, char *name) { struct netif *netif; u8_t num; if (name == NULL) { return NULL; } if (name[2] >= '0' && name [2] <= '9') num = name[2] - '0'; else num = 0; for(netif = stack->netif_list; netif != NULL; netif = netif->next) { if (num == netif->num && name[0] == netif->name[0] && name[1] == netif->name[1]) { LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1])); return netif; } } LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1])); return NULL; } struct netif * netif_find_id(struct stack *stack, int id) { struct netif *nip; for (nip=stack->netif_list; nip!=NULL && nip->id != id; nip=nip->next) ; return nip; } struct netif * netif_find_direct_destination(struct stack *stack, struct ip_addr *addr) { struct netif *nip; for (nip=stack->netif_list; nip!=NULL && ip_addr_list_maskfind(nip->addrs,addr) == NULL; nip=nip->next) ; return nip; } void netif_cleanup(struct stack *stack) { struct netif *nip; for (nip=stack->netif_list; nip!=NULL; nip=nip->next) { // shutdown interface if ((nip->flags & IFF_UP) && (nip->change)) nip->change(nip, NETIF_CHANGE_DOWN); if (nip->netifctl) nip->netifctl(nip,NETIFCTL_CLEANUP,NULL); } } static int netif_ifconf(struct stack *stack, struct ifconf *ifc) { struct netif *nip; register int i; register int maxlen=ifc->ifc_len; //printf("%s\n", __func__); #define ifr_v (ifc->ifc_req) /*printf("-netif_ifconf %p %p %d\n",ifc,ifc->ifc_req,ifc->ifc_len);*/ ifc->ifc_len=0; memset(ifr_v, 0, maxlen); /* jjsa clear the memory area */ for (nip=stack->netif_list, i=0; nip!=NULL && ifc->ifc_len < maxlen; nip=nip->next, i++) { ifc->ifc_len += sizeof(struct ifreq); if (ifc->ifc_len > maxlen) ifc->ifc_len =maxlen; else { ifr_v[i].ifr_name[0]=nip->name[0]; ifr_v[i].ifr_name[1]=nip->name[1]; ifr_v[i].ifr_name[2]=(nip->num%10)+'0'; ifr_v[i].ifr_name[3]= 0; ifr_v[i].ifr_name[4]= 0; ifr_v[i].ifr_name[5]= 0; { /* jjsa set zhe IPv4 address */ struct ip_addr_list *list, *listStart; list = listStart = nip->addrs; while ( list ) { if ( list->ipaddr.addr[2] == IP64_PREFIX ) { /* put the address idx 3 into our ifr struct */ ((struct sockaddr_in*)(&ifr_v[i].ifr_addr))->sin_family= AF_INET; memcpy((char*)&((struct sockaddr_in*)(&ifr_v[i].ifr_addr))->sin_addr, (char*)&list->ipaddr.addr[3], 4); break; } list = list->next; if ( list == listStart ) list = NULL; } } } } /*{int i; printf("%p len %d %d\n",ifc->ifc_req,ifc->ifc_len,sizeof(struct ifreq)); for (i=0;iifc_len;i++) { int c=*(((unsigned char *)(ifr_v))+i); printf("%02x%c ",c,(c>=' '&&c<='~')?c:'.'); if (i%16 == 15) printf("\n"); } if (i%16 != 15) printf("\n"); }*/ return ERR_OK; #undef ifr_v } int netif_ioctl(struct stack *stack, int cmd,struct ifreq *ifr #if LWIP_CAPABILITIES ,int cap #endif ) { u16_t oldflags; int retval; struct netif *nip; register int i; /*printf("netif_ioctl %x %p\n",cmd,ifr);*/ if (ifr == NULL) retval=EFAULT; else { #if LWIP_CAPABILITIES switch (cmd) { case SIOCSIFLINK: case SIOCSIFFLAGS: case SIOCSIFADDR: case SIOCSIFDSTADDR: case SIOCSIFBRDADDR: case SIOCSIFNETMASK: case SIOCSIFMETRIC: case SIOCSIFMEM: case SIOCSIFMTU: case SIOCSIFNAME: case SIOCSIFHWADDR: case SIOCSIFENCAP: case SIOCSIFSLAVE: case SIOCADDMULTI: case SIOCDELMULTI: case SIOCSIFPFLAGS: case SIOCSIFHWBROADCAST: case SIOCSIFBR: case SIOCSIFTXQLEN: if ((cap&LWIP_CAP_NET_ADMIN) == 0) return EPERM; } #endif if (cmd == SIOCGIFCONF) { retval=netif_ifconf(stack, (struct ifconf *)ifr); } else if (cmd == SIOCGIFNAME) { if ((nip = netif_find_id(stack, ifr->ifr_ifindex)) == NULL) retval=EINVAL; else { ifr->ifr_name[0]=nip->name[0]; ifr->ifr_name[1]=nip->name[1]; ifr->ifr_name[2]=(nip->num%10)+'0'; ifr->ifr_name[3]= 0; ifr->ifr_name[4]= 0; ifr->ifr_name[5]= 0; retval=ERR_OK; } } else { #define ifrname ifr->ifr_name ifrname[4]=ifrname[5]=0; if (ifrname[3] != 0 || (nip = netif_find(stack, ifrname)) == NULL) { retval=EINVAL; } else { #undef ifrname switch (cmd) { case SIOCSIFBRDADDR: LWIP_DEBUGF( NETIF_DEBUG, ("SIOCSIFBRDADDR\n")); retval = ENOSYS; break; case SIOCSIFNETMASK: LWIP_DEBUGF( NETIF_DEBUG, ("SIOCSIFNETMASK\n")); retval = ENOSYS; break; case SIOCSIFADDR: LWIP_DEBUGF( NETIF_DEBUG, ("SIOCSIFADDR\n")); retval = ENOSYS; break; case SIOCGIFADDR: { struct sockaddr_in *addr = (struct sockaddr_in *) &ifr->ifr_addr; struct ip_addr_list *al=nip->addrs; addr->sin_addr.s_addr=0; if (al) { do { if (al->ipaddr.addr[2] == IP64_PREFIX) { addr->sin_addr.s_addr=al->ipaddr.addr[3]; break; } al=al->next; } while (al != nip->addrs); } LWIP_DEBUGF( NETIF_DEBUG, ("SIOCGIFADDR\n")); } retval = ERR_OK; break; case SIOCGIFFLAGS: LWIP_DEBUGF( NETIF_DEBUG, ("SIOCGIFFLAGS %x\n",nip->flags)); ifr->ifr_flags= nip->flags & ~NETIF_IFF_INCOMPATIBLE_MASK; retval=ERR_OK; break; case SIOCSIFFLAGS: LWIP_DEBUGF( NETIF_DEBUG, ("SIOCSIFFLAGS %x %x\n",ifr->ifr_flags, nip->flags)); oldflags = nip->flags; /* If interface is going down */ if ( (oldflags & IFF_UP) && !(ifr->ifr_flags & IFF_UP) ) if (nip->change) nip->change(nip, NETIF_CHANGE_DOWN); nip->flags = (nip->flags & NETIF_IFF_INCOMPATIBLE_MASK) | (ifr->ifr_flags & ~NETIF_IFF_INCOMPATIBLE_MASK); /* If interface is now up */ if ( !(oldflags & IFF_UP) && (ifr->ifr_flags & IFF_UP) ) if (nip->change) nip->change(nip, NETIF_CHANGE_UP); retval=ERR_OK; break; case SIOCGIFMTU: ifr->ifr_mtu=nip->mtu; retval=ERR_OK; break; case SIOCSIFMTU: nip->mtu=ifr->ifr_mtu; if (nip->change) nip->change(nip, NETIF_CHANGE_MTU); retval=ERR_OK; break; case SIOCGIFHWADDR: ifr->ifr_hwaddr.sa_family=nip->type; if (nip->hwaddr_len > IFHWADDRLEN) nip->hwaddr_len = IFHWADDRLEN; for (i=0;ihwaddr_len;i++) ifr->ifr_hwaddr.sa_data[i]=nip->hwaddr[i]; retval=ERR_OK; break; case SIOCSIFHWADDR: ifr->ifr_hwaddr.sa_family==nip->type; nip->hwaddr_len = IFHWADDRLEN; for (i=0;ihwaddr_len;i++) nip->hwaddr[i]=ifr->ifr_hwaddr.sa_data[i]; retval=ERR_OK; break; case SIOCGIFINDEX: ifr->ifr_ifindex=nip->id; retval=ERR_OK; break; default: retval=ENOSYS; } } } } return retval; } /* * These function should be called only inside the Stack because * netif->change() handler is not called. */ u8_t netif_is_up(struct netif *netif) { return (netif->flags & NETIF_FLAG_UP)?1:0; } void netif_set_up(struct netif *netif, int flags) { netif->flags |= (NETIF_FLAG_UP | (flags & NETIF_IFUP_FLAGS)); if (netif->change) netif->change(netif, NETIF_CHANGE_UP); } void netif_set_up_low(struct netif *netif) { netif->flags |= NETIF_FLAG_UP; } void netif_set_down(struct netif *netif) { if (netif->change) netif->change(netif, NETIF_CHANGE_DOWN); netif->flags &= ~NETIF_FLAG_UP; } void netif_set_down_low(struct netif *netif) { netif->flags &= ~NETIF_FLAG_UP; } #if LWIP_NL static void netif_out_link_address (int index,struct netif *nip,void * buf,int *offset) { struct rtattr x; int fill=0; if (nip->hwaddr_len>0) { x.rta_len=sizeof(struct rtattr)+nip->hwaddr_len; x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); netlink_addanswer(buf,offset,nip->hwaddr,nip->hwaddr_len); if (nip->hwaddr_len % RTA_ALIGNTO > 0) netlink_addanswer(buf,offset,&fill,RTA_ALIGNTO - (nip->hwaddr_len % RTA_ALIGNTO)); } } static void netif_out_link_broadcast (int index,struct netif *nip,void * buf,int *offset) { struct rtattr x; int fill=0; if (nip->hwaddr_len>0) { x.rta_len=sizeof(struct rtattr)+nip->hwaddr_len; x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); for (fill=0; fillhwaddr_len; fill++) netlink_addanswer(buf,offset,"\377",1); fill=0; if (nip->hwaddr_len % RTA_ALIGNTO > 0) netlink_addanswer(buf,offset,&fill,RTA_ALIGNTO - (nip->hwaddr_len % RTA_ALIGNTO)); } } static void netif_out_link_ifname (int index,struct netif *nip,void * buf,int *offset) { struct rtattr x; char name[4]; x.rta_len=sizeof(struct rtattr)+3; x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); name[0]=nip->name[0]; name[1]=nip->name[1]; name[2]=(nip->num)%10+'0'; name[3]=0; netlink_addanswer(buf,offset,name,sizeof(name)); } static void netif_out_link_mtu (int index,struct netif *nip,void * buf,int *offset) { struct rtattr x; /*printf("netif_out_link_mtu\n");*/ unsigned int mtu=nip->mtu; x.rta_len=sizeof(struct rtattr)+sizeof(int); x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); netlink_addanswer(buf,offset,&mtu,sizeof(int)); } static void netif_out_link_link (int index,struct netif *nip,void * buf,int *offset) { } typedef void (*opt_out_link)(int index,struct netif *nip,void * buf,int *offset); static opt_out_link netif_link_out_table[]={ NULL, netif_out_link_address, netif_out_link_broadcast, netif_out_link_ifname, netif_out_link_mtu, netif_out_link_link, NULL}; #define NETIF_LINK_OUT_SIZE (sizeof(netif_link_out_table)/sizeof(opt_out_link)) static void netif_netlink_link_out(struct nlmsghdr *msg,struct netif *nip,void * buf,int *offset) { register int i; int myoffset=*offset; (*offset) += sizeof (struct nlmsghdr); struct ifinfomsg ifi; ifi.ifi_family=AF_INET6; ifi.__ifi_pad=0; ifi.ifi_type=nip->type; ifi.ifi_index=nip->id; ifi.ifi_flags=nip->flags & ~NETIF_IFF_INCOMPATIBLE_MASK; ifi.ifi_change=0xffffffff; netlink_addanswer(buf,offset,&ifi,sizeof (struct ifinfomsg)); for (i=0; i< NETIF_LINK_OUT_SIZE;i++) if (netif_link_out_table[i] != NULL) netif_link_out_table[i](i,nip,buf,offset); msg->nlmsg_flags = NLM_F_MULTI; msg->nlmsg_type = RTM_NEWLINK; msg->nlmsg_len = *offset - myoffset; netlink_addanswer(buf,&myoffset,msg,sizeof (struct nlmsghdr)); } void netif_netlink_adddellink(struct stack *stack, struct nlmsghdr *msg,void * buf,int *offset) { struct ifinfomsg *ifi=(struct ifinfomsg *)(msg+1); struct netif *nip; int lenrestore=msg->nlmsg_len; int flag=msg->nlmsg_flags; /*printf("netif_netlink_adddellink %d\n",msg->nlmsg_type);*/ netlink_ackerror(msg,-EOPNOTSUPP,buf,offset); } void netif_netlink_getlink(struct stack *stack, struct nlmsghdr *msg,void * buf,int *offset) { struct ifinfomsg *ifi=(struct ifinfomsg *)(msg+1); struct netif *nip; int lenrestore=msg->nlmsg_len; int flag=msg->nlmsg_flags; /*printf("netif_netlink_getlink\n");*/ if (msg->nlmsg_len < sizeof (struct nlmsghdr)) { fprintf(stderr,"Netlink getlink error\n"); netlink_ackerror(msg,-ENXIO,buf,offset); return; } for (nip=stack->netif_list; nip!=NULL; nip=nip->next) { if ((flag & NLM_F_DUMP) == NLM_F_DUMP || ifi->ifi_index == nip->id) netif_netlink_link_out(msg,nip,buf,offset); } msg->nlmsg_type = NLMSG_DONE; msg->nlmsg_flags = 0; msg->nlmsg_len = sizeof (struct nlmsghdr); netlink_addanswer(buf,offset,msg,sizeof (struct nlmsghdr)); msg->nlmsg_len=lenrestore; } static void netif_out_addr_address(int index,struct netif *nip,struct ip_addr_list *ipl,void * buf,int *offset) { struct rtattr x; int isv4=ip_addr_is_v4comp(&(ipl->ipaddr)); x.rta_len=sizeof(struct rtattr)+((isv4)?sizeof(u32_t):sizeof(struct ip_addr)); x.rta_type=index; netlink_addanswer(buf,offset,&x,sizeof (struct rtattr)); if (isv4) netlink_addanswer(buf,offset,&(ipl->ipaddr.addr[3]),sizeof(u32_t)); else netlink_addanswer(buf,offset,&(ipl->ipaddr),sizeof(struct ip_addr)); } typedef void (*opt_out_addr)(int index,struct netif *nip,struct ip_addr_list *ipl,void * buf,int *offset); static opt_out_addr netif_addr_out_table[]={ NULL, netif_out_addr_address, NULL, NULL, NULL, NULL, NULL}; #define NETIF_ADDR_OUT_SIZE (sizeof(netif_addr_out_table)/sizeof(opt_out_addr)) static void netif_netlink_out_addr(struct nlmsghdr *msg,struct netif *nip,struct ip_addr_list *ipl,void * buf,int *offset) { register int i; int myoffset=*offset; (*offset) += sizeof (struct nlmsghdr); struct ifaddrmsg ifa; /*printf("netif_netlink_out_addr\n");*/ ifa.ifa_family= ip_addr_is_v4comp(&(ipl->ipaddr))?PF_INET:PF_INET6; ifa.ifa_prefixlen=mask2prefix(&(ipl->netmask))-(ip_addr_is_v4comp(&(ipl->ipaddr))?(32*3):0); ifa.ifa_index=nip->id; ifa.ifa_flags=ipl->flags; ifa.ifa_scope=0; if ((ntohl(ipl->ipaddr.addr[0]) & 0xff000000) == 0xfe000000) { if ((ntohl(ipl->ipaddr.addr[0]) & 0xC00000) == 0x800000) ifa.ifa_scope=RT_SCOPE_LINK; else if ((ntohl(ipl->ipaddr.addr[0]) & 0xC00000)== 0x08000000) ifa.ifa_scope=RT_SCOPE_SITE; } else if ((ntohl(ipl->ipaddr.addr[0]) & 0xff000000) == 0) { if (ip_addr_is_v4comp(&(ipl->ipaddr))) { if (ntohl(ipl->ipaddr.addr[3]) >> 24 == 0x7f) ifa.ifa_scope=RT_SCOPE_HOST; } else ifa.ifa_scope=RT_SCOPE_HOST; } netlink_addanswer(buf,offset,&ifa,sizeof (struct ifaddrmsg)); for (i=0; i< NETIF_LINK_OUT_SIZE;i++) if (netif_addr_out_table[i] != NULL) netif_addr_out_table[i](i,nip,ipl,buf,offset); msg->nlmsg_flags = NLM_F_MULTI; msg->nlmsg_type = RTM_NEWADDR; msg->nlmsg_len = *offset - myoffset; netlink_addanswer(buf,&myoffset,msg,sizeof (struct nlmsghdr)); } void netif_netlink_getaddr(struct stack *stack, struct nlmsghdr *msg,void * buf,int *offset) { struct ifaddrmsg *ifa=(struct ifaddrmsg *)(msg+1); /*char *opt=(char *)(ifa+1);*/ struct netif *nip; int lenrestore=msg->nlmsg_len; int flag=msg->nlmsg_flags; /*printf("netif_netlink_getaddr\n");*/ if (msg->nlmsg_len < sizeof (struct nlmsghdr)) { fprintf(stderr,"Netlink getlink error\n"); netlink_ackerror(msg,-1,buf,offset); return; } for (nip=stack->netif_list; nip!=NULL; nip=nip->next) { if ((flag & NLM_F_DUMP) == NLM_F_DUMP || ifa->ifa_index == nip->id) { struct ip_addr_list *ial=nip->addrs; if (ial != NULL) { ial=nip->addrs->next; do { if (ifa->ifa_family== AF_UNSPEC || (ifa->ifa_family== AF_INET && ip_addr_is_v4comp(&ial->ipaddr) )|| (ifa->ifa_family== AF_INET6 && !ip_addr_is_v4comp(&ial->ipaddr))) netif_netlink_out_addr(msg,nip,ial,buf,offset); ial=ial->next; } while (ial != nip->addrs->next); } } } msg->nlmsg_type = NLMSG_DONE; msg->nlmsg_flags = 0; msg->nlmsg_len = sizeof (struct nlmsghdr); netlink_addanswer(buf,offset,msg,sizeof (struct nlmsghdr)); msg->nlmsg_len=lenrestore; } void netif_netlink_adddeladdr(struct stack *stack, struct nlmsghdr *msg,void * buf,int *offset) { struct ifaddrmsg *ifa=(struct ifaddrmsg *)(msg+1); struct rtattr *opt=(struct rtattr *)(ifa+1); struct netif *nip; int size=msg->nlmsg_len - sizeof(struct ifaddrmsg) - sizeof(struct nlmsghdr); struct ip_addr ipaddr,netmask; int err; /*printf("netif_netlink_adddeladdr %d\n",ifa->ifa_prefixlen);*/ if (msg->nlmsg_len < sizeof (struct nlmsghdr)) { fprintf(stderr,"Netlink add/deladdr error\n"); netlink_ackerror(msg,-ENXIO,buf,offset); return; } nip=netif_find_id(stack, ifa->ifa_index); if (nip == NULL) { fprintf(stderr,"Netlink add/deladdr id error\n"); netlink_ackerror(msg,-ENODEV,buf,offset); return; } memcpy(&ipaddr,IP_ADDR_ANY,sizeof(struct ip_addr)); prefix2mask((int)(ifa->ifa_prefixlen)+(ifa->ifa_family == PF_INET?(32*3):0),&netmask); while (RTA_OK(opt,size)) { switch(opt->rta_type) { case IFA_ADDRESS: case IFA_LOCAL: if (ifa->ifa_family == PF_INET && opt->rta_len == 8) { ipaddr.addr[2]=IP64_PREFIX; ipaddr.addr[3]=(*((int *)(opt+1))); } else if (ifa->ifa_family == PF_INET6 && opt->rta_len == 20) { register int i; for (i=0;i<4;i++) ipaddr.addr[i]=(*(((int *)(opt+1))+i)); } else { netlink_ackerror(msg,-EINVAL,buf,offset); return; } break; default: printf("Netlink: Unsupported IFA opt %d\n",opt->rta_type); break; } opt=RTA_NEXT(opt,size); } if (msg->nlmsg_type == RTM_NEWADDR) { err=netif_add_addr(nip,&ipaddr,&netmask); } else { err=netif_del_addr(nip,&ipaddr,NULL); } netlink_ackerror(msg,err,buf,offset); } #endif #if 0 case SIOCSIFADDR: { struct sockaddr_in *addr = (struct sockaddr_in *) &ifr->ifr_addr; if (addr->sin_family == AF_INET) { struct ip_addr ip; printf("IPv4\n"); IP64_CONV( &ip, (struct ip4_addr *) &addr->sin_addr); ip_addr_debug_print(NETIF_DEBUG, &ip); } else if (addr->sin_family == AF_INET) { printf("IPv6\n"); } } #endif lwipv6-1.5a/lwip-v6/src/core/pbuf.c0000644000175000017500000010400011671615010016137 0ustar renzorenzo/** * @file * Packet buffer management * * Packets are built from the pbuf data structure. It supports dynamic * memory allocation for packet contents or can reference externally * managed packet contents both in RAM and ROM. Quick allocation for * incoming packets is provided through pools with fixed sized pbufs. * * A packet may span over multiple pbufs, chained as a singly linked * list. This is called a "pbuf chain". * * Multiple packets may be queued, also using this singly linked list. * This is called a "packet queue". * * So, a packet queue consists of one or more pbuf chains, each of * which consist of one or more pbufs. Currently, queues are only * supported in a limited section of lwIP, this is the etharp queueing * code. Outside of this section no packet queues are supported yet. * * The differences between a pbuf chain and a packet queue are very * precise but subtle. * * The last pbuf of a packet has a ->tot_len field that equals the * ->len field. It can be found by traversing the list. If the last * pbuf of a packet has a ->next field other than NULL, more packets * are on the queue. * * Therefore, looping through a pbuf of a single packet, has an * loop end condition (tot_len == p->len), NOT (next == NULL). */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #include #include "lwip/opt.h" #include "lwip/stats.h" #include "lwip/def.h" #include "lwip/mem.h" #include "lwip/memp.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include "arch/perf.h" #if LWIP_USERFILTER && LWIP_NAT #include "lwip/netif.h" #include "lwip/ip.h" #include "lwip/nat/nat.h" #endif static u8_t pbuf_pool_memory[(PBUF_POOL_SIZE * MEM_ALIGN_SIZE(PBUF_POOL_BUFSIZE + sizeof(struct pbuf)))]; #if !SYS_LIGHTWEIGHT_PROT static volatile u8_t pbuf_pool_free_lock, pbuf_pool_alloc_lock; static sys_sem_t pbuf_pool_free_sem; #endif static struct pbuf *pbuf_pool = NULL; /** * Initializes the pbuf module. * * A large part of memory is allocated for holding the pool of pbufs. * The size of the individual pbufs in the pool is given by the size * parameter, and the number of pbufs in the pool by the num parameter. * * After the memory has been allocated, the pbufs are set up. The * ->next pointer in each pbuf is set up to point to the next pbuf in * the pool. * */ void pbuf_init(void) { struct pbuf *p, *q = NULL; u16_t i; pbuf_pool = (struct pbuf *)&pbuf_pool_memory[0]; LWIP_ASSERT("pbuf_init: pool aligned", (mem_ptr_t)pbuf_pool % MEM_ALIGNMENT == 0); #if PBUF_STATS lwip_stats.pbuf.avail = PBUF_POOL_SIZE; #endif /* PBUF_STATS */ /* Set up ->next pointers to link the pbufs of the pool together */ p = pbuf_pool; for(i = 0; i < PBUF_POOL_SIZE; ++i) { p->next = (struct pbuf *)((u8_t *)p + PBUF_POOL_BUFSIZE + sizeof(struct pbuf)); p->len = p->tot_len = PBUF_POOL_BUFSIZE; p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf))); p->flags = PBUF_FLAG_POOL; q = p; /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT nat_pbuf_init(p); #endif p = p->next; } /* The ->next pointer of last pbuf is NULL to indicate that there are no more pbufs in the pool */ q->next = NULL; #if !SYS_LIGHTWEIGHT_PROT pbuf_pool_alloc_lock = 0; pbuf_pool_free_lock = 0; pbuf_pool_free_sem = sys_sem_new(1); #endif } /** * @internal only called from pbuf_alloc() */ static struct pbuf * pbuf_pool_alloc(void) { struct pbuf *p = NULL; SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_PROTECT(old_level); #if !SYS_LIGHTWEIGHT_PROT /* Next, check the actual pbuf pool, but if the pool is locked, we pretend to be out of buffers and return NULL. */ if (pbuf_pool_free_lock) { #if PBUF_STATS ++lwip_stats.pbuf.alloc_locked; #endif /* PBUF_STATS */ return NULL; } pbuf_pool_alloc_lock = 1; if (!pbuf_pool_free_lock) { #endif /* SYS_LIGHTWEIGHT_PROT */ p = pbuf_pool; if (p) { pbuf_pool = p->next; } #if !SYS_LIGHTWEIGHT_PROT #if PBUF_STATS } else { ++lwip_stats.pbuf.alloc_locked; #endif /* PBUF_STATS */ } pbuf_pool_alloc_lock = 0; #endif /* SYS_LIGHTWEIGHT_PROT */ #if PBUF_STATS if (p != NULL) { ++lwip_stats.pbuf.used; if (lwip_stats.pbuf.used > lwip_stats.pbuf.max) { lwip_stats.pbuf.max = lwip_stats.pbuf.used; } } #endif /* PBUF_STATS */ SYS_ARCH_UNPROTECT(old_level); return p; } /** * Allocates a pbuf of the given type (possibly a chain for PBUF_POOL type). * * The actual memory allocated for the pbuf is determined by the * layer at which the pbuf is allocated and the requested size * (from the size parameter). * * @param flag this parameter decides how and where the pbuf * should be allocated as follows: * * - PBUF_RAM: buffer memory for pbuf is allocated as one large * chunk. This includes protocol headers as well. * - PBUF_ROM: no buffer memory is allocated for the pbuf, even for * protocol headers. Additional headers must be prepended * by allocating another pbuf and chain in to the front of * the ROM pbuf. It is assumed that the memory used is really * similar to ROM in that it is immutable and will not be * changed. Memory which is dynamic should generally not * be attached to PBUF_ROM pbufs. Use PBUF_REF instead. * - PBUF_REF: no buffer memory is allocated for the pbuf, even for * protocol headers. It is assumed that the pbuf is only * being used in a single thread. If the pbuf gets queued, * then pbuf_take should be called to copy the buffer. * - PBUF_POOL: the pbuf is allocated as a pbuf chain, with pbufs from * the pbuf pool that is allocated during pbuf_init(). * * @return the allocated pbuf. If multiple pbufs where allocated, this * is the first pbuf of a pbuf chain. */ struct pbuf * pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag) { struct pbuf *p, *q, *r; u16_t offset; s32_t rem_len; /* remaining length */ LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u)\n", length)); /* determine header offset */ offset = 0; switch (l) { case PBUF_TRANSPORT: /* add room for transport (often TCP) layer header */ offset += PBUF_TRANSPORT_HLEN; /* FALLTHROUGH */ case PBUF_IP: /* add room for IP layer header */ offset += PBUF_IP_HLEN; /* FALLTHROUGH */ case PBUF_LINK: /* add room for link layer header */ offset += PBUF_LINK_HLEN; break; case PBUF_RAW: break; default: LWIP_ASSERT("pbuf_alloc: bad pbuf layer", 0); return NULL; } switch (flag) { case PBUF_POOL: /* allocate head of pbuf chain into p */ p = pbuf_pool_alloc(); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", (void *)p)); if (p == NULL) { #if PBUF_STATS ++lwip_stats.pbuf.err; #endif /* PBUF_STATS */ return NULL; } p->next = NULL; /* make the payload pointer point 'offset' bytes into pbuf data memory */ p->payload = MEM_ALIGN((void *)((u8_t *)p + (sizeof(struct pbuf) + offset))); LWIP_ASSERT("pbuf_alloc: pbuf p->payload properly aligned", ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); /* the total length of the pbuf chain is the requested size */ p->tot_len = length; /* set the length of the first pbuf in the chain */ p->len = length > PBUF_POOL_BUFSIZE - offset? PBUF_POOL_BUFSIZE - offset: length; /* set reference count (needed here in case we fail) */ p->ref = 1; /* now allocate the tail of the pbuf chain */ /* remember first pbuf for linkage in next iteration */ r = p; /* remaining length to be allocated */ rem_len = length - p->len; /* any remaining pbufs to be allocated? */ while (rem_len > 0) { q = pbuf_pool_alloc(); if (q == NULL) { LWIP_DEBUGF(PBUF_DEBUG | 2, ("pbuf_alloc: Out of pbufs in pool.\n")); #if PBUF_STATS ++lwip_stats.pbuf.err; #endif /* PBUF_STATS */ /* free chain so far allocated */ pbuf_free(p); /* bail out unsuccesfully */ return NULL; } q->next = NULL; /* make previous pbuf point to this pbuf */ r->next = q; /* set total length of this pbuf and next in chain */ q->tot_len = rem_len; /* this pbuf length is pool size, unless smaller sized tail */ q->len = rem_len > PBUF_POOL_BUFSIZE? PBUF_POOL_BUFSIZE: rem_len; q->payload = (void *)((u8_t *)q + sizeof(struct pbuf)); LWIP_ASSERT("pbuf_alloc: pbuf q->payload properly aligned", ((mem_ptr_t)q->payload % MEM_ALIGNMENT) == 0); q->ref = 1; /* calculate remaining length to be allocated */ rem_len -= q->len; /* remember this pbuf for linkage in next iteration */ r = q; } /* end of chain */ /*r->next = NULL;*/ break; case PBUF_RAM: /* If pbuf is to be allocated in RAM, allocate memory for it. */ p = mem_malloc(MEM_ALIGN_SIZE(sizeof(struct pbuf) + offset) + MEM_ALIGN_SIZE(length)); if (p == NULL) { return NULL; } /* Set up internal structure of the pbuf. */ p->payload = MEM_ALIGN((void *)((u8_t *)p + sizeof(struct pbuf) + offset)); p->len = p->tot_len = length; p->next = NULL; p->flags = PBUF_FLAG_RAM; LWIP_ASSERT("pbuf_alloc: pbuf->payload properly aligned", ((mem_ptr_t)p->payload % MEM_ALIGNMENT) == 0); break; /* pbuf references existing (non-volatile static constant) ROM payload? */ case PBUF_ROM: /* pbuf references existing (externally allocated) RAM payload? */ case PBUF_REF: /* only allocate memory for the pbuf structure */ p = memp_malloc(MEMP_PBUF); if (p == NULL) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", flag == PBUF_ROM?"ROM":"REF")); return NULL; } /* caller must set this field properly, afterwards */ p->payload = NULL; p->len = p->tot_len = length; p->next = NULL; p->flags = (flag == PBUF_ROM? PBUF_FLAG_ROM: PBUF_FLAG_REF); break; default: LWIP_ASSERT("pbuf_alloc: erroneous flag", 0); return NULL; } /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT nat_pbuf_init(p); #endif /* set reference count */ p->ref = 1; LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u) == %p\n", length, (void *)p)); return p; } #if PBUF_STATS #define DEC_PBUF_STATS do { --lwip_stats.pbuf.used; } while (0) #else /* PBUF_STATS */ #define DEC_PBUF_STATS #endif /* PBUF_STATS */ #define PBUF_POOL_FAST_FREE(p) do { \ p->next = pbuf_pool; \ pbuf_pool = p; \ DEC_PBUF_STATS; \ } while (0) #if SYS_LIGHTWEIGHT_PROT #define PBUF_POOL_FREE(p) do { \ SYS_ARCH_DECL_PROTECT(old_level); \ SYS_ARCH_PROTECT(old_level); \ PBUF_POOL_FAST_FREE(p); \ SYS_ARCH_UNPROTECT(old_level); \ } while (0) #else /* SYS_LIGHTWEIGHT_PROT */ #define PBUF_POOL_FREE(p) do { \ sys_sem_wait(pbuf_pool_free_sem); \ PBUF_POOL_FAST_FREE(p); \ sys_sem_signal(pbuf_pool_free_sem); \ } while (0) #endif /* SYS_LIGHTWEIGHT_PROT */ /** * Shrink a pbuf chain to a desired length. * * @param p pbuf to shrink. * @param new_len desired new length of pbuf chain * * Depending on the desired length, the first few pbufs in a chain might * be skipped and left unchanged. The new last pbuf in the chain will be * resized, and any remaining pbufs will be freed. * * @note If the pbuf is ROM/REF, only the ->tot_len and ->len fields are adjusted. * @note May not be called on a packet queue. * * @bug Cannot grow the size of a pbuf (chain) (yet). */ void pbuf_realloc(struct pbuf *p, u16_t new_len) { struct pbuf *q; u16_t rem_len; /* remaining length */ s16_t grow; LWIP_ASSERT("pbuf_realloc: sane p->flags", p->flags == PBUF_FLAG_POOL || p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_RAM || p->flags == PBUF_FLAG_REF); /* desired length larger than current length? */ if (new_len >= p->tot_len) { /* enlarging not yet supported */ return; } /* the pbuf chain grows by (new_len - p->tot_len) bytes * (which may be negative in case of shrinking) */ grow = new_len - p->tot_len; /* first, step over any pbufs that should remain in the chain */ rem_len = new_len; q = p; /* should this pbuf be kept? */ while (rem_len > q->len) { /* decrease remaining length by pbuf length */ rem_len -= q->len; /* decrease total length indicator */ q->tot_len += grow; /* proceed to next pbuf in chain */ q = q->next; } /* we have now reached the new last pbuf (in q) */ /* rem_len == desired length for pbuf q */ /* shrink allocated memory for PBUF_RAM */ /* (other types merely adjust their length fields */ if ((q->flags == PBUF_FLAG_RAM) && (rem_len != q->len)) { /* reallocate and adjust the length of the pbuf that will be split */ mem_realloc(q, (u8_t *)q->payload - (u8_t *)q + rem_len); } /* adjust length fields for new last pbuf */ q->len = rem_len; q->tot_len = q->len; /* any remaining pbufs in chain? */ if (q->next != NULL) { /* free remaining pbufs in chain */ pbuf_free(q->next); } /* q is last packet in chain */ q->next = NULL; } /** * Adjusts the payload pointer to hide or reveal headers in the payload. * * Adjusts the ->payload pointer so that space for a header * (dis)appears in the pbuf payload. * * The ->payload, ->tot_len and ->len fields are adjusted. * * @param hdr_size_inc Number of bytes to increment header size which * increases the size of the pbuf. New space is on the front. * (Using a negative value decreases the header size.) * If hdr_size_inc is 0, this function does nothing and returns succesful. * * PBUF_ROM and PBUF_REF type buffers cannot have their sizes increased, so * the call will fail. A check is made that the increase in header size does * not move the payload pointer in front of the start of the buffer. * @return non-zero on failure, zero on success. * */ u8_t pbuf_header(struct pbuf *p, s16_t header_size_increment) { void *payload; LWIP_DEBUGF( PBUF_DEBUG , ("pbuf_header: %p inc %d\n",p,header_size_increment)); LWIP_ASSERT("p != NULL", p != NULL); if ((header_size_increment == 0) || (p == NULL)) return 0; /* remember current payload pointer */ payload = p->payload; /* pbuf types containing payloads? */ if (p->flags == PBUF_FLAG_RAM || p->flags == PBUF_FLAG_POOL) { /* set new payload pointer */ p->payload = (u8_t *)p->payload - header_size_increment; /* boundary check fails? */ if ((u8_t *)p->payload < (u8_t *)p + sizeof(struct pbuf)) { LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_header: failed as %p < %p (not enough space for new header size)\n", (void *)p->payload, (void *)(p + 1)));\ /* restore old payload pointer */ p->payload = payload; /* bail out unsuccesfully */ return 1; } /* pbuf types refering to external payloads? */ } else if (p->flags == PBUF_FLAG_REF || p->flags == PBUF_FLAG_ROM) { /* hide a header in the payload? */ if ((header_size_increment < 0) && (header_size_increment - p->len <= 0)) { /* increase payload pointer */ p->payload = (u8_t *)p->payload - header_size_increment; } else { /* cannot expand payload to front (yet!) * bail out unsuccesfully */ return 1; } } /* modify pbuf length fields */ p->len += header_size_increment; p->tot_len += header_size_increment; LWIP_DEBUGF( PBUF_DEBUG, ("pbuf_header: old %p new %p (%d)\n", (void *)payload, (void *)p->payload, header_size_increment)); return 0; } /** * Dereference a pbuf chain or queue and deallocate any no-longer-used * pbufs at the head of this chain or queue. * * Decrements the pbuf reference count. If it reaches zero, the pbuf is * deallocated. * * For a pbuf chain, this is repeated for each pbuf in the chain, * up to the first pbuf which has a non-zero reference count after * decrementing. So, when all reference counts are one, the whole * chain is free'd. * * @param pbuf The pbuf (chain) to be dereferenced. * * @return the number of pbufs that were de-allocated * from the head of the chain. * * @note MUST NOT be called on a packet queue (Not verified to work yet). * @note the reference counter of a pbuf equals the number of pointers * that refer to the pbuf (or into the pbuf). * * @internal examples: * * Assuming existing chains a->b->c with the following reference * counts, calling pbuf_free(a) results in: * * 1->2->3 becomes ...1->3 * 3->3->3 becomes 2->3->3 * 1->1->2 becomes ......1 * 2->1->1 becomes 1->1->1 * 1->1->1 becomes ....... * */ u8_t pbuf_free(struct pbuf *p) { struct pbuf *q; u8_t count; SYS_ARCH_DECL_PROTECT(old_level); LWIP_ASSERT("p != NULL", p != NULL); /* if assertions are disabled, proceed with debug output */ if (p == NULL) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_free(p == NULL) was called.\n")); return 0; } LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_free(%p) p->flags %d\n", (void *)p, p->flags)); PERF_START; LWIP_ASSERT("pbuf_free: sane flags", p->flags == PBUF_FLAG_RAM || p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_REF || p->flags == PBUF_FLAG_POOL); count = 0; /* Since decrementing ref cannot be guaranteed to be a single machine operation * we must protect it. Also, the later test of ref must be protected. */ SYS_ARCH_PROTECT(old_level); /* de-allocate all consecutive pbufs from the head of the chain that * obtain a zero reference count after decrementing*/ while (p != NULL) { /* all pbufs in a chain are referenced at least once */ LWIP_ASSERT("pbuf_free: p->ref > 0", p->ref > 0); /* decrease reference count (number of pointers to pbuf) */ p->ref--; /* this pbuf is no longer referenced to? */ if (p->ref == 0) { /* remember next pbuf in chain for next iteration */ q = p->next; /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT nat_pbuf_put(p); #endif LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: deallocating %p\n", (void *)p)); /* is this a pbuf from the pool? */ if (p->flags == PBUF_FLAG_POOL) { p->len = p->tot_len = PBUF_POOL_BUFSIZE; p->payload = (void *)((u8_t *)p + sizeof(struct pbuf)); PBUF_POOL_FREE(p); /* is this a ROM or RAM referencing pbuf? */ } else if (p->flags == PBUF_FLAG_ROM || p->flags == PBUF_FLAG_REF) { memp_free(MEMP_PBUF, p); /* p->flags == PBUF_FLAG_RAM */ } else { mem_free(p); } count++; /* proceed to next pbuf */ p = q; /* p->ref > 0, this pbuf is still referenced to */ /* (and so the remaining pbufs in chain as well) */ } else { LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: %p has ref %u, ending here.\n", (void *)p, (unsigned int)p->ref)); /* stop walking through the chain */ p = NULL; } } SYS_ARCH_UNPROTECT(old_level); PERF_STOP("pbuf_free"); /* return number of de-allocated pbufs */ return count; } /** * Count number of pbufs in a chain * * @param p first pbuf of chain * @return the number of pbufs in a chain */ u8_t pbuf_clen(struct pbuf *p) { u8_t len; len = 0; while (p != NULL) { ++len; p = p->next; } return len; } /** * Increment the reference count of the pbuf. * * @param p pbuf to increase reference counter of * */ void pbuf_ref(struct pbuf *p) { SYS_ARCH_DECL_PROTECT(old_level); /* pbuf given? */ if (p != NULL) { LWIP_DEBUGF(PBUF_DEBUG, ("pbuf_ref: %p ref %d\n", (void *)p, p->ref)); SYS_ARCH_PROTECT(old_level); ++(p->ref); SYS_ARCH_UNPROTECT(old_level); } } /** * Concatenate two pbufs (each may be a pbuf chain) and take over * the caller's reference of the tail pbuf. * * @note The caller MAY NOT reference the tail pbuf afterwards. * Use pbuf_chain() for that purpose. * * @see pbuf_chain() */ void pbuf_cat(struct pbuf *h, struct pbuf *t) { struct pbuf *p; LWIP_ASSERT("h != NULL (programmer violates API)", h != NULL); LWIP_ASSERT("t != NULL (programmer violates API)", t != NULL); if ((h == NULL) || (t == NULL)) return; /* proceed to last pbuf of chain */ for (p = h; p->next != NULL; p = p->next) { /* add total length of second chain to all totals of first chain */ p->tot_len += t->tot_len; } /* { p is last pbuf of first h chain, p->next == NULL } */ LWIP_ASSERT("p->tot_len == p->len (of last pbuf in chain)", p->tot_len == p->len); LWIP_ASSERT("p->next == NULL", p->next == NULL); /* add total length of second chain to last pbuf total of first chain */ p->tot_len += t->tot_len; /* chain last pbuf of head (p) with first of tail (t) */ p->next = t; /* p->next now references t, but the caller will drop its reference to t, * so netto there is no change to the reference count of t. */ } /** * Chain two pbufs (or pbuf chains) together. * * The caller MUST call pbuf_free(t) once it has stopped * using it. Use pbuf_cat() instead if you no longer use t. * * @param h head pbuf (chain) * @param t tail pbuf (chain) * @note The pbufs MUST belong to the same packet. * @note MAY NOT be called on a packet queue. * * The ->tot_len fields of all pbufs of the head chain are adjusted. * The ->next field of the last pbuf of the head chain is adjusted. * The ->ref field of the first pbuf of the tail chain is adjusted. * */ void pbuf_chain(struct pbuf *h, struct pbuf *t) { pbuf_cat(h, t); /* t is now referenced by h */ pbuf_ref(t); LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: %p references %p\n", (void *)h, (void *)t)); } /* For packet queueing. Note that queued packets MUST be dequeued first * using pbuf_dequeue() before calling other pbuf_() functions. */ #if ARP_QUEUEING /** * Add a packet to the end of a queue. * * @param q pointer to first packet on the queue * @param n packet to be queued * * Both packets MUST be given, and must be different. */ void pbuf_queue(struct pbuf *p, struct pbuf *n) { #if PBUF_DEBUG /* remember head of queue */ struct pbuf *q = p; #endif /* programmer stupidity checks */ LWIP_ASSERT("p == NULL in pbuf_queue: this indicates a programmer error\n", p != NULL); LWIP_ASSERT("n == NULL in pbuf_queue: this indicates a programmer error\n", n != NULL); LWIP_ASSERT("p == n in pbuf_queue: this indicates a programmer error\n", p != n); if ((p == NULL) || (n == NULL) || (p == n)){ LWIP_DEBUGF(PBUF_DEBUG | DBG_HALT | 3, ("pbuf_queue: programmer argument error\n")); return; } /* iterate through all packets on queue */ while (p->next != NULL) { /* be very picky about pbuf chain correctness */ #if PBUF_DEBUG /* iterate through all pbufs in packet */ while (p->tot_len != p->len) { /* make sure invariant condition holds */ LWIP_ASSERT("p->len < p->tot_len", p->len < p->tot_len); /* make sure each packet is complete */ LWIP_ASSERT("p->next != NULL", p->next != NULL); p = p->next; /* { p->tot_len == p->len => p is last pbuf of a packet } */ } /* { p is last pbuf of a packet } */ /* proceed to next packet on queue */ #endif /* proceed to next pbuf */ if (p->next != NULL) p = p->next; } /* { p->tot_len == p->len and p->next == NULL } ==> * { p is last pbuf of last packet on queue } */ /* chain last pbuf of queue with n */ p->next = n; /* n is now referenced to by the (packet p in the) queue */ pbuf_ref(n); #if PBUF_DEBUG LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_queue: newly queued packet %p sits after packet %p in queue %p\n", (void *)n, (void *)p, (void *)q)); #endif } /** * Remove a packet from the head of a queue. * * The caller MUST reference the remainder of the queue (as returned). The * caller MUST NOT call pbuf_ref() as it implicitly takes over the reference * from p. * * @param p pointer to first packet on the queue which will be dequeued. * @return first packet on the remaining queue (NULL if no further packets). * */ struct pbuf * pbuf_dequeue(struct pbuf *p) { struct pbuf *q; LWIP_ASSERT("p != NULL", p != NULL); /* iterate through all pbufs in packet p */ while (p->tot_len != p->len) { /* make sure invariant condition holds */ LWIP_ASSERT("p->len < p->tot_len", p->len < p->tot_len); /* make sure each packet is complete */ LWIP_ASSERT("p->next != NULL", p->next != NULL); p = p->next; } /* { p->tot_len == p->len } => p is the last pbuf of the first packet */ /* remember next packet on queue in q */ q = p->next; /* dequeue packet p from queue */ p->next = NULL; /* any next packet on queue? */ if (q != NULL) { /* although q is no longer referenced by p, it MUST be referenced by * the caller, who is maintaining this packet queue. So, we do not call * pbuf_free(q) here, resulting in an implicit pbuf_ref(q) for the caller. */ LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: first remaining packet on queue is %p\n", (void *)q)); } else { LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: no further packets on queue\n")); } return q; } #endif /** * * Create PBUF_POOL (or PBUF_RAM) copies of PBUF_REF pbufs. * * Used to queue packets on behalf of the lwIP stack, such as * ARP based queueing. * * Go through a pbuf chain and replace any PBUF_REF buffers * with PBUF_POOL (or PBUF_RAM) pbufs, each taking a copy of * the referenced data. * * @note You MUST explicitly use p = pbuf_take(p); * The pbuf you give as argument, may have been replaced * by a (differently located) copy through pbuf_take()! * * @note Any replaced pbufs will be freed through pbuf_free(). * This may deallocate them if they become no longer referenced. * * @param p Head of pbuf chain to process * * @return Pointer to head of pbuf chain */ struct pbuf * pbuf_take(struct pbuf *p) { struct pbuf *q , *prev, *head; LWIP_ASSERT("pbuf_take: p != NULL\n", p != NULL); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)p)); prev = NULL; head = p; /* iterate through pbuf chain */ do { /* pbuf is of type PBUF_REF? */ if (p->flags == PBUF_FLAG_REF) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p)); /* allocate a pbuf (w/ payload) fully in RAM */ /* PBUF_POOL buffers are faster if we can use them */ if (p->len <= PBUF_POOL_BUFSIZE) { q = pbuf_alloc(PBUF_RAW, p->len, PBUF_POOL); if (q == NULL) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_POOL\n")); } } else { /* no replacement pbuf yet */ q = NULL; LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: PBUF_POOL too small to replace PBUF_REF\n")); } /* no (large enough) PBUF_POOL was available? retry with PBUF_RAM */ if (q == NULL) { q = pbuf_alloc(PBUF_RAW, p->len, PBUF_RAM); if (q == NULL) { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_RAM\n")); } } /* replacement pbuf could be allocated? */ if (q != NULL) { /* copy p to q */ /* copy successor */ q->next = p->next; /* remove linkage from original pbuf */ p->next = NULL; /* remove linkage to original pbuf */ if (prev != NULL) { /* prev->next == p at this point */ LWIP_ASSERT("prev->next == p", prev->next == p); /* break chain and insert new pbuf instead */ prev->next = q; /* prev == NULL, so we replaced the head pbuf of the chain */ } else { head = q; } /* copy pbuf payload */ memcpy(q->payload, p->payload, p->len); q->tot_len = p->tot_len; q->len = p->len; /* in case p was the first pbuf, it is no longer refered to by * our caller, as the caller MUST do p = pbuf_take(p); * in case p was not the first pbuf, it is no longer refered to * by prev. we can safely free the pbuf here. * (note that we have set p->next to NULL already so that * we will not free the rest of the chain by accident.) */ pbuf_free(p); /* do not copy ref, since someone else might be using the old buffer */ LWIP_DEBUGF(PBUF_DEBUG, ("pbuf_take: replaced PBUF_REF %p with %p\n", (void *)p, (void *)q)); p = q; } else { /* deallocate chain */ pbuf_free(head); LWIP_DEBUGF(PBUF_DEBUG | 2, ("pbuf_take: failed to allocate replacement pbuf for %p\n", (void *)p)); return NULL; } /* p->flags != PBUF_FLAG_REF */ } else { LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: skipping pbuf not of type PBUF_REF\n")); } /* remember this pbuf */ prev = p; /* proceed to next pbuf in original chain */ p = p->next; } while (p); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n")); return head; } /** * Dechains the first pbuf from its succeeding pbufs in the chain. * * Makes p->tot_len field equal to p->len. * @param p pbuf to dechain * @return remainder of the pbuf chain, or NULL if it was de-allocated. * @note May not be called on a packet queue. */ struct pbuf * pbuf_dechain(struct pbuf *p) { struct pbuf *q; u8_t tail_gone = 1; /* tail */ q = p->next; /* pbuf has successor in chain? */ if (q != NULL) { /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ LWIP_ASSERT("p->tot_len == p->len + q->tot_len", q->tot_len == p->tot_len - p->len); /* enforce invariant if assertion is disabled */ q->tot_len = p->tot_len - p->len; /* decouple pbuf from remainder */ p->next = NULL; /* total length of pbuf p is its own length only */ p->tot_len = p->len; /* q is no longer referenced by p, free it */ LWIP_DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: unreferencing %p\n", (void *)q)); tail_gone = pbuf_free(q); if (tail_gone > 0) { LWIP_DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *)q)); } /* return remaining tail or NULL if deallocated */ } /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ LWIP_ASSERT("p->tot_len == p->len", p->tot_len == p->len); return (tail_gone > 0? NULL: q); } /* added by Diego Billi */ struct pbuf * pbuf_clone(pbuf_layer l, struct pbuf *p, pbuf_flag flag) { struct pbuf *q, *r; u8_t *ptr; r = pbuf_alloc(l, p->tot_len, PBUF_RAM); if (r != NULL) { ptr = r->payload; for(q = p; q != NULL; q = q->next) { memcpy(ptr, q->payload, q->len); ptr += q->len; } #if LWIP_USERFILTER && LWIP_NAT nat_pbuf_clone(r, p); #endif } return r ; } /* added by Diego Billi */ struct pbuf * pbuf_make_writable(struct pbuf *p) { struct pbuf *r = NULL; if (p->len < p->tot_len) { r = pbuf_clone(PBUF_LINK, p, PBUF_RAM); if (r != NULL) pbuf_free(p); } else r = p; return r; } #if 0 /* added by Diego Billi */ struct pbuf * pbuf_clone(pbuf_layer l, struct pbuf *p, pbuf_flag flag) { struct pbuf *q, *r; u8_t *ptr; r = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM); if (r != NULL) { ptr = r->payload; for(q = p; q != NULL; q = q->next) { memcpy(ptr, q->payload, q->len); ptr += q->len; } } return r ; } #endif lwipv6-1.5a/lwip-v6/src/userfilter/0000755000175000017500000000000011671615111016302 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/userfilter/nat/0000755000175000017500000000000011671615111017064 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/userfilter/nat/nat_rules.c0000644000175000017500000001537211671615005021236 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if LWIP_USERFILTER && LWIP_NAT #include #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/memp.h" /* MEMP_NAT_RULE */ #include "lwip/inet.h" #include "lwip/ip.h" #include "lwip/udp.h" #include "lwip/tcp.h" #include "lwip/icmp.h" #include "lwip/sockets.h" #include "lwip/if.h" #include "lwip/netif.h" #include "lwip/userfilter.h" #include "lwip/nat/nat.h" #include "lwip/nat/nat_rules.h" #ifndef NATRULE_DEBUG #define NATRULE_DEBUG DBG_OFF #endif /*--------------------------------------------------------------------------*/ /* Rules functions */ /*--------------------------------------------------------------------------*/ #define NAT_RULE_REG(rules_list, nrule) \ do { \ (nrule)->next = *(rules_list); \ *(rules_list) = (nrule); \ } while(0) #define NAT_RULE_APPEND(rules_list, nrule) \ do { \ struct nat_rule *nat_tmp_rule; \ if (*(rules_list) != NULL) { \ nat_tmp_rule = *(rules_list); \ while (nat_tmp_rule->next != NULL) \ nat_tmp_rule = nat_tmp_rule->next; \ nat_tmp_rule->next = (nrule); \ } \ else { \ (nrule)->next = NULL; \ *(rules_list) = (nrule); \ } \ } while(0) #define NAT_RULE_RMV(pcbs_list, npcb) \ do { \ if(*pcbs_list == npcb) { \ *pcbs_list = (*pcbs_list)->next; \ } else \ struct nat_rule *nat_tmp_rule; \ for(nat_tmp_rule = *pcbs_list; nat_tmp_rule != NULL; nat_tmp_rule = nat_tmp_rule->next) { \ if (nat_tmp_rule->next != NULL && nat_tmp_rule->next == npcb) { \ nat_tmp_rule->next = npcb->next; \ break; \ } \ } \ npcb->next = NULL; \ } while(0) #define NAT_RULE_FIND(rules_list, netif, result) do {\ struct nat_rule *nat_tmp_rule; \ for(nat_tmp_rule = *(rules_list); nat_tmp_rule != NULL; nat_tmp_rule = nat_tmp_rule->next) { \ if(nat_tmp_rule->iface == (netif)) { \ * (result) = nat_tmp_pcb; \ break; \ } \ } \ } while(0) // // Returns a new nat_rule structure. // Returns NULL if no more nat_rule can be created. // struct nat_rule * nat_new_rule(void) { struct nat_rule *r; r = memp_malloc(MEMP_NAT_RULE); if (r == NULL) return NULL; bzero(r, sizeof(struct nat_rule)); // clean all return r; } void nat_free_rule(struct nat_rule *rule) { memp_free(MEMP_NAT_RULE, rule); } int nat_add_rule(struct stack *stack, int ipv, nat_table_t where, struct nat_rule *new_rule) { if (stack->stack_nat == NULL) return -1; // MASQUARADE e SNAT can be used only on POSTROUTING if ((where == NAT_POSTROUTING) && ((new_rule->type == NAT_MASQUERADE) || (new_rule->type == NAT_SNAT)) ) { NAT_RULE_APPEND(&stack->stack_nat->nat_out_rules, new_rule); return 1; } else // DNAT can be used only on PREROUTING if ((where == NAT_PREROUTING) && (new_rule->type == NAT_DNAT)) { NAT_RULE_APPEND(&stack->stack_nat->nat_in_rules, new_rule); return 1; } return 0; } // Remove from 'list' the rule at position 'pos'. // Returns the pointer to the removed rule. struct nat_rule * nat_del_rule_raw(struct nat_rule **list, int pos) { int i=0; struct nat_rule *removed = NULL; struct nat_rule *p; // list empty, skip if (*list != NULL) { if (pos == 0) { removed = *list; *list = (*list)->next; } else for(p = *list; p != NULL; p = p->next, i++) { if ((p->next != NULL) && ((i+1) == pos)) { removed = p->next; p->next = removed->next; break; } } if (removed != NULL) { removed->next = NULL; return removed; } } return NULL; } struct nat_rule * nat_del_rule(struct stack *stack, nat_table_t where, int pos) { if (stack->stack_nat == NULL) return NULL; if (where == NAT_POSTROUTING) return nat_del_rule_raw(&stack->stack_nat->nat_out_rules, pos); else if (where == NAT_PREROUTING) return nat_del_rule_raw(&stack->stack_nat->nat_in_rules, pos); else return NULL; } void nat_rules_shutdown(struct stack *stack) { while (stack->stack_nat->nat_out_rules != NULL) nat_free_rule(nat_del_rule_raw(&stack->stack_nat->nat_out_rules, 0)); while (stack->stack_nat->nat_in_rules != NULL) nat_free_rule(nat_del_rule_raw(&stack->stack_nat->nat_in_rules, 0)); } int nat_match_rule(struct rule_matches *matches, struct netif *iface, struct ip_tuple *tuple) { if (matches->iface != NULL) { if (matches->iface != iface) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong interface.\n", __func__)); return 0; } } if (matches->ipv != tuple->ipv) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong IP version (%d, %d)\n", __func__,matches->ipv, tuple->ipv)); return 0; } if (! IS_IGNORE_IP(&matches->src_ip)) if (ip_addr_cmp(&matches->src_ip, &tuple->src.ip) != 0) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong src IP\n", __func__)); return 0; } if (! IS_IGNORE_IP(&matches->dst_ip)) if (ip_addr_cmp(&matches->dst_ip, &tuple->dst.ip) != 0) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong dst IP\n", __func__)); return 0; } if (! IS_IGNORE_PROTO(matches->protocol)) if (matches->protocol != tuple->src.proto.protonum) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong proto\n", __func__)); return 0; } if (tuple->src.proto.protonum == IP_PROTO_TCP) { if (! IS_IGNORE_PORT(matches->src_port)) if (matches->src_port != tuple->src.proto.upi.tcp.port) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong src port\n", __func__)); return 0; } if (! IS_IGNORE_PORT(matches->dst_port)) if (matches->dst_port != tuple->dst.proto.upi.tcp.port) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong dst port\n", __func__)); return 0; } } if (tuple->src.proto.protonum == IP_PROTO_UDP) { if (! IS_IGNORE_PORT(matches->src_port)) if (matches->src_port != tuple->src.proto.upi.udp.port) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong src port\n", __func__)); return 0; } if (! IS_IGNORE_PORT(matches->dst_port)) if (matches->dst_port != tuple->dst.proto.upi.udp.port) { LWIP_DEBUGF(NATRULE_DEBUG, ("%s: wrong dst port\n", __func__)); return 0; } } return 1; } #endif lwipv6-1.5a/lwip-v6/src/userfilter/nat/nat_track_proto_icmp4.c0000644000175000017500000003605511671615005023530 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if LWIP_USERFILTER && LWIP_NAT #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/memp.h" /* MEMP_NAT_RULE */ #include "lwip/inet.h" #include "lwip/ip.h" #include "lwip/icmp.h" #include "lwip/netif.h" #include "lwip/userfilter.h" #include "lwip/nat/nat.h" #include "lwip/nat/nat_tables.h" #ifndef NAT_ICMP_DEBUG #define NAT_ICMP_DEBUG DBG_OFF #endif /*--------------------------------------------------------------------------*/ #define SECOND 1000 #define NAT_IDLE_ICMP_TIMEOUT (30 * SECOND) /*--------------------------------------------------------------------------*/ int track_icmp4_tuple(struct ip_tuple *tuple, void *hdr) { struct icmp_echo_hdr *icmphdr = NULL; icmphdr = (struct icmp_echo_hdr *) hdr; LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: start\n", __func__)); tuple->src.proto.upi.icmp4.id = icmphdr->id; tuple->src.proto.upi.icmp4.type = icmphdr->type; tuple->src.proto.upi.icmp4.code = icmphdr->icode; return 1; } int track_icmp4_inverse(struct ip_tuple *reply, struct ip_tuple *tuple) { static u_int8_t invmap[] = { [ICMP4_ECHO] = ICMP4_ER + 1, [ICMP4_ER] = ICMP4_ECHO + 1 }; LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: start\n", __func__)); if ( (tuple->src.proto.upi.icmp4.type >= sizeof(invmap)) || !(invmap[tuple->src.proto.upi.icmp4.type])) { return -1; } reply->src.proto.upi.icmp4.id = tuple->src.proto.upi.icmp4.id; reply->src.proto.upi.icmp4.type = invmap[tuple->src.proto.upi.icmp4.type] - 1; reply->src.proto.upi.icmp4.code = tuple->src.proto.upi.icmp4.code; return 1; } int track_icmp6_tuple(struct ip_tuple *tuple, void *hdr) { struct icmp_echo_hdr *icmphdr = NULL; icmphdr = (struct icmp_echo_hdr *) hdr; LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: start\n", __func__)); tuple->src.proto.upi.icmp6.id = icmphdr->id; tuple->src.proto.upi.icmp6.type = icmphdr->type; tuple->src.proto.upi.icmp6.code = icmphdr->icode; return 1; } int track_icmp6_inverse(struct ip_tuple *reply, struct ip_tuple *tuple) { static u_int8_t invmap6[] = { [ICMP6_ECHO] = ICMP6_ER + 1, [ICMP6_ER] = ICMP6_ECHO + 1 }; LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: start\n", __func__)); if ( (tuple->src.proto.upi.icmp6.type >= sizeof(invmap6)) || !(invmap6[tuple->src.proto.upi.icmp6.type])) { return -1; } reply->src.proto.upi.icmp6.id = tuple->src.proto.upi.icmp6.id; reply->src.proto.upi.icmp6.type = invmap6[tuple->src.proto.upi.icmp6.type] - 1; reply->src.proto.upi.icmp6.code = tuple->src.proto.upi.icmp6.code; return 1; } /*--------------------------------------------------------------------------*/ static int error_message(struct stack *stack, uf_verdict_t *verdict, struct pbuf *p) { struct ip4_hdr *ip4hdr; struct ip_hdr *ip6hdr; struct icmp_echo_hdr *icmphdr; struct ip4_hdr *inside_ip4hdr; struct ip_hdr *inside_ip6hdr; char *inside_hdr; struct track_protocol *innerproto; struct ip_tuple original; struct ip_tuple inverse; struct nat_pcb * pcb; conn_dir_t direction; /* * 1) Get IP and ICMP header */ ip4hdr = (struct ip4_hdr *) p->payload; ip6hdr = (struct ip_hdr *) p->payload; if (IPH4_V(ip4hdr) == 4) icmphdr = p->payload + IPH4_HL(ip4hdr) * 4; else icmphdr = p->payload + IP_HLEN; /* * 2) Get Inner IP + PROTO */ inside_ip4hdr = (struct ip4_hdr *) (icmphdr + 1); inside_ip6hdr = (struct ip_hdr *) (icmphdr + 1); if (IPH4_V(ip4hdr) == 4) { inside_hdr = ((char *)inside_ip4hdr) + IPH4_LEN(inside_ip4hdr) * 4; innerproto = track_proto_find( IPH4_PROTO(inside_ip4hdr ) ); } else { inside_hdr = ((char *)inside_ip6hdr) + IP_HLEN; innerproto = track_proto_find( IPH_NEXTHDR(inside_ip6hdr) ); } /* * 3) Get the tuple of the packet */ if (tuple_create(&original, (char *) inside_ip4hdr, innerproto) < 0) { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: unable to create tuple!\n", __func__ )); * verdict = UF_ACCEPT; return -1; } /* This is an error message. Create a fake reply tuple and search for the connection the reply belongs to */ if (tuple_inverse(&inverse, &original) < 0) { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: unable to create tuple!\n", __func__ )); * verdict = UF_ACCEPT; return -1; } pcb = conn_find_track(stack, & direction, &inverse ); if (pcb == NULL) { /* No connection? */ LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: Not found original connection!\n", __func__ )); * verdict = UF_DROP; return -1; } /* Ok, we have found the right connection */ LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: Found connection!\n", __func__ )); p->nat.track = pcb; p->nat.dir = direction; p->nat.info = CT_RELATED; if (direction == CONN_DIR_REPLY) { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: CT_RELATED + CT_IS_REPLY!\n", __func__ )); p->nat.info += CT_IS_REPLY; } else { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: CT_RELATED!\n", __func__ )); } * verdict = UF_ACCEPT; return 1; } int track_icmp4_error (struct stack *stack, uf_verdict_t *verdict, struct pbuf *p) { struct ip4_hdr *ip4hdr; struct icmp_echo_hdr *icmphdr = NULL; LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: start\n", __func__)); ip4hdr = (struct ip4_hdr *) p->payload; if (IPH4_V(ip4hdr) == 4) icmphdr = (struct icmp_echo_hdr *) ((char *)p->payload + (IPH4_HL(ip4hdr) * 4)); else { *verdict = UF_DROP; return -1; } /* FIX: checksum? */ /* Drop unsupported types */ if (icmphdr->type > ICMP4_IR) { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: wrong ICMPv4 type %d.\n", __func__, icmphdr->type)); *verdict = UF_DROP; return -1; } LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: ICMPv4 type %d code %d.\n", __func__, icmphdr->type, icmphdr->icode)); /* Check only error messages and skip the others */ if (icmphdr->type != ICMP4_DUR && /* destination unreachable */ icmphdr->type != ICMP4_SQ && /* source quench */ icmphdr->type != ICMP4_TE && /* time exceeded */ icmphdr->type != ICMP4_PP && /* parameter problem */ icmphdr->type != ICMP4_RD) { /* redirect */ LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: not error message. return!\n", __func__)); return 1; } LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: ICMPv4 error message %d.\n", __func__, icmphdr->type)); return error_message(stack, verdict, p); } int track_icmp6_error (struct stack *stack, uf_verdict_t *verdict, struct pbuf *p) { struct ip_hdr *iphdr; struct icmp_echo_hdr *icmph = NULL; LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: start\n", __func__)); iphdr = (struct ip_hdr *) p->payload; if (IPH_V(iphdr) == 6) icmph = p->payload + IP_HLEN; else { *verdict = UF_DROP; return -1; } /* FIX: checksum? */ /* Don't track Neighbour Solicitation and Router Solicitation protocols */ if (icmph->type == ICMP6_RS || /* router solicitation */ icmph->type == ICMP6_RA || /* router advertisement */ icmph->type == ICMP6_NS || /* neighbor solicitation */ icmph->type == ICMP6_NA) { /* neighbor advertisement */ LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: not track NS or RA.\n", __func__)); *verdict = UF_ACCEPT; return -1; } /* Check only error messages and skip the others */ if (icmph->type != ICMP6_DUR && /* destination unreachable */ icmph->type != ICMP6_PTB && /* Packet Too Big */ icmph->type != ICMP6_TE && /* time exceeded */ icmph->type != ICMP4_PP && /* parameter problem */ icmph->type != ICMP4_RD) { /* redirect */ LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: not error message. return!\n", __func__)); return 1; } LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: ICMPv6 error message %d.\n", __func__, icmph->type)); return error_message(stack, verdict, p); } /*--------------------------------------------------------------------------*/ int track_icmp4_new(struct stack *stack, struct nat_pcb *pcb, struct pbuf *p, void *iphdr, int iplen) { pcb->proto.icmp4.count = 0; pcb->timeout = NAT_IDLE_ICMP_TIMEOUT; return 1; } int track_icmp6_new(struct stack *stack, struct nat_pcb *pcb, struct pbuf *p, void *iphdr, int iplen) { pcb->proto.icmp6.count = 0; pcb->timeout = NAT_IDLE_ICMP_TIMEOUT; return 1; } int track_icmp4_handle(struct stack *stack, uf_verdict_t *verdict, struct pbuf *p, conn_dir_t direction) { struct icmp_echo_hdr *icmphdr = NULL; struct ip_hdr *iphdr; struct ip4_hdr *ip4hdr; struct nat_pcb *pcb = p->nat.track; ip4hdr = p->payload; iphdr = p->payload; if (IPH_V(iphdr) == 6) icmphdr = p->payload + IP_HLEN; else if (IPH_V(iphdr) == 4) icmphdr = p->payload + IPH4_HL(ip4hdr) * 4; if (direction == CONN_DIR_ORIGINAL) { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: icmp4 ORIGINAL.\n", __func__)); pcb->proto.icmp4.count++; } else { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: icmp4 REPLY.\n", __func__)); pcb->proto.icmp4.count--; /* Last packet in this direction, remove timer */ if (pcb->proto.icmp4.count == 0) { if (conn_remove_timer(pcb)) conn_force_timeout(pcb); LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: REPLY RECEIVED.\n", __func__)); } } conn_refresh_timer(pcb->timeout, pcb); *verdict = UF_ACCEPT; return 1; } int track_icmp6_handle(struct stack *stack, uf_verdict_t *verdict, struct pbuf *p, conn_dir_t direction) { struct icmp_echo_hdr *icmphdr = NULL; struct ip_hdr *iphdr; struct ip4_hdr *ip4hdr; struct nat_pcb *pcb = p->nat.track; iphdr = p->payload; if (IPH_V(iphdr) == 6) icmphdr = p->payload + IP_HLEN; else if (IPH_V(iphdr) == 4) icmphdr = p->payload + IPH4_HL(ip4hdr) * 4; if (direction == CONN_DIR_ORIGINAL) { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: icmp6 ORIGINAL.\n", __func__)); pcb->proto.icmp6.count++; } else { LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: icmp6 REPLY.\n", __func__)); pcb->proto.icmp6.count--; /* Last packet in this direction, remove timer */ if (pcb->proto.icmp6.count == 0) { if (conn_remove_timer(pcb)) conn_force_timeout(pcb); LWIP_DEBUGF(NAT_ICMP_DEBUG, ("%s: REPLY RECEIVED.\n", __func__)); } } conn_refresh_timer(pcb->timeout, pcb); * verdict = UF_ACCEPT; return 1; } /*--------------------------------------------------------------------------*/ int nat_icmp4_manip (nat_manip_t type, void *iphdr, int iplen, struct ip_tuple *inverse, u8_t *iphdr_new_changed_buf, u8_t *iphdr_old_changed_buf, u32_t iphdr_changed_buflen) { struct icmp_echo_hdr *icmphdr = NULL; u16_t old_value; icmphdr = (struct icmp_echo_hdr *) (iphdr+iplen); if (ICMPH_TYPE(icmphdr) == ICMP4_ECHO || ICMPH_TYPE(icmphdr) == ICMP4_ER) { // Set icmp id old_value = icmphdr->id; if (type == MANIP_DST) icmphdr->id = inverse->src.proto.upi.icmp4.id; else if (type == MANIP_SRC) icmphdr->id = inverse->src.proto.upi.icmp4.id; nat_chksum_adjust((u8_t *) & ICMPH_CHKSUM(icmphdr), (u8_t *) & old_value, 2, (u8_t *) & icmphdr->id, 2); LWIP_DEBUGF(NAT_ICMP_DEBUG, ("\t\ticmp id: %d\n", ntohs(icmphdr->id)) ); } return -1; } //int nat_icmp6_manip (nat_type_t type, void *iphdr, int iplen, struct ip_tuple *inverse, int nat_icmp6_manip (nat_manip_t type, void *iphdr, int iplen, struct ip_tuple *inverse, u8_t *iphdr_new_changed_buf, u8_t *iphdr_old_changed_buf, u32_t iphdr_changed_buflen) { struct icmp_echo_hdr *icmphdr = NULL; u16_t old_value; icmphdr = (struct icmp_echo_hdr *) (iphdr+iplen); if ((ICMPH_TYPE(icmphdr) == ICMP6_ECHO || ICMPH_TYPE(icmphdr) == ICMP6_ER)) { // Adjust checksum because IP header (and pseudo header) is changed nat_chksum_adjust((u8_t *) & ICMPH_CHKSUM(icmphdr), iphdr_old_changed_buf, iphdr_changed_buflen, iphdr_new_changed_buf, iphdr_changed_buflen); // Set icmp id old_value = icmphdr->id; if (type == MANIP_DST) icmphdr->id = inverse->src.proto.upi.icmp6.id; else if (type == MANIP_SRC) icmphdr->id = inverse->src.proto.upi.icmp6.id; nat_chksum_adjust((u8_t *) & ICMPH_CHKSUM(icmphdr), (u8_t *) & old_value, 2, (u8_t *) & icmphdr->id, 2); LWIP_DEBUGF(NAT_ICMP_DEBUG, ("\t\ticmp id: %d\n", ntohs(icmphdr->id)) ); } return -1; } int nat_icmp4_tuple_inverse (struct stack *stack, struct ip_tuple *reply, struct ip_tuple *tuple, nat_type_t type, struct manip_range *nat_manip ) { u16_t id; u32_t min, max; if (type == NAT_SNAT) { if (nat_manip->flag & MANIP_RANGE_PROTO) { min = nat_manip->protomin.value; max = nat_manip->protomax.value; } else { min = 0; max = 0xFFFF; } if (nat_ports_getnew(stack, IP_PROTO_ICMP4, &id, min, max) > 0) { reply->src.proto.upi.icmp4.id = htons(id); } else return -1; } else if (type == NAT_DNAT) { reply->src.proto.upi.icmp4.id = tuple->src.proto.upi.icmp4.id; } return -1; } int nat_icmp6_tuple_inverse (struct stack *stack, struct ip_tuple *reply, struct ip_tuple *tuple, nat_type_t type, struct manip_range *nat_manip ) { u16_t id; u32_t min, max; if (type == NAT_SNAT || type == NAT_MASQUERADE) { if (nat_manip->flag & MANIP_RANGE_PROTO) { min = nat_manip->protomin.value; max = nat_manip->protomax.value; } else { min = 0; max = 0xFFFF; } if (nat_ports_getnew(stack, IP_PROTO_ICMP, &id, min, max) > 0) { reply->src.proto.upi.icmp6.id = htons(id); } else return -1; } else if (type == NAT_DNAT) { reply->src.proto.upi.icmp6.id = tuple->src.proto.upi.icmp6.id; } return 1; } int nat_icmp4_free(struct nat_pcb *pcb) { if (pcb->nat_type == NAT_SNAT) { nat_ports_free(pcb->stack, IP_PROTO_ICMP4, ntohs( pcb->tuple[CONN_DIR_REPLY].src.proto.upi.icmp4.id )); } return 1; } int nat_icmp6_free(struct nat_pcb *pcb) { if (pcb->nat_type == NAT_SNAT) { nat_ports_free(pcb->stack, IP_PROTO_ICMP, ntohs( pcb->tuple[CONN_DIR_REPLY].src.proto.upi.icmp6.id )); } return 1; } /*--------------------------------------------------------------------------*/ struct track_protocol icmp4_track = { .tuple = track_icmp4_tuple, .inverse = track_icmp4_inverse, .error = track_icmp4_error, .new = track_icmp4_new, .handle = track_icmp4_handle, .manip = nat_icmp4_manip, .nat_tuple_inverse = nat_icmp4_tuple_inverse, .nat_free = nat_icmp4_free }; struct track_protocol icmp6_track = { .tuple = track_icmp6_tuple, .inverse = track_icmp6_inverse, .error = track_icmp6_error, .new = track_icmp6_new, .handle = track_icmp6_handle, .manip = nat_icmp6_manip, .nat_tuple_inverse = nat_icmp6_tuple_inverse, .nat_free = nat_icmp6_free }; #endif lwipv6-1.5a/lwip-v6/src/userfilter/nat/nat_track_proto_udp.c0000644000175000017500000001255611671615005023304 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if LWIP_USERFILTER && LWIP_NAT #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/memp.h" /* MEMP_NAT_RULE */ #include "lwip/inet.h" #include "lwip/ip.h" #include "lwip/udp.h" #include "lwip/netif.h" #include "lwip/userfilter.h" #include "lwip/nat/nat.h" #include "lwip/nat/nat_tables.h" #ifndef NAT_UDP_DEBUG #define NAT_UDP_DEBUG DBG_OFF #endif /*--------------------------------------------------------------------------*/ #define SECOND 1000 #define NAT_IDLE_UDP_TIMEOUT (30 * SECOND) #define NAT_IDLE_UDP_STREAM_TIMEOUT (180 * SECOND) /*--------------------------------------------------------------------------*/ int track_udp_tuple(struct ip_tuple *tuple, void *hdr) { struct udp_hdr *udphdr = NULL; udphdr = (struct udp_hdr *) hdr; tuple->src.proto.upi.udp.port = udphdr->src; tuple->dst.proto.upi.udp.port = udphdr->dest; return 1; } int track_udp_inverse(struct ip_tuple *reply, struct ip_tuple *tuple) { reply->src.proto.upi.udp.port = tuple->dst.proto.upi.udp.port; reply->dst.proto.upi.udp.port = tuple->src.proto.upi.udp.port; return 1; } /*--------------------------------------------------------------------------*/ int track_udp_error (struct stack *stack, uf_verdict_t *verdict, struct pbuf *p) { // FIX: check packet len and checksum return 1; } int track_udp_new(struct stack *stack, struct nat_pcb *pcb, struct pbuf *p, void *iphdr, int iplen) { pcb->proto.udp.isstream = 0; pcb->timeout = NAT_IDLE_UDP_TIMEOUT; return 1; } int track_udp_handle(struct stack *stack, uf_verdict_t *verdict, struct pbuf *p, conn_dir_t direction) { struct udp_hdr *udphdr = NULL; struct ip_hdr *iphdr; struct ip4_hdr *ip4hdr; struct nat_pcb *pcb = p->nat.track; ip4hdr = p->payload; iphdr = p->payload; if (IPH_V(iphdr) == 6) udphdr = p->payload + IP_HLEN; else if (IPH_V(iphdr) == 4) udphdr = p->payload + IPH4_HL(ip4hdr) * 4; if (direction == CONN_DIR_REPLY) { LWIP_DEBUGF(NAT_UDP_DEBUG, ("%s: Maybe this is a UDP stream.\n", __func__)); pcb->proto.udp.isstream = 1; pcb->timeout = NAT_IDLE_UDP_STREAM_TIMEOUT; } conn_refresh_timer(pcb->timeout, pcb); *verdict = UF_ACCEPT; return 1; } /*--------------------------------------------------------------------------*/ int nat_udp_manip (nat_manip_t type, void *iphdr, int iplen, struct ip_tuple *inverse, u8_t *iphdr_new_changed_buf, u8_t *iphdr_old_changed_buf, u32_t iphdr_changed_buflen) { struct udp_hdr *udphdr = NULL; u16_t old_value; udphdr = (struct udp_hdr *) (iphdr+iplen); if (udphdr->chksum != 0) { // adjust udp checksum nat_chksum_adjust((u8_t *) & udphdr->chksum, (u8_t *) iphdr_old_changed_buf, iphdr_changed_buflen, (u8_t *) iphdr_new_changed_buf, iphdr_changed_buflen); // Set port if (type == MANIP_DST) { old_value = udphdr->dest; udphdr->dest = inverse->src.proto.upi.udp.port; nat_chksum_adjust((u8_t *) & udphdr->chksum, (u8_t *) & old_value, 2, (u8_t *) & udphdr->dest, 2); } else if (type == MANIP_SRC) { old_value = udphdr->src; udphdr->src = inverse->dst.proto.upi.udp.port; nat_chksum_adjust((u8_t *) & udphdr->chksum, (u8_t *) & old_value, 2, (u8_t *) & udphdr->src, 2); } LWIP_DEBUGF(NAT_UDP_DEBUG, ("\t\tdest port: %d\n", ntohs(udphdr->dest)) ); } return -1; } int nat_udp_tuple_inverse (struct stack *stack, struct ip_tuple *reply, struct ip_tuple *tuple, nat_type_t type, struct manip_range *nat_manip ) { u16_t port; u32_t min, max; if (type == NAT_SNAT) { if (nat_manip->flag & MANIP_RANGE_PROTO) { min = nat_manip->protomin.value; max = nat_manip->protomax.value; } else { min = 0; max = 0xFFFF; } if (nat_ports_getnew(stack, IP_PROTO_UDP, &port, min, max) > 0) { reply->dst.proto.upi.udp.port = htons(port); } else return -1; } else if (type == NAT_DNAT) { if (nat_manip->flag & MANIP_RANGE_PROTO) { reply->src.proto.upi.udp.port = nat_manip->protomin.value; } } return 1; } int nat_udp_free(struct nat_pcb *pcb) { if (pcb->nat_type == NAT_SNAT) { nat_ports_free(pcb->stack, IP_PROTO_UDP, ntohs(pcb->tuple[CONN_DIR_REPLY].dst.proto.upi.udp.port)); } return 1; } struct track_protocol udp_track = { .tuple = track_udp_tuple, .inverse = track_udp_inverse, .error = track_udp_error, .new = track_udp_new, .handle = track_udp_handle, .manip = nat_udp_manip, .nat_tuple_inverse = nat_udp_tuple_inverse, .nat_free = nat_udp_free }; #endif lwipv6-1.5a/lwip-v6/src/userfilter/nat/nat_tables.c0000644000175000017500000000630411671615005021351 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if LWIP_USERFILTER && LWIP_NAT #include #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/ip.h" #include "lwip/stack.h" #include "lwip/netif.h" #include "lwip/userfilter.h" #include "lwip/nat/nat_tables.h" #ifndef NATPORTS_DEBUG #define NATPOSTS_DEBUG DBG_OFF #endif void nat_ports_init(struct stack *stack) { memset(stack->stack_nat->nat_tcp_table , 0xff, TCP_PORTS_TABLE_SIZE); memset(stack->stack_nat->nat_udp_table , 0xff, UDP_PORTS_TABLE_SIZE); memset(stack->stack_nat->nat_icmp_table, 0xff, ICMP_PORTS_TABLE_SIZE); } /*--------------------------------------------------------------------------*/ int getnew_range(u16_t *val, unsigned char *table, u32_t start, u32_t range_min, u32_t range_max) { int i; range_min -= start; range_max -= start; if (range_min < 0) range_min = 0; for (i=range_min; i < range_max; i++) if (table[ i/8 ] & (0x01 << (i % 8))) break; if (i < range_max) { table[i/8] &= ~(0x01 << (i%8)); *val = i + start; // printf("NEW PORT ID=%d (%d)\n", *val, htons(*val)); return 1; } return 0; } int nat_ports_getnew(struct stack *stack, int protocol, u16_t *port, u32_t min, u32_t max) { u32_t r; switch (protocol) { case IP_PROTO_ICMP4: case IP_PROTO_ICMP: r = getnew_range(port, &stack->stack_nat->nat_icmp_table[0], ICMP_MIN_PORT, min, max); break; case IP_PROTO_TCP: r = getnew_range(port, &stack->stack_nat->nat_tcp_table[0], TCP_MIN_PORT, min, max); break; case IP_PROTO_UDP: r = getnew_range(port, &stack->stack_nat->nat_udp_table[0], UDP_MIN_PORT, min, max); break; default: r = -1; break; } return r; } /*--------------------------------------------------------------------------*/ #define nat_ports_unset(table, min, n) ( (table)[((n)-(min))/8] |= (1<<(((n)-(min))%8)) ) u16_t nat_ports_free(struct stack *stack, int protocol, u16_t port) { switch (protocol) { case IP_PROTO_ICMP4: case IP_PROTO_ICMP: nat_ports_unset(stack->stack_nat->nat_icmp_table, ICMP_MIN_PORT, port); break; case IP_PROTO_TCP: nat_ports_unset(stack->stack_nat->nat_tcp_table, TCP_MIN_PORT, port); break; case IP_PROTO_UDP: nat_ports_unset(stack->stack_nat->nat_udp_table, UDP_MIN_PORT, port); break; default: return -1; break; } return 1; } #endif /* LWIP_NAT */ lwipv6-1.5a/lwip-v6/src/userfilter/nat/nat_track_proto_tcp.c0000644000175000017500000010421411671615005023273 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* (C) 1999-2001 Paul `Rusty' Russell * (C) 2002-2004 Netfilter Core Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * Jozsef Kadlecsik : * - Real stateful connection tracking * - Modified state transitions table * - Window scaling support added * - SACK support added * * Willy Tarreau: * - State table bugfixes * - More robust state changes * - Tuning timer parameters * * version 2.2 */ #include "lwip/opt.h" #if LWIP_USERFILTER && LWIP_NAT #include "lwip/debug.h" #include "lwip/memp.h" /* MEMP_NAT_RULE */ #include "lwip/sys.h" #include "lwip/inet.h" #include "lwip/ip.h" #include "lwip/tcp.h" #include "netif/etharp.h" #include "lwip/netif.h" #include "lwip/userfilter.h" #include "lwip/nat/nat.h" #include "lwip/nat/nat_tables.h" #ifndef NAT_TCP_DEBUG #define NAT_TCP_DEBUG DBG_OFF #endif /*--------------------------------------------------------------------------*/ int track_tcp_tuple(struct ip_tuple *tuple, void *hdr) { struct tcp_hdr *tcphdr = NULL; tcphdr = (struct tcp_hdr *) hdr; tuple->src.proto.upi.tcp.port = tcphdr->src; tuple->dst.proto.upi.tcp.port = tcphdr->dest; return 1; } int track_tcp_inverse(struct ip_tuple *reply, struct ip_tuple *tuple) { reply->src.proto.upi.tcp.port = tuple->dst.proto.upi.tcp.port; reply->dst.proto.upi.tcp.port = tuple->src.proto.upi.tcp.port; return 1; } /*--------------------------------------------------------------------------*/ int track_tcp_error (struct stack *stack, uf_verdict_t *verdict, struct pbuf *p) { // FIX: check packet len and checksum return 1; } int nat_tcp_manip (nat_manip_t type, void *iphdr, int iplen, struct ip_tuple *inverse, u8_t *iphdr_new_changed_buf, u8_t *iphdr_old_changed_buf, u32_t iphdr_changed_buflen) { struct tcp_hdr *tcphdr = NULL; u16_t old_value; tcphdr = (struct tcp_hdr *) (iphdr+iplen); // Adjust tcp checksum nat_chksum_adjust((u8_t *) & tcphdr->chksum, (u8_t *) iphdr_old_changed_buf, iphdr_changed_buflen, (u8_t *) iphdr_new_changed_buf, iphdr_changed_buflen); // Set port if (type == MANIP_DST) { old_value = tcphdr->dest; tcphdr->dest = inverse->src.proto.upi.tcp.port; nat_chksum_adjust((u8_t *) & tcphdr->chksum, (u8_t *) & old_value, 2, (u8_t *) & tcphdr->dest, 2); } else if (type == MANIP_SRC) { old_value= tcphdr->src; tcphdr->src = inverse->dst.proto.upi.tcp.port; nat_chksum_adjust((u8_t *) & tcphdr->chksum, (u8_t *) & old_value, 2, (u8_t *) & tcphdr->src, 2); } return 1; } int nat_tcp_tuple_inverse (struct stack *stack, struct ip_tuple *reply, struct ip_tuple *tuple, nat_type_t type, struct manip_range *nat_manip ) { u16_t port; u32_t min, max; if (type == NAT_SNAT) { if (nat_manip->flag & MANIP_RANGE_PROTO) { min = nat_manip->protomin.value; max = nat_manip->protomax.value; } else { min = 0; max = 0xFFFF; } if (nat_ports_getnew(stack, IP_PROTO_TCP, &port, min, max) > 0) { reply->dst.proto.upi.tcp.port = htons(port); } else return -1; } else if (type == NAT_DNAT) { if (nat_manip->flag & MANIP_RANGE_PROTO) { reply->src.proto.upi.tcp.port = nat_manip->protomin.value; } } return 1; } int nat_tcp_free (struct nat_pcb *pcb) { if (pcb->nat_type == NAT_SNAT) { nat_ports_free(pcb->stack, IP_PROTO_TCP, ntohs(pcb->tuple[CONN_DIR_REPLY].dst.proto.upi.tcp.port)); } return 1; } /*--------------------------------------------------------------------------*/ /* Code from GNU/Linux Netfilter/IPtables code. */ /*--------------------------------------------------------------------------*/ #define NF_ACCEPT UF_ACCEPT #define NF_DROP UF_DROP #define NF_REPEAT UF_REPEAT #define skb_header_pointer(skb, offset, len, buffer) (((char*)(skb)->payload)+offset) #define write_lock_bh(x) sys_sem_wait ((*(x))) #define write_unlock_bh(x) sys_sem_signal((*(x))) #define read_lock_bh(x) sys_sem_wait ((*(x))) #define read_unlock_bh(x) sys_sem_signal((*(x))) # define TCPOPT_EOL 0 # define TCPOPT_NOP 1 # define TCPOPT_MAXSEG 2 # define TCPOLEN_MAXSEG 4 # define TCPOPT_WINDOW 3 # define TCPOLEN_WINDOW 3 # define TCPOPT_SACK_PERMITTED 4 /* Experimental */ # define TCPOLEN_SACK_PERMITTED 2 # define TCPOPT_SACK 5 /* Experimental */ # define TCPOPT_TIMESTAMP 8 # define TCPOLEN_TIMESTAMP 10 # define TCPOLEN_TSTAMP_APPA (TCPOLEN_TIMESTAMP+2) /* appendix A */ # define TCPOPT_TSTAMP_HDR \ (TCPOPT_NOP<<24|TCPOPT_NOP<<16|TCPOPT_TIMESTAMP<<8|TCPOLEN_TIMESTAMP) /* * Default maximum segment size for TCP. * With an IP MSS of 576, this is 536, * but 512 is probably more convenient. * This should be defined as MIN(512, IP_MSS - sizeof (struct tcpiphdr)). */ //#define TCP_MSS 512 #define TCP_MAXWIN 65535 /* largest value for (unscaled) window */ #define TCP_MAX_WINSHIFT 14 /* maximum window shift */ #define SOL_TCP 6 /* TCP level */ /* * TCP option */ #define TCPOPT_NOP 1 /* Padding */ #define TCPOPT_EOL 0 /* End of options */ #define TCPOPT_MSS 2 /* Segment size negotiating */ #define TCPOPT_WINDOW 3 /* Window scaling */ #define TCPOPT_SACK_PERM 4 /* SACK Permitted */ #define TCPOPT_SACK 5 /* SACK Block */ #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ /* * TCP option lengths */ #define TCPOLEN_MSS 4 #define TCPOLEN_WINDOW 3 #define TCPOLEN_SACK_PERM 2 #define TCPOLEN_TIMESTAMP 10 /* But this is what stacks really send out. */ #define TCPOLEN_TSTAMP_ALIGNED 12 #define TCPOLEN_WSCALE_ALIGNED 4 #define TCPOLEN_SACKPERM_ALIGNED 4 #define TCPOLEN_SACK_BASE 2 #define TCPOLEN_SACK_BASE_ALIGNED 4 #define TCPOLEN_SACK_PERBLOCK 8 /* * net/tcp.h */ /* * The next routines deal with comparing 32 bit unsigned ints * and worry about wraparound (automatic with unsigned arithmetic). */ static inline int before(u32_t seq1, u32_t seq2) { return ((s32_t)(seq1-seq2)) < 0; } static inline int after(u32_t seq1, u32_t seq2) { return ((s32_t)(seq2-seq1)) < 0; } /* is s2<=s1<=s3 ? */ static inline int between(u32_t seq1, u32_t seq2, u32_t seq3) { return seq3 - seq2 >= seq1 - seq2; } /* "Be conservative in what you do, be liberal in what you accept from others." If it's non-zero, we mark only out of window RST segments as INVALID. */ int ip_ct_tcp_be_liberal = 0; /* When connection is picked up from the middle, how many packets are required to pass in each direction when we assume we are in sync - if any side uses window scaling, we lost the game. If it is set to zero, we disable picking up already established connections. */ //int ip_ct_tcp_loose = 3; int ip_ct_tcp_loose = 0; /* Max number of the retransmitted packets without receiving an (acceptable) ACK from the destination. If this number is reached, a shorter timer will be started. */ int ip_ct_tcp_max_retrans = 3; /* FIXME: Examine ipfilter's timeouts and conntrack transitions more closely. They're more complex. --RR */ #if 0 static const char *tcp_conntrack_names[] = { "NONE", "SYN_SENT", "SYN_RECV", "ESTABLISHED", "FIN_WAIT", "CLOSE_WAIT", "LAST_ACK", "TIME_WAIT", "CLOSE", "LISTEN" }; #endif /* ATTENTION: lwip uses microseconds!!! */ #define HZ 1000 #define SECS * HZ #define MINS * 60 SECS #define HOURS * 60 MINS #define DAYS * 24 HOURS unsigned long ip_ct_tcp_timeout_syn_sent = 2 MINS; unsigned long ip_ct_tcp_timeout_syn_recv = 60 SECS; unsigned long ip_ct_tcp_timeout_established = 5 DAYS; unsigned long ip_ct_tcp_timeout_fin_wait = 2 MINS; unsigned long ip_ct_tcp_timeout_close_wait = 60 SECS; unsigned long ip_ct_tcp_timeout_last_ack = 30 SECS; unsigned long ip_ct_tcp_timeout_time_wait = 2 MINS; unsigned long ip_ct_tcp_timeout_close = 10 SECS; /* RFC1122 says the R2 limit should be at least 100 seconds. Linux uses 15 packets as limit, which corresponds to ~13-30min depending on RTO. */ unsigned long ip_ct_tcp_timeout_max_retrans = 5 MINS; static unsigned long * tcp_timeouts[] = { NULL, /* TCP_CONNTRACK_NONE */ &ip_ct_tcp_timeout_syn_sent, /* TCP_CONNTRACK_SYN_SENT, */ &ip_ct_tcp_timeout_syn_recv, /* TCP_CONNTRACK_SYN_RECV, */ &ip_ct_tcp_timeout_established, /* TCP_CONNTRACK_ESTABLISHED, */ &ip_ct_tcp_timeout_fin_wait, /* TCP_CONNTRACK_FIN_WAIT, */ &ip_ct_tcp_timeout_close_wait, /* TCP_CONNTRACK_CLOSE_WAIT, */ &ip_ct_tcp_timeout_last_ack, /* TCP_CONNTRACK_LAST_ACK, */ &ip_ct_tcp_timeout_time_wait, /* TCP_CONNTRACK_TIME_WAIT, */ &ip_ct_tcp_timeout_close, /* TCP_CONNTRACK_CLOSE, */ NULL, /* TCP_CONNTRACK_LISTEN */ }; #define sNO TCP_CONNTRACK_NONE #define sSS TCP_CONNTRACK_SYN_SENT #define sSR TCP_CONNTRACK_SYN_RECV #define sES TCP_CONNTRACK_ESTABLISHED #define sFW TCP_CONNTRACK_FIN_WAIT #define sCW TCP_CONNTRACK_CLOSE_WAIT #define sLA TCP_CONNTRACK_LAST_ACK #define sTW TCP_CONNTRACK_TIME_WAIT #define sCL TCP_CONNTRACK_CLOSE #define sLI TCP_CONNTRACK_LISTEN #define sIV TCP_CONNTRACK_MAX #define sIG TCP_CONNTRACK_IGNORE /* What TCP flags are set from RST/SYN/FIN/ACK. */ enum tcp_bit_set { TCP_SYN_SET, TCP_SYNACK_SET, TCP_FIN_SET, TCP_ACK_SET, TCP_RST_SET, TCP_NONE_SET, }; /* * The TCP state transition table needs a few words... * * We are the man in the middle. All the packets go through us * but might get lost in transit to the destination. * It is assumed that the destinations can't receive segments * we haven't seen. * * The checked segment is in window, but our windows are *not* * equivalent with the ones of the sender/receiver. We always * try to guess the state of the current sender. * * The meaning of the states are: * * NONE: initial state * SYN_SENT: SYN-only packet seen * SYN_RECV: SYN-ACK packet seen * ESTABLISHED: ACK packet seen * FIN_WAIT: FIN packet seen * CLOSE_WAIT: ACK seen (after FIN) * LAST_ACK: FIN seen (after FIN) * TIME_WAIT: last ACK seen * CLOSE: closed connection * * LISTEN state is not used. * * Packets marked as IGNORED (sIG): * if they may be either invalid or valid * and the receiver may send back a connection * closing RST or a SYN/ACK. * * Packets marked as INVALID (sIV): * if they are invalid * or we do not support the request (simultaneous open) */ static enum tcp_conntrack tcp_conntracks[2][6][TCP_CONNTRACK_MAX] = { { /* ORIGINAL */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*syn*/ { sSS, sSS, sIG, sIG, sIG, sIG, sIG, sSS, sSS, sIV }, /* * sNO -> sSS Initialize a new connection * sSS -> sSS Retransmitted SYN * sSR -> sIG Late retransmitted SYN? * sES -> sIG Error: SYNs in window outside the SYN_SENT state * are errors. Receiver will reply with RST * and close the connection. * Or we are not in sync and hold a dead connection. * sFW -> sIG * sCW -> sIG * sLA -> sIG * sTW -> sSS Reopened connection (RFC 1122). * sCL -> sSS */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*synack*/ { sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV }, /* * A SYN/ACK from the client is always invalid: * - either it tries to set up a simultaneous open, which is * not supported; * - or the firewall has just been inserted between the two hosts * during the session set-up. The SYN will be retransmitted * by the true client (or it'll time out). */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*fin*/ { sIV, sIV, sFW, sFW, sLA, sLA, sLA, sTW, sCL, sIV }, /* * sNO -> sIV Too late and no reason to do anything... * sSS -> sIV Client migth not send FIN in this state: * we enforce waiting for a SYN/ACK reply first. * sSR -> sFW Close started. * sES -> sFW * sFW -> sLA FIN seen in both directions, waiting for * the last ACK. * Migth be a retransmitted FIN as well... * sCW -> sLA * sLA -> sLA Retransmitted FIN. Remain in the same state. * sTW -> sTW * sCL -> sCL */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*ack*/ { sES, sIV, sES, sES, sCW, sCW, sTW, sTW, sCL, sIV }, /* * sNO -> sES Assumed. * sSS -> sIV ACK is invalid: we haven't seen a SYN/ACK yet. * sSR -> sES Established state is reached. * sES -> sES :-) * sFW -> sCW Normal close request answered by ACK. * sCW -> sCW * sLA -> sTW Last ACK detected. * sTW -> sTW Retransmitted last ACK. Remain in the same state. * sCL -> sCL */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*rst*/ { sIV, sCL, sCL, sCL, sCL, sCL, sCL, sCL, sCL, sIV }, /*none*/ { sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV } }, { /* REPLY */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*syn*/ { sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV }, /* * sNO -> sIV Never reached. * sSS -> sIV Simultaneous open, not supported * sSR -> sIV Simultaneous open, not supported. * sES -> sIV Server may not initiate a connection. * sFW -> sIV * sCW -> sIV * sLA -> sIV * sTW -> sIV Reopened connection, but server may not do it. * sCL -> sIV */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*synack*/ { sIV, sSR, sSR, sIG, sIG, sIG, sIG, sIG, sIG, sIV }, /* * sSS -> sSR Standard open. * sSR -> sSR Retransmitted SYN/ACK. * sES -> sIG Late retransmitted SYN/ACK? * sFW -> sIG Might be SYN/ACK answering ignored SYN * sCW -> sIG * sLA -> sIG * sTW -> sIG * sCL -> sIG */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*fin*/ { sIV, sIV, sFW, sFW, sLA, sLA, sLA, sTW, sCL, sIV }, /* * sSS -> sIV Server might not send FIN in this state. * sSR -> sFW Close started. * sES -> sFW * sFW -> sLA FIN seen in both directions. * sCW -> sLA * sLA -> sLA Retransmitted FIN. * sTW -> sTW * sCL -> sCL */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*ack*/ { sIV, sIV, sSR, sES, sCW, sCW, sTW, sTW, sCL, sIV }, /* * sSS -> sIV Might be a half-open connection. * sSR -> sSR Might answer late resent SYN. * sES -> sES :-) * sFW -> sCW Normal close request answered by ACK. * sCW -> sCW * sLA -> sTW Last ACK detected. * sTW -> sTW Retransmitted last ACK. * sCL -> sCL */ /* sNO, sSS, sSR, sES, sFW, sCW, sLA, sTW, sCL, sLI */ /*rst*/ { sIV, sCL, sCL, sCL, sCL, sCL, sCL, sCL, sCL, sIV }, /*none*/ { sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV, sIV } } }; static unsigned int get_conntrack_index(const struct tcp_hdr *tcph) { if ( TCPH_FLAGS(tcph) & TCP_RST) return TCP_RST_SET; else if ( TCPH_FLAGS(tcph) & TCP_SYN) return ((TCPH_FLAGS(tcph) & TCP_ACK) ? TCP_SYNACK_SET : TCP_SYN_SET); else if ( TCPH_FLAGS(tcph) & TCP_FIN) return TCP_FIN_SET; else if ( TCPH_FLAGS(tcph) & TCP_ACK) return TCP_ACK_SET; else return TCP_NONE_SET; } static inline u32_t segment_seq_plus_len(u32_t seq, size_t len, void *iph, struct tcp_hdr *tcph) { int iplen; struct ip4_hdr *ip4hdr = (struct ip4_hdr *) iph; struct ip_hdr *ip6hdr = (struct ip_hdr *) iph; if (IPH_V(ip6hdr) == 6) iplen = IP_HLEN; else if (IPH_V(ip6hdr) == 4) iplen = IPH4_HL(ip4hdr)*4; return ( seq + len - (iplen + ( TCPH_HDRLEN(tcph)*4)) + ((TCPH_FLAGS(tcph) & TCP_SYN) ? 1 : 0) + ((TCPH_FLAGS(tcph) & TCP_FIN) ? 1 : 0)); } /* Fixme: what about big packets? */ #define MAXACKWINCONST 66000 #define MAXACKWINDOW(sender) \ ((sender)->td_maxwin > MAXACKWINCONST ? (sender)->td_maxwin \ : MAXACKWINCONST) /* * Simplified tcp_parse_options routine from tcp_input.c */ static void tcp_options(const struct pbuf *skb, void *iph, struct tcp_hdr *tcph, struct ip_ct_tcp_state *state) { // unsigned char buff[(15 * 4) - sizeof(struct tcp_hdr)]; unsigned char *ptr; int length = ( TCPH_HDRLEN(tcph)*4) - sizeof(struct tcp_hdr); /* added by Diego Billi */ int iplen; struct ip4_hdr *ip4hdr = (struct ip4_hdr *) iph; struct ip_hdr *ip6hdr = (struct ip_hdr *) iph; if (IPH_V(ip6hdr) == 6) iplen = IP_HLEN; else if (IPH_V(ip6hdr) == 4) iplen = IPH4_HL(ip4hdr) * 4; //LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: length=%d.\n", __func__, length)); if (!length) { return; } ptr = (unsigned char *) skb_header_pointer(skb, iplen + sizeof(struct tcp_hdr), length, buff); state->td_scale = state->flags = 0; while (length > 0) { int opcode=*ptr++; int opsize; switch (opcode) { case TCPOPT_EOL: return; case TCPOPT_NOP: // Ref: RFC 793 section 3.1 length--; continue; default: opsize=*ptr++; if (opsize < 2) { // "silly options" return; } if (opsize > length) { break; // don't parse partial options } if (opcode == TCPOPT_SACK_PERM && opsize == TCPOLEN_SACK_PERM) { state->flags |= IP_CT_TCP_FLAG_SACK_PERM; } else if (opcode == TCPOPT_WINDOW && opsize == TCPOLEN_WINDOW) { state->td_scale = *(u8_t *)ptr; if (state->td_scale > 14) { // See RFC1323 state->td_scale = 14; } state->flags |= IP_CT_TCP_FLAG_WINDOW_SCALE; } ptr += opsize - 2; length -= opsize; } } } static void tcp_sack(const struct pbuf *skb, void *iph, struct tcp_hdr *tcph, u32_t *sack) { //unsigned char buff[(15 * 4) - sizeof(struct tcp_hdr)]; unsigned char *ptr; int length = ( TCPH_HDRLEN(tcph)*4) - sizeof(struct tcp_hdr); u32_t tmp; /* added by Diego Billi */ int iplen; struct ip4_hdr *ip4hdr = (struct ip4_hdr *) iph; struct ip_hdr *ip6hdr = (struct ip_hdr *) iph; if (IPH_V(ip6hdr) == 6) iplen = IP_HLEN; else if (IPH_V(ip6hdr) == 4) iplen = IPH4_HL(ip4hdr) * 4; //LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: length=%d. %d %d\n", __func__, length, ( TCPH_HDRLEN(tcph)*4), sizeof(struct tcp_hdr))); if (!length) { return; } ptr = (unsigned char *) skb_header_pointer(skb, iplen + sizeof(struct tcp_hdr), length, buff); //BUG_ON(ptr == NULL); /* Fast path for timestamp-only option */ if (length == TCPOLEN_TSTAMP_ALIGNED*4 && *(u32_t *)ptr == // __constant_ntohl((TCPOPT_NOP << 24) ntohl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { return; } while (length > 0) { int opcode=*ptr++; int opsize, i; switch (opcode) { case TCPOPT_EOL: return; case TCPOPT_NOP: // Ref: RFC 793 section 3.1 length--; continue; default: opsize=*ptr++; if (opsize < 2) { // "silly options" return; } if (opsize > length) { break; // don't parse partial options } if (opcode == TCPOPT_SACK && opsize >= (TCPOLEN_SACK_BASE + TCPOLEN_SACK_PERBLOCK) && !((opsize - TCPOLEN_SACK_BASE) % TCPOLEN_SACK_PERBLOCK)) { for (i = 0; i < (opsize - TCPOLEN_SACK_BASE); i += TCPOLEN_SACK_PERBLOCK) { tmp = ntohl(*((u32_t *)(ptr+i)+1)); if (after(tmp, *sack)) *sack = tmp; } return; } ptr += opsize - 2; length -= opsize; } } } static int tcp_in_window(struct ip_ct_tcp *state, //enum ip_conntrack_dir dir, u32_t dir, unsigned int index, const struct pbuf *skb, void *iph, struct tcp_hdr *tcph) { struct ip_ct_tcp_state *sender = &state->seen[dir]; struct ip_ct_tcp_state *receiver = &state->seen[!dir]; u32_t seq, ack, sack, end, win, swin; int res; /* * Get the required data from the packet. */ seq = ntohl(tcph->seqno); /* ntohl(tcph->seq); */ ack = sack = ntohl(tcph->ackno); /* ntohl(tcph->ack_seq); */ win = ntohs(tcph->wnd); /* ntohs(tcph->window); */ end = segment_seq_plus_len(seq, skb->tot_len, iph, tcph); if (receiver->flags & IP_CT_TCP_FLAG_SACK_PERM) tcp_sack(skb, iph, tcph, &sack); if (sender->td_end == 0) { /* * Initialize sender data. */ if ((TCPH_FLAGS(tcph) & TCP_SYN) && (TCPH_FLAGS(tcph) & TCP_ACK)) { /* * Outgoing SYN-ACK in reply to a SYN. */ sender->td_end = sender->td_maxend = end; sender->td_maxwin = (win == 0 ? 1 : win); tcp_options(skb, iph, tcph, sender); /* * RFC 1323: * Both sides must send the Window Scale option * to enable window scaling in either direction. */ if (!(sender->flags & IP_CT_TCP_FLAG_WINDOW_SCALE && receiver->flags & IP_CT_TCP_FLAG_WINDOW_SCALE)) sender->td_scale = receiver->td_scale = 0; } else { /* * We are in the middle of a connection, * its history is lost for us. * Let's try to use the data from the packet. */ sender->td_end = end; sender->td_maxwin = (win == 0 ? 1 : win); sender->td_maxend = end + sender->td_maxwin; } } else if (((state->state == TCP_CONNTRACK_SYN_SENT //&& dir == IP_CT_DIR_ORIGINAL) && dir == CONN_DIR_ORIGINAL) || (state->state == TCP_CONNTRACK_SYN_RECV //&& dir == IP_CT_DIR_REPLY)) && dir == CONN_DIR_REPLY)) && after(end, sender->td_end)) { /* * RFC 793: "if a TCP is reinitialized ... then it need * not wait at all; it must only be sure to use sequence * numbers larger than those recently used." */ sender->td_end = sender->td_maxend = end; sender->td_maxwin = (win == 0 ? 1 : win); tcp_options(skb, iph, tcph, sender); } if (!(TCPH_FLAGS(tcph) & TCP_ACK)) { /* * If there is no ACK, just pretend it was set and OK. */ ack = sack = receiver->td_end; LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: 2e\n", __func__)); } else if (((TCPH_FLAGS(tcph) & (TCP_ACK|TCP_RST)) == (TCP_ACK|TCP_RST)) && (ack == 0)) { /* * Broken TCP stacks, that set ACK in RST packets as well * with zero ack value. */ ack = sack = receiver->td_end; } if (seq == end && (!(TCPH_FLAGS(tcph) & TCP_RST) || (seq == 0 && state->state == TCP_CONNTRACK_SYN_SENT))) /* * Packets contains no data: we assume it is valid * and check the ack value only. * However RST segments are always validated by their * SEQ number, except when seq == 0 (reset sent answering * SYN. */ seq = end = sender->td_end; if (sender->loose || receiver->loose || (before(seq, sender->td_maxend + 1) && after(end, sender->td_end - receiver->td_maxwin - 1) && before(sack, receiver->td_end + 1) && after(ack, receiver->td_end - MAXACKWINDOW(sender)))) { /* * Take into account window scaling (RFC 1323). */ if (!(TCPH_FLAGS(tcph) & TCP_SYN)) win <<= sender->td_scale; /* * Update sender data. */ swin = win + (sack - ack); if (sender->td_maxwin < swin) sender->td_maxwin = swin; if (after(end, sender->td_end)) sender->td_end = end; /* * Update receiver data. */ if (after(end, sender->td_maxend)) receiver->td_maxwin += end - sender->td_maxend; if (after(sack + win, receiver->td_maxend - 1)) { receiver->td_maxend = sack + win; if (win == 0) receiver->td_maxend++; } /* * Check retransmissions. */ if (index == TCP_ACK_SET) { if (state->last_dir == dir && state->last_seq == seq && state->last_ack == ack && state->last_end == end) state->retrans++; else { state->last_dir = dir; state->last_seq = seq; state->last_ack = ack; state->last_end = end; state->retrans = 0; } } /* * Close the window of disabled window tracking :-) */ if (sender->loose) sender->loose--; res = 1; } else { res = ip_ct_tcp_be_liberal; } return res; } #define TH_FIN 0x01 #define TH_SYN 0x02 #define TH_RST 0x04 #define TH_PUSH 0x08 #define TH_ACK 0x10 #define TH_URG 0x20 #define TH_ECE 0x40 #define TH_CWR 0x80 #if 0 /* table of valid flag combinations - ECE and CWR are always valid */ static u8_t tcp_valid_flags[(TH_FIN|TH_SYN|TH_RST|TH_PUSH|TH_ACK|TH_URG) + 1] = { [TH_SYN] = 1, [TH_SYN|TH_ACK] = 1, [TH_SYN|TH_ACK|TH_PUSH] = 1, [TH_RST] = 1, [TH_RST|TH_ACK] = 1, [TH_RST|TH_ACK|TH_PUSH] = 1, [TH_FIN|TH_ACK] = 1, [TH_ACK] = 1, [TH_ACK|TH_PUSH] = 1, [TH_ACK|TH_URG] = 1, [TH_ACK|TH_URG|TH_PUSH] = 1, [TH_FIN|TH_ACK|TH_PUSH] = 1, [TH_FIN|TH_ACK|TH_URG] = 1, [TH_FIN|TH_ACK|TH_URG|TH_PUSH] = 1, }; #endif /* Returns verdict for packet, or -1 for invalid. */ static int track_tcp_handle2(struct stack *stack, uf_verdict_t *verdict, struct pbuf *skb, conn_dir_t direction) { enum tcp_conntrack new_state, old_state; //enum ip_conntrack_dir dir; u32_t dir; unsigned long timeout; unsigned int index; struct nat_pcb *pcb = skb->nat.track; /* added by Diego Billi */ int dataoff; struct ip4_hdr *iph = (struct ip4_hdr *) skb->payload; struct ip_hdr *ip6hdr = (struct ip_hdr *) skb->payload; struct tcp_hdr *th;// _tcph; if (IPH_V(ip6hdr) == 6) dataoff = IP_HLEN; else if (IPH_V(ip6hdr) == 4) dataoff = IPH4_HL(iph) * 4; th = (struct tcp_hdr *) skb_header_pointer(skb, dataoff, sizeof(_tcph), &_tcph); write_lock_bh(&stack->stack_nat->tcp_lock); old_state = pcb->proto.TCP.state; //dir = CTINFO2DIR(ctinfo); dir = direction; index = get_conntrack_index(th); new_state = tcp_conntracks[dir][index][old_state]; LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: old=%s new=%s\n", __func__, TCP_STRSTATE(old_state), TCP_STRSTATE(new_state) )); switch (new_state) { case TCP_CONNTRACK_IGNORE: LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: CONNTRACK IGNORE\n", __func__)); /* Either SYN in ORIGINAL * or SYN/ACK in REPLY. */ if (index == TCP_SYNACK_SET && pcb->proto.TCP.last_index == TCP_SYN_SET && pcb->proto.TCP.last_dir != dir && ntohl(th->ackno) == pcb->proto.TCP.last_end) { /* This SYN/ACK acknowledges a SYN that we earlier * ignored as invalid. This means that the client and * the server are both in sync, while the firewall is * not. We kill this session and block the SYN/ACK so * that the client cannot but retransmit its SYN and * thus initiate a clean new session. */ write_unlock_bh(&stack->stack_nat->tcp_lock); if (conn_remove_timer(pcb)) conn_force_timeout(pcb); //return -NF_DROP; * verdict = UF_DROP; return -1; } pcb->proto.TCP.last_index = index; pcb->proto.TCP.last_dir = dir; pcb->proto.TCP.last_seq = ntohl(th->seqno); pcb->proto.TCP.last_end = segment_seq_plus_len(ntohl(th->seqno), skb->tot_len, iph, th); write_unlock_bh(&stack->stack_nat->tcp_lock); //return NF_ACCEPT; * verdict = UF_ACCEPT; return 1; case TCP_CONNTRACK_MAX: /* Invalid packet */ write_unlock_bh(&stack->stack_nat->tcp_lock); // return -NF_ACCEPT; * verdict = UF_ACCEPT; return -1; case TCP_CONNTRACK_SYN_SENT: if (old_state < TCP_CONNTRACK_TIME_WAIT) break; if ((pcb->proto.TCP.seen[dir].flags & IP_CT_TCP_FLAG_CLOSE_INIT) || after(ntohl(th->seqno), pcb->proto.TCP.seen[dir].td_end)) { /* Attempt to reopen a closed connection. * Delete this connection and look up again. */ write_unlock_bh(&stack->stack_nat->tcp_lock); if (conn_remove_timer(pcb)) conn_force_timeout(pcb); LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: need REPEAT\n", __func__)); //return -NF_REPEAT; * verdict = UF_REPEAT; return -1; } else { write_unlock_bh(&stack->stack_nat->tcp_lock); //return -NF_ACCEPT; * verdict = UF_ACCEPT; return -1; } case TCP_CONNTRACK_CLOSE: LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: CLOSE\n", __func__)); if (index == TCP_RST_SET //&& test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status) && (pcb->status & TS_SEEN_REPLY) && pcb->proto.TCP.last_index == TCP_SYN_SET && ntohl(th->ackno) == pcb->proto.TCP.last_end) { /* RST sent to invalid SYN we had let trough * SYN was in window then, tear down connection. * We skip window checking, because packet might ACK * segments we ignored in the SYN. */ goto in_window; } /* Just fall trough */ default: /* Keep compilers happy. */ break; } if (!tcp_in_window(&pcb->proto.TCP, dir, index, skb, iph, th)) { LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: ! in window\n", __func__)); write_unlock_bh(&stack->stack_nat->tcp_lock); //return -NF_ACCEPT; * verdict = UF_ACCEPT; return -1; } in_window: /* From now on we have got in-window packets */ pcb->proto.TCP.last_index = index; pcb->proto.TCP.state = new_state; if (old_state != new_state && (new_state == TCP_CONNTRACK_FIN_WAIT || new_state == TCP_CONNTRACK_CLOSE)) pcb->proto.TCP.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT; timeout = pcb->proto.TCP.retrans >= ip_ct_tcp_max_retrans && *tcp_timeouts[new_state] > ip_ct_tcp_timeout_max_retrans ? ip_ct_tcp_timeout_max_retrans : *tcp_timeouts[new_state]; write_unlock_bh(&stack->stack_nat->tcp_lock); //if (!test_bit(IPS_SEEN_REPLY_BIT, &conntrack->status)) { if (!(TS_SEEN_REPLY & pcb->status)) { LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: ! SEEN REPLY \n", __func__)); /* If only reply is a RST, we can consider ourselves not to have an established connection: this is a fairly common problem case, so we can delete the conntrack immediately. --RR */ if (TCPH_FLAGS(th) & TCP_RST) { if (conn_remove_timer(pcb)) conn_force_timeout(pcb); // return NF_ACCEPT; * verdict = UF_ACCEPT; return 1; } /// } else if (!test_bit(IPS_ASSURED_BIT, &conntrack->status) /// && (old_state == TCP_CONNTRACK_SYN_RECV /// || old_state == TCP_CONNTRACK_ESTABLISHED) // && new_state == TCP_CONNTRACK_ESTABLISHED) { /* Set ASSURED if we see see valid ack in ESTABLISHED after SYN_RECV or a valid answer for a picked up connection. */ /// set_bit(IPS_ASSURED_BIT, &conntrack->status); } LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: new timer %d\n", __func__, (unsigned int) timeout)); // ip_ct_refresh_acct(conntrack, ctinfo, skb, timeout); conn_refresh_timer(timeout, pcb); //return NF_ACCEPT; * verdict = UF_ACCEPT; return 1; } int track_tcp_new2(struct stack *stack, struct nat_pcb *pcb, struct pbuf *p, void *iph, int iplen) { enum tcp_conntrack new_state; #ifdef DEBUGP_VARS //struct ip_ct_tcp_state *sender = &conntrack->proto.tcp.seen[0]; //struct ip_ct_tcp_state *receiver = &conntrack->proto.tcp.seen[1]; struct ip_ct_tcp_state *sender = &pcb->proto.TCP.seen[0]; struct ip_ct_tcp_state *receiver = &pcb->proto.TCP.seen[1]; #endif //int dataoff; //struct ip4_hdr *iph = (struct ip4_hdr *) skb->payload; //struct ip_hdr *ip6hdr = (struct ip_hdr *) skb->payload; struct tcp_hdr *th;// _tcph; //if (IPH_V(ip6hdr) == 6) dataoff = IP_HLEN; //else if (IPH_V(ip6hdr) == 4) dataoff = IPH4_HL(iph) * 4; //th = (struct tcp_hdr *) skb_header_pointer(skb, dataoff, sizeof(_tcph), &_tcph); th = (struct tcp_hdr *) (((char*)iph)+iplen); /* Don't need lock here: this conntrack not in circulation yet */ new_state = tcp_conntracks[0][get_conntrack_index(th)][TCP_CONNTRACK_NONE]; /* Invalid: delete conntrack */ if (new_state >= TCP_CONNTRACK_MAX) { return 0; } if (new_state == TCP_CONNTRACK_SYN_SENT) { LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: SYN SENT\n", __func__)); /* SYN packet */ //conntrack->proto.tcp.seen[0].td_end = segment_seq_plus_len(ntohl(th->seqno), skb->tot_len, iph, th); pcb->proto.TCP.seen[0].td_end = segment_seq_plus_len(ntohl(th->seqno), p->tot_len, iph, th); pcb->proto.TCP.seen[0].td_maxwin = ntohs(th->wnd); if (pcb->proto.TCP.seen[0].td_maxwin == 0) pcb->proto.TCP.seen[0].td_maxwin = 1; pcb->proto.TCP.seen[0].td_maxend = pcb->proto.TCP.seen[0].td_end; tcp_options(p, iph, th, &pcb->proto.TCP.seen[0]); pcb->proto.TCP.seen[1].flags = 0; pcb->proto.TCP.seen[0].loose = pcb->proto.TCP.seen[1].loose = 0; } else if (ip_ct_tcp_loose == 0) { /* Don't try to pick up connections. */ return 0; } else { LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: TCP LOOSE\n", __func__)); /* * We are in the middle of a connection, * its history is lost for us. * Let's try to use the data from the packet. */ pcb->proto.TCP.seen[0].td_end = segment_seq_plus_len(ntohl(th->seqno), p->tot_len, iph, th); pcb->proto.TCP.seen[0].td_maxwin = ntohs(th->wnd); if (pcb->proto.TCP.seen[0].td_maxwin == 0) pcb->proto.TCP.seen[0].td_maxwin = 1; pcb->proto.TCP.seen[0].td_maxend = pcb->proto.TCP.seen[0].td_end + pcb->proto.TCP.seen[0].td_maxwin; pcb->proto.TCP.seen[0].td_scale = 0; /* We assume SACK. Should we assume window scaling too? */ pcb->proto.TCP.seen[0].flags = pcb->proto.TCP.seen[1].flags = IP_CT_TCP_FLAG_SACK_PERM; pcb->proto.TCP.seen[0].loose = pcb->proto.TCP.seen[1].loose = ip_ct_tcp_loose; } pcb->proto.TCP.seen[1].td_end = 0; pcb->proto.TCP.seen[1].td_maxend = 0; pcb->proto.TCP.seen[1].td_maxwin = 1; pcb->proto.TCP.seen[1].td_scale = 0; /* tcp_packet will set them */ pcb->proto.TCP.state = TCP_CONNTRACK_NONE; pcb->proto.TCP.last_index = TCP_NONE_SET; LWIP_DEBUGF(NAT_TCP_DEBUG, ("%s: end\n", __func__)); return 1; } /*--------------------------------------------------------------------------*/ struct track_protocol tcp_track = { .tuple = track_tcp_tuple, .inverse = track_tcp_inverse, .error = track_tcp_error, .new = track_tcp_new2, .handle = track_tcp_handle2, .manip = nat_tcp_manip, .nat_tuple_inverse = nat_tcp_tuple_inverse, .nat_free = nat_tcp_free }; /* added by Diego Billi */ int ip_conntrack_protocol_tcp_lockinit(struct stack *stack) { stack->stack_nat->tcp_lock = sys_sem_new(1); return 0; } #endif lwipv6-1.5a/lwip-v6/src/userfilter/nat/nat_track_proto_generic.c0000644000175000017500000000554411671615005024127 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if LWIP_USERFILTER && LWIP_NAT #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/memp.h" /* MEMP_NAT_RULE */ #include "lwip/inet.h" #include "lwip/ip.h" #include "lwip/netif.h" #include "lwip/userfilter.h" #include "lwip/nat/nat.h" #include "lwip/nat/nat_tables.h" /*--------------------------------------------------------------------------*/ /* Abort, skip or drop everything we don't understand */ int track_default_tuple(struct ip_tuple *tuple, void *hdr) { return -1; } int track_default_inverse(struct ip_tuple *reply, struct ip_tuple *tuple) { return -1; } /*--------------------------------------------------------------------------*/ int track_default_error (struct stack *stack, uf_verdict_t *verdict, struct pbuf *q) { * verdict = UF_DROP; return -1; } int track_default_new(struct stack *stack, struct nat_pcb *pcb, struct pbuf *p, void *iphdr, int iplen) { return 1; } int track_default_handle(struct stack *stack, uf_verdict_t *verdict, struct pbuf *p, conn_dir_t direction) { *verdict = UF_DROP; return -1; } /*--------------------------------------------------------------------------*/ int nat_default_tuple_inverse (struct stack *stack, struct ip_tuple *reply, struct ip_tuple *tuple, nat_type_t type, struct manip_range *nat_manip ) { return -1; } int nat_default_manip (nat_manip_t type, void *iphdr, int iplen, struct ip_tuple *inverse, u8_t *iphdr_new_changed_buf, u8_t *iphdr_old_changed_buf, u32_t iphdr_changed_buflen) { return 1; } int nat_default_free(struct nat_pcb *pcb) { return 1; } /*--------------------------------------------------------------------------*/ struct track_protocol default_track = { .tuple = track_default_tuple, .inverse = track_default_inverse, .error = track_default_error, .new = track_default_new, .handle = track_default_handle, .manip = nat_default_manip, .nat_tuple_inverse = nat_default_tuple_inverse, .nat_free = nat_default_free }; #endif lwipv6-1.5a/lwip-v6/src/userfilter/nat/nat.c0000644000175000017500000010725711671615005020030 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #if LWIP_USERFILTER && LWIP_NAT #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/stats.h" #include "lwip/memp.h" /* MEMP_NAT_RULE */ #include "lwip/inet.h" #include "lwip/ip.h" #include "lwip/ip_frag.h" #include "lwip/udp.h" #include "lwip/tcp.h" #include "lwip/icmp.h" #include "lwip/sockets.h" #include "lwip/if.h" #include "lwip/netif.h" #include "lwip/userfilter.h" #include "lwip/nat/nat.h" #include "lwip/nat/nat_tables.h" #ifndef NAT_DEBUG #define NAT_DEBUG DBG_OFF #endif /*--------------------------------------------------------------------------*/ uf_verdict_t nat_defrag (struct stack *stack, uf_hook_t hooknum, struct pbuf **q, struct netif *inif, struct netif *outif); uf_verdict_t nat_track (struct stack *stack, uf_hook_t hooknum, struct pbuf **q, struct netif *inif, struct netif *outif); uf_verdict_t nat_perform (struct stack *stack, uf_hook_t hooknum, struct pbuf **q, struct netif *inif, struct netif *outif); uf_verdict_t nat_confirm (struct stack *stack, uf_hook_t hooknum, struct pbuf **q, struct netif *inif, struct netif *outif); #if 0 struct uf_hook_handler nat_prerouting_defrag = { .hooknum = UF_IP_PRE_ROUTING, .hook = nat_defrag, .priority = UF_PRI_NAT_PREROUTING_DEFRAG }; #endif struct uf_hook_handler nat_prerouting_track = { .hooknum = UF_IP_PRE_ROUTING, .hook = nat_track, .priority = UF_PRI_NAT_PREROUTING_TRACK }; struct uf_hook_handler nat_prerouting_dnat = { .hooknum = UF_IP_PRE_ROUTING, .hook = nat_perform, .priority = UF_PRI_NAT_PREROUTING_DNAT }; struct uf_hook_handler nat_input_confirm = { .hooknum = UF_IP_LOCAL_IN, .hook = nat_confirm, .priority = UF_PRI_NAT_INPUT_CONFIRM }; struct uf_hook_handler nat_output_track = { .hooknum = UF_IP_LOCAL_OUT, .hook = nat_track, .priority = UF_PRI_NAT_OUTPUT_TRACK }; struct uf_hook_handler nat_postrouting_snat = { .hooknum = UF_IP_POST_ROUTING, .hook = nat_perform, .priority = UF_PRI_NAT_POSTROUTING_SNAT }; struct uf_hook_handler nat_postrouting_confirm = { .hooknum = UF_IP_POST_ROUTING, .hook = nat_confirm, .priority = UF_PRI_NAT_POSTROUTING_CONFIRM }; /*--------------------------------------------------------------------------*/ /* Nat PCBS */ /*--------------------------------------------------------------------------*/ /* it seems useless: rd20100730 */ /*sys_sem_t unique_mutex;*/ #define LOCK(sem) sys_sem_wait_timeout((sem), 0) #define UNLOCK(sem) sys_sem_signal((sem)) #define NAT_LOCK(stack) LOCK(stack->stack_nat->nat_mutex) #define NAT_UNLOCK(stack) UNLOCK(stack->stack_nat->nat_mutex) #define NAT_PCB_REG(stack, pcbs_list, npcb) \ do { \ NAT_LOCK(stack); \ npcb->next = *pcbs_list; \ *(pcbs_list) = npcb; \ NAT_UNLOCK(stack); \ } while(0) #define NAT_PCB_RMV(stack, pcbs_list, npcb) \ do { \ struct nat_pcb *___tmp; \ NAT_LOCK(stack); \ if(*(pcbs_list) == npcb) { \ (*(pcbs_list)) = (*pcbs_list)->next; \ } else \ for(___tmp = *pcbs_list; ___tmp != NULL; ___tmp = ___tmp->next) { \ if((___tmp->next != NULL) && (___tmp->next == npcb)) { \ ___tmp->next = npcb->next; \ break; \ } \ } \ npcb->next = NULL; \ NAT_UNLOCK(stack); \ } while(0) /*--------------------------------------------------------------------------*/ #define MAX_TRACK_PROTO 256 static struct track_protocol *ip_ct_protos[MAX_TRACK_PROTO]; struct track_protocol * track_proto_find(u8_t protocol) { return ip_ct_protos[protocol]; } /*--------------------------------------------------------------------------*/ int nat_init(struct stack *stack) { int i; /* global mapping, initialized once */ if (ip_ct_protos[0] == NULL) { for (i = 0; i < MAX_TRACK_PROTO; i++) ip_ct_protos[i] = &default_track; ip_ct_protos[IP_PROTO_TCP] = &tcp_track; ip_ct_protos[IP_PROTO_UDP] = &udp_track; ip_ct_protos[IP_PROTO_ICMP4] = &icmp4_track; ip_ct_protos[IP_PROTO_ICMP] = &icmp6_track; } /* Register hooks */ stack->stack_nat = mem_malloc(sizeof(struct stack_nat)); if (stack->stack_nat == NULL) return -ENOMEM; stack->stack_nat->nat_mutex = sys_sem_new(1); /*unique_mutex = sys_sem_new(1);*/ // FIX: remove this and bind ip/port in the stack nat_ports_init(stack); // Init rules lists stack->stack_nat->nat_in_rules = NULL; stack->stack_nat->nat_out_rules = NULL; // Init pcbs lists stack->stack_nat->nat_active_pcbs = NULL; stack->stack_nat->nat_tentative_pcbs = NULL; /* Set protocol handlers */ ip_conntrack_protocol_tcp_lockinit(stack); //uf_register_hook( & nat_prerouting_defrag); uf_register_hook(stack, & nat_prerouting_track); uf_register_hook(stack, & nat_prerouting_dnat); uf_register_hook(stack, & nat_input_confirm); uf_register_hook(stack, & nat_output_track); uf_register_hook(stack, & nat_postrouting_snat); uf_register_hook(stack, & nat_postrouting_confirm); LWIP_DEBUGF(NAT_DEBUG, ("%s: registered NAT hooks!\n", __func__)); return ERR_OK; } void nat_free_pcb(struct nat_pcb *pcb); int nat_shutdown(struct stack *stack) { struct nat_pcb *nat_pcb_tmp; if (stack->stack_nat == NULL) return -EINVAL; nat_rules_shutdown(stack); while (stack->stack_nat->nat_tentative_pcbs != NULL) { nat_pcb_tmp = stack->stack_nat->nat_tentative_pcbs; NAT_PCB_RMV(stack, &stack->stack_nat->nat_tentative_pcbs, nat_pcb_tmp); nat_free_pcb(nat_pcb_tmp); } while (stack->stack_nat->nat_active_pcbs != NULL) { nat_pcb_tmp = stack->stack_nat->nat_active_pcbs; NAT_PCB_RMV(stack, &stack->stack_nat->nat_active_pcbs, nat_pcb_tmp); nat_free_pcb(nat_pcb_tmp); } mem_free(stack->stack_nat); return ERR_OK; } /*--------------------------------------------------------------------------*/ // assuming: unsigned char is 8 bits, long is 32 bits. // - chksum points to the chksum in the packet // - optr points to the old data in the packet // - nptr points to the new data in the packet void nat_chksum_adjust(u8_t * chksum, u8_t * optr, s16_t olen, u8_t * nptr, s16_t nlen) { s32_t x, old, new; x = chksum[0] * 256 + chksum[1]; x = ~x & 0xFFFF; while (olen) { old = optr[0] * 256 + optr[1]; optr += 2; x -= old & 0xffff; if (x <= 0) { x--; x &= 0xffff; } olen -= 2; } while (nlen) { new = nptr[0] * 256 + nptr[1]; nptr += 2; x += new & 0xffff; if (x & 0x10000) { x++; x &= 0xffff; } nlen -= 2; } x = ~x & 0xFFFF; chksum[0] = x / 256; chksum[1] = x & 0xff; } /*--------------------------------------------------------------------------*/ // NAT session descriptors /*--------------------------------------------------------------------------*/ static unsigned int pcb_id = 0; /* Return a new session descriptor. Returns NULL on error */ struct nat_pcb *nat_new_pcb(void) { struct nat_pcb *pcb; pcb = memp_malloc(MEMP_NAT_PCB); if (pcb != NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: get new! %p\n", __func__, pcb)); bzero(pcb, sizeof(struct nat_pcb)); pcb->nat_type = NAT_NONE; pcb->id = pcb_id++; } return pcb; } void nat_free_pcb(struct nat_pcb *pcb) { LWIP_DEBUGF(NAT_DEBUG, ("%s: free %p (id=%d)\n", __func__, pcb, pcb->id)); memp_free(MEMP_NAT_PCB, pcb); } /*--------------------------------------------------------------------------*/ void nat_session_get(struct nat_pcb *pcb); void nat_session_put(struct nat_pcb *pcb); void nat_pbuf_init(struct pbuf *p) { p->nat.track = NULL; p->nat.dir = 0; p->nat.info = 0; } void nat_pbuf_get(struct pbuf *p) { } void nat_pbuf_clone(struct pbuf *r, struct pbuf *p) { if (p->nat.track == NULL) return; nat_session_get(p->nat.track); r->nat.track = p->nat.track; r->nat.dir = p->nat.dir; r->nat.info = p->nat.info; } void nat_pbuf_put(struct pbuf *p) { if (p->nat.track == NULL) return; nat_session_put(p->nat.track); p->nat.track = NULL; p->nat.dir = 0; p->nat.info = 0; } void nat_pbuf_reset(struct pbuf *p) { nat_pbuf_put(p); } /*--------------------------------------------------------------------------*/ // Tuples /*--------------------------------------------------------------------------*/ #ifdef LWIP_DEBUG /* Print a tuple on output for debug messages */ void dump_tuple (struct ip_tuple *tuple) { LWIP_DEBUGF(NAT_DEBUG, ("TUPLE: ")); ip_addr_debug_print(NAT_DEBUG, &tuple->src.ip); LWIP_DEBUGF(NAT_DEBUG, (" ")); ip_addr_debug_print(NAT_DEBUG, &tuple->dst.ip); LWIP_DEBUGF(NAT_DEBUG, (" ")); switch (tuple->src.proto.protonum) { case IP_PROTO_TCP: LWIP_DEBUGF(NAT_DEBUG, ("TCP [%d,%d]", ntohs(tuple->src.proto.upi.tcp.port), ntohs(tuple->dst.proto.upi.tcp.port))); break; case IP_PROTO_UDP: LWIP_DEBUGF(NAT_DEBUG, ("UDP [%d,%d]", ntohs(tuple->src.proto.upi.udp.port), ntohs(tuple->dst.proto.upi.udp.port))); break; case IP_PROTO_ICMP4: LWIP_DEBUGF(NAT_DEBUG, ("Icmp4 id=%d type=%d code=%d", ntohs(tuple->src.proto.upi.icmp4.id), tuple->src.proto.upi.icmp4.type, tuple->src.proto.upi.icmp4.code)); break; case IP_PROTO_ICMP: LWIP_DEBUGF(NAT_DEBUG, ("Icmp6 id=%d (%x) type=%d code=%d", ntohs(tuple->src.proto.upi.icmp6.id), ntohs(tuple->src.proto.upi.icmp6.id), tuple->src.proto.upi.icmp6.type, tuple->src.proto.upi.icmp6.code)); break; default: LWIP_DEBUGF(NAT_DEBUG, ("%s: strange protocol", __func__ )); break; } LWIP_DEBUGF(NAT_DEBUG, ("\n")); } #else #define dump_tuple(p) {} #endif /*--------------------------------------------------------------------------*/ int get_masquerade_ip(struct ip_addr *ip, u8_t ipv, struct netif *netif) { struct ip_addr_list *addr; addr = ip_addr_list_masquarade_addr(netif->addrs, ipv); if (addr != NULL) { ip_addr_set(ip, &addr->ipaddr); return 1; } return -1; } /* Create a unique tuple for NAT */ int tuple_create_nat_inverse(struct ip_tuple *reply, struct ip_tuple *tuple, struct netif *iface, nat_type_t type, struct manip_range *nat_manip) { int r; struct track_protocol *proto; /* Set IP */ reply->ipv = tuple->ipv; if (type == NAT_MASQUERADE) { if (get_masquerade_ip(&reply->dst.ip, reply->ipv, iface) < 0) return -1; } else if (type == NAT_SNAT) { ip_addr_set (&reply->dst.ip, &nat_manip->ipmin); } else if (type == NAT_DNAT) { ip_addr_set (&reply->src.ip, &nat_manip->ipmin); } else { LWIP_DEBUGF(NAT_DEBUG, ("%s: BUG\n", __func__ )); return -1; } /* Set PROTO */ reply->src.proto.protonum = tuple->src.proto.protonum; proto = track_proto_find( tuple->src.proto.protonum ); if (proto == NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: BUG 2 \n", __func__ )); return -1; } r = proto->nat_tuple_inverse(iface->stack, reply, tuple, type, nat_manip); return r; } /*--------------------------------------------------------------------------*/ /* Returns 1 if t2 and t1 are equal. */ int nat_tuple_cmp(struct ip_tuple *t1, struct ip_tuple *t2) { int r; /* FIX: too simple */ r = memcmp(t1, t2, sizeof(struct ip_tuple)); if ( r == 0) return 1; else return 0; } int tuple_inverse(struct ip_tuple *reply, struct ip_tuple *tuple) { struct track_protocol *proto; bzero(reply, sizeof(struct ip_tuple)); reply->ipv = tuple->ipv; ip_addr_set (&reply->src.ip, &tuple->dst.ip); ip_addr_set (&reply->dst.ip, &tuple->src.ip); reply->src.proto.protonum = tuple->src.proto.protonum; proto = track_proto_find( tuple->src.proto.protonum ); return proto->inverse(reply, tuple); } int tuple_create(struct ip_tuple *tuple, char *iphdr, struct track_protocol *proto) { struct ip_hdr *ip6hdr; struct ip4_hdr *ip4hdr; u32_t iphdrlen; bzero(tuple, sizeof(struct ip_tuple)); ip6hdr = (struct ip_hdr *) iphdr; ip4hdr = (struct ip4_hdr *) iphdr; tuple->ipv = IPH_V(ip6hdr); if (tuple->ipv == 6) { LWIP_DEBUGF(NAT_DEBUG, ("%s: ipv6 \n", __func__ )); ip_addr_set (&tuple->src.ip , &(ip6hdr->src) ); ip_addr_set (&tuple->dst.ip , &(ip6hdr->dest) ); tuple->src.proto.protonum = IPH_NEXTHDR(ip6hdr); iphdrlen = IP_HLEN; } else if (tuple->ipv == 4) { LWIP_DEBUGF(NAT_DEBUG, ("%s: ipv4 \n", __func__ )); IP64_CONV (&tuple->src.ip , &(ip4hdr->src) ); IP64_CONV (&tuple->dst.ip , &(ip4hdr->dest) ); tuple->src.proto.protonum = IPH4_PROTO(ip4hdr); iphdrlen = IPH4_HL(ip4hdr) * 4; } else { LWIP_DEBUGF(NAT_DEBUG, ("%s: IP version wrong \n", __func__ )); return -1; /* error */ } return proto->tuple(tuple, iphdr + iphdrlen); } /*--------------------------------------------------------------------------*/ // NAT timer functions */ /*--------------------------------------------------------------------------*/ struct nat_pcb * nat_create_session(nat_type_t nat_type, struct nat_pcb *pcb, struct netif *iface, struct manip_range *manip) { LWIP_DEBUGF(NAT_DEBUG, ("\tnat=%s iface=%d \n",STR_NATNAME(nat_type), iface->id )); pcb->nat_type = nat_type; if (pcb->nat_type == NAT_MASQUERADE) { pcb->status |= TS_MASQUERADE; pcb->nat_type = NAT_SNAT; pcb->iface = iface; } /* Setup inverse natted tuple NOTE: pcb->tuple[CONN_DIR_ORIGINAL ]is already set */ if (tuple_create_nat_inverse(&pcb->tuple[CONN_DIR_REPLY], &pcb->tuple[CONN_DIR_ORIGINAL], iface, nat_type, manip ) < 0) return NULL; LWIP_DEBUGF(NAT_DEBUG, ("\tinverse=")); dump_tuple (&pcb->tuple[CONN_DIR_REPLY]); LWIP_DEBUGF(NAT_DEBUG, ("\n")); return pcb; } void nat_session_get(struct nat_pcb *pcb) { pcb->refcount++; } void nat_session_put(struct nat_pcb *pcb) { struct track_protocol *proto; struct stack *stack = pcb->stack; LWIP_DEBUGF(NAT_DEBUG, ("%s: pcb id=%d ref=%d\n", __func__, pcb->id, (int)pcb->refcount)); pcb->refcount--; if (pcb->refcount == 0) { LWIP_DEBUGF(NAT_DEBUG, ("\tid=%d ref now = 0 -> FREE\n", pcb->id)); /* The tracking not confirmed this connection, remove it */ if (!(pcb->status & TS_CONFIRMED)) { NAT_PCB_RMV(stack, &stack->stack_nat->nat_tentative_pcbs, pcb); } // Need to unbind() used ports for SNAT if (pcb->nat_type != NAT_NONE) { proto = track_proto_find( pcb->tuple[CONN_DIR_ORIGINAL].src.proto.protonum ); if (proto != NULL) { proto->nat_free(pcb); } else LWIP_DEBUGF(NAT_DEBUG, ("%s: BUG 2 \n", __func__ )); } nat_free_pcb(pcb); } } /*--------------------------------------------------------------------------*/ // Tracking /*--------------------------------------------------------------------------*/ void close_timeout(void *arg) { struct nat_pcb *pcb = (struct nat_pcb *) arg; struct stack *stack = pcb->stack; LWIP_DEBUGF(NAT_DEBUG, ("%s: session p=%p id=%d expired\n", __func__, pcb, pcb->id)); LWIP_DEBUGF(NAT_DEBUG, ("\t")); dump_tuple(&pcb->tuple[CONN_DIR_ORIGINAL]); NAT_PCB_RMV(stack, &stack->stack_nat->nat_active_pcbs, pcb); nat_session_put(pcb); } void conn_refresh_timer(u32_t timeout, struct nat_pcb *pcb) { pcb->timeout = timeout; LWIP_DEBUGF(NAT_DEBUG, ("%s: refresh on pcb id=%d\n", __func__, pcb->id)); if (!conn_remove_timer(pcb)) { LWIP_DEBUGF(NAT_DEBUG, ("%s: No timer\n", __func__)); return ; } sys_timeout(timeout, (sys_timeout_handler) close_timeout, pcb); } int conn_remove_timer(struct nat_pcb *pcb) { return sys_untimeout_and_check((sys_timeout_handler)close_timeout, pcb); } void conn_force_timeout(struct nat_pcb *pcb) { close_timeout(pcb); } int new_track(struct stack *stack, struct nat_pcb **newpcb, uf_hook_t hook, struct pbuf **q, struct ip_tuple * tuple, conn_dir_t *direction, struct track_protocol *proto) { struct ip_hdr *ip6hdr; struct ip4_hdr *ip4hdr; u16_t iphdrlen; struct nat_pcb *pcb; struct pbuf *p=*q; LWIP_DEBUGF(NAT_DEBUG, ("%s: start\n", __func__)); pcb = nat_new_pcb(); if (pcb == NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: NAT PCB memory full.\n", __func__)); return -1; } /* * Save ORIGINAL and REPLY connection tuple. */ memcpy(&pcb->tuple[CONN_DIR_ORIGINAL], tuple, sizeof (struct ip_tuple)); if (tuple_inverse(&pcb->tuple[CONN_DIR_REPLY], &pcb->tuple[CONN_DIR_ORIGINAL]) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: Unable to get inverse tuple\n", __func__)); return -1; } LWIP_DEBUGF(NAT_DEBUG, ("%s: New track. id=%d\n", __func__, pcb->id)); LWIP_DEBUGF(NAT_DEBUG, ("\tORIGINAL: ")); dump_tuple ( &pcb->tuple[CONN_DIR_ORIGINAL] ); LWIP_DEBUGF(NAT_DEBUG, ("\tREPLY : ")); dump_tuple ( &pcb->tuple[CONN_DIR_REPLY] ); /* Init per-protocol informations */ ip4hdr = (struct ip4_hdr *) p->payload; ip6hdr = (struct ip_hdr *) p->payload; if (tuple->ipv == 6) iphdrlen = IP_HLEN; else if (tuple->ipv == 4) iphdrlen = IPH4_HL(ip4hdr) * 4; else return -1; if (proto->new(stack, pcb, p, p->payload, iphdrlen) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: Unable to create new valid tracking.\n", __func__)); nat_free_pcb(pcb); return -1; } *direction = CONN_DIR_ORIGINAL; *newpcb = pcb; pcb->stack = stack; pcb->refcount = 1; pcb->next = NULL; /* Register this connection as a Tentative */ NAT_PCB_REG(stack, &stack->stack_nat->nat_tentative_pcbs, pcb); return 1; } struct nat_pcb * conn_find_track(struct stack *stack, conn_dir_t *direction, struct ip_tuple * tuple ) { struct nat_pcb *pcb = NULL; /* Search in the table */ NAT_LOCK(stack); for(pcb = stack->stack_nat->nat_active_pcbs; pcb != NULL; pcb = pcb->next) { LWIP_DEBUGF(NAT_DEBUG, ("\tpcb=%p\tORIGINAL: ", pcb)); dump_tuple(&pcb->tuple[CONN_DIR_ORIGINAL]); LWIP_DEBUGF(NAT_DEBUG, ("\t\t\tREPLY : ")); dump_tuple(&pcb->tuple[CONN_DIR_REPLY]); LWIP_DEBUGF(NAT_DEBUG, ("\n")); if (nat_tuple_cmp(&pcb->tuple[CONN_DIR_ORIGINAL], tuple)) { *direction = CONN_DIR_ORIGINAL; break; } if (nat_tuple_cmp(&pcb->tuple[CONN_DIR_REPLY] , tuple)) { *direction = CONN_DIR_REPLY; break; } } if (pcb != NULL) { LWIP_DEBUGF(NAT_DEBUG, ("\tFOUND pcb id=%d\n", pcb->id)); pcb->refcount++; } NAT_UNLOCK(stack); return pcb; } /* * Try to track the packet. If this packet doesn't belong to any existing connection * a new one will be created. On errors return -1. */ int conn_track(struct stack *stack, conn_dir_t *direction, uf_hook_t hook, struct pbuf **q, struct netif *inif, struct netif *outif, struct track_protocol *proto) { struct pbuf *p = * q; struct nat_pcb *tmppcb = NULL; struct ip_tuple tuple; LWIP_DEBUGF(NAT_DEBUG, ("%s: start\n", __func__ )); /* Get the tuple of the packet */ /// if (tuple_create(&tuple, p, proto) < 0) { if (tuple_create(&tuple, p->payload, proto) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: unable to create tuple!\n", __func__ )); return -1; } dump_tuple (&tuple); /* Find tracking informations */ tmppcb = conn_find_track(stack, direction, &tuple); if (tmppcb == NULL) { if (new_track(stack, &tmppcb, hook, q, &tuple, direction, proto) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: unable to create new track \n", __func__ )); return -1; } LWIP_DEBUGF(NAT_DEBUG, ("%s: NEW track %p id=%d!!\n", __func__, tmppcb, tmppcb->id)); } p->nat.track = tmppcb; p->nat.dir = *direction; /* It exists; we have (non-exclusive) reference. */ if (*direction == CONN_DIR_REPLY) { p->nat.info = CT_ESTABLISHED + CT_IS_REPLY; LWIP_DEBUGF(NAT_DEBUG, ("%s: CT_ESTABLISHED + CT_IS_REPLY\n", __func__)); } else { /* Once we've had two way comms, always ESTABLISHED. */ if (p->nat.track->status & TS_SEEN_REPLY) { LWIP_DEBUGF(NAT_DEBUG, ("%s: CT_ESTABLISHED\n", __func__)); p->nat.info = CT_ESTABLISHED; } else { LWIP_DEBUGF(NAT_DEBUG, ("%s: CT_NEW\n", __func__)); p->nat.info = CT_NEW; } } return 1; } /* Returns 1 if 'p' is a valid packet for tracking and NAT. Some ICMP6 packet (NS,ND, RA,RD) don't need tracking or NAT */ int conn_need_track(struct pbuf *p) { struct ip_hdr *ip6hdr; struct ip4_hdr *ip4hdr; u32_t iphdrlen; struct ip_addr src,dst; ip6hdr = (struct ip_hdr *) p->payload; ip4hdr = (struct ip4_hdr *) p->payload; if (IPH_V(ip6hdr) == 6) { iphdrlen = IP_HLEN; if (ip_addr_ismulticast(&ip6hdr->dest)) return 0; if (ip_addr_ismulticast(&ip6hdr->src)) return 0; if (ip_addr_islinkscope(&ip6hdr->dest)) return 0; if (ip_addr_islinkscope(&ip6hdr->src)) return 0; } else if (IPH_V(ip6hdr) == 4) { iphdrlen = IPH4_HL(ip4hdr) * 4; IP64_CONV (&src , &(ip4hdr->src) ); IP64_CONV (&dst , &(ip4hdr->dest) ); if (ip_addr_is_v4multicast(&dst)) return 0; } return 1; } /*--------------------------------------------------------------------------*/ /* HOOKS */ /*--------------------------------------------------------------------------*/ #if 0 uf_verdict_t nat_defrag (struct stack *stack, uf_hook_t hooknum, struct pbuf **q, struct netif *inif, struct netif *outif) { struct pbuf *p = *q; struct ip4_hdr *ip4hdr; struct ip_hdr *ip6hdr; u8_t proto; uf_verdict_t ret = UF_ACCEPT; LWIP_DEBUGF(NAT_DEBUG, ("%s: start\n", __func__)); /* ASSERT! This is the first hook, no tracking info yet! */ if (p->nat.track != NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: pcb not NULL!!!!!\n", __func__)); } nat_pbuf_reset(p); /* Find transport protocol handler */ ip6hdr = (struct ip_hdr *) p->payload; ip4hdr = (struct ip4_hdr *) p->payload; if (IPH_V(ip6hdr) == 4) { if ((IPH4_OFFSET(ip4hdr) & htons(IP_OFFMASK | IP_MF)) != 0) { #ifdef IPv4_FRAGMENTATION LWIP_DEBUGF(NAT_DEBUG, ("%s: Packet is a fragment (id=0x%04x tot_len=%u len=%u MF=%u offset=%u)\n", __func__, ntohs(IPH4_ID(ip4hdr)), p->tot_len, ntohs(IPH4_LEN(ip4hdr)), !!(IPH4_OFFSET(ip4hdr) & htons(IP_MF)), (ntohs(IPH4_OFFSET(ip4hdr)) & IP_OFFMASK)*8)); p = ip4_reass(p); #else ret = UF_DROP; #endif } } else if (IPH_V(ip6hdr) == 6) { proto = IPH_NEXTHDR(ip6hdr); if (proto == IP6_NEXTHDR_FRAGMENT) { #ifdef IPv6_FRAGMENTATION LWIP_DEBUGF(NAT_DEBUG, ("%s: Fragment Header\n", __func__)); struct ip6_fraghdr *fhdr = (struct ip6_fraghdr *) (p->payload + IP_HLEN); p = ip6_reass(p, fhdr, NULL); #else ret = UF_DROP; #endif } } else return UF_DROP; if (ret == UF_DROP) { LWIP_DEBUGF(NAT_DEBUG | 2, ("%s: IP packet dropped since it was fragmented\n", __func__)); IP_STATS_INC(ip.opterr); IP_STATS_INC(ip.drop); return UF_DROP; } if (p == NULL) { LWIP_DEBUGF(NAT_DEBUG,("%s: packet cached\n", __func__)); return UF_STOLEN; } *q = p; return UF_ACCEPT; } #endif uf_verdict_t nat_track (struct stack *stack, uf_hook_t hooknum, struct pbuf **q, struct netif *inif, struct netif *outif) { struct pbuf *p = *q; struct pbuf *new_p; struct ip4_hdr *ip4hdr; struct ip_hdr *ip6hdr; struct track_protocol *proto; conn_dir_t direction; uf_verdict_t verdict; LWIP_DEBUGF(NAT_DEBUG, ("%s: pbuf %d/%d\n", __func__, p->len, p->tot_len)); /* ASSERT! This is the first hook, no tracking info yet! */ if (p->nat.track != NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: pcb not NULL!!!!!\n", __func__)); } nat_pbuf_reset(p); /* * We need a not-memory-fragmented packet for NAT manipulation. */ new_p = pbuf_make_writable(p); if (new_p == NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: unable to realloc pbuf!!!!!\n", __func__)); return UF_ACCEPT; } LWIP_DEBUGF(NAT_DEBUG, ("%s: p now writable (old=%p new=%p)\n", __func__, p, new_p)); *q = p = new_p; /* Find transport protocol handler */ ip6hdr = (struct ip_hdr *) p->payload; ip4hdr = (struct ip4_hdr *) p->payload; if (IPH_V(ip6hdr) == 6) // FIX: handle IPv6 extension headers ? proto = track_proto_find( IPH_NEXTHDR(ip6hdr) ); else if (IPH_V(ip6hdr) == 4) proto = track_proto_find( IPH4_PROTO(ip4hdr) ); else return UF_DROP; LWIP_DEBUGF(NAT_DEBUG, ("%s: proto = %d\n", __func__, IPH4_PROTO(ip4hdr) )); if (proto->error != NULL) { if (proto->error(stack, &verdict, p) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: proto error() -> %s\n", __func__, STR_VERDICT(verdict) )); return verdict; } } if (!conn_need_track(p)) { LWIP_DEBUGF(NAT_DEBUG, ("%s: doesn't need track\n", __func__ )); return UF_ACCEPT; } /* Find connection, if none is found a new will be created */ if (conn_track(stack, &direction, hooknum, q, inif, outif, proto ) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: tracking failed (not new valid connection)! DROP\n", __func__ )); return UF_DROP; } /* Update tracking informations */ if (proto->handle(stack, &verdict, p, direction) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: drop this packet!!\n", __func__)); /* Invalid: inverse of the return code tells * the netfilter core what to do*/ nat_session_put(p->nat.track); p->nat.track = NULL; return verdict; } if (direction == CONN_DIR_REPLY) p->nat.track->status |= TS_SEEN_REPLY; LWIP_DEBUGF(NAT_DEBUG, ("%s: pcb %p, dir=%s -> %s!!\n", __func__, p->nat.track, STR_DIRECTIONNAME(direction), STR_VERDICT(verdict))); return verdict; } uf_verdict_t nat_confirm (struct stack *stack, uf_hook_t hooknum, struct pbuf **q, struct netif *inif, struct netif *outif) { struct nat_pcb *pcb = NULL; struct pbuf *p = *q; pcb = p->nat.track; if (pcb == NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: no track for this packet!!\n", __func__)); return UF_ACCEPT; } if (! (pcb->status & TS_CONFIRMED)) { /// FIX: controllare che non ci sia gia' un'altra connessione valida /// con le stesse tuple. Se e' presente vuol dire che: /// a) Il NAT ha modificato una connessione usando una tupla gia' occupata /// Una connessione proveniente dal LOCALOUT e' uguale ad una modificata in /// SNAT. pcb->status |= TS_CONFIRMED; pcb->refcount++; sys_timeout(pcb->timeout, (sys_timeout_handler) close_timeout, pcb); NAT_PCB_RMV(stack, &stack->stack_nat->nat_tentative_pcbs, pcb); NAT_PCB_REG(stack, &stack->stack_nat->nat_active_pcbs, pcb); LWIP_DEBUGF(NAT_DEBUG, ("%s: confirming track %p id=%d!!\n", __func__, pcb, pcb->id)); } return UF_ACCEPT; } /* Return -1 on error */ int nat_check_rule(struct nat_pcb *pcb, uf_hook_t hooknum, struct netif *inif,struct netif *outif) { struct nat_rule * list, *rule; struct netif * netif = NULL; struct manip_range *nat_manip; nat_type_t type; struct stack *stack = pcb->stack; if (hooknum == UF_IP_PRE_ROUTING) { list = stack->stack_nat->nat_in_rules; netif = inif; } else if (hooknum == UF_IP_POST_ROUTING) { list = stack->stack_nat->nat_out_rules; netif = outif; } else { LWIP_DEBUGF(NAT_DEBUG, ("%s: wrong hooknum!\n",__func__)); return -1; } /* Search for rules */ for(rule = list; rule != NULL; rule = rule->next) { if (nat_match_rule(&rule->matches, netif, &pcb->tuple[CONN_DIR_ORIGINAL])) break; } if (rule == NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: no rule found\n",__func__)); return 1; } else { type = rule->type; nat_manip = &rule->manip; } /* We try only SNAT or DNAT, not both */ pcb->status |= TS_NAT_TRY_MASK; if (nat_create_session(type, pcb, netif, nat_manip) == NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: unable to create session with rule\n",__func__)); return -1; } return 1; } void nat_modify_ip(nat_manip_t nat, char *p, struct ip_tuple *inverse, u8_t manip_innerproto) { struct ip_hdr *iphdr; struct ip4_hdr *ip4hdr; u16_t iphdrlen; struct track_protocol *proto; struct ip4_addr tmp_ip4; u32_t old_ip4_addr; struct ip_addr old_ip6_addr; u8_t *iphdr_old_changed_buf; u8_t *iphdr_new_changed_buf; u32_t iphdr_changed_buflen; /* Modify IP header */ iphdr = (struct ip_hdr *) p; ip4hdr = (struct ip4_hdr *) p; if (inverse->ipv == 4) { /* Need to convert tuple's IP used for manipulations from 128 bit to 32 bit */ if (nat == MANIP_DST) { // copy old address old_ip4_addr = ip4hdr->dest.addr; ip64_addr_set( &tmp_ip4, &inverse->src.ip); ip4_addr_set((struct ip4_addr *) &(ip4hdr->dest), &tmp_ip4); // Adjust IP checksum. Only IPv4 has checksum nat_chksum_adjust((u8_t *) & IPH4_CHKSUM(ip4hdr), (u8_t *) & old_ip4_addr, 4, (u8_t *) & ip4hdr->dest.addr, 4); // remember IP header changes iphdr_new_changed_buf = (u8_t *) &ip4hdr->dest.addr; iphdr_old_changed_buf = (u8_t *) &old_ip4_addr; iphdr_changed_buflen = 4; } if (nat == MANIP_SRC) { old_ip4_addr = ip4hdr->src.addr; ip64_addr_set( &tmp_ip4, &inverse->dst.ip); ip4_addr_set((struct ip4_addr *) &(ip4hdr->src), &tmp_ip4); // Adjust IP checksum. Only IPv4 has checksum nat_chksum_adjust((u8_t *) & IPH4_CHKSUM(ip4hdr), (u8_t *) & old_ip4_addr, 4, (u8_t *) & ip4hdr->src.addr, 4); // remember IP header changes iphdr_new_changed_buf = (u8_t *) &ip4hdr->src.addr; iphdr_old_changed_buf = (u8_t *) &old_ip4_addr; iphdr_changed_buflen = 4; } } else if (inverse->ipv == 6) { if (nat == MANIP_DST) { ip_addr_set( &old_ip6_addr, &iphdr->dest); ip_addr_set( &iphdr->dest, &inverse->src.ip); iphdr_new_changed_buf = (u8_t *) &iphdr->dest; } if (nat == MANIP_SRC) { ip_addr_set( &old_ip6_addr, &iphdr->src); ip_addr_set( &iphdr->src, &inverse->dst.ip); iphdr_new_changed_buf = (u8_t *) &iphdr->src; } iphdr_old_changed_buf = (u8_t *) &old_ip6_addr; iphdr_changed_buflen = 16; } /* Modify transport header */ if (manip_innerproto) { proto = track_proto_find(inverse->src.proto.protonum); if (inverse->ipv == 6) iphdrlen = IP_HLEN; else if (inverse->ipv == 4) iphdrlen = IPH4_HL(ip4hdr) * 4; proto->manip(nat, p, iphdrlen, inverse, iphdr_new_changed_buf, iphdr_old_changed_buf, iphdr_changed_buflen); } } int icmp_reply_translation(struct pbuf *p, nat_manip_t nat_here); uf_verdict_t nat_perform (struct stack *stack, uf_hook_t hooknum, struct pbuf **q, struct netif *inif, struct netif *outif) { struct pbuf *p = * q; struct ip_hdr *ip6hdr; struct ip4_hdr *ip4hdr; u16_t proto; struct nat_pcb *pcb; conn_dir_t direction; struct ip_tuple *tuple_inverse; nat_manip_t nat_here; /* NAT to do in this hook */ nat_manip_t nat_todo; /* NAT to do on the connection */ LWIP_DEBUGF(NAT_DEBUG, ("%s: start %s!\n", __func__, STR_HOOKNAME(hooknum))); if (p->nat.track == NULL) { LWIP_DEBUGF(NAT_DEBUG, ("%s: no track for this packet!!\n", __func__)); return UF_ACCEPT; } pcb = p->nat.track; direction = p->nat.dir; /* * Check what to do... */ nat_here = HOOK2MANIP(hooknum); ip6hdr = (struct ip_hdr *) p->payload; ip4hdr = (struct ip4_hdr *) p->payload; if (IPH_V(ip6hdr) == 6) proto = IPH_NEXTHDR(ip6hdr) ; else if (IPH_V(ip6hdr) == 4) proto = IPH4_PROTO(ip4hdr) ; else return UF_DROP; switch (p->nat.info) { case CT_RELATED: case CT_RELATED + CT_IS_REPLY: LWIP_DEBUGF(NAT_DEBUG, ("%s: is RELATED || RELATED+REPLY \n", __func__ )); if (proto == IP_PROTO_ICMP || proto == IP_PROTO_ICMP4) { if (icmp_reply_translation(p, nat_here) <= 0) return UF_DROP; else return UF_ACCEPT; } /* Fall thru... (Only ICMPs can be IP_CT_IS_REPLY) */ case CT_NEW: LWIP_DEBUGF(NAT_DEBUG, ("%s: is NEW \n", __func__ )); /* If no NAT has been done on this connection and one of SNAT or DNAT rules haven't been checked yet, try them */ if (pcb->nat_type == NAT_NONE) if ((pcb->status & TS_NAT_TRY_MASK) != TS_NAT_TRY_MASK) { LWIP_DEBUGF(NAT_DEBUG, ("%s: Check for rules...\n", __func__ )); if (nat_check_rule(pcb, hooknum, inif, outif ) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: error, DROP\n", __func__ )); return UF_DROP; } } break; default: LWIP_DEBUGF(NAT_DEBUG, ("%s: is ESTABLISHED or other... \n", __func__ )); /* ESTABLISHED: do NAT */ break; } #if 0 /* If no NAT has been done on this connection and one of SNAT or DNAT rules haven't been checked yet, try them */ if (pcb->nat_type == NAT_NONE) if ((pcb->status & TS_NAT_TRY_MASK) != TS_NAT_TRY_MASK) { LWIP_DEBUGF(NAT_DEBUG, ("%s: Check for rules...\n", __func__ )); if (nat_check_rule(pcb, hooknum, inif, outif ) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: error, DROP\n", __func__ )); return UF_DROP; } } #endif /* No NAT? No party */ if (pcb->nat_type == NAT_NONE) { LWIP_DEBUGF(NAT_DEBUG, ("%s: no NAT to do.\n", __func__ )); return UF_ACCEPT; } /* How tuples will be manipulated by Hooks * * NAT | DIRECTION | --> PREROUTING -----> POSTROUTING --> *------|-----------|------------------------------------------ * | ORIGINAL | [x,y] -> x,N (D) - * DNAT | | * | REPLY | - [N,x] -> y,x (S) *------|-----------|------------------------------------------ * | ORIGINAL | - [x,y] -> N,y (S) * SNAT | | * | REPLY | [y,N] -> y,x (D) - *------|-----------|------------------------------------------ * * x,y tuple (IP.src,IP.dst,proto.src,proto.dst) * [x,y] connection's tuple saved in tracking data * (D) new destination = source in the inverse tuple * (S) new source = destination in the inverse tuple */ /* We use the tuple in the other direction for NAT. See above */ if (direction == CONN_DIR_ORIGINAL) tuple_inverse = &pcb->tuple[CONN_DIR_REPLY]; else tuple_inverse = &pcb->tuple[CONN_DIR_ORIGINAL]; /* Manipulation's type depends on hook and packet direction */ nat_todo = NAT2MANIP(pcb->nat_type); if (direction == CONN_DIR_REPLY) { nat_todo = ! nat_todo; } /* Manipulation on this packet is needed in this hook? */ if (nat_todo == nat_here) { nat_modify_ip(nat_todo, p->payload, tuple_inverse, 1); LWIP_DEBUGF(NAT_DEBUG, ("%s: NATed packet !\n", __func__)); ip_debug_print(NAT_DEBUG, p); LWIP_DEBUGF(NAT_DEBUG, ("%s: END.\n", __func__)); } else { LWIP_DEBUGF(NAT_DEBUG, ("%s: no NAT to do in this hook\n", __func__ )); } return UF_ACCEPT; } int icmp_reply_translation(struct pbuf *p, nat_manip_t nat_here) { struct { struct icmp_echo_hdr icmp; union { struct ip4_hdr ip4hdr; struct ip_hdr ip6hdr; } uip; } *inside; conn_dir_t direction; struct ip4_hdr *ip4hdr; struct ip_hdr *ip6hdr; int hdrlen; nat_manip_t nat_todo; /* NAT to do on the connection */ struct ip_tuple *inverse; struct ip_tuple inner_inverse; struct nat_pcb *pcb = p->nat.track; direction = p->nat.dir; ip6hdr = (struct ip_hdr *) p->payload; ip4hdr = (struct ip4_hdr *) p->payload; if (IPH4_V(ip4hdr) == 4) hdrlen = IPH4_HL(ip4hdr) * 4; else hdrlen = IP_HLEN; inside = (void *)(p->payload + hdrlen); if (p->nat.info == CT_RELATED || p->nat.info == CT_RELATED + CT_IS_REPLY) { LWIP_DEBUGF(NAT_DEBUG, ("%s: Strange, not RELATED or RELATED+REPLY\n", __func__)); return -1; } /* * Get tuples for translations */ /* We use the tuple in the other direction for NAT. See above */ if (direction == CONN_DIR_ORIGINAL) inverse = &pcb->tuple[CONN_DIR_REPLY]; else inverse = &pcb->tuple[CONN_DIR_ORIGINAL]; if (tuple_inverse( &inner_inverse, inverse ) < 0) { LWIP_DEBUGF(NAT_DEBUG, ("%s: Strange, can't get tuple inverse!\n", __func__)); return -1; } /* * */ nat_todo = NAT2MANIP(pcb->nat_type); if (direction == CONN_DIR_REPLY) { nat_todo = ! nat_todo; } if (nat_todo != nat_here) return 1; /* * Change Inner packet */ nat_modify_ip(!nat_todo, (char *) &inside->uip.ip4hdr, &inner_inverse, 1); LWIP_DEBUGF(NAT_DEBUG, ("%s: NATed INNER PACKET !\n", __func__)); ip_debug_print(NAT_DEBUG, p); /// CHECKSUM? /* * Change Packet hearde */ nat_modify_ip(nat_todo, p->payload, inverse, 0); LWIP_DEBUGF(NAT_DEBUG, ("%s: NATed PACKET !\n", __func__)); ip_debug_print(NAT_DEBUG, p); LWIP_DEBUGF(NAT_DEBUG, ("%s: END !\n", __func__)); return 1; } #endif /* LWIP_NAT */ lwipv6-1.5a/lwip-v6/src/userfilter/userfilter.c0000644000175000017500000001477311671615005020650 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/debug.h" #include "lwip/sys.h" #include "lwip/netif.h" #include "lwip/stack.h" #if LWIP_USERFILTER #include "lwip/userfilter.h" //#ifndef USERFILTER_DEBUG //#define USERFILTER_DEBUG DBG_OFF //#endif /* linked list of filters */ struct uf_item { struct uf_item *next; struct uf_hook_handler *uf_h; }; /* Table of registered hooks */ struct stack_userfilter { struct uf_item *uf_hooks_list[UF_IP_NUMHOOKS]; sys_sem_t uf_mutex; }; /*--------------------------------------------------------------------------*/ /* Variabiles */ /*--------------------------------------------------------------------------*/ #define UF_LOCK(stack) sys_sem_wait_timeout(stack->stack_userfilter->uf_mutex, 0) #define UF_UNLOCK(stack) sys_sem_signal(stack->stack_userfilter->uf_mutex) /*--------------------------------------------------------------------------*/ /* Functions */ /*--------------------------------------------------------------------------*/ int userfilter_init(struct stack *stack) { int i; stack->stack_userfilter=mem_malloc(sizeof(struct stack_userfilter)); if (stack->stack_userfilter == NULL) return -1; else { stack->stack_userfilter->uf_mutex = sys_sem_new(1); LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: init hooks table\n", __func__)); for (i=0; i < UF_IP_NUMHOOKS; i++) stack->stack_userfilter->uf_hooks_list[i] = NULL; return 1; } } int userfilter_shutdown(struct stack *stack) { if (stack->stack_userfilter == NULL) return -1; else { int i; for (i=0; i < UF_IP_NUMHOOKS; i++) { struct uf_item *ufscan; ufscan=stack->stack_userfilter->uf_hooks_list[i]; while(ufscan != NULL) { struct uf_item *ufold=ufscan; ufscan=ufscan->next; mem_free(ufold); } } mem_free(stack->stack_userfilter); stack->stack_userfilter=NULL; return 1; } } int uf_register_hook(struct stack *stack, struct uf_hook_handler *h) { struct uf_item *current; struct uf_item *last; struct uf_item *new; if (stack->stack_userfilter == NULL) return -1; UF_LOCK(stack); if (h->hooknum < UF_IP_PRE_ROUTING || h->hooknum > UF_IP_POST_ROUTING) { LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: wrong hook number %d...\n", __func__, h->hooknum)); UF_UNLOCK(stack); return -1 ; } new=mem_malloc(sizeof(struct uf_item)); if (new==NULL) { UF_UNLOCK(stack); return -1 ; } new->uf_h = h; /* Find the first registered hook with priority greater than 'h' */ last = NULL; current = stack->stack_userfilter->uf_hooks_list[h->hooknum] ; while (current != NULL) { /* found the handler position in the hook */ if (current->uf_h->priority > h->priority) break; last = current; current = current->next; } new->next = current; /* if 'h' is not the first element of the list */ if (last != NULL) last->next = new; else stack->stack_userfilter->uf_hooks_list[h->hooknum] = new; LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: registered hook %s, p=%p fun=%p\n", __func__, STR_HOOKNAME (h->hooknum), h, h->hook)); UF_UNLOCK(stack); return 1; } int uf_unregister_hook(struct stack *stack, struct uf_hook_handler *h) { int ret = 0; struct uf_item *current; struct uf_item *last; if (stack->stack_userfilter == NULL) return -1; UF_LOCK(stack); if (h->hooknum < UF_IP_PRE_ROUTING || h->hooknum > UF_IP_POST_ROUTING) { LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: wrong hook number %d...\n", __func__, h->hooknum)); UF_UNLOCK(stack); return -1 ; } /* Find 'h' in the list of registered hooks */ last = NULL; current = stack->stack_userfilter->uf_hooks_list[h->hooknum] ; while (current != NULL) { /* found */ if (current->uf_h == h) { /* if 'h' is the first element */ if (last == NULL) stack->stack_userfilter->uf_hooks_list[h->hooknum] = current->next; else last->next = current->next; mem_free(current); ret = 1; break; } last = current; current = current->next; } if (ret == 1) LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: hook %s, unregistered handler p=%p fun=%p\n", __func__, STR_HOOKNAME(h->hooknum), h, h->hook)); else LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: hook %s, not found handler p=%p fun=%p\n", __func__, STR_HOOKNAME(h->hooknum), h, h->hook)); UF_UNLOCK(stack); return ret; } INLINE static uf_verdict_t uf_iterate(struct stack *stack, uf_hook_t hooknum, struct pbuf **p, struct netif *in, struct netif *out) { struct uf_item *currhook; uf_verdict_t ret = UF_ACCEPT; LWIP_DEBUGF(USERFILTER_DEBUG, ("\n%s: %s START (pbuf=%p)\n", __func__, STR_HOOKNAME(hooknum), *p)); currhook = stack->stack_userfilter->uf_hooks_list[hooknum]; while (currhook != NULL) { LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: hook=%p...\n", __func__, currhook->uf_h->hook)); ret = currhook->uf_h->hook(stack, hooknum, p, in, out); if (ret != UF_ACCEPT) { if (ret == UF_REPEAT) { LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: hook=%p need REPEAT!\n", __func__, currhook->uf_h->hook)); /* repeat last */ continue; } else break; } currhook = currhook->next; } LWIP_DEBUGF(USERFILTER_DEBUG, ("%s: %s STOP -> %s \n", __func__, STR_HOOKNAME(hooknum), STR_VERDICT(ret))); return ret; } int uf_visit_hook(struct stack *stack, uf_hook_t hooknum, struct pbuf **p, struct netif *in, struct netif *out, u8_t freebuf) { int ret = 0; if (stack->stack_userfilter == NULL) return -1; UF_LOCK(stack); ret = uf_iterate(stack, hooknum, p, in, out); if (ret == UF_ACCEPT) ret = 1; else if (ret == UF_DROP) { if (freebuf == UF_FREE_BUF) pbuf_free(*p); ret = -1; } else /* I know, this is paranoic! */ if (ret == UF_STOLEN) ret = 0; UF_UNLOCK(stack); return ret; } #endif /* LWIP_USERFILTER */ lwipv6-1.5a/lwip-v6/src/include/0000755000175000017500000000000011671615111015541 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/radv/0000755000175000017500000000000011671615111016475 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/radv/lwip/0000755000175000017500000000000011671615111017450 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/radv/lwip/radvconf.h0000644000175000017500000000221011671615005021420 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if IPv6_RADVCONF #ifndef __LWIP_RADVCONF_H__ #define __LWIP_RADVCONF_H__ #include void radv_load_config(struct stack *stack, FILE *filein); int radv_load_configfile(struct stack *stack, char *path); #endif #endif lwipv6-1.5a/lwip-v6/src/include/netif/0000755000175000017500000000000011671615111016646 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/netif/etharp.h0000644000175000017500000001303111671615004020301 0ustar renzorenzo/* * Copyright (c) 2001-2003 Swedish Institute of Computer Science. * Copyright (c) 2003-2004 Leon Woestenberg * Copyright (c) 2003-2004 Axon Digital Design B.V., The Netherlands. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __NETIF_ETHARP_H__ #define __NETIF_ETHARP_H__ #ifndef ETH_PAD_SIZE #define ETH_PAD_SIZE 0 #endif #include "lwip/pbuf.h" #include "lwip/ip_addr.h" #include "lwip/netif.h" #include "lwip/ip.h" #include "lwip/sockets.h" #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct eth_addr { PACK_STRUCT_FIELD(u8_t addr[6]); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* ethernet receiving rule: (low level interface packet selection: * interface must be up && * (unicast for this if || multi or broadcast || promisc mode) */ #define ETH_RECEIVING_RULE(PCKTMAC,IFMAC,FLAGS) \ ((FLAGS) & NETIF_FLAG_UP && \ (memcmp((PCKTMAC),(IFMAC),sizeof(struct eth_addr)) == 0 || \ (*(u8_t *)(PCKTMAC)) & 0x1 || \ (FLAGS) & NETIF_PROMISC)) #if LWIP_PACKET #include "lwip/packet.h" #define ARPHRD_ETHER 1 #define ETH_CHECK_PACKET_IN(NETIF,P) ({ \ if ((NETIF)->stack->active_pfpacket) eth_packet_mgmt((NETIF),(P),0) ; \ }) #define ETH_CHECK_PACKET_OUT(NETIF,P) ({ \ if ((NETIF)->stack->active_pfpacket) eth_packet_mgmt((NETIF),(P),PACKET_OUTGOING) ; \ }) void eth_packet_mgmt(struct netif *netif, struct pbuf *p,u8_t pkttype); u16_t eth_packet_out(struct netif *netif, struct pbuf *p, struct sockaddr_ll *sll, u16_t protocol, u16_t dgramflag); #else #define ETH_CHECK_PACKET_IN(NETIF,P) ({}) #define ETH_CHECK_PACKET_OUT(NETIF,P) ({}) #endif #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct eth_hdr { #if ETH_PAD_SIZE PACK_STRUCT_FIELD(u8_t padding[ETH_PAD_SIZE]); #endif PACK_STRUCT_FIELD(struct eth_addr dest); PACK_STRUCT_FIELD(struct eth_addr src); PACK_STRUCT_FIELD(u16_t type); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN /** the ARP message */ struct etharp_hdr { PACK_STRUCT_FIELD(struct eth_hdr ethhdr); PACK_STRUCT_FIELD(u16_t hwtype); PACK_STRUCT_FIELD(u16_t proto); PACK_STRUCT_FIELD(u16_t _hwlen_protolen); PACK_STRUCT_FIELD(u16_t opcode); PACK_STRUCT_FIELD(struct eth_addr shwaddr); PACK_STRUCT_FIELD(struct ip4_addr sipaddr); PACK_STRUCT_FIELD(struct eth_addr dhwaddr); PACK_STRUCT_FIELD(struct ip4_addr dipaddr); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct ethip_hdr { PACK_STRUCT_FIELD(struct eth_hdr eth); PACK_STRUCT_FIELD(struct ip_hdr ip); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct ethip4_hdr { PACK_STRUCT_FIELD(struct eth_hdr eth); PACK_STRUCT_FIELD(struct ip4_hdr ip); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /** 5 seconds period */ #define ARP_TMR_INTERVAL 5000 #define ETHTYPE_ARP 0x0806 #define ETHTYPE_IP 0x0800 #define ETHTYPE_IP6 0x86DD void etharp_init(void); void etharp_tmr(struct netif *netif); void etharp_ip_input(struct netif *netif, struct pbuf *p); void etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p); err_t etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q); err_t etharp_query(struct ip_addr_list *al, struct ip_addr *ipaddr, struct pbuf *q); err_t etharp_request(struct ip_addr_list *al, struct ip_addr *ipaddr); int etharp_ioctl(struct stack *stack, int cmd,struct arpreq *ifr #if LWIP_CAPABILITIES ,int cap #endif ); err_t update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u32_t flags); #endif /* __NETIF_ARP_H__ */ lwipv6-1.5a/lwip-v6/src/include/netif/slipif.h0000644000175000017500000000345411671615004020314 0ustar renzorenzo/* * Copyright (c) 2001, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __NETIF_SLIPIF_H__ #define __NETIF_SLIPIF_H__ #include "lwip/netif.h" err_t slipif_init(struct netif * netif); #endif lwipv6-1.5a/lwip-v6/src/include/netif/loopif.h0000644000175000017500000000334111671615004020311 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __NETIF_LOOPIF_H__ #define __NETIF_LOOPIF_H__ #include "lwip/netif.h" err_t loopif_init(struct netif *netif); #endif /* __NETIF_LOOPIF_H__ */ lwipv6-1.5a/lwip-v6/src/include/userfilter/0000755000175000017500000000000011671615111017725 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/0000755000175000017500000000000011671615111020700 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/nat/0000755000175000017500000000000011671615111021462 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/nat/nat_track_icmp.h0000644000175000017500000000214511671615004024614 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if LWIP_USERFILTER && LWIP_NAT #ifndef _NAT_TRACK_ICMP_H #define _NAT_TRACK_ICMP_H struct ip_ct_icmp { /* Optimization: when number in == number out, forget immediately. */ u32_t count; }; #endif #endif lwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/nat/nat_tables.h0000644000175000017500000000363511671615004023757 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if LWIP_USERFILTER && LWIP_NAT #ifndef __NAT_PORTS_H__ #define __NAT_PORTS_H__ /*--------------------------------------------------------------------------*/ #define TCP_MIN_PORT 0 #define TCP_MAX_PORT 65535 #define TCP_MAX_PORTS (TCP_MAX_PORT - TCP_MIN_PORT) #define TCP_PORTS_TABLE_SIZE (TCP_MAX_PORTS / 8) #define UDP_MIN_PORT 0 #define UDP_MAX_PORT 65535 #define UDP_MAX_PORTS (UDP_MAX_PORT - UDP_MIN_PORT) #define UDP_PORTS_TABLE_SIZE (UDP_MAX_PORTS / 8) #define ICMP_MIN_PORT 0 #define ICMP_MAX_PORT 65535 #define ICMP_MAX_PORTS (ICMP_MAX_PORT - ICMP_MIN_PORT) #define ICMP_PORTS_TABLE_SIZE (ICMP_MAX_PORTS / 8) /*--------------------------------------------------------------------------*/ void nat_ports_init(struct stack *stack); int nat_ports_getnew(struct stack *stack, int protocol, u16_t *port, u32_t min, u32_t max); u16_t nat_ports_free(struct stack *stack, int protocol, u16_t val); #endif /* NAT_PORTS */ #endif lwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/nat/nat_track_protocol.h0000644000175000017500000000361011671615004025523 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if LWIP_USERFILTER && LWIP_NAT #ifndef _NAT_TRACK_PROTOCOL_H #define _NAT_TRACK_PROTOCOL_H struct track_protocol { u_int8_t proto; /* Tuple functions */ int (*tuple)(struct ip_tuple *tuple, void *hdr); int (*inverse) (struct ip_tuple *reply, struct ip_tuple *tuple); /* Tracking functions */ int (*error) (struct stack *stack, uf_verdict_t *verdict, struct pbuf *q); int (*new) (struct stack *stack, struct nat_pcb *pcb, struct pbuf *p, void *iphdr, int iplen); int (*handle) (struct stack *stack, uf_verdict_t *verdict, struct pbuf *p, conn_dir_t direction); /* NAT functions */ int (*nat_tuple_inverse) (struct stack *stack, struct ip_tuple *reply, struct ip_tuple *tuple, nat_type_t type, struct manip_range *nat_manip); int (*nat_free) (struct nat_pcb *pcb); int (*manip) (nat_manip_t type, void *iphdr, int iplen, struct ip_tuple *inverse, u8_t *iphdr_new_changed_buf, u8_t *iphdr_old_changed_buf, u32_t iphdr_changed_buflen); }; #endif /*_INAT_TRACK_PROTOCOL */ #endif lwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/nat/nat_rules.h0000644000175000017500000000566611671615004023645 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if LWIP_USERFILTER && LWIP_NAT #ifndef __NAT_RULES_H__ #define __NAT_RULES_H__ // Max number of rule the stack can handle #ifndef MEMP_NUM_NAT_RULE #define MEMP_NUM_NAT_RULE 100 #endif /* * Manipulation range. FIX: up to now, only ipmin and protomin are used! */ struct manip_range { u8_t flag; /* values to use */ #define MANIP_RANGE_IP 0x01 #define MANIP_RANGE_PROTO 0x02 /* IP range */ struct ip_addr ipmin, ipmax; /* TCP/UDP port range */ struct proto_range { u16_t value; } protomin, protomax; }; // // Matching options // struct rule_matches { struct netif *iface; // Interface // Match IP u8_t ipv; struct ip_addr src_ip; struct ip_addr dst_ip; #define SET_IGNORE_IP(ipaddr) IP6_ADDR((ipaddr), 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000) #define IS_IGNORE_IP(ipaddr) ((ipaddr)->addr[3] == 0x0000 && (ipaddr)->addr[2] == 0x0000 && (ipaddr)->addr[0] == 0x0000 && (ipaddr)->addr[1] == 0x0000) // Transport protocol (TCP/UDP) u16_t protocol; #define IGNORE_PROTO 0xFFFF #define IS_IGNORE_PROTO(proto) ((proto) == IGNORE_PROTO) // Match port TCP/UDP u16_t src_port; u16_t dst_port; #define IGNORE_PORT 0x0000 #define IS_IGNORE_PORT(p) ((p) == IGNORE_PORT) }; struct nat_rule { struct nat_rule *next; // For the linked list struct rule_matches matches; nat_type_t type; struct manip_range manip; }; /*--------------------------------------------------------------------------*/ /* Functions */ /*--------------------------------------------------------------------------*/ // Malloc a new nat_rule structure struct nat_rule * nat_new_rule(void); void nat_free_rule(struct nat_rule *rule); int nat_add_rule(struct stack *stack, int ipv, nat_table_t where, struct nat_rule *new_rule); struct nat_rule * nat_del_rule(struct stack *stack, nat_table_t where, int pos); /* Returns 1 if "rule" matches with the tuple "tuple" */ int nat_match_rule(struct rule_matches *matches, struct netif *iface, struct ip_tuple *tuple); void nat_rules_shutdown(struct stack *stack); #endif #endif lwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/nat/nat.h0000644000175000017500000002247311671615004022426 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if LWIP_USERFILTER && LWIP_NAT #ifndef __NAT_H__ #define __NAT_H__ #include "lwip/sys.h" /* Don't remove these. */ struct pbuf; struct netif; #include "lwip/userfilter.h" #include "lwip/pbuf.h" #include "lwip/netif.h" #include "lwip/nat/nat_tables.h" // Max number of session the module can handle #ifndef MEMP_NUM_NAT_PCB #define MEMP_NUM_NAT_PCB 32 #endif /*--------------------------------------------------------------------------*/ /* Costants for hook registration. */ /*--------------------------------------------------------------------------*/ #define UF_PRI_NAT_PREROUTING_DEFRAG 99 #define UF_PRI_NAT_PREROUTING_TRACK 100 #define UF_PRI_NAT_PREROUTING_DNAT 200 #define UF_PRI_NAT_INPUT_CONFIRM 100 #define UF_PRI_NAT_OUTPUT_TRACK 100 #define UF_PRI_NAT_POSTROUTING_SNAT 100 #define UF_PRI_NAT_POSTROUTING_CONFIRM 200 /* NAT Hooks * +----- APPS -----+ * | | * INPUT [C] [T] OUTPUT * | | * | | * PREROUTING | FORWARD | POSTROUTING * netif --+-->[F][T][N]-->-+--->--[ ]--->---+->--[N][C]--+--> netif * | | * +-------------<--------------<-----------------+ * * [F}rag = Fragmented packet are reassembled before everything (review this!) * [T}rak = New valid connection are tracked for possible NAT * [N]at = Rules are checked and DNAT or SNAT is performed * [C]confirm = timeout is set or refreshed and if packet reach this * hook the new connections is confirmed and expire . */ /*--------------------------------------------------------------------------*/ /* NAT costants */ /*--------------------------------------------------------------------------*/ /* Types of NAT */ typedef enum { NAT_NONE = 0, NAT_SNAT, NAT_DNAT, NAT_MASQUERADE, } nat_type_t; #define NAT2MANIP(t) ( (t) == NAT_DNAT ? MANIP_DST : MANIP_SRC ) /* Type of packet manipulation */ typedef enum { MANIP_DST = 0, MANIP_SRC = 1 } nat_manip_t; #define HOOK2MANIP(h) ( (h) == UF_IP_PRE_ROUTING ? MANIP_DST : MANIP_SRC ) /* Direction of a packet */ typedef enum { CONN_DIR_ORIGINAL, CONN_DIR_REPLY, CONN_DIR_MAX } conn_dir_t; /*--------------------------------------------------------------------------*/ /* Connection tuple data */ /*--------------------------------------------------------------------------*/ struct proto_info { u8_t protonum; union { struct { u16_t port; } tcp; struct { u16_t port; } udp; struct { u8_t type, code; u16_t id; } icmp4; struct { u8_t type, code; u16_t id; } icmp6; u_int32_t all; } upi; }; struct ip_pair { /* Use 128bit addresses for both IPv4 and IPv6 */ struct ip_addr ip; struct proto_info proto; }; struct ip_tuple { u8_t ipv; struct ip_pair src; struct ip_pair dst; }; /*--------------------------------------------------------------------------*/ /* NAT process controll blocks */ /*--------------------------------------------------------------------------*/ enum track_status { /* We've seen packets both ways: bit 1 set. Can be set, not unset. */ TS_SEEN_REPLY_BIT = 1, TS_SEEN_REPLY = (1 << TS_SEEN_REPLY_BIT), /* Connection is confirmed: originating packet has NATed successfully */ TS_CONFIRMED_BIT = 2, TS_CONFIRMED = (1 << TS_CONFIRMED_BIT), /* Connection is dying (removed from lists), can not be unset. */ TS_DYING_BIT = 3, TS_DYING = (1 << TS_DYING_BIT), /* Which kind of NAT has been tryed so far */ TS_SNAT_TRY_BIT = 4, TS_SNAT_TRY = (1 << TS_SNAT_TRY_BIT), TS_DNAT_TRY_BIT = 5, TS_DNAT_TRY = (1 << TS_DNAT_TRY_BIT), TS_NAT_TRY_MASK = (TS_SNAT_TRY | TS_DNAT_TRY), TS_MASQUERADE_BIT = 8, TS_MASQUERADE = (1 << TS_MASQUERADE_BIT ), }; #include "lwip/nat/nat_track_tcp.h" #include "lwip/nat/nat_track_udp.h" #include "lwip/nat/nat_track_icmp.h" /* * NAT Process Control Block */ struct nat_pcb { struct nat_pcb *next; // For the linked list struct stack *stack; unsigned int id; u32_t refcount; /* Tracking data */ enum track_status status; /* Connection's tuples in both directions. For NATed connections, CONN_DIR_REPLY tuple's fields are modifed. CONN_DIR_ORIGINAL tuple is fixed and never changes */ struct ip_tuple tuple[CONN_DIR_MAX]; u32_t timeout; /* mseconds */ union track_data { struct ip_ct_tcp TCP; struct ip_ct_udp udp; struct ip_ct_icmp icmp4; struct ip_ct_icmp icmp6; } proto; /* NAT info */ nat_type_t nat_type; struct netif *iface; // Interface linked with NAT session }; /*--------------------------------------------------------------------------*/ /* Data stored in the stack structure */ /*--------------------------------------------------------------------------*/ struct stack_nat { sys_sem_t nat_mutex; /* Semaphore for critical section */ struct nat_pcb *nat_tentative_pcbs; struct nat_pcb *nat_active_pcbs; struct nat_rule *nat_in_rules; struct nat_rule *nat_out_rules; sys_sem_t tcp_lock; unsigned char nat_tcp_table[TCP_PORTS_TABLE_SIZE]; unsigned char nat_udp_table[UDP_PORTS_TABLE_SIZE]; unsigned char nat_icmp_table[ICMP_PORTS_TABLE_SIZE]; }; /*--------------------------------------------------------------------------*/ /* Pbuf data & functions */ /*--------------------------------------------------------------------------*/ enum conn_info { /* Part of an established connection (either direction). */ CT_ESTABLISHED, /* Like NEW, but related to an existing connection, or ICMP error (in either direction). */ CT_RELATED, /* Started a new connection to track (only IP_CT_DIR_ORIGINAL); may be a retransmission. */ CT_NEW, /* >= this indicates reply direction */ CT_IS_REPLY, /* Number of distinct IP_CT types (no NEW in reply dirn). */ CT_NUMBER = CT_IS_REPLY * 2 - 1 }; struct nat_info { enum conn_info info; u32_t dir; struct nat_pcb *track; }; void nat_pbuf_init(struct pbuf *p); void nat_pbuf_get(struct pbuf *p); void nat_pbuf_clone(struct pbuf *r, struct pbuf *p); void nat_pbuf_put(struct pbuf *p); void nat_pbuf_reset(struct pbuf *p); /*--------------------------------------------------------------------------*/ /* NAT Rules */ /*--------------------------------------------------------------------------*/ // NAT operations are performed in several points. typedef enum { NAT_PREROUTING, NAT_POSTROUTING } nat_table_t; #include "lwip/nat/nat_rules.h" /*--------------------------------------------------------------------------*/ /* Protocol handlers */ /*--------------------------------------------------------------------------*/ #include "lwip/nat/nat_track_protocol.h" extern struct track_protocol default_track; extern struct track_protocol tcp_track; extern struct track_protocol icmp4_track; extern struct track_protocol icmp6_track; extern struct track_protocol udp_track; struct track_protocol * track_proto_find(u8_t protocol); struct stack; /*--------------------------------------------------------------------------*/ /* NAT functions */ /*--------------------------------------------------------------------------*/ int nat_init(struct stack *stack); int nat_shutdown(struct stack *stack); int conn_remove_timer(struct nat_pcb *pcb); void conn_refresh_timer(u32_t timeout, struct nat_pcb *pcb); void conn_force_timeout(struct nat_pcb *pcb); int tuple_create(struct ip_tuple *tuple, char *p, struct track_protocol *proto); int tuple_inverse(struct ip_tuple *reply, struct ip_tuple *tuple) ; struct nat_pcb * conn_find_track(struct stack *stack, conn_dir_t *direction, struct ip_tuple * tuple ); /* Functions used by NAT modules */ void nat_chksum_adjust(u8_t * chksum, u8_t * optr, s16_t olen, u8_t * nptr, s16_t nlen); /*--------------------------------------------------------------------------*/ /* Debug */ /*--------------------------------------------------------------------------*/ #ifdef LWIP_DEBUG #define STR_DIRECTIONNAME(dir) ( \ (dir)==CONN_DIR_ORIGINAL ? "ORIGINAL": \ (dir)==CONN_DIR_REPLY ? "REPLY" : \ "***BUG***" ) #define STR_NATNAME(dir) ( \ (dir)==NAT_NONE ? "(NONE)" : \ (dir)==NAT_SNAT ? "SNAT" : \ (dir)==NAT_DNAT ? "DNAT" : \ (dir)==NAT_MASQUERADE ? "MASQUERADE" : \ "***BUG***" ) #endif #endif /* NAT_H */ #endif /* LWIP_UNAT */ lwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/nat/nat_track_tcp.h0000644000175000017500000000700011671615004024445 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if LWIP_USERFILTER && LWIP_NAT #ifndef _NAT_TRACK_TCP_H #define _NAT_TRACK_TCP_H enum tcp_conntrack { TCP_CONNTRACK_NONE, TCP_CONNTRACK_SYN_SENT, TCP_CONNTRACK_SYN_RECV, TCP_CONNTRACK_ESTABLISHED, TCP_CONNTRACK_FIN_WAIT, TCP_CONNTRACK_CLOSE_WAIT, TCP_CONNTRACK_LAST_ACK, TCP_CONNTRACK_TIME_WAIT, TCP_CONNTRACK_CLOSE, TCP_CONNTRACK_LISTEN, TCP_CONNTRACK_MAX, TCP_CONNTRACK_IGNORE }; /* Window scaling is advertised by the sender */ #define IP_CT_TCP_FLAG_WINDOW_SCALE 0x01 /* SACK is permitted by the sender */ #define IP_CT_TCP_FLAG_SACK_PERM 0x02 /* This sender sent FIN first */ #define IP_CT_TCP_FLAG_CLOSE_INIT 0x03 struct ip_ct_tcp_state { u32_t td_end; /* max of seq + len */ u32_t td_maxend; /* max of ack + max(win, 1) */ u32_t td_maxwin; /* max(win) */ u8_t td_scale; /* window scale factor */ u8_t loose; /* used when connection picked up from the middle */ u8_t flags; /* per direction options */ }; struct ip_ct_tcp { struct ip_ct_tcp_state seen[2]; /* connection parameters per direction */ u8_t state; /* state of the connection (enum tcp_conntrack) */ /* For detecting stale connections */ u8_t last_dir; /* Direction of the last packet (enum ip_conntrack_dir) */ u8_t retrans; /* Number of retransmitted packets */ u8_t last_index; /* Index of the last packet */ u32_t last_seq; /* Last sequence number seen in dir */ u32_t last_ack; /* Last sequence number seen in opposite dir */ u32_t last_end; /* Last seq + len */ }; int ip_conntrack_protocol_tcp_lockinit(struct stack *stack); /*--------------------------------------------------------------------------*/ /* Costants for hook registration. */ /*--------------------------------------------------------------------------*/ #ifdef LWIP_DEBUG #define TCP_STRSTATE(x) ( \ (x)==TCP_CONNTRACK_NONE ? "TCP_CONNTRACK_NONE" : \ (x)==TCP_CONNTRACK_SYN_SENT ? "TCP_CONNTRACK_SYN_SENT" : \ (x)==TCP_CONNTRACK_SYN_RECV ? "TCP_CONNTRACK_SYN_RECV" : \ (x)==TCP_CONNTRACK_ESTABLISHED ? "TCP_CONNTRACK_ESTABLISHED" : \ (x)==TCP_CONNTRACK_FIN_WAIT ? "TCP_CONNTRACK_FIN_WAIT" : \ (x)==TCP_CONNTRACK_CLOSE_WAIT ? "TCP_CONNTRACK_CLOSE_WAIT" : \ (x)==TCP_CONNTRACK_LAST_ACK ? "TCP_CONNTRACK_LAST_ACK" : \ (x)==TCP_CONNTRACK_TIME_WAIT ? "TCP_CONNTRACK_TIME_WAIT" : \ (x)==TCP_CONNTRACK_CLOSE ? "TCP_CONNTRACK_CLOSE" : \ (x)==TCP_CONNTRACK_LISTEN ? "TCP_CONNTRACK_LISTEN" : \ (x)==TCP_CONNTRACK_MAX ? "TCP_CONNTRACK_MAX" : \ (x)==TCP_CONNTRACK_IGNORE ? "TCP_CONNTRACK_IGNORE" : \ "XXXXXXXXX BUG XXXXXXXXXXX" ) #endif #endif /* _NAT_TRACK_TCP_H */ #endif /* LWIP_NAT */ lwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/nat/nat_track_udp.h0000644000175000017500000000203411671615004024451 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if LWIP_USERFILTER && LWIP_NAT #ifndef _NAT_TRACK_UDP_H #define _NAT_TRACK_UDP_H struct ip_ct_udp { u8_t isstream; }; #endif #endif lwipv6-1.5a/lwip-v6/src/include/userfilter/lwip/userfilter.h0000644000175000017500000001375111671615004023245 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if LWIP_USERFILTER #ifndef __USERFILTER_H__ #define __USERFILTER_H__ struct stack; /* * Trip of IPv4/IPv6 packets throw Userfilter's hooks in the stack. * * Apps * .---> Lwipv6 --->. * | | * | | * [2] [4] * | | * | [routing] * | | * | | * +--->[1]--->[routing]-->[3]----->+--->[5]--->+ * | | * | | * input output * netif netif * * [1] PRE_ROUTING * [2] LOCAL_IN * [3] FORWARD * [4] LOCAL_OUT * [5] POST_ROUTING * * ATTENTION: When userfilter is enable, Fragmentation should be handled in a * particular way. * * Ingoing packets are NOT reassembled BEFORE any PRE_ROUTING * filtering [1]. User's hooks should use defragmentation * function at [1] before any other operation. * * Outgoing packets are fragmented AFTER any POST_ROUTING [5] * filtering. * * In this way, filtering code is sure that it's working on * entire packets. */ typedef enum { UF_IP_PRE_ROUTING = 0, UF_IP_LOCAL_IN, UF_IP_FORWARD, UF_IP_LOCAL_OUT, UF_IP_POST_ROUTING, UF_IP_NUMHOOKS } uf_hook_t; /* Hook handler verdicts. After computation an handler must * return one of these values. * ATTENTION: DO NOT change order or position of UF_DROP and UF_ACCEPT! */ typedef enum { UF_DROP, /* packet must be dropped */ UF_ACCEPT, /* packet can pass to the next handler */ UF_REPEAT, /* packet have to repeat the last handler */ UF_STOLEN, /* packet has been "stolen" by the handler. */ UF_MAX_VERDICT } uf_verdict_t; /* * Hook handler function. * ATTENTION: hook handlers must not call pbuf_free() on 'p'. The handler * can return UF_DROP and tell to Userfilter to free the memory. */ typedef uf_verdict_t uf_hookfun_t(struct stack *stack, uf_hook_t hooknum, struct pbuf **p, struct netif *inif, struct netif *outif); /* Hook handler priority */ typedef short int uf_priority_t; /* Hook handler descriptor */ struct uf_hook_handler { // struct uf_hook_handler *next; /* used internaly */ uf_hook_t hooknum; /* handled hook */ uf_hookfun_t *hook; /* User fills in from here down. */ uf_priority_t priority; /* ascending priority. */ }; /*--------------------------------------------------------------------------*/ /* Functions */ /*--------------------------------------------------------------------------*/ /* * Initialize hooks. Call this first. */ int userfilter_init(struct stack *stack); /* * Cleanup hooks. */ int userfilter_shutdown(struct stack *stack); /* * ATTENTION: don't register/unregister hooks when the stack is active. * These functions are not thread-safe. */ /* * Register a new hook (with ascending priority). If there are other * handlers with same priority, 'h' is registered after them. * Return 1 on success, 0 on failure. */ int uf_register_hook(struct stack *stack, struct uf_hook_handler *h); /* * Unregister a hook. On success returns 1. If 'h' is not found, * return 0. */ int uf_unregister_hook(struct stack *stack, struct uf_hook_handler *h); /* * Pass 'p' to all handlers registered ad hook 'hooknum'. * Returns 1 if 'p' can go along (after a UF_ACCEPT verdict). * Return 0 if 'p' has been captured by one of the hooks. (after a UF_STOLEN) * Returns < 0 if 'p' has been dropped by a hook. (for a UF_DROP verdict). * If 'freedrop' is 1 then dropped packet 'p' is freed before exit. */ int uf_visit_hook(struct stack *stack, uf_hook_t hooknum, struct pbuf **p, struct netif *in, struct netif *out, u8_t freebuf); #define UF_FREE_BUF 1 #define UF_DONTFREE_BUF 0 /* * Used inside ip6.c source. */ #define UF_HOOK(stack, hook, pbuf, inif, outif, freebuf) \ ({ int ___r = 1; \ if (stack->stack_userfilter != NULL) \ ___r = uf_visit_hook((stack), (hook), (pbuf), (inif), (outif), (freebuf)); \ ___r; /* return value */ \ }) /*--------------------------------------------------------------------------*/ /* Debug */ /*--------------------------------------------------------------------------*/ #ifdef LWIP_DEBUG #define STR_VERDICT(v) ( \ (v)==UF_ACCEPT ? "ACCEPT" : \ (v)==UF_DROP ? "DROP" : \ (v)==UF_STOLEN ? "STOLEN" : \ (v)==UF_REPEAT ? "REPEAT" : \ "***BUG***" ) #define STR_HOOKNAME(hook) ( \ (hook)==UF_IP_PRE_ROUTING ? "PRE_ROUTING" : \ (hook)==UF_IP_LOCAL_IN ? "LOCAL_IN" : \ (hook)==UF_IP_FORWARD ? "FORWARD" : \ (hook)==UF_IP_LOCAL_OUT ? "LOCAL_OUT" : \ (hook)==UF_IP_POST_ROUTING ? "POST_ROUTING" : \ "***BUG***" ) #endif #endif /* USERFILTER */ #endif /* LWIP_USERFILTER */ lwipv6-1.5a/lwip-v6/src/include/ipv6/0000755000175000017500000000000011671615111016425 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/0000755000175000017500000000000011671615111017400 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/ip_autoconf.h0000644000175000017500000001244311671615004022064 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if IPv6_AUTO_CONFIGURATION #ifndef __LWIP_IP_AUTOCONF_H__ #define __LWIP_IP_AUTOCONF_H__ /*--------------------------------------------------------------------------*/ /* Protocol Costants (RFC 2461) */ /*--------------------------------------------------------------------------*/ #define UNSPECIFIED 0 #define INFINITE_LIFETIME 0xffffffff #define RETRANS_TIMER 1000 /* milliseconds */ /* Host constants: */ #define MAX_RTR_SOLICITATION_DELAY 1 /* seconds */ #define RTR_SOLICITATION_INTERVAL 4 /* seconds */ #define MAX_RTR_SOLICITATIONS 3 /* transmissions */ /*--------------------------------------------------------------------------*/ /* Per-interface data used by stateless autoconfiguration protocol. */ /*--------------------------------------------------------------------------*/ struct netif; struct ip_addr; struct autoconf { /* Autoconfiguration protocol status */ u8_t status; #define AUTOCONF_INIT 0x00 #define AUTOCONF_FAIL 0x01 #define AUTOCONF_SUCC 0x02 u8_t flag_M; u8_t flag_O; /* List of tentative addresses. A tentative address is not considered "assigned to an interface" in the traditional sense. That is, the interface must accept Neighbor Solicitation and Advertisement messages containing the tentative address in the Target Address field. */ struct ip_addr_list * addrs_tentative; /* DupAddrDetectTransmits The number of consecutive Neighbor Solicitation messages sent while performing Duplicate Address Detection on a tentative address [rfc2462]. */ u8_t dad_duptrans; #define DUP_ADDR_DETECT_TRANSMITS 1 /* RetransTimer. Milliseconds between retransmitted Neighbor Solicitation messages. Default: RETRANS_TIMER. */ u32_t retrans_timer; /* Number of sent RS */ u8_t rtr_sol_counter; /* Initial delay befor first solicitation in seconds. Default: MAX_RTR_SOLICITATION_DELAY */ u16_t max_rtr_solicitation_delay; /* Interval between solicitations in seconds. Default: RTR_SOLICITATION_INTERVAL */ u16_t rtr_solicitation_interval; /* Max Number of solicitations. Default: MAX_RTR_SOLICITATIONS */ u8_t max_rtr_solicitations; }; /*--------------------------------------------------------------------------*/ /* Per-address informations */ /*--------------------------------------------------------------------------*/ /* * Autoconfigured Address States * * |<----------Valid ---------->| * | Tentative | Preferred | Deprecated | Invalid * |==========================================================> TIME * |<-- Preferred Lifetime --->| | * |<----------- Valid Lifetime ------------->| */ #define IPADDR_NONE 0x00 /* IPADDR_TENTATIVE addresses aren't stored in net->addr */ #define IPADDR_TENTATIVE 0x01 #define IPADDR_VALID 0x02 #define IPADDR_PREFERRED 0x12 #define IPADDR_DEPRECATED 0x22 #define IPADDR_INVALID 0x04 /* * FIX: Netlink code defines IFA_F_DEPRECATED, IFA_F_TENTATIVE, IFA_F_PERMANENT * for the ip_addr_list::flag field. We set both IFA_F_* and IPADDR_* * during autoconfiguration. Find a way to use only one of them. */ struct addr_info { u8_t flag; u8_t dad_counter; /* number of tentatives for DAD protocol */ /* Life-time */ u32_t prefered; u32_t valid; }; /*--------------------------------------------------------------------------*/ /* Module Functions and costants */ /*--------------------------------------------------------------------------*/ /* Autoconfiguration Timer timeout (1 second) */ #define AUTOCONF_TMR_INTERVAL 1000 /* Called by ip_init() */ void ip_autoconf_init(struct stack *stack); void ip_autoconf_shutdown(struct stack *stack); /* Called by netif_add() */ void ip_autoconf_netif_init(struct netif *netif); /* Called by ip_change() */ void ip_autoconf_start(struct netif *netif); void ip_autoconf_stop(struct netif *netif); struct ip_hdr; struct icmp_ra_hdr; struct icmp_na_hdr; struct pbuf; /* Called by ICMP level when Router Advertisment messages are received */ void ip_autoconf_handle_ra(struct netif *netif, struct pbuf *p, struct ip_hdr *iphdr, struct icmp_ra_hdr *ira); /* Called by ICMP level when Neighbor Advertisment messages are received */ void ip_autoconf_handle_na(struct netif *netif, struct pbuf *p, struct ip_hdr *iphdr, struct icmp_na_hdr *ina); #endif /* LWIP_IP_AUTOCONF */ #endif /* IPv6_AUTO_CONFIGURATION */ lwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/ip_addr.h0000644000175000017500000003166211671615004021164 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_IP_ADDR_H__ #define __LWIP_IP_ADDR_H__ #include "lwip/opt.h" #include "lwip/arch.h" struct stack; struct ip_addr { u32_t addr[4]; }; struct ip4_addr { u32_t addr; }; /* Added by Diego Billi */ extern const struct ip4_addr ip4_addr_broadcast; #define IP4_ADDR_BROADCAST ((struct ip4_addr *)&ip4_addr_broadcast) extern const struct ip_addr ip_addr_any; extern const struct ip_addr ip4_addr_any; /** IP_ADDR_ can be used as a fixed IP address * * for the wildcard and the broadcast address * */ #define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any) #define IP4_ADDR_ANY ((struct ip_addr *)&ip4_addr_any) typedef struct { u32_t a1; u32_t a2; u32_t a3; u32_t a4; } u128_t; /* FOR SOCKET CALL! */ ///struct in6_addr { /// unsigned char s6_addr[16];/* IPv6 address */ ///}; ///struct in_addr { /// u32_t s_addr; ///}; #define IP6_ADDR(ipaddr, a,b,c,d,e,f,g,h) do { (ipaddr)->addr[0] = htonl((u32_t)(((a) & 0xffff) << 16) | ((b) & 0xffff)); \ (ipaddr)->addr[1] = htonl((((c) & 0xffff) << 16) | ((d) & 0xffff)); \ (ipaddr)->addr[2] = htonl((((e) & 0xffff) << 16) | ((f) & 0xffff)); \ (ipaddr)->addr[3] = htonl((((g) & 0xffff) << 16) | ((h) & 0xffff)); } while(0) #define IP4_ADDR(ip4addr, a,b,c,d) (ip4addr)->addr = htonl(((u32_t)((a) & 0xff) << 24) | ((u32_t)((b) & 0xff) << 16) | \ ((u32_t)((c) & 0xff) << 8) | (u32_t)((d) & 0xff)) #define IP4_ADDRX(ip4ax, a,b,c,d) (ip4ax) = htonl(((u32_t)((a) & 0xff) << 24) | ((u32_t)((b) & 0xff) << 16) | \ ((u32_t)((c) & 0xff) << 8) | (u32_t)((d) & 0xff)) #define IP64_PREFIX (htonl(0xffff)) #define IP64_CONV(ipaddr, ip4) do { \ (ipaddr)->addr[0] = 0; \ (ipaddr)->addr[1] = 0; \ (ipaddr)->addr[2] = IP64_PREFIX; \ (ipaddr)->addr[3] = (ip4)->addr; } while (0) #define IP64_ADDR(ipaddr, a,b,c,d) do { \ (ipaddr)->addr[0] = 0; \ (ipaddr)->addr[1] = 0; \ (ipaddr)->addr[2] = IP64_PREFIX; \ IP4_ADDRX(((ipaddr)->addr[3]),(a),(b),(c),(d)); } while (0) #define IP64_MASKCONV(ipaddr, ip4) do { \ (ipaddr)->addr[0] = 0xffffffff; \ (ipaddr)->addr[1] = 0xffffffff; \ (ipaddr)->addr[2] = 0xffffffff; \ (ipaddr)->addr[3] = (ip4)->addr; } while (0) #define IP64_MASKADDR(ipaddr, a,b,c,d) do { \ (ipaddr)->addr[0] = 0xffffffff; \ (ipaddr)->addr[1] = 0xffffffff; \ (ipaddr)->addr[2] = 0xffffffff; \ IP4_ADDRX(((ipaddr)->addr[3]),(a),(b),(c),(d)); } while (0) #define ip4_addr1(x) ((x)->addr[3] >> 24) #define ip4_addr2(x) ((x)->addr[3] >> 16 & 0xff) #define ip4_addr3(x) ((x)->addr[3] >> 8 & 0xff) #define ip4_addr4(x) ((x)->addr[3] & 0xff) int ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2, struct ip_addr *mask); int ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2); void ip_addr_set(struct ip_addr *dest, struct ip_addr *src); void ip_addr_set_mask(struct ip_addr *dest, struct ip_addr *src, struct ip_addr *mask); void ip64_addr_set(struct ip4_addr *dest, struct ip_addr *src); void ip4_addr_set(struct ip4_addr *dest, struct ip4_addr *src); #define ip4_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr) /*int ip_addr_isany(struct ip_addr *addr);*/ #define ip_addr_isany(addrx) (((addrx) == NULL) || \ ((((addrx)->addr[0] | \ (addrx)->addr[1] | \ (addrx)->addr[3]) == 0)&& \ (((addrx)->addr[2])==0 || \ ((addrx)->addr[2])==htonl(0xffff)))) /* * IPv6 Unspecified */ #define ip_addr_isunspecified(ipaddr) \ (((ipaddr)->addr[0] == 0) && \ ((ipaddr)->addr[1] == 0) && \ ((ipaddr)->addr[2] == 0) && \ ((ipaddr)->addr[3] == 0)) #define IP6_ADDR_UNSPECIFIED(ipaddr) do { \ (ipaddr)->addr[0] = 0; \ (ipaddr)->addr[1] = 0; \ (ipaddr)->addr[2] = 0; \ (ipaddr)->addr[3] = 0; } while (0); /* * IPv6 Link-scope addresses */ /* Creates link-scope address "ip" based on link address "hwaddr". * * ethernet 00-80-ad-c8-a9-81 * / / / \ \ \ * 00-80-ad-FF-FE-c8-a9-81 * | / * invert bit 02 / * | / * fe80:0000:0000:0000:0280:adFF:FEc8:a981 * */ #define IP6_ADDR_LINKSCOPE(ip, hwaddr) \ IP6_ADDR((ip), 0xfe80, 0x0000, 0x0000, 0x0000, \ ((((hwaddr)[0])&(0x02) ? ((hwaddr)[0])&(~(0x02)) : ((hwaddr)[0])&(0x02) <<8) | (hwaddr)[1] ), \ ((hwaddr)[2]<<8 | 0xff), (0xfe00 | (hwaddr)[3] ), \ ((hwaddr)[4]<<8 | (hwaddr)[5])) #define ip_addr_islinkscope(ip) \ (((ip)->addr[0]==htonl(0xfe800000)) && ((ip)->addr[1]==0x00000000)) /* * IPv6 Multicast addresses */ #define ip_addr_ismulticast(addr1) ((ntohl((addr1)->addr[0]) >> 24) == 0xff) /* #define ip_addr_isbroadcast(addr1, mask) ip_addr_ismulticast(addr1) */ #define ip_addr_isallnode(addr1) \ ((((addr1)->addr[0] == htonl(0xff010000)) || \ ((addr1)->addr[0] == htonl(0xff020000))) && \ ((addr1)->addr[1] == 0) && \ ((addr1)->addr[2] == 0) && \ ((addr1)->addr[3] == 1)) #define ip_addr_isallrouter(addr1) \ ((((addr1)->addr[0] == htonl(0xff010000)) || \ ((addr1)->addr[0] == htonl(0xff020000))) && \ ((addr1)->addr[1] == 0) && \ ((addr1)->addr[2] == 0) && \ ((addr1)->addr[3] == 2)) #define IP6_NODELOCAL 0xff010000 #define IP6_LINKLOCAL 0xff020000 #define IP6_ADDR_ALLNODE(ipaddr, type) do { \ (ipaddr)->addr[0] = htonl((type)); \ (ipaddr)->addr[1] = 0; \ (ipaddr)->addr[2] = 0; \ (ipaddr)->addr[3] = htonl(1); } while (0) #define IP6_ADDR_ALLROUTER(ipaddr, type) do { \ (ipaddr)->addr[0] = htonl((type)); \ (ipaddr)->addr[1] = 0; \ (ipaddr)->addr[2] = 0; \ (ipaddr)->addr[3] = htonl(2); } while (0) /* * IPv6 Solicited node multicast addresses */ #define ip_addr_issolicited(addr1,myaddr) \ ((myaddr) != NULL && \ ((addr1)->addr[0] == htonl(0xff020000)) && \ ((addr1)->addr[1] == 0) && \ ((addr1)->addr[2] == 1) && \ ((addr1)->addr[3] == (((myaddr)->addr[3]) | htonl(0xff000000)))) #define IP6_ADDR_SOLICITED(solicited, ipaddr) do { \ (solicited)->addr[0] = htonl(0xff020000); \ (solicited)->addr[1] = 0x00000000; \ (solicited)->addr[2] = htonl(0x00000001); \ (solicited)->addr[3] = htonl(0xff000000) | (ipaddr)->addr[3]; } while (0) #ifdef LWSLIRP #define ip_addr_is_addr_solicited(addr1) \ (((addr1)->addr[0] == htonl(0xff020000)) && \ ((addr1)->addr[1] == htonl(0)) && \ ((addr1)->addr[2] == htonl(1)) && \ (htonl(htonl((addr1)->addr[3]) >> 24 ) == htonl(0xff))) #endif #define ip_addr_is_v4comp(addr1) \ (((addr1)->addr[0] == 0) && \ ((addr1)->addr[1] == 0) && \ ((addr1)->addr[2] == IP64_PREFIX)) #define ip_addr_is_v4broadcast_allones(addr1) \ (((addr1)->addr[0] == 0) && \ ((addr1)->addr[1] == 0) && \ ((addr1)->addr[2] == IP64_PREFIX) && \ ((addr1)->addr[3] == 0xffffffff) ) #define ip_addr_is_v4broadcast(addr1,localaddr,mask) \ (((addr1)->addr[0] == 0) && \ ((addr1)->addr[1] == 0) && \ ((addr1)->addr[2] == IP64_PREFIX) && \ ((addr1)->addr[3] == ((localaddr)->addr[3] | (0xffffffff & ~((mask)->addr[3]))))) #define ip_addr_is_v4multicast(addr1) \ (((addr1)->addr[0] == 0) && \ ((addr1)->addr[1] == 0) && \ ((addr1)->addr[2] == IP64_PREFIX) && \ (((addr1)->addr[3] & htonl(0xf0000000)) == htonl(0xe0000000))) /*#if IP_DEBUG*/ void ip_addr_debug_print(int how, struct ip_addr *addr); /*#endif*/ /* IP_DEBUG */ struct netif; #if IPv6_AUTO_CONFIGURATION #include "lwip/ip_autoconf.h" #endif struct ip_addr_list { struct ip_addr_list *next; struct ip_addr ipaddr; struct ip_addr netmask; struct netif *netif; char flags; #if IPv6_AUTO_CONFIGURATION /* FIX: "flags" use NETLINK values (IFA_F_TENTATIVE), but "info.flag" doesn't. */ struct addr_info info; #endif }; void ip_addr_list_add(struct ip_addr_list **ptail, struct ip_addr_list *el); void ip_addr_list_del(struct ip_addr_list **ptail, struct ip_addr_list *el); void ip_addr_list_init(struct stack *stack); void ip_addr_list_shutdown(struct stack *stack); struct ip_addr_list *ip_addr_list_alloc(struct stack *stack); void ip_addr_list_free(struct stack *stack, struct ip_addr_list *el); void ip_addr_list_freelist(struct stack *stack, struct ip_addr_list *tail); struct ip_addr_list *ip_addr_list_find(struct ip_addr_list *tail, struct ip_addr *addr, struct ip_addr *netmask); struct ip_addr_list *ip_addr_list_maskfind(struct ip_addr_list *tail, struct ip_addr *addr); struct ip_addr_list *ip_addr_list_deliveryfind(struct ip_addr_list *tail, struct ip_addr *addr, struct ip_addr *sender); /* Added by Diego Billi */ struct ip_addr_list *ip_addr_list_masquarade_addr(struct ip_addr_list *tail, u8_t ipv); #ifdef LWSLIRP struct ip_addr *ip_addr_find_unicast_from_solicited(struct ip_addr_list *tail, struct ip_addr *addr); #endif #define ip_addr_list_first(x) (((x)==NULL) ? NULL : ((x)->next)) #if LWIP_PACKET /* Conversion Macros to create fake ip_addr containing all the info * of sockaddr_ll structures (but sll_protocol). * This simplify the implementation as all the internal structures * can be reused */ ///#include ///#include "lwip/packet.h" #define SALL2IPADDR(S,I) ({ \ (I).addr[0] = (u32_t) ((S).sll_ifindex);\ (I).addr[1] = (u32_t) (((S).sll_hatype << 16) + ((S).sll_pkttype << 8) + \ (S).sll_halen);\ (I).addr[2] = (u32_t) (((S).sll_addr[0] << 24) + ((S).sll_addr[1] << 16) + \ ((S).sll_addr[2] << 8) + (S).sll_addr[3]); \ (I).addr[3] = (u32_t) (((S).sll_addr[4] << 24) + ((S).sll_addr[5] << 16) + \ ((S).sll_addr[6] << 8) + (S).sll_addr[7]); \ }) #define IPADDR2SALL(I,S) ({ \ register u32_t tmp; \ (S).sll_ifindex = (int) ((I).addr[0]);\ (S).sll_hatype = ((I).addr[1] >> 16); \ (S).sll_pkttype = ((I).addr[1] >> 8 & 0xff); \ (S).sll_halen = ((I).addr[1] & 0xff); \ tmp = (I).addr[2]; \ (S).sll_addr[3] = tmp & 0xff; tmp >>= 8; \ (S).sll_addr[2] = tmp & 0xff; tmp >>= 8; \ (S).sll_addr[1] = tmp & 0xff; tmp >>= 8; \ (S).sll_addr[0] = tmp & 0xff; \ tmp = (I).addr[3]; \ (S).sll_addr[7] = tmp & 0xff; tmp >>= 8; \ (S).sll_addr[6] = tmp & 0xff; tmp >>= 8; \ (S).sll_addr[5] = tmp & 0xff; tmp >>= 8; \ (S).sll_addr[4] = tmp & 0xff; \ }) #define IPSADDR_IFINDEX(I) ((I).addr[0]) #endif /* LWIP_PACKET */ /* added by Diego Billi * Fill up to "len" bits of array "mask". */ #define SET_ADDR_MASK(mask, len) \ do { \ const u8_t bitmap_bits[8] = { 0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01 }; \ int ___i; \ for (___i = 0; ___i < ((len)/8); ++___i) \ (mask)[___i] = 0xff; \ (mask)[(len)/8] |= ~bitmap_bits[((len)%8)]; \ } while(0); #endif /* __LWIP_IP_ADDR_H__ */ lwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/inet.h0000644000175000017500000001012211671615004020505 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_INET_H__ #define __LWIP_INET_H__ #include "lwip/arch.h" #include "lwip/opt.h" #include "lwip/pbuf.h" #include "lwip/ip_addr.h" u16_t inet_chksum(void *data, u16_t len); u16_t inet_chksum_pbuf(struct pbuf *p); u16_t inet6_chksum_pseudo(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, u8_t proto, u32_t proto_len); /* We need this here because we can not include lwip/sockets.h in some files (vdeif.c) */ struct in_addr; u32_t inet_addr(const char *cp); int inet_aton(const char *cp, struct in_addr *addr); // FIX: it creates compilation warning due to the 'struct in_addr' parameter //char *inet_ntoa(struct in_addr addr); /* returns ptr to static buffer; not reentrant! */ int inet_pton(int af, const char *src, void *dst); /*--------------------------------------------------------------------*/ #ifndef htons #if BYTE_ORDER == BIG_ENDIAN #define htons(x) (x) #define ntohs(x) (x) #define htonl(x) (x) #define ntohl(x) (x) #else u16_t htons(u16_t x); u16_t ntohs(u16_t x); u32_t htonl(u32_t x); u32_t ntohl(u32_t x); #endif /* BYTE_ORDER == LITTLE_ENDIAN */ #endif #endif /* __LWIP_INET_H__ */ #if 0 #ifdef htons #undef htons #endif /* htons */ #ifdef htonl #undef htonl #endif /* htonl */ #ifdef ntohs #undef ntohs #endif /* ntohs */ #ifdef ntohl #undef ntohl #endif /* ntohl */ #endif #if 0 #ifndef _MACHINE_ENDIAN_H_ #ifndef _NETINET_IN_H #ifndef _LINUX_BYTEORDER_GENERIC_H u16_t htons(u16_t n); u16_t ntohs(u16_t n); u32_t htonl(u32_t n); u32_t ntohl(u32_t n); #endif /* _LINUX_BYTEORDER_GENERIC_H */ #endif /* _NETINET_IN_H */ #endif /* _MACHINE_ENDIAN_H_ */ #endif lwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/ip_radv.h0000644000175000017500000001523211671615004021201 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #if IPv6_ROUTER_ADVERTISEMENT /* FIX: add MULTISTACK support */ #ifndef __LWIP_IP_RADV_H__ #define __LWIP_IP_RADV_H__ /*--------------------------------------------------------------------------*/ /* Costants */ /*--------------------------------------------------------------------------*/ #ifndef UNSPECIFIED #define UNSPECIFIED 0 #endif #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif #define RADV_MAX(X,Y) (((X)>=(Y)) ? (X) : (Y)) /*--------------------------------------------------------------------------*/ /* Protocol Costants */ /*--------------------------------------------------------------------------*/ /* Router constants: */ #define MAX_INITIAL_RTR_ADVERT_INTERVAL 16 /* seconds */ #define MAX_INITIAL_RTR_ADVERTISEMENTS 3 /* transmissions */ #define MAX_FINAL_RTR_ADVERTISEMENTS 3 /* transmissions */ #define MIN_DELAY_BETWEEN_RAS 3.0 /* seconds */ #define MAX_RA_DELAY_TIME (1000.0/2.0) /* milliseconds */ /* Node constants: */ #define MAX_MULTICAST_SOLICIT 3 /* transmissions */ #define MAX_UNICAST_SOLICIT 3 /* transmissions */ #define MAX_ANYCAST_DELAY_TIME 1 /* transmissions */ #define MAX_NEIGHBOR_ADVERTISEMENT 3 /* transmissions */ #define REACHABLE_TIME 30000 /* milliseconds */ #define DELAY_FIRST_PROBE_TIME 5 /* seconds */ #define MIN_RANDOM_FACTOR (1.0/2.0) #define MAX_RANDOM_FACTOR (3.0/2.0) #define MIN_MaxRtrAdvInterval 4 #define MAX_MaxRtrAdvInterval 1800 #define MIN_MinRtrAdvInterval 3 #define MAX_MinRtrAdvInterval(netif) (0.75 * (netif)->radv->MaxRtrAdvInterval) #define MIN_AdvDefaultLifetime(netif) (RADV_MAX(1,(netif)->radv->MaxRtrAdvInterval)) #define MAX_AdvDefaultLifetime 9000 #define MIN_AdvLinkMTU 1280 #define MAX_AdvReachableTime 3600000 /* 1 hour in milliseconds */ #define MAX_AdvCurHopLimit 255 #define MAX_PrefixLen 128 /*--------------------------------------------------------------------------*/ /* Prefix informations */ /*--------------------------------------------------------------------------*/ struct radv_prefix { struct radv_prefix *next; struct ip_addr Prefix; u8_t PrefixLen; u8_t AdvOnLinkFlag; /* true/false */ u8_t AdvAutonomousFlag; /* true/false */ u32_t AdvValidLifetime; /* seconds */ u32_t AdvPreferredLifetime; /* seconds */ }; #define DFLT_AdvOnLinkFlag TRUE #define DFLT_AdvAutonomousFlag TRUE #define DFLT_AdvValidLifetime 2592000 #define DFLT_AdvPreferredLifetime 604800 struct radv_prefix *radv_prefix_list_alloc(); void radv_prefix_list_free(struct radv_prefix *el); /*--------------------------------------------------------------------------*/ /* Interface informations */ /*--------------------------------------------------------------------------*/ /* See Rfc 2461 - 6.2.1. Router Configuration Variables */ struct radv { //int if_prefix_len; u8_t AdvSendAdvert; /* true/false */ u32_t MaxRtrAdvInterval; /* seconds */ u32_t MinRtrAdvInterval; /* seconds */ u32_t MinDelayBetweenRAs ; /* seconds */ u8_t AdvManagedFlag; /* true/false */ u8_t AdvOtherConfigFlag; /* true/false */ u32_t AdvLinkMTU; /* integer */ u32_t AdvReachableTime; /* millisecond */ u32_t AdvRetransTimer; /* milliseconds */ u8_t AdvCurHopLimit; /* integer */ u16_t AdvDefaultLifetime; /* seconds */ u8_t AdvSourceLLAddress; /* true/false */ u8_t UnicastOnly; /* true/false */ struct radv_prefix *prefix_list; /* Is true if we received a RS before the MinDelayBetweenRAs timeout*/ u8_t solicited_received; /* True if MinDelayBetweenRAs has been reached */ u8_t min_delay_RA_reached; /* This option is not in the original RFC */ //int AdvDefaultPreference; }; #define DFLT_AdvSendAdv FALSE #define DFLT_MaxRtrAdvInterval 600 #define DFLT_MinRtrAdvInterval(rinfo) (0.33 * (rinfo)->MaxRtrAdvInterval) #define DFLT_MinDelayBetweenRAs MIN_DELAY_BETWEEN_RAS #define DFLT_AdvManagedFlag FALSE #define DFLT_AdvOtherConfigFlag FALSE #define DFLT_AdvLinkMTU UNSPECIFIED #define DFLT_AdvReachableTime UNSPECIFIED #define DFLT_AdvRetransTimer UNSPECIFIED #define DFLT_AdvCurHopLimit 64 #define DFLT_AdvDefaultLifetime(rinfo) RADV_MAX(1, (int)(3.0 * (rinfo)->MaxRtrAdvInterval)) #define DFLT_AdvSourceLLAddress TRUE #define DFLT_UnicastOnly FALSE void ip_radv_data_init(struct radv *rinfo); void ip_radv_data_reset(struct radv *rinfo); void ip_radv_netif_init(struct netif *netif); void ip_radv_netif_reset(struct netif *netif); /*--------------------------------------------------------------------------*/ /* Global functions */ /*--------------------------------------------------------------------------*/ /* Called by ip_init() */ void ip_radv_init(struct stack *stack); /* Called when netif goes UP */ void ip_radv_start(struct netif *netif); /* Called when netif goes DOWN */ void ip_radv_stop(struct netif *netif); /* FIX: Call at Stack shutdown */ void ip_radv_shutdown(struct netif *netif); /* Retuns <=0 if any RA option is invalid */ int ip_radv_check_options(struct netif *netif); struct ip_hdr; struct pbuf; struct icmp_rs_hdr; /* Called by ICMP level when Router Solicitation messages are received */ void ip_radv_handle_rs(struct netif *netif, struct pbuf *p, struct ip_hdr *iphdr, struct icmp_rs_hdr *irs); /*--------------------------------------------------------------------------*/ /* Debug */ /*--------------------------------------------------------------------------*/ void ip_radv_data_dump(struct radv *rinfo); #endif /* LWIP_IP_RADV_H */ #endif /* IPv6_ROUTER_ADVERTISEMENT */ lwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/ip_route.h0000644000175000017500000001012311671615004021375 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __LWIP_ROUTE_H__ #define __LWIP_ROUTE_H__ #include "lwip/ip_addr.h" #include "lwip/err.h" struct stack; #if 0 #ifdef IPv6_PMTU_DISCOVERY struct pmtu_info; #endif #endif struct netif; struct ip_route_list { struct ip_route_list *next; struct ip_addr addr; struct ip_addr netmask; struct ip_addr nexthop; struct netif *netif; char flags; #if 0 #ifdef IPv6_PMTU_DISCOVERY /* List of Per-host Path MTU for each destination throw this route */ struct pmtu_info *pmtu_list; #endif #endif }; void ip_route_list_init(struct stack *stack); void ip_route_list_shutdown(struct stack *stack); err_t ip_route_list_add(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags); err_t ip_route_list_del(struct stack *stack, struct ip_addr *addr, struct ip_addr *netmask, struct ip_addr *nexthop, struct netif *netif, int flags); err_t ip_route_findpath(struct stack *stack, struct ip_addr *addr, struct ip_addr **pnexthop, struct netif **pnetif, int *flags); err_t ip_route_list_delnetif(struct stack *stack, struct netif *netif); /* Select the source address for the given destination IP "dst" and the outgoing interface "outif" */ //struct ip_addr_list * ip_route_ipv6_select_source(struct netif *outif, struct ip_addr *dst); struct ip_addr_list * ip_route_select_source_ip(struct netif *outif, struct ip_addr *dst, struct ip_addr *nexthop); /* added by Diego Billi */ #if 0 #ifdef IPv6_PMTU_DISCOVERY /* PMTU's timer timeout interval in msec (1 second) */ #define PMTU_TMR_INTERVAL 1000 /*(10 * 1000)*/ /* Path MTU Destination information */ struct pmtu_info { struct pmtu_info *next; struct ip_addr dest; struct ip_addr src; u8_t tos; /* not used yet, use 0 */ u16_t pmtu; /* time counter (in seconds) for garbage collection */ u32_t expire_time; u32_t op_timeout; /* timeout to the next operation */ u8_t flags; }; #define PMTU_EXPIRE_TIMEOUT 10 #define PMTU_NEVER_EXPIRE 0xffff #define PMTU_FLAG_INCREASE 0x01 #define PMTU_FLAG_DECREASE 0x02 #define PMTU_TOS_NONE 0 /* Timeout in seconds before MTU decrease should be done. * From RFC: once this timer expires and a larger MTU is * attempted, the timeout can be set to a much smaller * value (say, 2 minutes). */ #define PMTU_DECREASE_TIMEOUT 5 /*(2 * 60)*/ /* Timeout in seconds before MTU increase should be done * from RFC: after the PTMU estimate is decreased, the * timeout should be set to 10 minutes; */ #define PMTU_INCREASE_TIMEOUT 10 /* (10 * 60) */ /* Add new Path MTU informations for the given destinatioin. Used by ICMP system */ err_t ip_pmtu_add(struct ip_addr *src, struct ip_addr *dest, u8_t tos, u16_t mtu); /* Find the extimated Path MTU for the given destination and stores it in 'mtu' */ err_t ip_pmtu_getmtu(struct ip_addr *dest, struct ip_addr *src, u8_t tos,u16_t *mtu); /* Decrease Path MTU for the given destiantion. Used by ICMP system. * NOTE: Increase of Path MTU is done internaly by PMTU Discovery algorithm. */ err_t ip_pmtu_decrease(struct ip_addr *dest, struct ip_addr *src, u8_t tos, u16_t new_mtu); #endif /* IPv6_PMTU_DISCOVERY */ #endif #endif /* LWIP_ROUTE_H */ lwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/icmp.h0000644000175000017500000002617411671615004020514 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_ICMP_H__ #define __LWIP_ICMP_H__ #include "lwip/opt.h" #include "lwip/arch.h" #include "lwip/def.h" #include "lwip/pbuf.h" #include "lwip/netif.h" #define ICMP4_ER 0 /* echo reply */ #define ICMP4_DUR 3 /* destination unreachable */ #define ICMP4_SQ 4 /* source quench */ #define ICMP4_RD 5 /* redirect */ #define ICMP4_ECHO 8 /* echo */ #define ICMP4_TE 11 /* time exceeded */ #define ICMP4_PP 12 /* parameter problem */ #define ICMP4_TS 13 /* timestamp */ #define ICMP4_TSR 14 /* timestamp reply */ #define ICMP4_IRQ 15 /* information request */ #define ICMP4_IR 16 /* information reply */ #define ICMP6_DUR 1 #define ICMP6_PTB 2 /* Packet Too Big */ #define ICMP6_TE 3 #define ICMP6_ECHO 128 /* echo */ #define ICMP6_ER 129 /* echo reply */ #define ICMP6_RS 133 /* router solicitation */ #define ICMP6_RA 134 /* router advertisement */ #define ICMP6_NS 135 /* neighbor solicitation */ #define ICMP6_NA 136 /* neighbor advertisement */ enum icmp_dur_type { ICMP_DUR_NET = 0, /* net unreachable */ ICMP_DUR_HOST = 1, /* host unreachable */ ICMP_DUR_PROTO = 2, /* protocol unreachable */ ICMP_DUR_PORT = 3, /* port unreachable */ ICMP_DUR_FRAG = 4, /* fragmentation needed and DF set */ ICMP_DUR_SR = 5 /* source route failed */ }; enum icmp_te_type { ICMP_TE_TTL = 0, /* time to live exceeded in transit */ ICMP_TE_FRAG = 1 /* fragment reassembly time exceeded */ }; void icmp_input(struct stack *stack, struct pbuf *p, struct ip_addr_list *inad, struct pseudo_iphdr *piphdr); void icmp_send_dad(struct stack *stack, struct ip_addr_list *targetip, struct netif *srcnetif); void icmp_neighbor_solicitation(struct stack *stack, struct ip_addr *ipaddr, struct ip_addr_list *inad); void icmp_router_solicitation(struct stack *stack, struct ip_addr *ipaddr, struct ip_addr_list *inad); void icmp_dest_unreach(struct stack *stack, struct pbuf *p, enum icmp_dur_type t); void icmp_time_exceeded(struct stack *stack, struct pbuf *p, enum icmp_te_type t); void icmp_packet_too_big(struct stack *stack, struct pbuf *p, u16_t mtu); /* * ICMP Headers used for IPv4 and IPv6 */ #define ICMPH_TYPE_SET(hdr,typ) (hdr)->type=(typ) #define ICMPH_TYPE(hdr) ((hdr)->type) #define ICMPH_CODE(hdr) ((hdr)->icode) #define ICMPH_CHKSUM(hdr) ((hdr)->chksum) /* Echo Request, Echo Reply */ /* The IPv6 header. */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_echo_hdr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t icode); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u16_t id); PACK_STRUCT_FIELD(u16_t seqno); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* Destination Unreachable */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_dur_hdr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t icode); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u16_t unused); PACK_STRUCT_FIELD(u16_t nextmtu); /* this is used only in ICMPv4 packets */ } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* Time Exceeded */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_te_hdr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t icode); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u32_t unused); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* * ICMPv6 Headers */ /* Packet Too Big */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_ptb_hdr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t icode); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u32_t mtu); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* NS - Neighbor Solicitation */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_ns_hdr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t icode); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u32_t reserved); PACK_STRUCT_FIELD(u32_t targetip[4]); //struct icmp_opt option; /* for Source link-layer address */ } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* NA - Neighbor advertisement */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_na_hdr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t icode); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u8_t rso_flags); #define ICMP6_NA_R 0x01 #define ICMP6_NA_S 0x02 #define ICMP6_NA_O 0x04 PACK_STRUCT_FIELD(u8_t reserved[3]); PACK_STRUCT_FIELD(u32_t targetip[4]); //struct icmp_opt option; /* for Target link-layer address */ } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* RS - Router Solicitation */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_rs_hdr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t icode); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u32_t reserved); //struct icmp_opt option; /* for Source link-layer addres */ } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* RA - Router Advertisement */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_ra_hdr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t icode); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u8_t hoplimit); PACK_STRUCT_FIELD(u8_t m_o_flag); #define ICMP6_RA_M 0x80 #define ICMP6_RA_O 0x40 PACK_STRUCT_FIELD(u16_t life); /* (seconds) The lifetime associated with the default router */ PACK_STRUCT_FIELD(u32_t reach); /* (milliseconds) */ PACK_STRUCT_FIELD(u32_t retran); /* (milliseconds) between retransmitted Neighbor Solicitation messages. */ //struct icmp_opt option; /* for Source link-layer addres */ //struct icmp_opt option; /* MTU */ //struct icmp_opt option; /* Prefix Information */ } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* * ICMP6 Options */ #define ICMP6_OPT_SRCADDR 1 #define ICMP6_OPT_DESTADDR 2 #define ICMP6_OPT_PREFIX 3 #define ICMP6_OPT_REDIRECT 4 #define ICMP6_OPT_MTU 5 /* Generic ICMP option */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_opt { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t len); /* in units of 8 octets (including the type and length fields). */ PACK_STRUCT_FIELD(u8_t data[0]); }PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* ICMPv6 Address Options field */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_opt_addr { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t len); /* in units of 8 octets (including the type and length fields). */ PACK_STRUCT_FIELD(u8_t addr[0]); /* 0 is not allowed with some compilers */ }PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /* Length of ethernet address in 8-octects */ #define ICMP6_OPT_LEN_ETHER 1 #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_opt_prefix { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t len); /* 4 */ PACK_STRUCT_FIELD(u8_t preflen); /* Prefix len */ PACK_STRUCT_FIELD(u8_t flags); #define ICMP6_OPT_PREF_L 0x80 #define ICMP6_OPT_PREF_A 0x40 #define ICMP6_OPT_PREF_R 0x20 #define ICMP6_OPT_PREF_S 0x10 PACK_STRUCT_FIELD(u32_t valid); PACK_STRUCT_FIELD(u32_t prefered); /* seconds */ PACK_STRUCT_FIELD(u32_t reserved); /* seconds */ PACK_STRUCT_FIELD(u32_t prefix[4]); }PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct icmp_opt_mtu { PACK_STRUCT_FIELD(u8_t type); PACK_STRUCT_FIELD(u8_t len); /* 1 */ PACK_STRUCT_FIELD(u16_t reserved); PACK_STRUCT_FIELD(u32_t mtu); }PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #endif /* __LWIP_ICMP_H__ */ lwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/ip_frag.h0000644000175000017500000001270211671615004021163 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2005 Diego Billi University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Jani Monoses * */ #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION #ifndef __LWIP_IP_FRAG_H__ #define __LWIP_IP_FRAG_H__ struct stack; /* Module init */ void ip_frag_reass_init(struct stack *stack); void ip_frag_reass_shutdown(struct stack *stack); #if IPv4_FRAGMENTATION /* * IPv4 Frag/Defrag functions */ struct pbuf *ip4_reass(struct stack *stack, struct pbuf *p); err_t ip4_frag(struct stack *stack, struct pbuf *, struct netif *, struct ip_addr *); #endif /* IPv4_FRAGMENTATION */ #if IPv6_FRAGMENTATION /* * IPv6 Frag/Defrag functions */ /* Fragmentation extension header */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct ip6_fraghdr { PACK_STRUCT_FIELD(u8_t nexthdr); PACK_STRUCT_FIELD(u8_t reserved); PACK_STRUCT_FIELD(u16_t offset_res_m); #define IP6_OFFMASK 0xfff8 #define IP6_MF 0x0001 PACK_STRUCT_FIELD(u32_t id); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #define IP6_NEXTHDR(fhdr) (fhdr)->nexthdr #define IP6_OFFSET(fhdr) (ntohs((fhdr)->offset_res_m) & IP6_OFFMASK) #define IP6_M(fhdr) (ntohs((fhdr)->offset_res_m) & IP6_MF) #define IP6_ID(fhdr) (ntohl((fhdr)->id) ) /* Lenght in bytes of the fragmentation header. */ #define IP_EXTFRAG_LEN 8 struct pbuf *ip6_reass(struct stack *stack, struct pbuf *p, struct ip6_fraghdr *fragext, struct ip_exthdr *lastext); err_t ip6_frag(struct stack *stack, struct pbuf *p, struct netif *netif, struct ip_addr *dest); #endif /* IPv6_FRAGMENTATION */ /* Max IP Payload len */ #define IP_REASS_BUFSIZE 65535 /* Reassembly buffer */ struct ip_reassbuf { u8_t ipv; /* ip version (4, 6). 0 if the entry is empty */ u32_t id; /* fragmentation id (16bit Ipv4, 32bit Ipv6) */ u8_t age; /* seconds */ u8_t flags; /* entry's state */ u32_t len; u8_t buf[IP_REASS_BUFSIZE]; #define IP4_REASS_BITMAP_SIZE (IP_REASS_BUFSIZE / (8 * 8)) u8_t bitmap[IP4_REASS_BITMAP_SIZE]; }; #endif /* __LWIP_IP_FRAG_H__ */ #endif /* IPv4_FRAGMENTATION || IPv6_FRAGMENTATION */ lwipv6-1.5a/lwip-v6/src/include/ipv6/lwip/ip.h0000644000175000017500000003217611671615004020173 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004,..,2011 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_IP_H__ #define __LWIP_IP_H__ #include "lwip/opt.h" #include "lwip/def.h" #include "lwip/pbuf.h" #include "lwip/ip_addr.h" #include "lwip/err.h" /* This is the common part of all PCB types. It needs to be at the * beginning of a PCB type definition. It is located here so that * changes to this common part are made in one location instead of * having to change all PCB structs. */ #ifdef LWSLIRP #define IP_PCB \ /* Stack */ \ struct stack *stack; \ /* IP tuple */ \ struct ip_addr local_ip; \ struct ip_addr remote_ip; \ /* Socket options */ \ u16_t so_options; \ /* Type Of Service */ \ u8_t tos; \ /* Time To Live */ \ u8_t ttl; \ /* Data for Slirp */ \ void *slirp_fddata #else #define IP_PCB \ /* Stack */ \ struct stack *stack; \ /* IP tuple */ \ struct ip_addr local_ip; \ struct ip_addr remote_ip; \ /* Socket options */ \ u16_t so_options; \ /* Type Of Service */ \ u8_t tos; \ /* Time To Live */ \ u8_t ttl #endif /* To cast common fields of all tcp types */ struct common_pcb { /* Common members of all PCB types */ IP_PCB; }; /* This is passed as the destination address to ip_output_if (not * to ip_output), meaning that an IP header already is constructed * in the pbuf. This is used when TCP retransmits. */ #define IP_LWHDRINCL NULL /* * Protocols numbers */ #define IP_PROTO_ICMP4 1 #define IP_PROTO_TCP 6 /* TCP segment. */ #define IP_PROTO_UDP 17 /* UDP message. */ #define IP_FRAG_TAG 44 #define IP_PROTO_ICMP 58 /* ICMP for IPv6. */ #define IP_PROTO_UDPLITE 170 /*****************************************************************************/ /* IPv6 structures and macroes */ /*****************************************************************************/ /* Extensions headers */ #define IP6_NEXTHDR_HOP 0 /* Hop-by-hop option header. */ #define IP6_NEXTHDR_DEST 60 /* Destination options header. */ #define IP6_NEXTHDR_ROUTING 43 /* Routing header. */ #define IP6_NEXTHDR_FRAGMENT 44 /* Fragmentation/reassembly header. */ #define IP6_NEXTHDR_ESP 50 /* Encapsulating security payload. */ #define IP6_NEXTHDR_AUTH 51 /* Authentication header. */ #define IP6_NEXTHDR_NONE 59 /* No next header */ #define IP6_NEXTHDR_IPV6 41 /* IPv6 in IPv6 */ #define IP6_NEXTHDR_MAX 255 /* Max value */ /* The IPv6 header. */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct ip_hdr { /* version / class1 */ PACK_STRUCT_FIELD(u16_t _v_cl_fl); /* class2 / flow */ PACK_STRUCT_FIELD(u16_t flow2); /* length */ PACK_STRUCT_FIELD(u16_t len); /* next_hdr / hoplim*/ PACK_STRUCT_FIELD(u16_t _next_hop); /* source and destination IP addresses */ PACK_STRUCT_FIELD(struct ip_addr src); PACK_STRUCT_FIELD(struct ip_addr dest); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #define IP_HLEN 40 #define IPH_V(hdr) (ntohs((hdr)->_v_cl_fl) >> 12) #define IPH_CL(hdr) ((ntohs((hdr)->_v_cl_fl) >> 4) & 0xff) #define IPH_FLOW(hdr) ((ntohs((hdr)->_v_cl_fl) & 0xf) + ((hdr)->flow2)) #define IPH_NEXTHDR(hdr) (ntohs((hdr)->_next_hop) >> 8) #define IPH_HOPLIMIT(hdr) (ntohs((hdr)->_next_hop) & 0xff) #define IPH_V_SET(hdr,vv) ((hdr)->_v_cl_fl) = htons((ntohs((hdr)->_v_cl_fl) & 0xffffff) | ((vv) << 12)) #define IPH_NEXTHDR_SET(hdr, nexthdr) ((hdr)->_next_hop) = htons((nexthdr) << 8 | IPH_HOPLIMIT(hdr)) #define IPH_HOPLIMIT_SET(hdr, hop) ((hdr)->_next_hop) = htons(IPH_NEXTHDR(hdr) << 8 | (hop)) #define IPH_NEXT_HOP_SET(hdr, nexthdr, hop) ((hdr)->_next_hop) = htons((nexthdr) << 8 | (hop)) #define IPH_PAYLOADLEN(hdr) ((hdr)->len) #define IPH_PAYLOADLEN_SET(hdr, newlen) ((hdr)->len = htons((newlen))) /* Generic IPv6 Extension Header */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct ip_exthdr { /* Next Header */ PACK_STRUCT_FIELD(u8_t nexthdr); /* Hdr Ext Len */ PACK_STRUCT_FIELD(u8_t len); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #define IPEXTH_NEXTHDR(hdr) ((hdr)->nexthdr) #define IPEXTH_NEXTHDR_SET(hdr, nexthdr) ((hdr)->nexthdr = (nexthdr)) #define is_ipv6_exthdr(nexthdr) \ (((nexthdr)==IP6_NEXTHDR_HOP) || \ ((nexthdr)==IP6_NEXTHDR_ROUTING) || \ ((nexthdr)==IP6_NEXTHDR_FRAGMENT) || \ ((nexthdr)==IP6_NEXTHDR_AUTH) || \ ((nexthdr)==IP6_NEXTHDR_NONE) || \ ((nexthdr)==IP6_NEXTHDR_DEST)) /* Generic IPv6 Option */ struct ip6_option { u8_t type; u8_t len; /* in units of 8 octets (including the type and length fields). */ u8_t data[0]; /* 0 is not allowed with some compilers */ }; /* Option Type field encoding : 00?? ???? - skip over and continue processing. 01?? ???? - discard. 10?? ???? - discard and send an ICMP Parameter Problem, Code 2. 11?? ???? - discard and, if Destination Address was not multicast address, send ICMP Parameter Problem. ??0? ???? - Option Data does not change en-route. ??1? ???? - Option Data may change en-route. */ #define IP6_OPT_SKIP(opt) (((opt)->type & 0xC0) == 0) #define IP6_OPT_DISCARD(opt) ((opt)->type & 0x40) #define IP6_OPT_INVALID(opt) ((opt)->type & 0x80) #define IP6_OPT_INVALID_NOTMULTI(opt) ((opt)->type & 0xC0) #define IP6_OPT_DONTCHANGE(opt) (((opt)->type & 0x20) == 0) #define IP6_OPT_CHANGE(opt) ((opt)->type & 0x20) #define IP6_OPT_LEN(opt) ((opt)->len * 8) /*****************************************************************************/ /* IPv4 structures and macroes */ /*****************************************************************************/ /* The IPv4 header. */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct ip4_hdr { /* version / header length / type of service */ PACK_STRUCT_FIELD(u16_t _v_hl_tos); /* total length */ PACK_STRUCT_FIELD(u16_t _len); /* identification */ PACK_STRUCT_FIELD(u16_t _id); /* fragment offset field */ PACK_STRUCT_FIELD(u16_t _offset); #define IP_RF 0x8000 /* reserved fragment flag */ #define IP_DF 0x4000 /* dont fragment flag */ #define IP_MF 0x2000 /* more fragments flag */ #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */ /* time to live / protocol*/ PACK_STRUCT_FIELD(u16_t _ttl_proto); /* checksum */ PACK_STRUCT_FIELD(u16_t _chksum); /* source and destination IP addresses */ PACK_STRUCT_FIELD(struct ip4_addr src); PACK_STRUCT_FIELD(struct ip4_addr dest); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #define IP4_HLEN 20 #define IPH4_V(hdr) (ntohs((hdr)->_v_hl_tos) >> 12) #define IPH4_HL(hdr) ((ntohs((hdr)->_v_hl_tos) >> 8) & 0x0f) #define IPH4_TOS(hdr) (htons((ntohs((hdr)->_v_hl_tos) & 0xff))) #define IPH4_LEN(hdr) ((hdr)->_len) #define IPH4_ID(hdr) ((hdr)->_id) #define IPH4_OFFSET(hdr) ((hdr)->_offset) #define IPH4_TTL(hdr) (ntohs((hdr)->_ttl_proto) >> 8) #define IPH4_PROTO(hdr) (ntohs((hdr)->_ttl_proto) & 0xff) #define IPH4_CHKSUM(hdr) ((hdr)->_chksum) #define IPH4_VHLTOS_SET(hdr, v, hl, tos) (hdr)->_v_hl_tos = (htons(((v) << 12) | ((hl) << 8) | (tos))) #define IPH4_LEN_SET(hdr, len) (hdr)->_len = (len) #define IPH4_ID_SET(hdr, id) (hdr)->_id = (id) #define IPH4_OFFSET_SET(hdr, off) (hdr)->_offset = (off) #define IPH4_TTL_SET(hdr, ttl) (hdr)->_ttl_proto = (htons(IPH4_PROTO(hdr) | ((ttl) << 8))) #define IPH4_PROTO_SET(hdr, proto) (hdr)->_ttl_proto = (htons((proto) | (IPH4_TTL(hdr) << 8))) #define IPH4_CHKSUM_SET(hdr, chksum) (hdr)->_chksum = (chksum) /* no variable part */ #define IPH_HL(x) (IP_HLEN >> 2) /*IPv4 compatibility*/ #define IPH_PROTO(x) ((x)->nexthdr) #include "lwip/netif.h" /* * Option flags per-socket. These are the same like SO_XXX. */ #define SOF_DEBUG (u16_t)0x0001U /* turn on debugging info recording */ #define SOF_ACCEPTCONN (u16_t)0x0002U /* socket has had listen() */ #define SOF_REUSEADDR (u16_t)0x0004U /* allow local address reuse */ #define SOF_KEEPALIVE (u16_t)0x0008U /* keep connections alive */ #define SOF_DONTROUTE (u16_t)0x0010U /* just use interface addresses */ #define SOF_BROADCAST (u16_t)0x0020U /* permit sending of broadcast msgs */ #define SOF_USELOOPBACK (u16_t)0x0040U /* bypass hardware when possible */ #define SOF_LINGER (u16_t)0x0080U /* linger on close if data present */ #define SOF_OOBINLINE (u16_t)0x0100U /* leave received OOB data in line */ #define SOF_REUSEPORT (u16_t)0x0200U /* allow local address & port reuse */ #define SOF_IPV6_CHECKSUM (u16_t)0x8000U /* RAW socket IPv6 checksum */ #define SOF_HDRINCL (u16_t)0x4000U /* Header included */ /*****************************************************************************/ /* IP Layer functions */ /*****************************************************************************/ /* Fragmentation IDs */ /* FIX: race condition between ipv4 and ipv6 fragmentation code */ void ip_init(struct stack *stack); void ip_shutdown(struct stack *stack); /* Input functions for netif interfaces */ void ip_input(struct pbuf *p, struct netif *inp); /* source and destination addresses in network byte order, please */ err_t ip_output(struct stack *stack, struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, unsigned char ttl, unsigned char tos, unsigned char proto); err_t ip_output_if(struct stack *stack, struct pbuf *p, struct ip_addr *src, struct ip_addr *dest, unsigned char ttl, unsigned char tos, unsigned char proto, struct netif *netif, struct ip_addr *nexthop, int flags); /* Called when the stack need to know something about the interface's state */ void ip_notify(struct netif *netif, u32_t type); #ifdef IP_DEBUG void ip_debug_print(int how, struct pbuf *p); #else #define ip_debug_print(how,p) #endif /* IP_DEBUG */ /* Used in ip6.c to handle ingoing packets from both IPv4 and IPv6 */ struct pseudo_iphdr { u8_t version; /* ip version */ u16_t iphdrlen; /* header len (IPv4+options, IPv6 main header only) */ u16_t proto; /* Next protocol (also IPv6 extension headers) */ struct ip_addr *src; struct ip_addr *dest; }; int ip_build_piphdr(struct pseudo_iphdr *piphdr, struct pbuf *p, struct ip_addr *src4, struct ip_addr *dest4); #endif /* __LWIP_IP_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/0000755000175000017500000000000011671615111016514 5ustar renzorenzolwipv6-1.5a/lwip-v6/src/include/lwip/err.h0000644000175000017500000000511511671615005017461 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_ERR_H__ #define __LWIP_ERR_H__ #include "lwip/opt.h" #include "arch/cc.h" typedef s8_t err_t; /* Definitions for error constants. */ #define ERR_OK 0 /* No error, everything OK. */ #define ERR_MEM -1 /* Out of memory error. */ #define ERR_BUF -2 /* Buffer error. */ #define ERR_ABRT -3 /* Connection aborted. */ #define ERR_RST -4 /* Connection reset. */ #define ERR_CLSD -5 /* Connection closed. */ #define ERR_CONN -6 /* Not connected. */ #define ERR_VAL -7 /* Illegal value. */ #define ERR_ARG -8 /* Illegal argument. */ #define ERR_RTE -9 /* Routing problem. */ #define ERR_USE -10 /* Address in use. */ #define ERR_IF -11 /* Low-level netif error */ #define ERR_ISCONN -12 /* Already connected. */ #ifdef LWIP_DEBUG extern char *lwip_strerr(err_t err); #else #define lwip_strerr(x) "" #endif /* LWIP_DEBUG */ #endif /* __LWIP_ERR_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/sio.h0000644000175000017500000000413711671615005017466 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. */ /* * This is the interface to the platform specific serial IO module * It needs to be implemented by those platforms which need SLIP or PPP */ #include "arch/cc.h" #ifndef __sio_fd_t_defined typedef void * sio_fd_t; #endif #ifndef sio_open sio_fd_t sio_open(u8_t); #endif #ifndef sio_send void sio_send(u8_t, sio_fd_t); #endif #ifndef sio_recv u8_t sio_recv(sio_fd_t); #endif #ifndef sio_read u32_t sio_read(sio_fd_t, u8_t *, u32_t); #endif #ifndef sio_write u32_t sio_write(sio_fd_t, u8_t *, u32_t); #endif #ifndef sio_read_abort void sio_read_abort(sio_fd_t); #endif lwipv6-1.5a/lwip-v6/src/include/lwip/arphdr.h0000644000175000017500000000654211671615005020156 0ustar renzorenzo#ifndef _NET_IF_ARPHDR #define _NET_IF_ARPHDR /* ARP protocol HARDWARE identifiers. */ #define ARPHRD_NETROM 0 /* From KA9Q: NET/ROM pseudo. */ #define ARPHRD_ETHER 1 /* Ethernet 10/100Mbps. */ #define ARPHRD_EETHER 2 /* Experimental Ethernet. */ #define ARPHRD_AX25 3 /* AX.25 Level 2. */ #define ARPHRD_PRONET 4 /* PROnet token ring. */ #define ARPHRD_CHAOS 5 /* Chaosnet. */ #define ARPHRD_IEEE802 6 /* IEEE 802.2 Ethernet/TR/TB. */ #define ARPHRD_ARCNET 7 /* ARCnet. */ #define ARPHRD_APPLETLK 8 /* APPLEtalk. */ #define ARPHRD_DLCI 15 /* Frame Relay DLCI. */ #define ARPHRD_ATM 19 /* ATM. */ #define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id). */ #define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734. */ #define ARPHRD_METRICOM 23 /* Metricom STRIP (new IANA id). */ #define ARPHRD_IEEE1394 24 /* IEEE 1394 IPv4 - RFC 2734. */ #define ARPHRD_EUI64 27 /* EUI-64. */ #define ARPHRD_INFINIBAND 32 /* InfiniBand. */ /* Dummy types for non ARP hardware */ #define ARPHRD_SLIP 256 #define ARPHRD_CSLIP 257 #define ARPHRD_SLIP6 258 #define ARPHRD_CSLIP6 259 #define ARPHRD_RSRVD 260 /* Notional KISS type. */ #define ARPHRD_ADAPT 264 #define ARPHRD_ROSE 270 #define ARPHRD_X25 271 /* CCITT X.25. */ #define ARPHRD_HWX25 272 /* Boards with X.25 in firmware. */ #define ARPHRD_PPP 512 #define ARPHRD_CISCO 513 /* Cisco HDLC. */ #define ARPHRD_HDLC ARPHRD_CISCO #define ARPHRD_LAPB 516 /* LAPB. */ #define ARPHRD_DDCMP 517 /* Digital's DDCMP. */ #define ARPHRD_RAWHDLC 518 /* Raw HDLC. */ #define ARPHRD_TUNNEL 768 /* IPIP tunnel. */ #define ARPHRD_TUNNEL6 769 /* IPIP6 tunnel. */ #define ARPHRD_FRAD 770 /* Frame Relay Access Device. */ #define ARPHRD_SKIP 771 /* SKIP vif. */ #define ARPHRD_LOOPBACK 772 /* Loopback device. */ #define ARPHRD_LOCALTLK 773 /* Localtalk device. */ #define ARPHRD_FDDI 774 /* Fiber Distributed Data Interface. */ #define ARPHRD_BIF 775 /* AP1000 BIF. */ #define ARPHRD_SIT 776 /* sit0 device - IPv6-in-IPv4. */ #define ARPHRD_IPDDP 777 /* IP-in-DDP tunnel. */ #define ARPHRD_IPGRE 778 /* GRE over IP. */ #define ARPHRD_PIMREG 779 /* PIMSM register interface. */ #define ARPHRD_HIPPI 780 /* High Performance Parallel I'face. */ #define ARPHRD_ASH 781 /* (Nexus Electronics) Ash. */ #define ARPHRD_ECONET 782 /* Acorn Econet. */ #define ARPHRD_IRDA 783 /* Linux-IrDA. */ #define ARPHRD_FCPP 784 /* Point to point fibrechanel. */ #define ARPHRD_FCAL 785 /* Fibrechanel arbitrated loop. */ #define ARPHRD_FCPL 786 /* Fibrechanel public loop. */ #define ARPHRD_FCFABRIC 787 /* Fibrechanel fabric. */ #define ARPHRD_IEEE802_TR 800 /* Magic type ident for TR. */ #define ARPHRD_IEEE80211 801 /* IEEE 802.11. */ #endif lwipv6-1.5a/lwip-v6/src/include/lwip/netlinkdefs.h0000644000175000017500000004504111671615005021201 0ustar renzorenzo#ifndef _NETLINKDEFS_H #define _NETLINKDEFS_H #define NETLINK_ROUTE 0 /* Routing/device hook */ #define NETLINK_SKIP 1 /* Reserved for ENskip */ #define NETLINK_USERSOCK 2 /* Reserved for user mode socket protocols */ #define NETLINK_FIREWALL 3 /* Firewalling hook */ #define NETLINK_TCPDIAG 4 /* TCP socket monitoring */ #define NETLINK_NFLOG 5 /* netfilter/iptables ULOG */ #define NETLINK_XFRM 6 /* ipsec */ #define NETLINK_ARPD 8 #define NETLINK_ROUTE6 11 /* af_inet6 route comm channel */ #define NETLINK_IP6_FW 13 #define NETLINK_DNRTMSG 14 /* DECnet routing messages */ #define NETLINK_TAPBASE 16 /* 16 to 31 are ethertap */ #define MAX_LINKS 32 struct sockaddr_nl { unsigned short nl_family; /* AF_NETLINK */ unsigned short nl_pad; /* zero */ u32_t nl_pid; /* process pid */ u32_t nl_groups; /* multicast groups mask */ }; struct nlmsghdr { u32_t nlmsg_len; /* Length of message including header */ u16_t nlmsg_type; /* Message content */ u16_t nlmsg_flags; /* Additional flags */ u32_t nlmsg_seq; /* Sequence number */ u32_t nlmsg_pid; /* Sending process PID */ }; /* Flags values */ #define NLM_F_REQUEST 1 /* It is request message. */ #define NLM_F_MULTI 2 /* Multipart message, terminated by NLMSG_DONE */ #define NLM_F_ACK 4 /* Reply with ack, with zero or error code */ #define NLM_F_ECHO 8 /* Echo this request */ /* Modifiers to GET request */ #define NLM_F_ROOT 0x100 /* specify tree root */ #define NLM_F_MATCH 0x200 /* return all matching */ #define NLM_F_ATOMIC 0x400 /* atomic GET */ #define NLM_F_DUMP (NLM_F_ROOT|NLM_F_MATCH) /* Modifiers to NEW request */ #define NLM_F_REPLACE 0x100 /* Override existing */ #define NLM_F_EXCL 0x200 /* Do not touch, if it exists */ #define NLM_F_CREATE 0x400 /* Create, if it does not exist */ #define NLM_F_APPEND 0x800 /* Add to end of list */ /* 4.4BSD ADD NLM_F_CREATE|NLM_F_EXCL 4.4BSD CHANGE NLM_F_REPLACE True CHANGE NLM_F_CREATE|NLM_F_REPLACE Append NLM_F_CREATE Check NLM_F_EXCL */ #define NLMSG_ALIGNTO 4 #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) ) #define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(sizeof(struct nlmsghdr))) #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len)) #define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0))) #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) #define NLMSG_OK(nlh,len) ((len) > 0 && (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ (nlh)->nlmsg_len <= (len)) #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len))) #define NLMSG_NOOP 0x1 /* Nothing. */ #define NLMSG_ERROR 0x2 /* Error */ #define NLMSG_DONE 0x3 /* End of a dump */ #define NLMSG_OVERRUN 0x4 /* Data lost */ struct nlmsgerr { int error; struct nlmsghdr msg; }; #define NET_MAJOR 36 /* Major 36 is reserved for networking */ /**** * Routing/neighbour discovery messages. ****/ /* Types of messages */ #define RTM_BASE 0x10 #define RTM_NEWLINK (RTM_BASE+0) #define RTM_DELLINK (RTM_BASE+1) #define RTM_GETLINK (RTM_BASE+2) #define RTM_SETLINK (RTM_BASE+3) #define RTM_NEWADDR (RTM_BASE+4) #define RTM_DELADDR (RTM_BASE+5) #define RTM_GETADDR (RTM_BASE+6) #define RTM_NEWROUTE (RTM_BASE+8) #define RTM_DELROUTE (RTM_BASE+9) #define RTM_GETROUTE (RTM_BASE+10) #define RTM_NEWNEIGH (RTM_BASE+12) #define RTM_DELNEIGH (RTM_BASE+13) #define RTM_GETNEIGH (RTM_BASE+14) #define RTM_NEWRULE (RTM_BASE+16) #define RTM_DELRULE (RTM_BASE+17) #define RTM_GETRULE (RTM_BASE+18) #define RTM_NEWQDISC (RTM_BASE+20) #define RTM_DELQDISC (RTM_BASE+21) #define RTM_GETQDISC (RTM_BASE+22) #define RTM_NEWTCLASS (RTM_BASE+24) #define RTM_DELTCLASS (RTM_BASE+25) #define RTM_GETTCLASS (RTM_BASE+26) #define RTM_NEWTFILTER (RTM_BASE+28) #define RTM_DELTFILTER (RTM_BASE+29) #define RTM_GETTFILTER (RTM_BASE+30) #define RTM_MAX (RTM_BASE+31) /* Generic structure for encapsulation of optional route information. It is reminiscent of sockaddr, but with sa_family replaced with attribute type. */ struct rtattr { unsigned short rta_len; unsigned short rta_type; }; /* Macros to handle rtattributes */ #define RTA_ALIGNTO 4 #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) ) #define RTA_OK(rta,len) ((len) > 0 && (rta)->rta_len >= sizeof(struct rtattr) && \ (rta)->rta_len <= (len)) #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \ (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len))) #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len)) #define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len)) #define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0))) #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0)) /****************************************************************************** * Definitions used in routing table administration. ****/ struct rtmsg { unsigned char rtm_family; unsigned char rtm_dst_len; unsigned char rtm_src_len; unsigned char rtm_tos; unsigned char rtm_table; /* Routing table id */ unsigned char rtm_protocol; /* Routing protocol; see below */ unsigned char rtm_scope; /* See below */ unsigned char rtm_type; /* See below */ unsigned rtm_flags; }; /* rtm_type */ enum { RTN_UNSPEC, RTN_UNICAST, /* Gateway or direct route */ RTN_LOCAL, /* Accept locally */ RTN_BROADCAST, /* Accept locally as broadcast, send as broadcast */ RTN_ANYCAST, /* Accept locally as broadcast, but send as unicast */ RTN_MULTICAST, /* Multicast route */ RTN_BLACKHOLE, /* Drop */ RTN_UNREACHABLE, /* Destination is unreachable */ RTN_PROHIBIT, /* Administratively prohibited */ RTN_THROW, /* Not in this table */ RTN_NAT, /* Translate this address */ RTN_XRESOLVE /* Use external resolver */ }; #define RTN_MAX RTN_XRESOLVE /* rtm_protocol */ #define RTPROT_UNSPEC 0 #define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects; not used by current IPv4 */ #define RTPROT_KERNEL 2 /* Route installed by kernel */ #define RTPROT_BOOT 3 /* Route installed during boot */ #define RTPROT_STATIC 4 /* Route installed by administrator */ /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel; they are just passed from user and back as is. It will be used by hypothetical multiple routing daemons. Note that protocol values should be standardized in order to avoid conflicts. */ #define RTPROT_GATED 8 /* Apparently, GateD */ #define RTPROT_RA 9 /* RDISC/ND router advertisements */ #define RTPROT_MRT 10 /* Merit MRT */ #define RTPROT_ZEBRA 11 /* Zebra */ #define RTPROT_BIRD 12 /* BIRD */ #define RTPROT_DNROUTED 13 /* DECnet routing daemon */ /* rtm_scope Really it is not scope, but sort of distance to the destination. NOWHERE are reserved for not existing destinations, HOST is our local addresses, LINK are destinations, located on directly attached link and UNIVERSE is everywhere in the Universe. Intermediate values are also possible f.e. interior routes could be assigned a value between UNIVERSE and LINK. */ enum rt_scope_t { RT_SCOPE_UNIVERSE=0, /* User defined values */ RT_SCOPE_SITE=200, RT_SCOPE_LINK=253, RT_SCOPE_HOST=254, RT_SCOPE_NOWHERE=255 }; /* rtm_flags */ #define RTM_F_NOTIFY 0x100 /* Notify user of route change */ #define RTM_F_CLONED 0x200 /* This route is cloned */ #define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */ #define RTM_F_PREFIX 0x800 /* Prefix addresses */ /* Reserved table identifiers */ enum rt_class_t { RT_TABLE_UNSPEC=0, /* User defined values */ RT_TABLE_DEFAULT=253, RT_TABLE_MAIN=254, RT_TABLE_LOCAL=255 }; #define RT_TABLE_MAX RT_TABLE_LOCAL /* Routing message attributes */ enum rtattr_type_t { RTA_UNSPEC, RTA_DST, RTA_SRC, RTA_IIF, RTA_OIF, RTA_GATEWAY, RTA_PRIORITY, RTA_PREFSRC, RTA_METRICS, RTA_MULTIPATH, RTA_PROTOINFO, RTA_FLOW, RTA_CACHEINFO, RTA_SESSION }; #define RTA_MAX RTA_SESSION #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg)))) #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg)) /* RTM_MULTIPATH --- array of struct rtnexthop. * * "struct rtnexthop" describes all necessary nexthop information, * i.e. parameters of path to a destination via this nexthop. * * At the moment it is impossible to set different prefsrc, mtu, window * and rtt for different paths from multipath. */ struct rtnexthop { unsigned short rtnh_len; unsigned char rtnh_flags; unsigned char rtnh_hops; int rtnh_ifindex; }; /* rtnh_flags */ #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */ #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */ #define RTNH_F_ONLINK 4 /* Gateway is forced on link */ /* Macros to handle hexthops */ #define RTNH_ALIGNTO 4 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) ) #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \ ((int)(rtnh)->rtnh_len) <= (len)) #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len))) #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len)) #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len)) #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0))) /* RTM_CACHEINFO */ struct rta_cacheinfo { u32_t rta_clntref; u32_t rta_lastuse; s32_t rta_expires; u32_t rta_error; u32_t rta_used; #define RTNETLINK_HAVE_PEERINFO 1 u32_t rta_id; u32_t rta_ts; u32_t rta_tsage; }; /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */ enum { RTAX_UNSPEC, #define RTAX_UNSPEC RTAX_UNSPEC RTAX_LOCK, #define RTAX_LOCK RTAX_LOCK RTAX_MTU, #define RTAX_MTU RTAX_MTU RTAX_WINDOW, #define RTAX_WINDOW RTAX_WINDOW RTAX_RTT, #define RTAX_RTT RTAX_RTT RTAX_RTTVAR, #define RTAX_RTTVAR RTAX_RTTVAR RTAX_SSTHRESH, #define RTAX_SSTHRESH RTAX_SSTHRESH RTAX_CWND, #define RTAX_CWND RTAX_CWND RTAX_ADVMSS, #define RTAX_ADVMSS RTAX_ADVMSS RTAX_REORDERING, #define RTAX_REORDERING RTAX_REORDERING RTAX_HOPLIMIT, #define RTAX_HOPLIMIT RTAX_HOPLIMIT RTAX_INITCWND, #define RTAX_INITCWND RTAX_INITCWND RTAX_FEATURES #define RTAX_FEATURES RTAX_FEATURES }; #define RTAX_MAX RTAX_FEATURES #define RTAX_FEATURE_ECN 0x00000001 #define RTAX_FEATURE_SACK 0x00000002 #define RTAX_FEATURE_TIMESTAMP 0x00000004 struct rta_session { u8_t proto; union { struct { u16_t sport; u16_t dport; } ports; struct { u8_t type; u8_t code; u16_t ident; } icmpt; u32_t spi; } u; }; /********************************************************* * Interface address. ****/ struct ifaddrmsg { unsigned char ifa_family; unsigned char ifa_prefixlen; /* The prefix length */ unsigned char ifa_flags; /* Flags */ unsigned char ifa_scope; /* See above */ int ifa_index; /* Link index */ }; enum { IFA_UNSPEC, IFA_ADDRESS, IFA_LOCAL, IFA_LABEL, IFA_BROADCAST, IFA_ANYCAST, IFA_CACHEINFO }; #define IFA_MAX IFA_CACHEINFO /* ifa_flags */ #define IFA_F_SECONDARY 0x01 #define IFA_F_TEMPORARY IFA_F_SECONDARY #define IFA_F_DEPRECATED 0x20 #define IFA_F_TENTATIVE 0x40 #define IFA_F_PERMANENT 0x80 struct ifa_cacheinfo { s32_t ifa_prefered; s32_t ifa_valid; }; #define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg)))) #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg)) /* Important comment: IFA_ADDRESS is prefix address, rather than local interface address. It makes no difference for normally configured broadcast interfaces, but for point-to-point IFA_ADDRESS is DESTINATION address, local address is supplied in IFA_LOCAL attribute. */ /************************************************************** * Neighbour discovery. ****/ struct ndmsg { unsigned char ndm_family; unsigned char ndm_pad1; unsigned short ndm_pad2; int ndm_ifindex; /* Link index */ u16_t ndm_state; u8_t ndm_flags; u8_t ndm_type; }; enum { NDA_UNSPEC, NDA_DST, NDA_LLADDR, NDA_CACHEINFO }; #define NDA_MAX NDA_CACHEINFO #define NDA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg)))) #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg)) /* * Neighbor Cache Entry Flags */ #define NTF_PROXY 0x08 /* == ATF_PUBL */ #define NTF_ROUTER 0x80 /* * Neighbor Cache Entry States. */ #define NUD_INCOMPLETE 0x01 #define NUD_REACHABLE 0x02 #define NUD_STALE 0x04 #define NUD_DELAY 0x08 #define NUD_PROBE 0x10 #define NUD_FAILED 0x20 /* Dummy states */ #define NUD_NOARP 0x40 #define NUD_PERMANENT 0x80 #define NUD_NONE 0x00 struct nda_cacheinfo { u32_t ndm_confirmed; u32_t ndm_used; u32_t ndm_updated; u32_t ndm_refcnt; }; /**** * General form of address family dependent message. ****/ struct rtgenmsg { unsigned char rtgen_family; }; /***************************************************************** * Link layer specific messages. ****/ /* struct ifinfomsg * passes link level specific information, not dependent * on network protocol. */ struct ifinfomsg { unsigned char ifi_family; unsigned char __ifi_pad; unsigned short ifi_type; /* ARPHRD_* */ int ifi_index; /* Link index */ unsigned ifi_flags; /* IFF_* flags */ unsigned ifi_change; /* IFF_* change mask */ }; /* The struct should be in sync with struct net_device_stats */ struct rtnl_link_stats { u32_t rx_packets; /* total packets received */ u32_t tx_packets; /* total packets transmitted */ u32_t rx_bytes; /* total bytes received */ u32_t tx_bytes; /* total bytes transmitted */ u32_t rx_errors; /* bad packets received */ u32_t tx_errors; /* packet transmit problems */ u32_t rx_dropped; /* no space in linux buffers */ u32_t tx_dropped; /* no space available in linux */ u32_t multicast; /* multicast packets received */ u32_t collisions; /* detailed rx_errors: */ u32_t rx_length_errors; u32_t rx_over_errors; /* receiver ring buff overflow */ u32_t rx_crc_errors; /* recved pkt with crc error */ u32_t rx_frame_errors; /* recv'd frame alignment error */ u32_t rx_fifo_errors; /* recv'r fifo overrun */ u32_t rx_missed_errors; /* receiver missed packet */ /* detailed tx_errors */ u32_t tx_aborted_errors; u32_t tx_carrier_errors; u32_t tx_fifo_errors; u32_t tx_heartbeat_errors; u32_t tx_window_errors; /* for cslip etc */ u32_t rx_compressed; u32_t tx_compressed; }; enum { IFLA_UNSPEC, IFLA_ADDRESS, IFLA_BROADCAST, IFLA_IFNAME, IFLA_MTU, IFLA_LINK, IFLA_QDISC, IFLA_STATS, IFLA_COST, #define IFLA_COST IFLA_COST IFLA_PRIORITY, #define IFLA_PRIORITY IFLA_PRIORITY IFLA_MASTER, #define IFLA_MASTER IFLA_MASTER IFLA_WIRELESS, /* Wireless Extension event - see wireless.h */ #define IFLA_WIRELESS IFLA_WIRELESS IFLA_PROTINFO /* Protocol specific information for a link */ #define IFLA_PROTINFO IFLA_PROTINFO }; #define IFLA_MAX IFLA_PROTINFO #define IFLA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg)))) #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg)) /* ifi_flags. IFF_* flags. The only change is: IFF_LOOPBACK, IFF_BROADCAST and IFF_POINTOPOINT are more not changeable by user. They describe link media characteristics and set by device driver. Comments: - Combination IFF_BROADCAST|IFF_POINTOPOINT is invalid - If neither of these three flags are set; the interface is NBMA. - IFF_MULTICAST does not mean anything special: multicasts can be used on all not-NBMA links. IFF_MULTICAST means that this media uses special encapsulation for multicast frames. Apparently, all IFF_POINTOPOINT and IFF_BROADCAST devices are able to use multicasts too. */ /* IFLA_LINK. For usual devices it is equal ifi_index. If it is a "virtual interface" (f.e. tunnel), ifi_link can point to real physical interface (f.e. for bandwidth calculations), or maybe 0, what means, that real media is unknown (usual for IPIP tunnels, when route to endpoint is allowed to change) */ /* Subtype attributes for IFLA_PROTINFO */ enum { IFLA_INET6_UNSPEC, IFLA_INET6_FLAGS, /* link flags */ IFLA_INET6_CONF, /* sysctl parameters */ IFLA_INET6_STATS, /* statistics */ IFLA_INET6_MCAST /* MC things. What of them? */ }; #define IFLA_INET6_MAX IFLA_INET6_MCAST /***************************************************************** * Traffic control messages. ****/ struct tcmsg { unsigned char tcm_family; unsigned char tcm__pad1; unsigned short tcm__pad2; int tcm_ifindex; u32_t tcm_handle; u32_t tcm_parent; u32_t tcm_info; }; enum { TCA_UNSPEC, TCA_KIND, TCA_OPTIONS, TCA_STATS, TCA_XSTATS, TCA_RATE }; #define TCA_MAX TCA_RATE #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg)))) #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg)) /* SUMMARY: maximal rtattr understood by kernel */ #define RTATTR_MAX RTA_MAX /* RTnetlink multicast groups */ #define RTMGRP_LINK 1 #define RTMGRP_NOTIFY 2 #define RTMGRP_NEIGH 4 #define RTMGRP_TC 8 #define RTMGRP_IPV4_IFADDR 0x10 #define RTMGRP_IPV4_MROUTE 0x20 #define RTMGRP_IPV4_ROUTE 0x40 #define RTMGRP_IPV6_IFADDR 0x100 #define RTMGRP_IPV6_MROUTE 0x200 #define RTMGRP_IPV6_ROUTE 0x400 #define RTMGRP_DECnet_IFADDR 0x1000 #define RTMGRP_DECnet_ROUTE 0x4000 #if 0 enum { IFF_UP = 0x1, /* Interface is up. */ # define IFF_UP IFF_UP IFF_BROADCAST = 0x2, /* Broadcast address valid. */ # define IFF_BROADCAST IFF_BROADCAST IFF_DEBUG = 0x4, /* Turn on debugging. */ # define IFF_DEBUG IFF_DEBUG IFF_LOOPBACK = 0x8, /* Is a loopback net. */ # define IFF_LOOPBACK IFF_LOOPBACK IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link. */ # define IFF_POINTOPOINT IFF_POINTOPOINT IFF_NOTRAILERS = 0x20, /* Avoid use of trailers. */ # define IFF_NOTRAILERS IFF_NOTRAILERS IFF_RUNNING = 0x40, /* Resources allocated. */ # define IFF_RUNNING IFF_RUNNING IFF_NOARP = 0x80, /* No address resolution protocol. */ # define IFF_NOARP IFF_NOARP IFF_PROMISC = 0x100, /* Receive all packets. */ # define IFF_PROMISC IFF_PROMISC /* Not supported */ IFF_ALLMULTI = 0x200, /* Receive all multicast packets. */ # define IFF_ALLMULTI IFF_ALLMULTI IFF_MASTER = 0x400, /* Master of a load balancer. */ # define IFF_MASTER IFF_MASTER IFF_SLAVE = 0x800, /* Slave of a load balancer. */ # define IFF_SLAVE IFF_SLAVE IFF_MULTICAST = 0x1000, /* Supports multicast. */ # define IFF_MULTICAST IFF_MULTICAST IFF_PORTSEL = 0x2000, /* Can set media type. */ # define IFF_PORTSEL IFF_PORTSEL IFF_AUTOMEDIA = 0x4000 /* Auto media select active. */ # define IFF_AUTOMEDIA IFF_AUTOMEDIA }; #endif /* End of information exported to user level */ #endif lwipv6-1.5a/lwip-v6/src/include/lwip/mem.h0000644000175000017500000000671711671615005017460 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_MEM_H__ #define __LWIP_MEM_H__ #include "lwip/opt.h" #include "lwip/arch.h" typedef unsigned long mem_size_t; #ifndef DEBUGMEM void mem_init(void); void *mem_malloc(mem_size_t size); void mem_free(void *mem); void *mem_realloc(void *mem, mem_size_t size); void *mem_reallocm(void *mem, mem_size_t size); #else void mem_d_init(char *file,int line); void *mem_d_malloc(mem_size_t size,char *file,int line); void mem_d_free(void *mem,char *file,int line); void *mem_d_realloc(void *mem, mem_size_t size,char *file,int line); void *mem_d_reallocm(void *mem, mem_size_t size,char *file,int line); #define mem_init() mem_d_init(__FILE__,__LINE__) #define mem_free(X) mem_d_free((X),__FILE__,__LINE__) #define mem_malloc(X) mem_d_malloc((X),__FILE__,__LINE__) #define mem_realloc(Y,X) mem_d_realloc((Y),(X),__FILE__,__LINE__) #define mem_reallocm(Y,X) mem_d_reallocm((Y),(X),__FILE__,__LINE__) #endif #if 0 #define MEM_ALIGN_1 (MEM_ALIGNMENT - 1) #define ALIGN_SIZE(X) (((X) + MEM_ALIGN_1) & (~MEM_ALIGN_1)) #define mem_init() ({ ; }) #define mem_free(X) ({ printf("MEM-FREE %x %s %d\n",(X),__FILE__,__LINE__); \ free(X); }) #define mem_malloc(X) ({ void *x; x=malloc(ALIGN_SIZE(X)); \ printf("MEM-MALLOC %x %s %d\n",x,__FILE__,__LINE__); \ x; }) #define mem_realloc(Y,X) ({ void *x,*old; \ old=(Y);\ x=realloc(old,ALIGN_SIZE(X)); \ printf("MEM-REALLOC %x->%x %s %d\n",old,x,__FILE__,__LINE__); \ x; }) #define mem_reallocm(Y,X) ({ void *x,*old; \ old=(Y);\ x=realloc(old,ALIGN_SIZE(X)); \ printf("MEM-REALLOCM %x->%x %s %d\n",old,x,__FILE__,__LINE__); \ x; }) #endif #ifndef MEM_ALIGN_SIZE #define MEM_ALIGN_SIZE(size) (((size) + MEM_ALIGNMENT - 1) & ~(MEM_ALIGNMENT-1)) #endif #ifndef MEM_ALIGN #define MEM_ALIGN(addr) ((void *)(((mem_ptr_t)(addr) + MEM_ALIGNMENT - 1) & ~(mem_ptr_t)(MEM_ALIGNMENT-1))) #endif #endif /* __LWIP_MEM_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/udp.h0000644000175000017500000001016211671615005017457 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_UDP_H__ #define __LWIP_UDP_H__ #include "lwip/arch.h" #include "lwip/pbuf.h" ///#include "lwip/inet.h" #include "lwip/ip.h" struct stack; #define UDP_HLEN 8 struct udp_hdr { PACK_STRUCT_FIELD(u16_t src); PACK_STRUCT_FIELD(u16_t dest); /* src/dest UDP ports */ PACK_STRUCT_FIELD(u16_t len); PACK_STRUCT_FIELD(u16_t chksum); } PACK_STRUCT_STRUCT; #define UDP_FLAGS_NOCHKSUM 0x01U #define UDP_FLAGS_UDPLITE 0x02U #define UDP_FLAGS_CONNECTED 0x04U #ifdef LWSLIRP #define UDP_PCB_EXPIRE 240 #define UDP_PCB_EXPIREFAST 10 /* for tests #define UDP_PCB_EXPIRE 12 #define UDP_PCB_EXPIREFAST 3 */ #endif /* SLIRPVDE */ struct udp_pcb { /* Common members of all PCB types */ IP_PCB; /* Protocol specific PCB members */ struct udp_pcb *next; u8_t flags; u16_t local_port, remote_port; u16_t chksum_len; void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port); void *recv_arg; #ifdef LWSLIRP u32_t slirp_expire; #endif }; /* The following functions is the application layer interface to the UDP code. */ struct udp_pcb * udp_new (struct stack *stack); void udp_remove (struct udp_pcb *pcb); err_t udp_bind (struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port #ifdef LWSLIRP , struct netif *slirpif #endif ); err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port); void udp_disconnect (struct udp_pcb *pcb); void udp_recv (struct udp_pcb *pcb, void (* recv)(void *arg, struct udp_pcb *upcb, struct pbuf *p, struct ip_addr *addr, u16_t port), void *recv_arg); err_t udp_sendto (struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *dst_ip, u16_t dst_port); err_t udp_send (struct udp_pcb *pcb, struct pbuf *p); #define udp_flags(pcb) ((pcb)->flags) #define udp_setflags(pcb, f) ((pcb)->flags = (f)) /* The following functions are the lower layer interface to UDP. */ void udp_input (struct pbuf *p, struct ip_addr_list *inad, struct pseudo_iphdr *piphdr #ifdef LWSLIRP , struct netif *slirpif #endif ); void udp_init (struct stack *stack); void udp_shutdown (struct stack *stack); #if UDP_DEBUG int udp_debug_print(struct udp_hdr *udphdr); #else #define udp_debug_print(udphdr) #endif #endif /* __LWIP_UDP_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/raw.h0000644000175000017500000000631311671615005017463 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_RAW_H__ #define __LWIP_RAW_H__ #include "lwip/arch.h" #include "lwip/stack.h" #include "lwip/pbuf.h" ///#include "lwip/inet.h" #include "lwip/ip.h" struct stack; struct raw_pcb { /* Common members of all PCB types */ IP_PCB; struct raw_pcb *next; u16_t in_protocol; #define checksumoffset out_protocol u16_t out_protocol; void (* recv)(void *arg, struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t protocol); void *recv_arg; }; /* The following functions is the application layer interface to the RAW code. */ struct raw_pcb * raw_new (struct stack *stack, u16_t proto); void raw_remove (struct raw_pcb *pcb); err_t raw_bind (struct raw_pcb *pcb, struct ip_addr *ipaddr, u16_t protocol); err_t raw_connect (struct raw_pcb *pcb, struct ip_addr *ipaddr, u16_t protocol); void raw_recv (struct raw_pcb *pcb, void (* recv)(void *arg, struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t protocol), void *recv_arg); err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr); err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); /* The following functions are the lower layer interface to RAW. */ u8_t raw_input (struct pbuf *p, struct ip_addr_list *inad, struct pseudo_iphdr *piphdr); void raw_init (struct stack *stack); #endif /* __LWIP_RAW_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/dhcp.h0000644000175000017500000002060611671615005017611 0ustar renzorenzo/** @file */ /* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Diego Billi - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef __LWIP_DHCP_H__ #define __LWIP_DHCP_H__ #include "lwip/opt.h" ///#include "lwip/netif.h" ///#include "lwip/udp.h" struct ip4_addr; struct netif; struct udp_pcb; /** period (in seconds) of the application calling dhcp_coarse_tmr() */ #define DHCP_COARSE_TIMER_SECS 60 /** period (in milliseconds) of the application calling dhcp_fine_tmr() */ #define DHCP_FINE_TIMER_MSECS 500 struct dhcp { /** current DHCP state machine state */ u8_t state; /** retries of current request */ u8_t tries; /** transaction identifier of last sent request */ u32_t xid; /** our connection to the DHCP server */ struct udp_pcb *pcb; /** (first) pbuf of incoming msg */ struct pbuf *p; /** incoming msg */ struct dhcp_msg *msg_in; /** incoming msg options */ struct dhcp_msg *options_in; /** ingoing msg options length */ u16_t options_in_len; struct pbuf *p_out; /* pbuf of outcoming msg */ struct dhcp_msg *msg_out; /* outgoing msg */ u16_t options_out_len; /* outgoing msg options length */ u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */ u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */ struct ip4_addr server_ip_addr; /* dhcp server address that offered this lease */ struct ip4_addr offered_ip_addr; struct ip4_addr offered_sn_mask; struct ip4_addr offered_gw_addr; struct ip4_addr offered_bc_addr; #define DHCP_MAX_DNS 2 u32_t dns_count; /* actual number of DNS servers obtained */ struct ip4_addr offered_dns_addr[DHCP_MAX_DNS]; /* DNS server addresses */ u32_t offered_t0_lease; /* lease period (in seconds) */ u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */ /** Patch #1308 * TODO: See dhcp.c "TODO"s */ #if 0 struct ip_addr offered_si_addr; u8_t *boot_file_name; #endif }; /* MUST be compiled with "pack structs" or equivalent! */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN /** minimum set of fields of any DHCP message */ struct dhcp_msg { PACK_STRUCT_FIELD(u8_t op); PACK_STRUCT_FIELD(u8_t htype); PACK_STRUCT_FIELD(u8_t hlen); PACK_STRUCT_FIELD(u8_t hops); PACK_STRUCT_FIELD(u32_t xid); PACK_STRUCT_FIELD(u16_t secs); PACK_STRUCT_FIELD(u16_t flags); PACK_STRUCT_FIELD(struct ip4_addr ciaddr); PACK_STRUCT_FIELD(struct ip4_addr yiaddr); PACK_STRUCT_FIELD(struct ip4_addr siaddr); PACK_STRUCT_FIELD(struct ip4_addr giaddr); #define DHCP_CHADDR_LEN 16U PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]); #define DHCP_SNAME_LEN 64U PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]); #define DHCP_FILE_LEN 128U PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]); PACK_STRUCT_FIELD(u32_t cookie); #define DHCP_MIN_OPTIONS_LEN 68U /** make sure user does not configure this too small */ #if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN)) # undef DHCP_OPTIONS_LEN #endif /** allow this to be configured in lwipopts.h, but not too small */ #if (!defined(DHCP_OPTIONS_LEN)) /** set this to be sufficient for your options in outgoing DHCP msgs */ # define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN #endif PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #if 0 void dhcp_init(struct stack *stack); #endif /** start DHCP configuration */ err_t dhcp_start(struct netif *netif); /** enforce early lease renewal (not needed normally)*/ err_t dhcp_renew(struct netif *netif); /** release the DHCP lease, usually called before dhcp_stop()*/ err_t dhcp_release(struct netif *netif); /** stop DHCP configuration */ void dhcp_stop(struct netif *netif); /** inform server of our manual IP address */ void dhcp_inform(struct netif *netif); /** if enabled, check whether the offered IP address is not in use, using ARP */ #if DHCP_DOES_ARP_CHECK void dhcp_arp_reply(struct netif *netif, struct ip4_addr *addr); #endif /** to be called every minute */ void dhcp_coarse_tmr(void *arg); /** to be called every half second */ void dhcp_fine_tmr(void *arg); /** DHCP message item offsets and length */ #define DHCP_MSG_OFS (UDP_DATA_OFS) #define DHCP_OP_OFS (DHCP_MSG_OFS + 0) #define DHCP_HTYPE_OFS (DHCP_MSG_OFS + 1) #define DHCP_HLEN_OFS (DHCP_MSG_OFS + 2) #define DHCP_HOPS_OFS (DHCP_MSG_OFS + 3) #define DHCP_XID_OFS (DHCP_MSG_OFS + 4) #define DHCP_SECS_OFS (DHCP_MSG_OFS + 8) #define DHCP_FLAGS_OFS (DHCP_MSG_OFS + 10) #define DHCP_CIADDR_OFS (DHCP_MSG_OFS + 12) #define DHCP_YIADDR_OFS (DHCP_MSG_OFS + 16) #define DHCP_SIADDR_OFS (DHCP_MSG_OFS + 20) #define DHCP_GIADDR_OFS (DHCP_MSG_OFS + 24) #define DHCP_CHADDR_OFS (DHCP_MSG_OFS + 28) #define DHCP_SNAME_OFS (DHCP_MSG_OFS + 44) #define DHCP_FILE_OFS (DHCP_MSG_OFS + 108) #define DHCP_MSG_LEN 236 #define DHCP_COOKIE_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN) #define DHCP_OPTIONS_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN + 4) #define DHCP_CLIENT_PORT 68 #define DHCP_SERVER_PORT 67 /** DHCP client states */ #define DHCP_REQUESTING 1 #define DHCP_INIT 2 #define DHCP_REBOOTING 3 #define DHCP_REBINDING 4 #define DHCP_RENEWING 5 #define DHCP_SELECTING 6 #define DHCP_INFORMING 7 #define DHCP_CHECKING 8 #define DHCP_PERMANENT 9 #define DHCP_BOUND 10 /** not yet implemented #define DHCP_RELEASING 11 */ #define DHCP_BACKING_OFF 12 #define DHCP_OFF 13 #define DHCP_BOOTREQUEST 1 #define DHCP_BOOTREPLY 2 #define DHCP_DISCOVER 1 #define DHCP_OFFER 2 #define DHCP_REQUEST 3 #define DHCP_DECLINE 4 #define DHCP_ACK 5 #define DHCP_NAK 6 #define DHCP_RELEASE 7 #define DHCP_INFORM 8 #define DHCP_HTYPE_ETH 1 #define DHCP_HLEN_ETH 6 #define DHCP_BROADCAST_FLAG 15 #define DHCP_BROADCAST_MASK (1 << DHCP_FLAG_BROADCAST) /** BootP options */ #define DHCP_OPTION_PAD 0 #define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */ #define DHCP_OPTION_ROUTER 3 #define DHCP_OPTION_DNS_SERVER 6 #define DHCP_OPTION_HOSTNAME 12 #define DHCP_OPTION_IP_TTL 23 #define DHCP_OPTION_MTU 26 #define DHCP_OPTION_BROADCAST 28 #define DHCP_OPTION_TCP_TTL 37 #define DHCP_OPTION_END 255 /** DHCP options */ #define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */ #define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */ #define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */ #define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */ #define DHCP_OPTION_MESSAGE_TYPE_LEN 1 #define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */ #define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */ #define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */ #define DHCP_OPTION_MAX_MSG_SIZE_LEN 2 #define DHCP_OPTION_T1 58 /* T1 renewal time */ #define DHCP_OPTION_T2 59 /* T2 rebinding time */ #define DHCP_OPTION_CLIENT_ID 61 #define DHCP_OPTION_TFTP_SERVERNAME 66 #define DHCP_OPTION_BOOTFILE 67 /** possible combinations of overloading the file and sname fields with options */ #define DHCP_OVERLOAD_NONE 0 #define DHCP_OVERLOAD_FILE 1 #define DHCP_OVERLOAD_SNAME 2 #define DHCP_OVERLOAD_SNAME_FILE 3 #endif /*__LWIP_DHCP_H__*/ lwipv6-1.5a/lwip-v6/src/include/lwip/netif.h0000644000175000017500000002116411671615005020000 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_NETIF_H__ #define __LWIP_NETIF_H__ #include "lwip/opt.h" #include "lwip/err.h" #include "lwip/ip_addr.h" #include "lwip/ip_route.h" #include "lwip/inet.h" #include "lwip/pbuf.h" #define NETIF_LOOPIF 0 #define NETIF_TAPIF 1 #define NETIF_TUNIF 2 #define NETIF_VDEIF 3 #define NETIF_SLIRPIF 4 #define NETIF_SLIPIF 5 #define NETIF_NUMIF 6 #if IPv6_AUTO_CONFIGURATION #include "lwip/ip_autoconf.h" #endif #if IPv6_ROUTER_ADVERTISEMENT #include "lwip/ip_radv.h" #endif /** must be the maximum of all used hardware address lengths across all types of interfaces in use */ #define NETIF_MAX_HWADDR_LEN 6U /** TODO: define the use (where, when, whom) of netif flags */ /** whether the network interface is 'up'. this is * a software flag used to control whether this network * interface is enabled and processes traffic. */ #define NETIF_FLAG_UP 0x1U /** if set, the netif has broadcast capability */ #define NETIF_FLAG_BROADCAST 0x2U /** if set, the netif is the loopback interface */ /* NETIF_DEBUG 0x4U not used */ #define NETIF_FLAG_LOOPBACK 0x8U /** if set, the netif is one end of a point-to-point connection */ #define NETIF_FLAG_POINTTOPOINT 0x10U /* NETIF_NOTRAILERS 0x20U not used */ /* #define NETIF_RUNNING 0x40U not used */ /* NETIF_NOARP 0x80U not used */ /* Promisquous mode: pass all the traffic up to the stack */ #define NETIF_PROMISC 0x100U /* bits here below are not compatible with IFF */ /* if set use IPv6 AUTOCONF */ #define NETIF_FLAG_AUTOCONF 0x800U /* if set this interface supports Router Advertising */ #define NETIF_FLAG_RADV 0x2000U /** if set, the interface is configured using DHCP */ #define NETIF_FLAG_DHCP 0x4000U /** if set, the interface has an active link * (set by the network interface driver) */ #define NETIF_FLAG_LINK_UP 0x8000U #define NETIF_IFF_INCOMPATIBLE_MASK \ (NETIF_FLAG_AUTOCONF | NETIF_FLAG_RADV | NETIF_FLAG_DHCP | NETIF_FLAG_LINK_UP) #define NETIF_STD_FLAGS (NETIF_FLAG_AUTOCONF) #define NETIF_ADD_FLAGS (NETIF_FLAG_AUTOCONF | NETIF_FLAG_RADV) #define NETIF_IFUP_FLAGS (NETIF_FLAG_DHCP) /** Generic data structure used for all lwIP network interfaces. * The following fields should be filled in by the initialization * function for the device driver: hwaddr_len, hwaddr[], mtu, flags */ struct netif { /** pointer to next in linked list */ struct netif *next; /** IP address configuration in network byte order */ struct ip_addr_list *addrs; /** This function is called by the network device driver * to pass a packet up the TCP/IP stack. */ err_t (* input)(struct pbuf *p, struct netif *inp); /** This function is called by the IP module when it wants * to send a packet on the interface. This function typically * first resolves the hardware address, then sends the packet. */ err_t (* output)(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr); /** This function is called by the ARP module when it wants * to send a packet on the interface. This function outputs * the pbuf as-is on the link medium. */ err_t (* linkoutput)(struct netif *netif, struct pbuf *p); #define NETIFCTL_CLEANUP 1 #define NETIFCTL_SLIRPSOCK_DGRAM 0x100 #define NETIFCTL_SLIRPSOCK_STREAM 0x101 /* netif netifctl function */ err_t (* netifctl)(struct netif *netif, int request, void *arg); /** This field can be set by the device driver and could point * to state information for the device. */ void *state; #define NETIF_CHANGE_UP 1 #define NETIF_CHANGE_DOWN 2 #define NETIF_CHANGE_MTU 3 void (* change)(struct netif *netif, u32_t type); #if LWIP_DHCP /** the DHCP client state information for this netif */ struct dhcp *dhcp; #endif #if IPv6_AUTO_CONFIGURATION struct autoconf *autoconf; #endif #if IPv6_ROUTER_ADVERTISEMENT struct radv *radv; #endif /** number of bytes used in hwaddr */ unsigned char hwaddr_len; /** link level hardware address of this interface */ unsigned char hwaddr[NETIF_MAX_HWADDR_LEN]; /** maximum transfer unit (in bytes) */ u16_t mtu; /** link type */ u8_t link_type; /** descriptive abbreviation */ char name[2]; /** number of this interface */ u8_t num; /* unique id */ u8_t id; /** NETIF_FLAG_* */ u16_t flags; #ifdef LWIP_NL u16_t type; /* type */ #endif /* Stack identifier */ struct stack *stack; }; struct netif_fddata { int fd; short events; struct netif *netif; void (*fun)(struct netif_fddata *fddata, short revents); void *opaque; int flags; int refcnt; }; /* netif_init() must be called first. */ void netif_init(struct stack *stack); void netif_shutdown(struct stack *stack); /* netif_cleanup() must be called for a final garbage collection. */ void netif_cleanup(struct stack *stack); struct netif_fddata *netif_addfd(struct netif *netif, int fd, void (*fun)(struct netif_fddata *fddata, short revents), void *opaque, int flags, short events); void netif_thread_wake(struct stack *stack); #define NETIF_ARGS_1SEC_POLL 0x1 /* range 0x1000-0x8000 reserved for LWSLIRP_LISTEN */ #if 0 struct netif_args { void (*fun)(struct netif *netif, int posfd, void *arg, short revents); struct netif *netif; void *funarg; int flags; }; #endif struct netif * netif_add( struct stack *stack, struct netif *netif, void *state, err_t (* init )(struct netif *netif), err_t (* input )(struct pbuf *p, struct netif *netif), void (* change)(struct netif *netif, u32_t type) ); u8_t netif_next_num(struct netif *netif,int netif_model); int netif_add_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask); int netif_del_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask); void netif_remove(struct netif * netif); struct ifreq; int netif_ioctl(struct stack *stack, int cmd,struct ifreq *ifr #if LWIP_CAPABILITIES ,int cap #endif ); /* Returns a network interface given its name. The name is of the form "et0", where the first two letters are the "name" field in the netif structure, and the digit is in the num field in the same structure. */ struct netif *netif_find(struct stack *stack, char *name); struct netif *netif_find_id(struct stack *stack, int id); struct netif * netif_find_direct_destination(struct stack *stack, struct ip_addr *addr); /* These functions change interface state and inform IP layer */ void netif_set_up(struct netif *netif, int flags); u8_t netif_is_up(struct netif *netif); void netif_set_down(struct netif *netif); /* These functions change interface state BUT DO NOT inform IP layer */ void netif_set_up_low(struct netif *netif); void netif_set_down_low(struct netif *netif); #endif /* __LWIP_NETIF_H__ */ /* void netif_set_default(struct netif *netif); void netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr); void netif_set_netmask(struct netif *netif, struct ip_addr *netmast); void netif_set_gw(struct netif *netif, struct ip_addr *gw); void netif_set_up(struct netif *netif); void netif_set_down(struct netif *netif); u8_t netif_is_up(struct netif *netif); */ //struct netif *netif_add(struct netif *netif, // void *state, // err_t (* init)(struct netif *netif), // err_t (* input)(struct pbuf *p, struct netif *netif)); lwipv6-1.5a/lwip-v6/src/include/lwip/tcpip.h0000644000175000017500000001067511671615005020017 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_TCPIP_H__ #define __LWIP_TCPIP_H__ #include "lwip/pbuf.h" #include "lwip/stack.h" #if LWIP_CAPABILITIES typedef int (*lwip_capfun)(void); #endif enum tcpip_msg_type { /* Core messages */ TCPIP_MSG_API, TCPIP_MSG_INPUT, TCPIP_MSG_CALLBACK, TCPIP_MSG_SYNC_CALLBACK, /* other messages */ TCPIP_MSG_NETIFADD, TCPIP_MSG_SHUTDOWN, TCPIP_MSG_NETIF_NOTIFY }; enum tcpip_sync { ASYNC = 0, SYNC = 1 }; struct tcpip_msg { enum tcpip_msg_type type; sys_sem_t *sem; // FIX: for what????????? union { struct api_msg *apimsg; struct { struct pbuf *p; struct netif *netif; } inp; struct { sys_sem_t *sem; // used for synchronous calls void (*f)(void *ctx); void *ctx; } cb; /* Signal to the main thread to add a new network interface */ struct { sys_sem_t *sem; // used for synchronous calls struct netif *netif; void *state; err_t (* init)(struct netif *netif); err_t (* input)(struct pbuf *p, struct netif *netif); void (* change)(struct netif *netif, u32_t type); struct netif **retval; } netif; struct { sys_sem_t *sem; // used for synchronous calls struct netif *netif; u32_t type; } netif_notify; } msg; }; int tcpip_init(void); typedef void (* tcpip_handler)(void *arg); #if LWIP_CAPABILITIES struct stack *tcpip_start(tcpip_handler init_func, void *arg, unsigned long flags, lwip_capfun capfun); #else /* Alloc a new stack thread and return stack number */ struct stack *tcpip_start(tcpip_handler init_func, void *arg, unsigned long flags); #endif /* Signal to the stack to shutdown */ void tcpip_shutdown(struct stack *stack, tcpip_handler shutdown_func, void *arg); /* Get "current" stack */ struct stack *tcpip_stack_get(void); /* Set "current" stack */ struct stack *tcpip_stack_set(struct stack *id); /* These functions send messages to the stack thread. After tcpip_shutdown() they are unuseful. */ void tcpip_apimsg(struct stack *stack, struct api_msg *apimsg); err_t tcpip_input(struct pbuf *p, struct netif *inp); err_t tcpip_callback(struct stack *stack, void (*f)(void *ctx), void *ctx, enum tcpip_sync sync); void tcpip_tcp_timer_needed(struct stack *stack); /* Tell to the stack to create a new interface. This function should be used only when you can't create interfaces before the launch of the stack thread. N.B: this functions has been created for the ViewOS project. */ struct netif * tcpip_netif_add( struct stack *stack, struct netif *netif, void *state, err_t (* init)(struct netif *netif), err_t (* input)(struct pbuf *p, struct netif *netif), void (* change)(struct netif *netif, u32_t type)); /* Signal to the stack the interface's state is changed */ void tcpip_notify(struct netif *netif, u32_t type); #endif /* __LWIP_TCPIP_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/debug.h0000644000175000017500000000634711671615005017767 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_DEBUG_H__ #define __LWIP_DEBUG_H__ #include "arch/cc.h" /** lower two bits indicate debug level * - 0 off * - 1 warning * - 2 serious * - 3 severe */ #define DBG_LEVEL_OFF 0 #define DBG_LEVEL_WARNING 1 /* bad checksums, dropped packets, ... */ #define DBG_LEVEL_SERIOUS 2 /* memory allocation failures, ... */ #define DBG_LEVEL_SEVERE 3 /* */ #define DBG_MASK_LEVEL 3 /** flag for LWIP_DEBUGF to enable that debug message */ #define DBG_ON 0x80U /** flag for LWIP_DEBUGF to disable that debug message */ #define DBG_OFF 0x00U /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ #define DBG_TRACE 0x40U /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ #define DBG_STATE 0x20U /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ #define DBG_FRESH 0x10U /** flag for LWIP_DEBUGF to halt after printing this debug message */ #define DBG_HALT 0x08U #ifndef LWIP_NOASSERT # define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0) #else # define LWIP_ASSERT(x,y) #endif #ifdef LWIP_DEBUG /** print debug message only if debug message type is enabled... * AND is of correct type AND is at least DBG_LEVEL */ # define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && ((int)((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0) # define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0) #else /* LWIP_DEBUG */ # define LWIP_DEBUGF(debug,x) # define LWIP_ERROR(x) #endif /* LWIP_DEBUG */ #endif /* __LWIP_DEBUG_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/sys.h0000644000175000017500000001516511671615005017515 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_SYS_H__ #define __LWIP_SYS_H__ #include "arch/cc.h" #include "lwip/opt.h" #if NO_SYS /* For a totally minimal and standalone system, we provide null definitions of the sys_ functions. */ typedef u8_t sys_sem_t; typedef u8_t sys_mbox_t; struct sys_timeout {u8_t dummy;}; #define sys_init() #define sys_timeout(m,h,a) #define sys_untimeout(m,a) #define sys_sem_new(c) c #define sys_sem_signal(s) #define sys_sem_wait(s) #define sys_sem_free(s) #define sys_mbox_new() 0 #define sys_mbox_fetch(m,d) #define sys_mbox_post(m,d) #define sys_mbox_free(m) #define sys_thread_new(t,a,p) #else /* NO_SYS */ #include "arch/sys_arch.h" /** Return code for timeouts from sys_arch_mbox_fetch and sys_arch_sem_wait */ #define SYS_ARCH_TIMEOUT 0xffffffff typedef void (* sys_timeout_handler)(void *arg); struct sys_timeout { struct sys_timeout *next; u32_t time; sys_timeout_handler h; void *arg; /* Added by Diego Billi */ u8_t raw; /* = 1 if this timeout where created by _XXX functions */ }; struct sys_timeouts { struct sys_timeout *next; }; /* sys_init() must be called before anthing else. */ void sys_init(void); /* * sys_timeout(): * * Schedule a timeout a specified amount of milliseconds in the * future. When the timeout occurs, the specified timeout handler will * be called. The handler will be passed the "arg" argument when * called. * */ void sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg); void sys_untimeout(sys_timeout_handler h, void *arg); struct sys_timeouts *sys_arch_timeouts(void); /* Added by Diego Billi: here for future Radvd porting */ int sys_untimeout_and_check(sys_timeout_handler h, void *arg); void sys_timeout_raw(struct sys_timeout * timeout); int sys_untimeout_raw(struct sys_timeout *timeout); /* Added by Renzo Davoli: for slirp timeout */ unsigned long time_now(); /* Semaphore functions. */ sys_sem_t sys_sem_new(u8_t count); void sys_sem_signal(sys_sem_t sem); u32_t sys_arch_sem_wait(sys_sem_t sem, u32_t timeout); void sys_sem_free(sys_sem_t sem); void sys_sem_wait(sys_sem_t sem); int sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout); /* Time functions. */ #ifndef sys_msleep void sys_msleep(u32_t ms); /* only has a (close to) 1 jiffy resolution. */ #endif #ifndef sys_jiffies unsigned long sys_jiffies(void); /* since power up. */ #endif /* Mailbox functions. */ sys_mbox_t sys_mbox_new(void); void sys_mbox_post(sys_mbox_t mbox, void *msg); void sys_mbox_post_d(sys_mbox_t mbox, void *msg, char *file, int line); u32_t sys_arch_mbox_fetch(sys_mbox_t mbox, void **msg, u32_t timeout); void sys_mbox_free(sys_mbox_t mbox); void sys_mbox_fetch(sys_mbox_t mbox, void **msg); /* Thread functions. */ sys_thread_t sys_thread_new(void (* thread)(void *arg), void *arg, int prio); /* The following functions are used only in Unix code, and can be omitted when porting the stack. */ /* Returns the current time in microseconds. */ unsigned long sys_now(void); #endif /* NO_SYS */ /* Critical Region Protection */ /* These functions must be implemented in the sys_arch.c file. In some implementations they can provide a more light-weight protection mechanism than using semaphores. Otherwise semaphores can be used for implementation */ #ifndef SYS_ARCH_PROTECT /** SYS_LIGHTWEIGHT_PROT * define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection * for certain critical regions during buffer allocation, deallocation and memory * allocation and deallocation. */ #if SYS_LIGHTWEIGHT_PROT /** SYS_ARCH_DECL_PROTECT * declare a protection variable. This macro will default to defining a variable of * type sys_prot_t. If a particular port needs a different implementation, then * this macro may be defined in sys_arch.h. */ #define SYS_ARCH_DECL_PROTECT(lev) sys_prot_t lev /** SYS_ARCH_PROTECT * Perform a "fast" protect. This could be implemented by * disabling interrupts for an embedded system or by using a semaphore or * mutex. The implementation should allow calling SYS_ARCH_PROTECT when * already protected. The old protection level is returned in the variable * "lev". This macro will default to calling the sys_arch_protect() function * which should be implemented in sys_arch.c. If a particular port needs a * different implementation, then this macro may be defined in sys_arch.h */ #define SYS_ARCH_PROTECT(lev) lev = sys_arch_protect() /** SYS_ARCH_UNPROTECT * Perform a "fast" set of the protection level to "lev". This could be * implemented by setting the interrupt level to "lev" within the MACRO or by * using a semaphore or mutex. This macro will default to calling the * sys_arch_unprotect() function which should be implemented in * sys_arch.c. If a particular port needs a different implementation, then * this macro may be defined in sys_arch.h */ #define SYS_ARCH_UNPROTECT(lev) sys_arch_unprotect(lev) sys_prot_t sys_arch_protect(void); void sys_arch_unprotect(sys_prot_t pval); #else #define SYS_ARCH_DECL_PROTECT(lev) #define SYS_ARCH_PROTECT(lev) #define SYS_ARCH_UNPROTECT(lev) #endif /* SYS_LIGHTWEIGHT_PROT */ #endif /* SYS_ARCH_PROTECT */ #endif /* __LWIP_SYS_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/native_syscalls.h0000644000175000017500000000603511671615005022076 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Neelkanth Natu (neelnatu@yahoo.com) is the author of this file. * As long as you keep this blurb in the file, feel free to do whatever. */ #ifndef NATIVE_SYSCALLS_H #define NATIVE_SYSCALLS_H extern int native_socket(int domain, int type, int protocol); extern int native_connect(int sockfd, const void *servaddr, socklen_t addrlen); extern int native_bind(int sockfd, void *my_addr, socklen_t addrlen); extern int native_accept(int sockfd, void *my_addr, socklen_t *addrlen); extern int native_listen(int s, int backlog); extern int native_getsockname(int s, void *name, socklen_t *namelen); extern int native_getpeername(int s, void *name, socklen_t *namelen); extern int native_select(int nfds, fd_set *rdset, fd_set *wrset, fd_set *xpset, struct timeval *timeout); extern int native_read(int fd, void *buf, size_t count); extern ssize_t native_write(int fd, const void *buf, size_t count); extern int native_open(const char *pathname, int flags); extern int native_close(int fd); extern int native_ioctl(int fd, unsigned long int command, char *data); extern int native_setsockopt(int fd, int level, int optname, void *optval, socklen_t optlen); extern int native_getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen); extern ssize_t native_send(int s, const void *msg, size_t len, int flags); extern int native_sendto(int s, const void *msg, size_t len, int flags, void *to, socklen_t tolen); extern int native_sendmsg(int s, const void *msg, int flags); extern int native_recv(int s, void *buf, size_t len, int flags); extern int native_recvfrom(int s, void *buf, size_t len, int flags, void *from, socklen_t *fromlen); extern int native_recvmsg(int s, void *msg, int flags); extern int native_shutdown(int s, int how); extern int native_fcntl(int fd, int cmd, long arg); extern pid_t native_fork(void); extern int native_dup2(int old_fd, int new_fd); extern int native_dup(int old_fd); extern off_t native_lseek(int fd, off_t offset, int whence); extern ssize_t native_sendfile(int out_fd, int in_fd, off_t *offset, size_t n); #endif /* ifndef NATIVE_SYSCALLS_H */ lwipv6-1.5a/lwip-v6/src/include/lwip/netlink.h0000644000175000017500000000550411671615005020337 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _NETLINK_H__ #define _NETLINK_H__ #include "lwip/api.h" #include "lwip/sockets.h" #include "lwip/netlinkdefs.h" #include "lwip/if.h" struct netconn * netlink_open(struct stack *stack, int type,int proto); int netlink_accept(void *sock, struct sockaddr *addr, socklen_t *addrlen); int netlink_bind(void *sock, struct sockaddr *name, socklen_t namelen); int netlink_close(void *sock); int netlink_connect(void *sock, struct sockaddr *name, socklen_t namelen); int netlink_recvfrom(void *sock, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen); int netlink_send(void *sock, void *data, int size, unsigned int flags); int netlink_sendto(void *sock, void *data, int size, unsigned int flags, struct sockaddr *to, socklen_t tolen); int netlink_getsockname (void *sock, struct sockaddr *name, socklen_t *namelen); int netlink_getsockopt (void *sock, int level, int optname, void *optval, socklen_t *optlen); int netlink_setsockopt (void *sock, int level, int optname, const void *optval, socklen_t optlen); /* CONSTANT DEFINITION */ #if LWIP_NL void netlink_addanswer(void *buf,int *offset,void *in,int len); int mask2prefix (struct ip_addr *netmask); void prefix2mask(int prefix,struct ip_addr *netmask); void netlink_ackerror(void *msg,int ackerr,void *buf,int *offset); void netif_netlink_adddellink(struct stack *stack, struct nlmsghdr *msg, void * buf,int *offset); void netif_netlink_getlink(struct stack *stack, struct nlmsghdr *msg, void * buf,int *offset); void netif_netlink_adddeladdr(struct stack *stack, struct nlmsghdr *msg, void * buf, int *offset); void netif_netlink_getaddr(struct stack *stack, struct nlmsghdr *msg, void * buf, int *offset); void ip_route_netlink_adddelroute(struct stack *stack, struct nlmsghdr *msg, void * buf, int *offset); void ip_route_netlink_getroute(struct stack *stack, struct nlmsghdr *msg, void * buf, int *offset); #endif #endif lwipv6-1.5a/lwip-v6/src/include/lwip/sockets.h0000644000175000017500000004562111671615005020352 0ustar renzorenzo/* This is part of LWIPv6 * Developed for the Ale4NET project * Application Level Environment for Networking * * Copyright 2004 Renzo Davoli University of Bologna - Italy * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_SOCKETS_H__ #define __LWIP_SOCKETS_H__ #include #include #include #include #include "lwip/ip_addr.h" #if 0 struct stack; struct in_addr { u32_t s_addr; }; #define INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */ struct in6_addr { unsigned char s6_addr[16];/* IPv6 address */ }; struct sockaddr_in { u16_t sin_family; u16_t sin_port; struct in_addr sin_addr; char sin_zero[8]; }; struct sockaddr_in6 { u16_t sin6_family; u16_t sin6_port; u_int32_t sin6_flowinfo; struct in6_addr sin6_addr; u_int32_t sin6_scope_id; }; struct sockaddr { u16_t sa_family; char sa_data[14]; }; #ifndef socklen_t # define socklen_t int #endif struct msghdr { void *msg_name; /* optional address */ socklen_t msg_namelen; /* size of address */ struct iovec *msg_iov; /* scatter/gather array */ size_t msg_iovlen; /* # elements in msg_iov */ void *msg_control; /* ancillary data, see below */ socklen_t msg_controllen; /* ancillary data buffer len */ int msg_flags; /* flags on received message */ }; #define SOCK_STREAM 1 #define SOCK_DGRAM 2 #define SOCK_RAW 3 /* * Option flags per-socket. */ #define SO_DEBUG 1 #define SO_REUSEADDR 2 #define SO_TYPE 3 #define SO_ERROR 4 #define SO_DONTROUTE 5 #define SO_BROADCAST 6 #define SO_SNDBUF 7 #define SO_RCVBUF 8 #define SO_KEEPALIVE 9 #define SO_OOBINLINE 10 #define SO_NO_CHECK 11 #define SO_PRIORITY 12 #define SO_LINGER 13 #define SO_BSDCOMPAT 14 #define SO_REUSEPORT 15 #define SO_RCVLOWAT 16 #define SO_SNDLOWAT 17 #define SO_RCVTIMEO 18 #define SO_SNDTIMEO 19 #define SO_PASSCRED 20 #define SO_PEERCRED 21 #define SO_SECURITY_AUTHENTICATION 22 #define SO_SECURITY_ENCRYPTION_TRANSPORT 23 #define SO_SECURITY_ENCRYPTION_NETWORK 24 #define SO_BINDTODEVICE 25 #define SO_ATTACH_FILTER 26 #define SO_DETACH_FILTER 27 #define SO_PEERNAME 28 #define SO_TIMESTAMP 29 #define SCM_TIMESTAMP SO_TIMESTAMP #define SO_ACCEPTCONN 30 #if 0 #define SO_DEBUG 0x0001 /* turn on debugging info recording */ #define SO_ACCEPTCONN 0x0002 /* socket has had listen() */ #define SO_REUSEADDR 0x0004 /* allow local address reuse */ #define SO_KEEPALIVE 0x0008 /* keep connections alive */ #define SO_DONTROUTE 0x0010 /* just use interface addresses */ #define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */ #define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */ #define SO_LINGER 0x0080 /* linger on close if data present */ #define SO_OOBINLINE 0x0100 /* leave received OOB data in line */ #define SO_REUSEPORT 0x0200 /* allow local address & port reuse */ #define SO_DONTLINGER (int)(~SO_LINGER) /* * Additional options, not kept in so_options. */ #define SO_SNDBUF 0x1001 /* send buffer size */ #define SO_RCVBUF 0x1002 /* receive buffer size */ #define SO_SNDLOWAT 0x1003 /* send low-water mark */ #define SO_RCVLOWAT 0x1004 /* receive low-water mark */ #define SO_SNDTIMEO 0x1005 /* send timeout */ #define SO_RCVTIMEO 0x1006 /* receive timeout */ #define SO_ERROR 0x1007 /* get error status and clear */ #define SO_TYPE 0x1008 /* get socket type */ #endif /* * Structure used for manipulating linger option. */ struct linger { int l_onoff; /* option on/off */ int l_linger; /* linger time */ }; /* * Level number for (get/set)sockopt() to apply to socket itself. */ #define SOL_SOCKET 0x1 /* options for socket level */ #if LWIP_PACKET #define SOL_PACKET 263 #endif #define AF_UNSPEC 0 #define AF_INET 2 #define PF_INET AF_INET #define AF_INET6 10 #define PF_INET6 AF_INET6 #define AF_NETLINK 16 #define PF_NETLINK AF_NETLINK #define AF_PACKET 17 #define PF_PACKET AF_PACKET #define PF_UNSPEC AF_UNSPEC #define IPPROTO_IP 0 #define IPPROTO_TCP 6 #define IPPROTO_UDP 17 #define IPPROTO_IPV6 41 #define IPPROTO_ICMPV6 58 #define IPPROTO_RAW 255 #define INADDR_ANY 0 #define INADDR_BROADCAST 0xffffffff /* Flags we can use with send and recv. */ #define MSG_DONTWAIT 0x40 /* Nonblocking i/o for this operation only */ /* * Options for level IPPROTO_IP */ #define IP_TOS 1 #define IP_TTL 2 #define IP_HDRINCL 3 #define IP_MTU_DISCOVER 10 /* int */ #define IP_RECVERR 11 /* bool */ #define IP_RECVTTL 12 /* bool */ #define IP_RECVTOS 13 /* bool */ /* * Options for level IPPROTO_RAW */ #define IPV6_CHECKSUM 7 /* * Options for level IPPROTO_ICMPV6 */ #define ICMPV6_FILTER 1 /* * Options for level IPPROTO_IPV6 */ #define IPV6_HOPLIMIT 8 #define IPV6_UNICAST_HOPS 16 #define IPV6_MULTICAST_HOPS 18 #define IPTOS_TOS_MASK 0x1E #define IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK) #define IPTOS_LOWDELAY 0x10 #define IPTOS_THROUGHPUT 0x08 #define IPTOS_RELIABILITY 0x04 #define IPTOS_LOWCOST 0x02 #define IPTOS_MINCOST IPTOS_LOWCOST /* * Definitions for IP precedence (also in ip_tos) (hopefully unused) */ #define IPTOS_PREC_MASK 0xe0 #define IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK) #define IPTOS_PREC_NETCONTROL 0xe0 #define IPTOS_PREC_INTERNETCONTROL 0xc0 #define IPTOS_PREC_CRITIC_ECP 0xa0 #define IPTOS_PREC_FLASHOVERRIDE 0x80 #define IPTOS_PREC_FLASH 0x60 #define IPTOS_PREC_IMMEDIATE 0x40 #define IPTOS_PREC_PRIORITY 0x20 #define IPTOS_PREC_ROUTINE 0x00 /* FIX: not needed? */ ///#include /* * Commands for ioctlsocket(), taken from the BSD file fcntl.h. * * * Ioctl's have the command encoded in the lower word, * and the size of any in or out parameters in the upper * word. The high 2 bits of the upper word are used * to encode the in/out status of the parameter; for now * we restrict parameters to at most 128 bytes. */ #if !defined(FIONREAD) || !defined(FIONBIO) #define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */ #define IOC_VOID 0x20000000 /* no parameters */ #define IOC_OUT 0x40000000 /* copy out parameters */ #define IOC_IN 0x80000000 /* copy in parameters */ #define IOC_INOUT (IOC_IN|IOC_OUT) /* 0x20000000 distinguishes new & old ioctl's */ #define _IO(x,y) (IOC_VOID|((x)<<8)|(y)) #define _IOR(x,y,t) (IOC_OUT|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) #define _IOW(x,y,t) (IOC_IN|(((long)sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|(y)) #endif #ifndef FIONREAD #define FIONREAD _IOR('f', 127, unsigned long) /* get # bytes to read */ #endif #ifndef FIONBIO #define FIONBIO _IOW('f', 126, unsigned long) /* set/clear non-blocking i/o */ #endif /* Socket I/O Controls */ #ifndef SIOCSHIWAT #define SIOCSHIWAT _IOW('s', 0, unsigned long) /* set high watermark */ #define SIOCGHIWAT _IOR('s', 1, unsigned long) /* get high watermark */ #define SIOCSLOWAT _IOW('s', 2, unsigned long) /* set low watermark */ #define SIOCGLOWAT _IOR('s', 3, unsigned long) /* get low watermark */ #define SIOCATMARK _IOR('s', 7, unsigned long) /* at oob mark? */ #endif #ifndef O_NONBLOCK #define O_NONBLOCK 04000U #endif #ifndef FD_SET #undef FD_SETSIZE #define FD_SETSIZE 16 #define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7))) #define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7))) #define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7))) #define FD_ZERO(p) memset((void*)(p),0,sizeof(*(p))) typedef struct fd_set { unsigned char fd_bits [(FD_SETSIZE+7)/8]; } fd_set; /* * only define this in sockets.c so it does not interfere * with other projects namespaces where timeval is present */ #ifndef LWIP_TIMEVAL_PRIVATE #define LWIP_TIMEVAL_PRIVATE 1 #endif #if LWIP_TIMEVAL_PRIVATE struct timeval { long tv_sec; /* seconds */ long tv_usec; /* and microseconds */ }; #endif #endif /* other calls */ #define SIOCGSTAMP 0x8906 /* Get stamp */ /* Routing table calls. */ #define SIOCADDRT 0x890B /* add routing table entry */ #define SIOCDELRT 0x890C /* delete routing table entry */ #define SIOCRTMSG 0x890D /* call to routing system */ /* Socket configuration controls. */ #define SIOCGIFNAME 0x8910 /* get iface name */ #define SIOCSIFLINK 0x8911 /* set iface channel */ #define SIOCGIFCONF 0x8912 /* get iface list */ #define SIOCGIFFLAGS 0x8913 /* get flags */ #define SIOCSIFFLAGS 0x8914 /* set flags */ #define SIOCGIFADDR 0x8915 /* get PA address */ #define SIOCSIFADDR 0x8916 /* set PA address */ #define SIOCGIFDSTADDR 0x8917 /* get remote PA address */ #define SIOCSIFDSTADDR 0x8918 /* set remote PA address */ #define SIOCGIFBRDADDR 0x8919 /* get broadcast PA address */ #define SIOCSIFBRDADDR 0x891a /* set broadcast PA address */ #define SIOCGIFNETMASK 0x891b /* get network PA mask */ #define SIOCSIFNETMASK 0x891c /* set network PA mask */ #define SIOCGIFMETRIC 0x891d /* get metric */ #define SIOCSIFMETRIC 0x891e /* set metric */ #define SIOCGIFMEM 0x891f /* get memory address (BSD) */ #define SIOCSIFMEM 0x8920 /* set memory address (BSD) */ #define SIOCGIFMTU 0x8921 /* get MTU size */ #define SIOCSIFMTU 0x8922 /* set MTU size */ #define SIOCSIFNAME 0x8923 /* set interface name */ #define SIOCSIFHWADDR 0x8924 /* set hardware address */ #define SIOCGIFENCAP 0x8925 /* get/set encapsulations */ #define SIOCSIFENCAP 0x8926 #define SIOCGIFHWADDR 0x8927 /* Get hardware address */ #define SIOCGIFSLAVE 0x8929 /* Driver slaving support */ #define SIOCSIFSLAVE 0x8930 #define SIOCADDMULTI 0x8931 /* Multicast address lists */ #define SIOCDELMULTI 0x8932 #define SIOCGIFINDEX 0x8933 /* name -> if_index mapping */ #define SIOGIFINDEX SIOCGIFINDEX /* misprint compatibility :-) */ #define SIOCSIFPFLAGS 0x8934 /* set/get extended flags set */ #define SIOCGIFPFLAGS 0x8935 #define SIOCDIFADDR 0x8936 /* delete PA address */ #define SIOCSIFHWBROADCAST 0x8937 /* set hardware broadcast addr */ #define SIOCGIFCOUNT 0x8938 /* get number of devices */ #define SIOCGIFBR 0x8940 /* Bridging support */ #define SIOCSIFBR 0x8941 /* Set bridging options */ #define SIOCGIFTXQLEN 0x8942 /* Get the tx queue length */ #define SIOCSIFTXQLEN 0x8943 /* Set the tx queue length */ /* ARP cache control calls. */ /* 0x8950 - 0x8952 * obsolete calls, don't re-use */ #define SIOCDARP 0x8953 /* delete ARP table entry */ #define SIOCGARP 0x8954 /* get ARP table entry */ #define SIOCSARP 0x8955 /* set ARP table entry */ /* RARP cache control calls. */ #define SIOCDRARP 0x8960 /* delete RARP table entry */ #define SIOCGRARP 0x8961 /* get RARP table entry */ #define SIOCSRARP 0x8962 /* set RARP table entry */ /* Driver configuration calls */ #define SIOCGIFMAP 0x8970 /* Get device parameters */ #define SIOCSIFMAP 0x8971 /* Set device parameters */ /* DLCI configuration calls */ #define SIOCADDDLCI 0x8980 /* Create new DLCI device */ #define SIOCDELDLCI 0x8981 /* Delete DLCI device */ /* Device private ioctl calls. */ /* These 16 ioctls are available to devices via the do_ioctl() device * vector. Each device should include this file and redefine these * names as their own. Because these are device dependent it is a good * idea _NOT_ to issue them to random objects and hope. */ #define SIOCDEVPRIVATE 0x89F0 /* to 89FF */ /* * These 16 ioctl calls are protocol private * */ #define SIOCPROTOPRIVATE 0x89E0 /* to 89EF */ #endif #ifndef SO_REUSEPORT #define SO_REUSEPORT 15 #endif #ifndef ICMPV6_FILTER #define ICMPV6_FILTER 1 #endif int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen); int lwip_bind(int s, struct sockaddr *name, socklen_t namelen); int lwip_shutdown(int s, int how); int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen); int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen); int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen); int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen); int lwip_close(int s); int lwip_connect(int s, struct sockaddr *name, socklen_t namelen); int lwip_listen(int s, int backlog); ssize_t lwip_recv(int s, void *mem, int len, unsigned int flags); ssize_t lwip_read(int s, void *mem, int len); ssize_t lwip_recvfrom(int s, void *mem, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen); ssize_t lwip_recvmsg(int fd, struct msghdr *msg, int flags); ssize_t lwip_send(int s, void *dataptr, int size, unsigned int flags); ssize_t lwip_sendto(int s, void *dataptr, int size, unsigned int flags, struct sockaddr *to, socklen_t tolen); ssize_t lwip_sendmsg(int fd, struct msghdr *msg, int flags); int lwip_msocket(struct stack *stack, int domain, int type, int protocol); int lwip_socket(int domain, int type, int protocol); ssize_t lwip_write(int s, void *dataptr, int size); int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset, struct timeval *timeout); int lwip_ioctl(int s, unsigned long cmd, void *argp); int lwip_fcntl64(int s, int cmd, long arg); int lwip_fcntl(int s, int cmd, long arg); /* * Taken from sys/uio.h and bits/uio.h */ /* Size of object which can be written atomically. This macro has different values in different kernel versions. The latest versions of ther kernel use 1024 and this is good choice. Since the C library implementation of readv/writev is able to emulate the functionality even if the currently running kernel does not support this large value the readv/writev call will not fail because of this. */ #define UIO_MAXIOV 1024 #define size_t u32_t #if 0 /* Structure for scatter/gather I/O. */ struct iovec { void *iov_base; /* Pointer to data. */ int iov_len; /* Length of data. */ /* FIX: iov_len, and many other parameters should be size_t or socklen_t */ }; #endif ssize_t lwip_readv(int s, struct iovec *vector, int count); ssize_t lwip_writev(int s, struct iovec *vectorc, int count); #if LWIP_COMPAT_SOCKETS #define accept(a,b,c) lwip_accept(a,b,c) #define bind(a,b,c) lwip_bind(a,b,c) #define shutdown(a,b) lwip_shutdown(a,b) #define close(s) lwip_close(s) #define connect(a,b,c) lwip_connect(a,b,c) #define getsockname(a,b,c) lwip_getsockname(a,b,c) #define getpeername(a,b,c) lwip_getpeername(a,b,c) #define setsockopt(a,b,c,d,e) lwip_setsockopt(a,b,c,d,e) #define getsockopt(a,b,c,d,e) lwip_getsockopt(a,b,c,d,e) #define listen(a,b) lwip_listen(a,b) #define recv(a,b,c,d) lwip_recv(a,b,c,d) #define read(a,b,c) lwip_read(a,b,c) #define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f) #define send(a,b,c,d) lwip_send(a,b,c,d) #define sendto(a,b,c,d,e,f) lwip_sendto(a,b,c,d,e,f) #define socket(a,b,c) lwip_socket(a,b,c) #define write(a,b,c) lwip_write(a,b,c) #define select(a,b,c,d,e) lwip_select(a,b,c,d,e) #define ioctlsocket(a,b,c) lwip_ioctl(a,b,c) #define writev(a,b,c) lwip_writev(a,b,c) #define readv(a,b,c) lwip_readv(a,b,c) #endif /* LWIP_COMPAT_SOCKETS */ #endif /* __LWIP_SOCKETS_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/if.h0000644000175000017500000001542511671615005017274 0ustar renzorenzo/* net/if.h -- declarations for inquiring about network interfaces Copyright (C) 1997,98,99,2000,2001 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ /* modifies for ale4net */ #ifndef _NET_IF_H #define _NET_IF_H 1 #include #include /* Length of interface name. */ #define IF_NAMESIZE 16 struct if_nameindex { unsigned int if_index; /* 1, 2, ... */ char *if_name; /* null terminated name: "eth0", ... */ }; #ifdef __USE_MISC /* Standard interface flags. */ enum { IFF_UP = 0x1, /* Interface is up. */ # define IFF_UP IFF_UP IFF_BROADCAST = 0x2, /* Broadcast address valid. */ # define IFF_BROADCAST IFF_BROADCAST IFF_DEBUG = 0x4, /* Turn on debugging. */ # define IFF_DEBUG IFF_DEBUG IFF_LOOPBACK = 0x8, /* Is a loopback net. */ # define IFF_LOOPBACK IFF_LOOPBACK IFF_POINTOPOINT = 0x10, /* Interface is point-to-point link. */ # define IFF_POINTOPOINT IFF_POINTOPOINT IFF_NOTRAILERS = 0x20, /* Avoid use of trailers. */ # define IFF_NOTRAILERS IFF_NOTRAILERS IFF_RUNNING = 0x40, /* Resources allocated. */ # define IFF_RUNNING IFF_RUNNING IFF_NOARP = 0x80, /* No address resolution protocol. */ # define IFF_NOARP IFF_NOARP IFF_PROMISC = 0x100, /* Receive all packets. */ # define IFF_PROMISC IFF_PROMISC /* Not supported */ IFF_ALLMULTI = 0x200, /* Receive all multicast packets. */ # define IFF_ALLMULTI IFF_ALLMULTI IFF_MASTER = 0x400, /* Master of a load balancer. */ # define IFF_MASTER IFF_MASTER IFF_SLAVE = 0x800, /* Slave of a load balancer. */ # define IFF_SLAVE IFF_SLAVE IFF_MULTICAST = 0x1000, /* Supports multicast. */ # define IFF_MULTICAST IFF_MULTICAST IFF_PORTSEL = 0x2000, /* Can set media type. */ # define IFF_PORTSEL IFF_PORTSEL IFF_AUTOMEDIA = 0x4000 /* Auto media select active. */ # define IFF_AUTOMEDIA IFF_AUTOMEDIA }; /* The ifaddr structure contains information about one address of an interface. They are maintained by the different address families, are allocated and attached when an address is set, and are linked together so all addresses for an interface can be located. */ struct ifaddr { struct sockaddr ifa_addr; /* Address of interface. */ union { struct sockaddr ifu_broadaddr; struct sockaddr ifu_dstaddr; } ifa_ifu; struct iface *ifa_ifp; /* Back-pointer to interface. */ struct ifaddr *ifa_next; /* Next address for interface. */ }; # define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */ # define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of link */ /* Device mapping structure. I'd just gone off and designed a beautiful scheme using only loadable modules with arguments for driver options and along come the PCMCIA people 8) Ah well. The get() side of this is good for WDSETUP, and it'll be handy for debugging things. The set side is fine for now and being very small might be worth keeping for clean configuration. */ struct ifmap { unsigned long int mem_start; unsigned long int mem_end; unsigned short int base_addr; unsigned char irq; unsigned char dma; unsigned char port; /* 3 bytes spare */ }; /* Interface request structure used for socket ioctl's. All interface ioctl's must have parameter definitions which begin with ifr_name. The remainder may be interface specific. */ struct ifreq { # define IFHWADDRLEN 6 # define IFNAMSIZ IF_NAMESIZE union { char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */ } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short int ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[IFNAMSIZ]; /* Just fits the size */ char ifru_newname[IFNAMSIZ]; __caddr_t ifru_data; } ifr_ifru; }; # define ifr_name ifr_ifrn.ifrn_name /* interface name */ # define ifr_hwaddr ifr_ifru.ifru_hwaddr /* MAC address */ # define ifr_addr ifr_ifru.ifru_addr /* address */ # define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-p lnk */ # define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */ # define ifr_netmask ifr_ifru.ifru_netmask /* interface net mask */ # define ifr_flags ifr_ifru.ifru_flags /* flags */ # define ifr_metric ifr_ifru.ifru_ivalue /* metric */ # define ifr_mtu ifr_ifru.ifru_mtu /* mtu */ # define ifr_map ifr_ifru.ifru_map /* device map */ # define ifr_slave ifr_ifru.ifru_slave /* slave device */ # define ifr_data ifr_ifru.ifru_data /* for use by interface */ # define ifr_ifindex ifr_ifru.ifru_ivalue /* interface index */ # define ifr_bandwidth ifr_ifru.ifru_ivalue /* link bandwidth */ # define ifr_qlen ifr_ifru.ifru_ivalue /* queue length */ # define ifr_newname ifr_ifru.ifru_newname /* New name */ # define _IOT_ifreq _IOT(_IOTS(char),IFNAMSIZ,_IOTS(char),16,0,0) # define _IOT_ifreq_short _IOT(_IOTS(char),IFNAMSIZ,_IOTS(short),1,0,0) # define _IOT_ifreq_int _IOT(_IOTS(char),IFNAMSIZ,_IOTS(int),1,0,0) /* Structure used in SIOCGIFCONF request. Used to retrieve interface configuration for machine (useful for programs which must know all networks accessible). */ struct ifconf { int ifc_len; /* Size of buffer. */ union { __caddr_t ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu; }; # define ifc_buf ifc_ifcu.ifcu_buf /* Buffer address. */ # define ifc_req ifc_ifcu.ifcu_req /* Array of structures. */ # define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0) /* not right */ #endif /* Misc. */ __BEGIN_DECLS /* Convert an interface name to an index, and vice versa. */ extern unsigned int if_nametoindex (__const char *__ifname) __THROW; extern char *if_indextoname (unsigned int __ifindex, char *__ifname) __THROW; /* Return a list of all interfaces and their indices. */ extern struct if_nameindex *if_nameindex (void) __THROW; /* Free the data returned from if_nameindex. */ extern void if_freenameindex (struct if_nameindex *__ptr) __THROW; __END_DECLS #endif /* net/if.h */ lwipv6-1.5a/lwip-v6/src/include/lwip/stats.h0000644000175000017500000000750311671615005020032 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_STATS_H__ #define __LWIP_STATS_H__ /* FIX: add MULTISTACK support. Race condition on counters!! */ #include "lwip/opt.h" #include "arch/cc.h" #include "lwip/mem.h" #include "lwip/memp.h" #if LWIP_STATS struct stats_proto { u16_t xmit; /* Transmitted packets. */ u16_t rexmit; /* Retransmitted packets. */ u16_t recv; /* Received packets. */ u16_t fw; /* Forwarded packets. */ u16_t drop; /* Dropped packets. */ u16_t chkerr; /* Checksum error. */ u16_t lenerr; /* Invalid length error. */ u16_t memerr; /* Out of memory error. */ u16_t rterr; /* Routing error. */ u16_t proterr; /* Protocol error. */ u16_t opterr; /* Error in options. */ u16_t err; /* Misc error. */ u16_t cachehit; }; struct stats_mem { mem_size_t avail; mem_size_t used; mem_size_t max; mem_size_t err; }; struct stats_pbuf { u16_t avail; u16_t used; u16_t max; u16_t err; u16_t alloc_locked; u16_t refresh_locked; }; struct stats_syselem { u16_t used; u16_t max; u16_t err; }; struct stats_sys { struct stats_syselem sem; struct stats_syselem mbox; }; struct stats_ { struct stats_proto link; struct stats_proto ip_frag; struct stats_proto ip; struct stats_proto icmp; struct stats_proto udp; struct stats_proto tcp; struct stats_pbuf pbuf; struct stats_mem mem; struct stats_mem memp[MEMP_MAX]; struct stats_sys sys; }; extern struct stats_ lwip_stats; void stats_init(void); #define STATS_INC(x) ++lwip_stats.x #else #define stats_init() #define STATS_INC(x) #endif /* LWIP_STATS */ #if TCP_STATS #define TCP_STATS_INC(x) STATS_INC(x) #else #define TCP_STATS_INC(x) #endif #if UDP_STATS #define UDP_STATS_INC(x) STATS_INC(x) #else #define UDP_STATS_INC(x) #endif #if ICMP_STATS #define ICMP_STATS_INC(x) STATS_INC(x) #else #define ICMP_STATS_INC(x) #endif #if IP_STATS #define IP_STATS_INC(x) STATS_INC(x) #else #define IP_STATS_INC(x) #endif #if IPFRAG_STATS #define IPFRAG_STATS_INC(x) STATS_INC(x) #else #define IPFRAG_STATS_INC(x) #endif #if LINK_STATS #define LINK_STATS_INC(x) STATS_INC(x) #else #define LINK_STATS_INC(x) #endif /* Display of statistics */ #if LWIP_STATS_DISPLAY void stats_display(void); #else #define stats_display() #endif #endif /* __LWIP_STATS_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/tcp.h0000644000175000017500000005324411671615005017465 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_TCP_H__ #define __LWIP_TCP_H__ #include "lwip/sys.h" #include "lwip/mem.h" #include "lwip/pbuf.h" #include "lwip/opt.h" #include "lwip/ip.h" #include "lwip/icmp.h" #include "lwip/err.h" struct tcp_pcb; /* Functions for interfacing with TCP: */ /* Lower layer interface to TCP: */ void tcp_init (struct stack *stack); /* Must be called first to initialize TCP. */ void tcp_tmr (struct stack *stack); /* Must be called every TCP_TMR_INTERVAL ms. (Typically 250 ms). */ /* Application program's interface: */ struct tcp_pcb * tcp_new (struct stack *stack); struct tcp_pcb * tcp_alloc (struct stack *stack, u8_t prio); void tcp_arg (struct tcp_pcb *pcb, void *arg); void tcp_accept (struct tcp_pcb *pcb, err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err)); void tcp_recv (struct tcp_pcb *pcb, err_t (* recv)(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err)); void tcp_sent (struct tcp_pcb *pcb, err_t (* sent)(void *arg, struct tcp_pcb *tpcb, u16_t len)); void tcp_poll (struct tcp_pcb *pcb, err_t (* poll)(void *arg, struct tcp_pcb *tpcb), u8_t interval); void tcp_err (struct tcp_pcb *pcb, void (* err)(void *arg, err_t err)); #define tcp_mss(pcb) ((pcb)->mss) #define tcp_sndbuf(pcb) ((pcb)->snd_buf) void tcp_recved (struct tcp_pcb *pcb, u16_t len); err_t tcp_bind (struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port); err_t tcp_connect (struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port, err_t (* connected)(void *arg, struct tcp_pcb *tpcb, err_t err)); struct tcp_pcb * tcp_listen (struct tcp_pcb *pcb); void tcp_abort (struct tcp_pcb *pcb); err_t tcp_close (struct tcp_pcb *pcb); err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len, u8_t copy); void tcp_setprio (struct tcp_pcb *pcb, u8_t prio); #define TCP_PRIO_MIN 1 #define TCP_PRIO_NORMAL 64 #define TCP_PRIO_MAX 127 /* It is also possible to call these two functions at the right intervals (instead of calling tcp_tmr()). */ void tcp_slowtmr (struct stack *stack); void tcp_fasttmr (struct stack *stack); /* Only used by IP to pass a TCP segment to TCP: */ void tcp_input (struct pbuf *p, struct ip_addr_list *inad,struct pseudo_iphdr *piphdr #ifdef LWSLIRP , struct netif *slirpif #endif ); /* Used within the TCP code only: */ err_t tcp_output (struct tcp_pcb *pcb); void tcp_rexmit (struct tcp_pcb *pcb); void tcp_rexmit_rto (struct tcp_pcb *pcb); #define TCP_SEQ_LT(a,b) ((s32_t)((a)-(b)) < 0) #define TCP_SEQ_LEQ(a,b) ((s32_t)((a)-(b)) <= 0) #define TCP_SEQ_GT(a,b) ((s32_t)((a)-(b)) > 0) #define TCP_SEQ_GEQ(a,b) ((s32_t)((a)-(b)) >= 0) /* is b<=a<=c? */ #if 0 /* see bug #10548 */ #define TCP_SEQ_BETWEEN(a,b,c) ((c)-(b) >= (a)-(b)) #endif #define TCP_SEQ_BETWEEN(a,b,c) (TCP_SEQ_GEQ(a,b) && TCP_SEQ_LEQ(a,c)) #define TCP_FIN 0x01U #define TCP_SYN 0x02U #define TCP_RST 0x04U #define TCP_PSH 0x08U #define TCP_ACK 0x10U #define TCP_URG 0x20U #define TCP_ECE 0x40U #define TCP_CWR 0x80U #define TCP_FLAGS 0x3fU /* Length of the TCP header, excluding options. */ #define TCP_HLEN 20 #ifndef TCP_TMR_INTERVAL #define TCP_TMR_INTERVAL 250 /* The TCP timer interval in milliseconds. */ #endif /* TCP_TMR_INTERVAL */ #ifndef TCP_FAST_INTERVAL #define TCP_FAST_INTERVAL TCP_TMR_INTERVAL /* the fine grained timeout in milliseconds */ #endif /* TCP_FAST_INTERVAL */ #ifndef TCP_SLOW_INTERVAL #define TCP_SLOW_INTERVAL (2*TCP_TMR_INTERVAL) /* the coarse grained timeout in milliseconds */ #endif /* TCP_SLOW_INTERVAL */ #define TCP_FIN_WAIT_TIMEOUT 20000 /* milliseconds */ #define TCP_SYN_RCVD_TIMEOUT 20000 /* milliseconds */ #define TCP_OOSEQ_TIMEOUT 6 /* x RTO */ #define TCP_MSL 60000 /* The maximum segment lifetime in microseconds */ /* * User-settable options (used with setsockopt). */ #define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */ #define TCP_KEEPALIVE 0x02 /* send KEEPALIVE probes when idle for pcb->keepalive miliseconds */ /* Keepalive values */ #define TCP_KEEPDEFAULT 7200000 /* KEEPALIVE timer in miliseconds */ #define TCP_KEEPINTVL 75000 /* Time between KEEPALIVE probes in miliseconds */ #define TCP_KEEPCNT 9 /* Counter for KEEPALIVE probes */ #define TCP_MAXIDLE TCP_KEEPCNT * TCP_KEEPINTVL /* Maximum KEEPALIVE probe time */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN struct tcp_hdr { PACK_STRUCT_FIELD(u16_t src); PACK_STRUCT_FIELD(u16_t dest); PACK_STRUCT_FIELD(u32_t seqno); PACK_STRUCT_FIELD(u32_t ackno); PACK_STRUCT_FIELD(u16_t _hdrlen_rsvd_flags); PACK_STRUCT_FIELD(u16_t wnd); PACK_STRUCT_FIELD(u16_t chksum); PACK_STRUCT_FIELD(u16_t urgp); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #define TCPH_OFFSET(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 8) #define TCPH_HDRLEN(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) >> 12) #define TCPH_FLAGS(phdr) (ntohs((phdr)->_hdrlen_rsvd_flags) & TCP_FLAGS) #define TCPH_OFFSET_SET(phdr, offset) (phdr)->_hdrlen_rsvd_flags = htons(((offset) << 8) | TCPH_FLAGS(phdr)) #define TCPH_HDRLEN_SET(phdr, len) (phdr)->_hdrlen_rsvd_flags = htons(((len) << 12) | TCPH_FLAGS(phdr)) #define TCPH_FLAGS_SET(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons((ntohs((phdr)->_hdrlen_rsvd_flags) & ~TCP_FLAGS) | (flags)) #define TCPH_SET_FLAG(phdr, flags ) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (flags)) #define TCPH_UNSET_FLAG(phdr, flags) (phdr)->_hdrlen_rsvd_flags = htons(ntohs((phdr)->_hdrlen_rsvd_flags) | (TCPH_FLAGS(phdr) & ~(flags)) ) #define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & TCP_FIN || \ TCPH_FLAGS((seg)->tcphdr) & TCP_SYN)? 1: 0)) #ifdef LWSLIRP /* * Socket state bits. (peer means the host on the Internet, * local host means the host on the virtual net) */ #define SS_NOFDREF 0x001 /* No fd reference */ #define SS_ISFCONNECTING 0x002 /* Socket is connecting to peer (non-blocking connect()'s) */ #define SS_ISFCONNECTED 0x004 /* Socket is connected to peer */ #define SS_FCANTRCVMORE 0x008 /* Socket can't receive more from peer (for half-closes) */ #define SS_FCANTSENDMORE 0x010 /* Socket can't send more to peer (for half-closes) */ #define SS_FWDRAIN 0x040 /* We received a FIN, drain data and set SS_FCANTSENDMORE */ #define SS_CTL 0x080 #define SS_FACCEPTCONN 0x100 /* Socket is accepting connections from a host on the internet */ #define SS_FACCEPTONCE 0x200 /* If set, the SS_FACCEPTCONN socket will die after one accept */ /* Socket state bits: END */ #endif /* LWSLIRP */ enum tcp_state { CLOSED = 0, LISTEN = 1, SYN_SENT = 2, SYN_RCVD = 3, ESTABLISHED = 4, FIN_WAIT_1 = 5, FIN_WAIT_2 = 6, CLOSE_WAIT = 7, CLOSING = 8, LAST_ACK = 9, TIME_WAIT = 10 }; /* the TCP protocol control block */ struct tcp_pcb { /** common PCB members */ IP_PCB; /** protocol specific PCB members */ struct tcp_pcb *next; /* for the linked list */ enum tcp_state state; /* TCP state */ #ifdef LWSLIRP u32_t slirp_state; /* internal state flags SS_* */ #endif u8_t prio; void *callback_arg; u16_t local_port; u16_t remote_port; u8_t flags; #define TF_ACK_DELAY (u8_t)0x01U /* Delayed ACK. */ #define TF_ACK_NOW (u8_t)0x02U /* Immediate ACK. */ #define TF_INFR (u8_t)0x04U /* In fast recovery. */ #define TF_RESET (u8_t)0x08U /* Connection was reset. */ #define TF_CLOSED (u8_t)0x10U /* Connection was sucessfully closed. */ #define TF_GOT_FIN (u8_t)0x20U /* Connection was closed by the remote end. */ #define TF_NODELAY (u8_t)0x40U /* Disable Nagle algorithm */ /* receiver variables */ u32_t rcv_nxt; /* next seqno expected */ u16_t rcv_wnd; /* receiver window */ /* Timers */ u32_t tmr; u8_t polltmr, pollinterval; /* Retransmission timer. */ u16_t rtime; u16_t mss; /* maximum segment size */ /* RTT (round trip time) estimation variables */ u32_t rttest; /* RTT estimate in 500ms ticks */ u32_t rtseq; /* sequence number being timed */ s16_t sa, sv; /* @todo document this */ u16_t rto; /* retransmission time-out */ u8_t nrtx; /* number of retransmissions */ /* fast retransmit/recovery */ u32_t lastack; /* Highest acknowledged seqno. */ u8_t dupacks; /* congestion avoidance/control variables */ u16_t cwnd; u16_t ssthresh; /* sender variables */ u32_t snd_nxt, /* next seqno to be sent */ snd_max, /* Highest seqno sent. */ snd_wnd, /* sender window */ snd_wl1, snd_wl2, /* Sequence and acknowledgement numbers of last window update. */ snd_lbb; /* Sequence number of next byte to be buffered. */ u16_t acked; u16_t snd_buf; /* Available buffer space for sending (in bytes). */ u8_t snd_queuelen; /* Available buffer space for sending (in tcp_segs). */ /* These are ordered by sequence number: */ struct tcp_seg *unsent; /* Unsent (queued) segments. */ struct tcp_seg *unacked; /* Sent but unacknowledged segments. */ #if TCP_QUEUE_OOSEQ struct tcp_seg *ooseq; /* Received out of sequence segments. */ #endif /* TCP_QUEUE_OOSEQ */ #if LWIP_CALLBACK_API /* Function to be called when more send buffer space is available. */ err_t (* sent)(void *arg, struct tcp_pcb *pcb, u16_t space); /* Function to be called when (in-sequence) data has arrived. */ err_t (* recv)(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); /* Function to be called when a connection has been set up. */ err_t (* connected)(void *arg, struct tcp_pcb *pcb, err_t err); /* Function to call when a listener has been connected. */ err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err); /* Function which is called periodically. */ err_t (* poll)(void *arg, struct tcp_pcb *pcb); /* Function to be called whenever a fatal error occurs. */ void (* errf)(void *arg, err_t err); #endif /* LWIP_CALLBACK_API */ /* idle time before KEEPALIVE is sent */ u32_t keepalive; /* KEEPALIVE counter */ u8_t keep_cnt; #ifdef LWSLIRP /* Buffer of packet received by LWIP stack and waiting to be sent on the socket ->slirp */ struct pbuf *slirp_recvbuf; #endif }; struct tcp_pcb_listen { /* Common members of all PCB types */ IP_PCB; /* Protocol specific PCB members */ struct tcp_pcb_listen *next; /* for the linked list */ /* Even if state is obviously LISTEN this is here for * field compatibility with tpc_pcb to which it is cast sometimes * Until a cleaner solution emerges this is here.FIXME */ enum tcp_state state; /* TCP state */ #ifdef LWSLIRP u32_t slirp_state; /* internal state flags SS_* */ #endif u8_t prio; void *callback_arg; u16_t local_port; u16_t remote_port; #if LWIP_CALLBACK_API /* Function to call when a listener has been connected. */ err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err); #endif /* LWIP_CALLBACK_API */ #if 1 #ifdef LWSLIRP struct pbuf *slirp_m; /* Pointer to the original SYN packet, * for non-blocking connect() */ #endif #endif }; #if LWIP_EVENT_API enum lwip_event { LWIP_EVENT_ACCEPT, LWIP_EVENT_SENT, LWIP_EVENT_RECV, LWIP_EVENT_CONNECTED, LWIP_EVENT_POLL, LWIP_EVENT_ERR }; err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, enum lwip_event, struct pbuf *p, u16_t size, err_t err); #define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ LWIP_EVENT_ACCEPT, NULL, 0, err) #define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ LWIP_EVENT_SENT, NULL, space, ERR_OK) #define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ LWIP_EVENT_RECV, (p), 0, (err)) #define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ LWIP_EVENT_CONNECTED, NULL, 0, (err)) #define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\ LWIP_EVENT_POLL, NULL, 0, ERR_OK) #define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \ LWIP_EVENT_ERR, NULL, 0, (err)) #else /* LWIP_EVENT_API */ #define TCP_EVENT_ACCEPT(pcb,err,ret) \ if((pcb)->accept != NULL) \ (ret = (pcb)->accept((pcb)->callback_arg,(pcb),(err))) #define TCP_EVENT_SENT(pcb,space,ret) \ if((pcb)->sent != NULL) \ (ret = (pcb)->sent((pcb)->callback_arg,(pcb),(space))) #define TCP_EVENT_RECV(pcb,p,err,ret) \ if((pcb)->recv != NULL) \ { ret = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err)); } else { \ if (p) pbuf_free(p); } #define TCP_EVENT_CONNECTED(pcb,err,ret) \ if((pcb)->connected != NULL) \ (ret = (pcb)->connected((pcb)->callback_arg,(pcb),(err))) #define TCP_EVENT_POLL(pcb,ret) \ if((pcb)->poll != NULL) \ (ret = (pcb)->poll((pcb)->callback_arg,(pcb))) #define TCP_EVENT_ERR(errf,arg,errx) \ if((errf) != NULL) \ (errf)((arg),(errx)); #endif /* LWIP_EVENT_API */ /* This structure represents a TCP segment on the unsent and unacked queues */ struct tcp_seg { struct tcp_seg *next; /* used when putting segements on a queue */ struct pbuf *p; /* buffer containing data + TCP header */ void *dataptr; /* pointer to the TCP data in the pbuf */ u16_t len; /* the TCP length of this segment */ struct tcp_hdr *tcphdr; /* the TCP header */ }; /* Internal functions and global variables: */ struct tcp_pcb *tcp_pcb_copy(struct tcp_pcb *pcb); void tcp_pcb_purge(struct tcp_pcb *pcb); void tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb); u8_t tcp_segs_free(struct tcp_seg *seg); u8_t tcp_seg_free(struct tcp_seg *seg); struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg); #define tcp_ack(pcb) if((pcb)->flags & TF_ACK_DELAY) { \ (pcb)->flags &= ~TF_ACK_DELAY; \ (pcb)->flags |= TF_ACK_NOW; \ tcp_output(pcb); \ } else { \ (pcb)->flags |= TF_ACK_DELAY; \ } #define tcp_ack_now(pcb) (pcb)->flags |= TF_ACK_NOW; \ tcp_output(pcb) err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags); err_t tcp_enqueue(struct tcp_pcb *pcb, void *dataptr, u16_t len, u8_t flags, u8_t copy, u8_t *optdata, u8_t optlen); void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg); void tcp_rst(struct stack *stack, u32_t seqno, u32_t ackno, struct ip_addr *local_ip, struct ip_addr *remote_ip, u16_t local_port, u16_t remote_port); u32_t tcp_next_iss(struct stack *stack); void tcp_keepalive(struct tcp_pcb *pcb); #if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG void tcp_debug_print(struct tcp_hdr *tcphdr); void tcp_debug_print_flags(u8_t flags); void tcp_debug_print_state(enum tcp_state s); void tcp_debug_print_pcbs(void); int tcp_pcbs_sane(void); #else # define tcp_debug_print(tcphdr) # define tcp_debug_print_flags(flags) # define tcp_debug_print_state(s) # define tcp_debug_print_pcbs() # define tcp_pcbs_sane() 1 #endif /* TCP_DEBUG */ #if NO_SYS #define tcp_timer_needed() #else void tcp_timer_needed(struct stack *stack); #endif /* The TCP PCB lists. */ union tcp_listen_pcbs_t { /* List of all TCP PCBs in LISTEN state. */ struct tcp_pcb_listen *listen_pcbs; struct tcp_pcb *pcbs; }; #if 0 /* in the struct stack! */ extern union tcp_listen_pcbs_t tcp_listen_pcbs; extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a state in which they accept or send data. */ extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */ #endif /* Axioms about the above lists: 1) Every TCP PCB that is not CLOSED is in one of the lists. 2) A PCB is only in one of the lists. 3) All PCBs in the tcp_listen_pcbs list is in LISTEN state. 4) All PCBs in the tcp_tw_pcbs list is in TIME-WAIT state. */ /* Define two macros, TCP_REG and TCP_RMV that registers a TCP PCB with a PCB list or removes a PCB from a list, respectively. */ #if 0 #define TCP_REG(pcbs, npcb) do {\ LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \ for(tcp_tmp_pcb = *pcbs; \ tcp_tmp_pcb != NULL; \ tcp_tmp_pcb = tcp_tmp_pcb->next) { \ LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \ } \ LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \ npcb->next = *pcbs; \ LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \ *(pcbs) = npcb; \ LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ tcp_timer_needed(); \ } while(0) #define TCP_RMV(pcbs, npcb) do { \ LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \ LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \ if(*pcbs == npcb) { \ *pcbs = (*pcbs)->next; \ } else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \ if(tcp_tmp_pcb->next != NULL && tcp_tmp_pcb->next == npcb) { \ tcp_tmp_pcb->next = npcb->next; \ break; \ } \ } \ npcb->next = NULL; \ LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \ } while(0) #else /* LWIP_DEBUG */ #define TCP_REG(pcbs, npcb) do { \ npcb->next = *pcbs; \ *(pcbs) = npcb; \ tcp_timer_needed((npcb)->stack); \ } while(0) #define TCP_RMV(pcbs, npcb) do { \ typeof (npcb) tcp_tmp_pcb; \ if(*(pcbs) == npcb) { \ (*(pcbs)) = (*pcbs)->next; \ } else \ for(tcp_tmp_pcb = *pcbs; \ tcp_tmp_pcb != NULL; \ tcp_tmp_pcb = tcp_tmp_pcb->next) { \ if(tcp_tmp_pcb->next != NULL && tcp_tmp_pcb->next == npcb) { \ tcp_tmp_pcb->next = npcb->next; \ break; \ } \ } \ npcb->next = NULL; \ } while(0) #endif /* LWIP_DEBUG */ #endif /* __LWIP_TCP_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/opt.h0000644000175000017500000005401711671615005017500 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_OPT_H__ #define __LWIP_OPT_H__ /* Include user defined options first */ #include "lwipopts.h" #include "lwip/debug.h" /*----------------------------------------------------------------------*/ /* Define default values for unconfigured parameters. */ /* Platform specific locking */ /* * enable SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection * for certain critical regions during buffer allocation, deallocation and memory * allocation and deallocation. */ #ifndef SYS_LIGHTWEIGHT_PROT #define SYS_LIGHTWEIGHT_PROT 0 #endif #ifndef NO_SYS #define NO_SYS 0 #endif /*----------------------------------------------------------------------*/ /* Memory options */ /*----------------------------------------------------------------------*/ /* MEM_ALIGNMENT: should be set to the alignment of the CPU for which lwIP is compiled. 4 byte alignment -> define MEM_ALIGNMENT to 4, 2 byte alignment -> define MEM_ALIGNMENT to 2. */ #ifndef MEM_ALIGNMENT #define MEM_ALIGNMENT 1 #endif /* MEM_SIZE: the size of the heap memory. If the application will send a lot of data that needs to be copied, this should be set high. */ #ifndef MEM_SIZE #define MEM_SIZE 1600 #endif #ifndef MEMP_SANITY_CHECK #define MEMP_SANITY_CHECK 0 #endif /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application sends a lot of data out of ROM (or other static memory), this should be set high. */ #ifndef MEMP_NUM_PBUF #define MEMP_NUM_PBUF 16 #endif /* Number of raw connection PCBs */ #ifndef MEMP_NUM_RAW_PCB #define MEMP_NUM_RAW_PCB 4 #endif /* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One per active UDP "connection". */ #ifndef MEMP_NUM_UDP_PCB #define MEMP_NUM_UDP_PCB 4 #endif /* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. */ #ifndef MEMP_NUM_TCP_PCB #define MEMP_NUM_TCP_PCB 5 #endif /* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. */ #ifndef MEMP_NUM_TCP_PCB_LISTEN #define MEMP_NUM_TCP_PCB_LISTEN 8 #endif /* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. */ #ifndef MEMP_NUM_TCP_SEG #define MEMP_NUM_TCP_SEG 16 #endif /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */ #ifndef MEMP_NUM_SYS_TIMEOUT #define MEMP_NUM_SYS_TIMEOUT 3 #endif /* The following four are used only with the sequential API and can be set to 0 if the application only will use the raw API. */ /* MEMP_NUM_NETBUF: the number of struct netbufs. */ #ifndef MEMP_NUM_NETBUF #define MEMP_NUM_NETBUF 2 #endif /* MEMP_NUM_NETCONN: the number of struct netconns. */ #ifndef MEMP_NUM_NETCONN #define MEMP_NUM_NETCONN 4 #endif /* MEMP_NUM_APIMSG: the number of struct api_msg, used for communication between the TCP/IP stack and the sequential programs. */ #ifndef MEMP_NUM_API_MSG #define MEMP_NUM_API_MSG 8 #endif #ifndef API_MSG_RETRY_DELAY #define API_MSG_RETRY_DELAY 10 #endif /* MEMP_NUM_TCPIPMSG: the number of struct tcpip_msg, which is used for sequential API communication and incoming packets. Used in src/api/tcpip.c. */ #ifndef MEMP_NUM_TCPIP_MSG #define MEMP_NUM_TCPIP_MSG 8 #endif /* ---------- Pbuf options ---------- */ /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */ #ifndef PBUF_POOL_SIZE #define PBUF_POOL_SIZE 16 #endif /* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */ #ifndef PBUF_POOL_BUFSIZE #define PBUF_POOL_BUFSIZE 128 #endif /* PBUF_LINK_HLEN: the number of bytes that should be allocated for a link level header. Defaults to 14 for Ethernet. */ #ifndef PBUF_LINK_HLEN #define PBUF_LINK_HLEN 14 #endif /* ---------- IP ADDR LIST options --------- */ /* how many addresses the system can manage */ #ifndef IP_ADDR_POOL_SIZE #define IP_ADDR_POOL_SIZE 16 #endif #define MEMP_NUM_ADDRS IP_ADDR_POOL_SIZE #ifndef IP_ROUTE_POOL_SIZE #define IP_ROUTE_POOL_SIZE 16 #endif #define MEMP_NUM_ROUTES IP_ROUTE_POOL_SIZE #ifndef IP_REASS_POOL_SIZE #define IP_REASS_POOL_SIZE 8 #endif #define MEMP_NUM_REASS IP_REASS_POOL_SIZE /*----------------------------------------------------------------------*/ /* ARP Options */ /*----------------------------------------------------------------------*/ /** Number of active hardware address, IP address pairs cached */ #ifndef ARP_TABLE_SIZE #define ARP_TABLE_SIZE 10 #endif /** * If enabled, outgoing packets are queued during hardware address * resolution. * * This feature has not stabilized yet. Single-packet queueing is * believed to be stable, multi-packet queueing is believed to * clash with the TCP segment queueing. * * As multi-packet-queueing is currently disabled, enabling this * _should_ work, but we need your testing feedback on lwip-users. * */ #ifndef ARP_QUEUEING #define ARP_QUEUEING 1 #endif /* This option is deprecated */ #ifdef ETHARP_QUEUE_FIRST #error ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h. #endif /* This option is removed to comply with the ARP standard */ #ifdef ETHARP_ALWAYS_INSERT #error ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h. #endif /*----------------------------------------------------------------------*/ /* DHCP options */ /*----------------------------------------------------------------------*/ /* NOTE: under testing */ #ifndef LWIP_DHCP #define LWIP_DHCP 0 #endif /* 1 if you want to do an ARP check on the offered address (recommended). */ #ifndef DHCP_DOES_ARP_CHECK #define DHCP_DOES_ARP_CHECK 0 #endif /*----------------------------------------------------------------------*/ /* IPv4 IPv6 Settings */ /*----------------------------------------------------------------------*/ /* Define IP_FORWARD to 1 if you wish to have the ability to forward IP packets across network interfaces. If you are going to run lwIP on a device with only one network interface, define this to 0. */ #ifndef IP_FORWARD #define IP_FORWARD 0 #endif /* If defined to 1, IP options are allowed (but not parsed). If defined to 0, all packets with IP options are dropped. */ #ifndef IP_OPTIONS #define IP_OPTIONS 0 #endif /* IPv6 Support */ #ifndef IPv6 #define IPv6 1 #endif /* Enable IPv4 checksum validation */ #ifndef IPv4_CHECK_CHECKSUM #define IPv4_CHECK_CHECKSUM 0 #endif /* Enable IPv4 Fragmentation/Defragmentation */ #ifndef IPv4_FRAGMENTATION #define IPv4_FRAGMENTATION 0 #endif /* Enable IPv6 Fragmentation/Defragmentation */ #ifndef IPv6_FRAGMENTATION #define IPv6_FRAGMENTATION 0 #endif /* Enable IPv6 Stateless Autoconfiguration */ #ifndef IPv6_AUTO_CONFIGURATION #define IPv6_AUTO_CONFIGURATION 0 #endif /* Enable IPv6 Router Advertising service */ #ifndef IPv6_ROUTER_ADVERTISEMENT #define IPv6_ROUTER_ADVERTISEMENT 0 #endif /* Add support for Router Advertising configuration file */ #ifndef IPv6_RADVCONF #define IPv6_RADVCONF 0 #endif /*----------------------------------------------------------------------*/ /* Userfilter & NAT support */ /*----------------------------------------------------------------------*/ /* Enable Userfilter Hooks sub-system */ #ifndef LWIP_USERFILTER #define LWIP_USERFILTER 0 #endif /* Enable NAT (IPv4/IPv6) support over Userfilter */ #ifndef LWIP_NAT #define LWIP_NAT 0 #endif /*----------------------------------------------------------------------*/ /* ICMP Settings */ /*----------------------------------------------------------------------*/ /* ---------- ICMP options ---------- */ #ifndef ICMP_TTL #define ICMP_TTL 255 #endif /* ---------- RAW options ---------- */ #ifndef LWIP_RAW #define LWIP_RAW 1 #endif #ifndef RAW_TTL #define RAW_TTL 255 #endif /*----------------------------------------------------------------------*/ /* UDP Settings */ /*----------------------------------------------------------------------*/ #ifndef LWIP_UDP #define LWIP_UDP 1 #endif #ifndef UDP_TTL #define UDP_TTL 255 #endif /*----------------------------------------------------------------------*/ /* TCP Settings */ /*----------------------------------------------------------------------*/ #ifndef LWIP_TCP #define LWIP_TCP 1 #endif #ifndef TCP_TTL #define TCP_TTL 255 #endif #ifndef TCP_WND #define TCP_WND 2048 #endif #ifndef TCP_MAXRTX #define TCP_MAXRTX 12 #endif #ifndef TCP_SYNMAXRTX #define TCP_SYNMAXRTX 6 #endif /* Controls if TCP should queue segments that arrive out of order. Define to 0 if your device is low on memory. */ #ifndef TCP_QUEUE_OOSEQ #define TCP_QUEUE_OOSEQ 1 #endif /* TCP Maximum segment size. */ #ifndef TCP_MSS #define TCP_MSS 128 /* A *very* conservative default. */ #endif /* TCP sender buffer space (bytes). */ #ifndef TCP_SND_BUF #define TCP_SND_BUF 256 #endif /* TCP sender buffer space (pbufs). This must be at least = 2 * TCP_SND_BUF/TCP_MSS for things to work. */ #ifndef TCP_SND_QUEUELEN #define TCP_SND_QUEUELEN 4 * TCP_SND_BUF/TCP_MSS #endif /* Maximum number of retransmissions of data segments. */ /* Maximum number of retransmissions of SYN segments. */ /* TCP writable space (bytes). This must be less than or equal to TCP_SND_BUF. It is the amount of space which must be available in the tcp snd_buf for select to return writable */ #ifndef TCP_SNDLOWAT #define TCP_SNDLOWAT TCP_SND_BUF/2 #endif /* Support loop interface (127.0.0.1) */ #ifndef LWIP_HAVE_LOOPIF #define LWIP_HAVE_LOOPIF 1 #endif /*----------------------------------------------------------------------*/ /* TCPIP THREAD (tcpip.c) */ /*----------------------------------------------------------------------*/ #ifndef TCPIP_THREAD_PRIO #define TCPIP_THREAD_PRIO 1 #endif /*----------------------------------------------------------------------*/ /* API Settings */ /*----------------------------------------------------------------------*/ #ifndef LWIP_EVENT_API #define LWIP_EVENT_API 0 #define LWIP_CALLBACK_API 1 #else #define LWIP_EVENT_API 1 #define LWIP_CALLBACK_API 0 #endif #ifndef LWIP_COMPAT_SOCKETS #define LWIP_COMPAT_SOCKETS 0 #endif //#ifndef SLIPIF_THREAD_PRIO //#define SLIPIF_THREAD_PRIO 1 //#endif //#ifndef PPP_THREAD_PRIO //#define PPP_THREAD_PRIO 1 //#endif #ifndef DEFAULT_THREAD_PRIO #define DEFAULT_THREAD_PRIO 1 #endif /*----------------------------------------------------------------------*/ /* Sockets Options */ /*----------------------------------------------------------------------*/ /* Enable SO_REUSEADDR and SO_REUSEPORT options */ #ifndef SO_REUSE # define SO_REUSE 1 #endif /*----------------------------------------------------------------------*/ /* Sockets API Settings */ /*----------------------------------------------------------------------*/ /* Enable Renzo Davoli changes (used only inside renzosockets.c) */ #ifndef RD235LIB #define RD235LIB 0 #endif /* Netlink Socket support */ #ifndef LWIP_NL #define LWIP_NL 0 #endif /* PACKET Socket support */ #ifndef LWIP_PACKET #define LWIP_PACKET 0 #endif /*----------------------------------------------------------------------*/ /* Statistics options */ /*----------------------------------------------------------------------*/ #ifndef LWIP_STATS #define LWIP_STATS 0 #endif #if LWIP_STATS #ifndef LWIP_STATS_DISPLAY #define LWIP_STATS_DISPLAY 0 #endif #ifndef LINK_STATS #define LINK_STATS 1 #endif #ifndef IP_STATS #define IP_STATS 1 #endif #ifndef IPFRAG_STATS #define IPFRAG_STATS 1 #endif #ifndef ICMP_STATS #define ICMP_STATS 1 #endif #ifndef UDP_STATS #define UDP_STATS 1 #endif #ifndef TCP_STATS #define TCP_STATS 1 #endif #ifndef MEM_STATS #define MEM_STATS 1 #endif #ifndef MEMP_STATS #define MEMP_STATS 1 #endif #ifndef PBUF_STATS #define PBUF_STATS 1 #endif #ifndef SYS_STATS #define SYS_STATS 1 #endif #ifndef RAW_STATS #define RAW_STATS 0 #endif #else #define LINK_STATS 0 #define IP_STATS 0 #define IPFRAG_STATS 0 #define ICMP_STATS 0 #define UDP_STATS 0 #define TCP_STATS 0 #define MEM_STATS 0 #define MEMP_STATS 0 #define PBUF_STATS 0 #define SYS_STATS 0 #define RAW_STATS 0 #define DEBUG_STATS 0 #define LWIP_STATS_DISPLAY 0 #endif /* LWIP_STATS */ /* checksum options - set to zero for hardware checksum support */ #ifndef CHECKSUM_GEN_IP #define CHECKSUM_GEN_IP 1 #endif #ifndef CHECKSUM_GEN_UDP #define CHECKSUM_GEN_UDP 1 #endif #ifndef CHECKSUM_GEN_TCP #define CHECKSUM_GEN_TCP 1 #endif #ifndef CHECKSUM_CHECK_IP #define CHECKSUM_CHECK_IP 1 #endif #ifndef CHECKSUM_CHECK_UDP #define CHECKSUM_CHECK_UDP 1 #endif #ifndef CHECKSUM_CHECK_TCP #define CHECKSUM_CHECK_TCP 1 #endif /*----------------------------------------------------------------------*/ /* DEBUG Settings */ /*----------------------------------------------------------------------*/ /* Debugging options all default to off */ #ifndef DBG_MIN_LEVEL #define DBG_MIN_LEVEL DBG_LEVEL_OFF #endif #ifndef DBG_TYPES_ON #define DBG_TYPES_ON 0 #endif #ifndef MEM_DEBUG #define MEM_DEBUG DBG_OFF #endif #ifndef MEMP_DEBUG #define MEMP_DEBUG DBG_OFF #endif #ifndef SYS_DEBUG #define SYS_DEBUG DBG_OFF #endif #ifndef ETHARP_DEBUG #define ETHARP_DEBUG DBG_OFF #endif #ifndef NETIF_DEBUG #define NETIF_DEBUG DBG_OFF #endif #ifndef PBUF_DEBUG #define PBUF_DEBUG DBG_OFF #endif #ifndef API_LIB_DEBUG #define API_LIB_DEBUG DBG_OFF #endif #ifndef API_MSG_DEBUG #define API_MSG_DEBUG DBG_OFF #endif #ifndef DHCP_DEBUG #define DHCP_DEBUG DBG_OFF #endif #ifndef IP_DEBUG #define IP_DEBUG DBG_OFF #endif #ifndef IP_REASS_DEBUG #define IP_REASS_DEBUG DBG_OFF #endif #ifndef ROUTE_DEBUG #define ROUTE_DEBUG DBG_OFF #endif #ifndef PMTU_DEBUG #define PMTU_DEBUG DBG_OFF #endif #ifndef IPv6_ADDRSELECT_DBG #define IPv6_ADDRSELECT_DBG DBG_OFF #endif #ifndef IP_AUTOCONF_DEBUG #define IP_AUTOCONF_DEBUG DBG_OFF #endif #ifndef IP_RADV_DEBUG #define IP_RADV_DEBUG DBG_OFF #endif #ifndef IP_RADVCONF_DEBUG #define IP_RADVCONF_DEBUG DBG_OFF #endif #ifndef USERFILTER_DEBUG #define USERFILTER_DEBUG DBG_OFF #endif #ifndef NAT_DEBUG #define NAT_DEBUG DBG_OFF #endif #ifndef ICMP_DEBUG #define ICMP_DEBUG DBG_OFF #endif #ifndef SOCKETS_DEBUG #define SOCKETS_DEBUG DBG_OFF #endif #ifndef INET_DEBUG #define INET_DEBUG DBG_OFF #endif #ifndef RAW_DEBUG #define RAW_DEBUG DBG_OFF #endif #ifndef PACKET_DEBUG #define PACKET_DEBUG DBG_OFF #endif #ifndef TCP_DEBUG #define TCP_DEBUG DBG_OFF #endif #ifndef TCP_INPUT_DEBUG #define TCP_INPUT_DEBUG DBG_OFF #endif #ifndef TCP_FR_DEBUG #define TCP_FR_DEBUG DBG_OFF #endif #ifndef TCP_RTO_DEBUG #define TCP_RTO_DEBUG DBG_OFF #endif #ifndef TCP_REXMIT_DEBUG #define TCP_REXMIT_DEBUG DBG_OFF #endif #ifndef TCP_CWND_DEBUG #define TCP_CWND_DEBUG DBG_OFF #endif #ifndef TCP_WND_DEBUG #define TCP_WND_DEBUG DBG_OFF #endif #ifndef TCP_OUTPUT_DEBUG #define TCP_OUTPUT_DEBUG DBG_OFF #endif #ifndef TCP_RST_DEBUG #define TCP_RST_DEBUG DBG_OFF #endif #ifndef TCP_QLEN_DEBUG #define TCP_QLEN_DEBUG DBG_OFF #endif #ifndef UDP_DEBUG #define UDP_DEBUG DBG_OFF #endif #ifndef TCPIP_DEBUG #define TCPIP_DEBUG DBG_OFF #endif #ifndef LWSLIRP_DEBUG #define LWSLIRP_DEBUG DBG_OFF #endif #endif /* __LWIP_OPT_H__ */ /*----------------------------------------------------------------------*/ /* No more working features */ /*----------------------------------------------------------------------*/ #if 0 /** IP reassembly and segmentation. Even if they both deal with IP * fragments, note that these are orthogonal, one dealing with incoming * packets, the other with outgoing packets */ /** Reassemble incoming fragmented IP packets */ //#ifndef IP_REASSEMBLY //#define IP_REASSEMBLY 1 //#endif /** Fragment outgoing IP packets if their size exceeds MTU */ //#ifndef IP_FRAG //#define IP_FRAG 1 //#endif #ifndef PPP_DEBUG #define PPP_DEBUG DBG_OFF #endif #ifndef SLIP_DEBUG #define SLIP_DEBUG DBG_OFF #endif /* ---------- PPP options ---------- */ #ifndef PPP_SUPPORT #define PPP_SUPPORT 0 /* Set for PPP */ #endif #if PPP_SUPPORT #define NUM_PPP 1 /* Max PPP sessions. */ #ifndef PAP_SUPPORT #define PAP_SUPPORT 0 /* Set for PAP. */ #endif #ifndef CHAP_SUPPORT #define CHAP_SUPPORT 0 /* Set for CHAP. */ #endif #define MSCHAP_SUPPORT 0 /* Set for MSCHAP (NOT FUNCTIONAL!) */ #define CBCP_SUPPORT 0 /* Set for CBCP (NOT FUNCTIONAL!) */ #define CCP_SUPPORT 0 /* Set for CCP (NOT FUNCTIONAL!) */ #ifndef VJ_SUPPORT #define VJ_SUPPORT 0 /* Set for VJ header compression. */ #endif #ifndef MD5_SUPPORT #define MD5_SUPPORT 0 /* Set for MD5 (see also CHAP) */ #endif /* * Timeouts. */ #define FSM_DEFTIMEOUT 6 /* Timeout time in seconds */ #define FSM_DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */ #define FSM_DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */ #define FSM_DEFMAXNAKLOOPS 5 /* Maximum number of nak loops */ #define UPAP_DEFTIMEOUT 6 /* Timeout (seconds) for retransmitting req */ #define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ #define CHAP_DEFTIMEOUT 6 /* Timeout time in seconds */ #define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */ /* Interval in seconds between keepalive echo requests, 0 to disable. */ #if 1 #define LCP_ECHOINTERVAL 0 #else #define LCP_ECHOINTERVAL 10 #endif /* Number of unanswered echo requests before failure. */ #define LCP_MAXECHOFAILS 3 /* Max Xmit idle time (in jiffies) before resend flag char. */ #define PPP_MAXIDLEFLAG 100 /* * Packet sizes * * Note - lcp shouldn't be allowed to negotiate stuff outside these * limits. See lcp.h in the pppd directory. * (XXX - these constants should simply be shared by lcp.c instead * of living in lcp.h) */ #define PPP_MTU 1500 /* Default MTU (size of Info field) */ #if 0 #define PPP_MAXMTU 65535 - (PPP_HDRLEN + PPP_FCSLEN) #else #define PPP_MAXMTU 1500 /* Largest MTU we allow */ #endif #define PPP_MINMTU 64 #define PPP_MRU 1500 /* default MRU = max length of info field */ #define PPP_MAXMRU 1500 /* Largest MRU we allow */ #define PPP_DEFMRU 296 /* Try for this */ #define PPP_MINMRU 128 /* No MRUs below this */ #define MAXNAMELEN 256 /* max length of hostname or name for auth */ #define MAXSECRETLEN 256 /* max length of password or secret */ #endif /* PPP_SUPPORT */ #endif lwipv6-1.5a/lwip-v6/src/include/lwip/arch.h0000644000175000017500000002320111671615005017602 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_ARCH_H__ #define __LWIP_ARCH_H__ #ifndef LITTLE_ENDIAN #define LITTLE_ENDIAN 1234 #endif #ifndef BIG_ENDIAN #define BIG_ENDIAN 4321 #endif #include "arch/cc.h" #ifndef PACK_STRUCT_BEGIN #define PACK_STRUCT_BEGIN #endif /* PACK_STRUCT_BEGIN */ #ifndef PACK_STRUCT_END #define PACK_STRUCT_END #endif /* PACK_STRUCT_END */ #ifndef PACK_STRUCT_FIELD #define PACK_STRUCT_FIELD(x) x #endif /* PACK_STRUCT_FIELD */ #ifdef LWIP_PROVIDE_ERRNO #define EPERM 1 /* Operation not permitted */ #define ENOENT 2 /* No such file or directory */ #define ESRCH 3 /* No such process */ #define EINTR 4 /* Interrupted system call */ #define EIO 5 /* I/O error */ #define ENXIO 6 /* No such device or address */ #define E2BIG 7 /* Arg list too long */ #define ENOEXEC 8 /* Exec format error */ #define EBADF 9 /* Bad file number */ #define ECHILD 10 /* No child processes */ #define EAGAIN 11 /* Try again */ #define ENOMEM 12 /* Out of memory */ #define EACCES 13 /* Permission denied */ #define EFAULT 14 /* Bad address */ #define ENOTBLK 15 /* Block device required */ #define EBUSY 16 /* Device or resource busy */ #define EEXIST 17 /* File exists */ #define EXDEV 18 /* Cross-device link */ #define ENODEV 19 /* No such device */ #define ENOTDIR 20 /* Not a directory */ #define EISDIR 21 /* Is a directory */ #define EINVAL 22 /* Invalid argument */ #define ENFILE 23 /* File table overflow */ #define EMFILE 24 /* Too many open files */ #define ENOTTY 25 /* Not a typewriter */ #define ETXTBSY 26 /* Text file busy */ #define EFBIG 27 /* File too large */ #define ENOSPC 28 /* No space left on device */ #define ESPIPE 29 /* Illegal seek */ #define EROFS 30 /* Read-only file system */ #define EMLINK 31 /* Too many links */ #define EPIPE 32 /* Broken pipe */ #define EDOM 33 /* Math argument out of domain of func */ #define ERANGE 34 /* Math result not representable */ #define EDEADLK 35 /* Resource deadlock would occur */ #define ENAMETOOLONG 36 /* File name too long */ #define ENOLCK 37 /* No record locks available */ #define ENOSYS 38 /* Function not implemented */ #define ENOTEMPTY 39 /* Directory not empty */ #define ELOOP 40 /* Too many symbolic links encountered */ #define EWOULDBLOCK EAGAIN /* Operation would block */ #define ENOMSG 42 /* No message of desired type */ #define EIDRM 43 /* Identifier removed */ #define ECHRNG 44 /* Channel number out of range */ #define EL2NSYNC 45 /* Level 2 not synchronized */ #define EL3HLT 46 /* Level 3 halted */ #define EL3RST 47 /* Level 3 reset */ #define ELNRNG 48 /* Link number out of range */ #define EUNATCH 49 /* Protocol driver not attached */ #define ENOCSI 50 /* No CSI structure available */ #define EL2HLT 51 /* Level 2 halted */ #define EBADE 52 /* Invalid exchange */ #define EBADR 53 /* Invalid request descriptor */ #define EXFULL 54 /* Exchange full */ #define ENOANO 55 /* No anode */ #define EBADRQC 56 /* Invalid request code */ #define EBADSLT 57 /* Invalid slot */ #define EDEADLOCK EDEADLK #define EBFONT 59 /* Bad font file format */ #define ENOSTR 60 /* Device not a stream */ #define ENODATA 61 /* No data available */ #define ETIME 62 /* Timer expired */ #define ENOSR 63 /* Out of streams resources */ #define ENONET 64 /* Machine is not on the network */ #define ENOPKG 65 /* Package not installed */ #define EREMOTE 66 /* Object is remote */ #define ENOLINK 67 /* Link has been severed */ #define EADV 68 /* Advertise error */ #define ESRMNT 69 /* Srmount error */ #define ECOMM 70 /* Communication error on send */ #define EPROTO 71 /* Protocol error */ #define EMULTIHOP 72 /* Multihop attempted */ #define EDOTDOT 73 /* RFS specific error */ #define EBADMSG 74 /* Not a data message */ #define EOVERFLOW 75 /* Value too large for defined data type */ #define ENOTUNIQ 76 /* Name not unique on network */ #define EBADFD 77 /* File descriptor in bad state */ #define EREMCHG 78 /* Remote address changed */ #define ELIBACC 79 /* Can not access a needed shared library */ #define ELIBBAD 80 /* Accessing a corrupted shared library */ #define ELIBSCN 81 /* .lib section in a.out corrupted */ #define ELIBMAX 82 /* Attempting to link in too many shared libraries */ #define ELIBEXEC 83 /* Cannot exec a shared library directly */ #define EILSEQ 84 /* Illegal byte sequence */ #define ERESTART 85 /* Interrupted system call should be restarted */ #define ESTRPIPE 86 /* Streams pipe error */ #define EUSERS 87 /* Too many users */ #define ENOTSOCK 88 /* Socket operation on non-socket */ #define EDESTADDRREQ 89 /* Destination address required */ #define EMSGSIZE 90 /* Message too long */ #define EPROTOTYPE 91 /* Protocol wrong type for socket */ #define ENOPROTOOPT 92 /* Protocol not available */ #define EPROTONOSUPPORT 93 /* Protocol not supported */ #define ESOCKTNOSUPPORT 94 /* Socket type not supported */ #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */ #define EPFNOSUPPORT 96 /* Protocol family not supported */ #define EAFNOSUPPORT 97 /* Address family not supported by protocol */ #define EADDRINUSE 98 /* Address already in use */ #define EADDRNOTAVAIL 99 /* Cannot assign requested address */ #define ENETDOWN 100 /* Network is down */ #define ENETUNREACH 101 /* Network is unreachable */ #define ENETRESET 102 /* Network dropped connection because of reset */ #define ECONNABORTED 103 /* Software caused connection abort */ #define ECONNRESET 104 /* Connection reset by peer */ #define ENOBUFS 105 /* No buffer space available */ #define EISCONN 106 /* Transport endpoint is already connected */ #define ENOTCONN 107 /* Transport endpoint is not connected */ #define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */ #define ETOOMANYREFS 109 /* Too many references: cannot splice */ #define ETIMEDOUT 110 /* Connection timed out */ #define ECONNREFUSED 111 /* Connection refused */ #define EHOSTDOWN 112 /* Host is down */ #define EHOSTUNREACH 113 /* No route to host */ #define EALREADY 114 /* Operation already in progress */ #define EINPROGRESS 115 /* Operation now in progress */ #define ESTALE 116 /* Stale NFS file handle */ #define EUCLEAN 117 /* Structure needs cleaning */ #define ENOTNAM 118 /* Not a XENIX named type file */ #define ENAVAIL 119 /* No XENIX semaphores available */ #define EISNAM 120 /* Is a named type file */ #define EREMOTEIO 121 /* Remote I/O error */ #define EDQUOT 122 /* Quota exceeded */ #define ENOMEDIUM 123 /* No medium found */ #define EMEDIUMTYPE 124 /* Wrong medium type */ #define ENSROK 0 /* DNS server returned answer with no data */ #define ENSRNODATA 160 /* DNS server returned answer with no data */ #define ENSRFORMERR 161 /* DNS server claims query was misformatted */ #define ENSRSERVFAIL 162 /* DNS server returned general failure */ #define ENSRNOTFOUND 163 /* Domain name not found */ #define ENSRNOTIMP 164 /* DNS server does not implement requested operation */ #define ENSRREFUSED 165 /* DNS server refused query */ #define ENSRBADQUERY 166 /* Misformatted DNS query */ #define ENSRBADNAME 167 /* Misformatted domain name */ #define ENSRBADFAMILY 168 /* Unsupported address family */ #define ENSRBADRESP 169 /* Misformatted DNS reply */ #define ENSRCONNREFUSED 170 /* Could not contact DNS servers */ #define ENSRTIMEOUT 171 /* Timeout while contacting DNS servers */ #define ENSROF 172 /* End of file */ #define ENSRFILE 173 /* Error reading file */ #define ENSRNOMEM 174 /* Out of memory */ #define ENSRDESTRUCTION 175 /* Application terminated lookup */ #define ENSRQUERYDOMAINTOOLONG 176 /* Domain name is too long */ #define ENSRCNAMELOOP 177 /* Domain name is too long */ #ifndef errno extern int errno; #endif #endif /* LWIP_PROVIDE_ERRNO */ #endif /* __LWIP_ARCH_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/api_msg.h0000644000175000017500000000546311671615005020316 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_API_MSG_H__ #define __LWIP_API_MSG_H__ #include "lwip/opt.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include "lwip/ip.h" #include "lwip/udp.h" #include "lwip/tcp.h" #ifdef LWIP_RAW #include "lwip/raw.h" #endif #if LWIP_PACKET #include "lwip/packet.h" #endif #include "lwip/api.h" enum api_msg_type { API_MSG_NEWCONN, API_MSG_DELCONN, API_MSG_BIND, API_MSG_CONNECT, API_MSG_DISCONNECT, API_MSG_LISTEN, API_MSG_ACCEPT, API_MSG_SEND, API_MSG_RECV, API_MSG_WRITE, API_MSG_CLOSE, API_MSG_PEER, API_MSG_ADDR, API_MSG_CALLBACK, API_MSG_MAX }; struct netconn; struct api_msg_msg { struct netconn *conn; err_t err; union { struct pbuf *p; struct { struct ip_addr *ipaddr; u16_t port; } bc; struct { struct ip_addr *ipaddr; u16_t *port; } bp; struct { void *dataptr; u16_t len; u8_t copy; } w; struct { err_t (*fun) (struct netconn *conn, void *arg); void *arg; } cb; u16_t len; } msg; }; struct api_msg { enum api_msg_type type; struct api_msg_msg msg; }; void api_msg_input(struct api_msg *msg); void api_msg_post(struct stack *stack, struct api_msg *msg); #endif /* __LWIP_API_MSG_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/memp.h0000644000175000017500000000777411671615005017644 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_MEMP_H__ #define __LWIP_MEMP_H__ #include "lwip/opt.h" #include "lwip/pbuf.h" #include "lwip/udp.h" #include "lwip/raw.h" #include "lwip/tcp.h" #include "lwip/api.h" #include "lwip/tcpip.h" typedef enum { MEMP_PBUF, MEMP_RAW_PCB, MEMP_UDP_PCB, MEMP_TCP_PCB, MEMP_TCP_PCB_LISTEN, MEMP_TCP_SEG, MEMP_NETBUF, MEMP_NETCONN, MEMP_TCPIP_MSG, MEMP_SYS_TIMEOUT, MEMP_ROUTE, MEMP_ADDR, MEMP_NETIF_FDDATA, #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION MEMP_REASS, #endif /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT MEMP_NAT_PCB, MEMP_NAT_RULE, #endif MEMP_MAX } memp_t; #ifndef DEBUGMEM void memp_init(void); void *memp_malloc(memp_t type); void memp_free(memp_t type, void *mem); #else void memp_d_init(char *file, int line); void *memp_d_malloc(memp_t type, char *file, int line); void memp_d_free(memp_t type, void *mem, char *file, int line); #define memp_init() memp_d_init(__FILE__,__LINE__) #define memp_malloc(X) memp_d_malloc((X),__FILE__,__LINE__) #define memp_free(X,Y) memp_d_free((X), (Y), __FILE__,__LINE__) #endif #if 0 #define memp_init() ({ ; }) #define memp_free(T,X) ({ printf("MEMP-FREE %x %s %d\n",(X),__FILE__,__LINE__); \ free(X); }) #if LWIP_USERFILTER && LWIP_NAT #include "lwip/nat/nat.h" #define memp_malloc(T) ({ void *x; \ u16_t memp_sizes[MEMP_MAX] = {\ sizeof(struct pbuf),\ sizeof(struct raw_pcb),\ sizeof(struct udp_pcb),\ sizeof(struct tcp_pcb),\ sizeof(struct tcp_pcb_listen),\ sizeof(struct tcp_seg),\ sizeof(struct netbuf),\ sizeof(struct netconn),\ sizeof(struct tcpip_msg),\ sizeof(struct sys_timeout),\ sizeof(struct ip_addr_list),\ sizeof(struct ip_reassbuf),\ sizeof(struct nat_pcb),\ sizeof(struct nat_rule)\ };\ x=malloc(memp_sizes[T]); \ printf("MEMP-MALLOC %x (T=%d Size=%d) %s %d\n",x,T,memp_sizes[T],__FILE__,__LINE__); \ x; }) #else #define memp_malloc(T) ({ void *x; \ u16_t memp_sizes[MEMP_MAX] = {\ sizeof(struct pbuf),\ sizeof(struct raw_pcb),\ sizeof(struct udp_pcb),\ sizeof(struct tcp_pcb),\ sizeof(struct tcp_pcb_listen),\ sizeof(struct tcp_seg),\ sizeof(struct netbuf),\ sizeof(struct netconn),\ sizeof(struct tcpip_msg),\ sizeof(struct sys_timeout),\ sizeof(struct ip_addr_list),\ sizeof(struct ip_reassbuf)\ };\ x=malloc(memp_sizes[T]); \ printf("MEMP-MALLOC %x (T=%d Size=%d) %s %d\n",x,T,memp_sizes[T],__FILE__,__LINE__); \ x; }) #endif #endif #endif /* __LWIP_MEMP_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/api.h0000644000175000017500000001330211671615005017437 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_API_H__ #define __LWIP_API_H__ #include "lwip/opt.h" #include "lwip/pbuf.h" #include "lwip/sys.h" #include "lwip/ip.h" #include "lwip/raw.h" #include "lwip/udp.h" #include "lwip/tcp.h" #include "lwip/err.h" #define NETCONN_NOCOPY 0x00 #define NETCONN_COPY 0x01 enum netconn_type { NETCONN_TCP, NETCONN_UDP, NETCONN_UDPLITE, NETCONN_UDPNOCHKSUM, NETCONN_RAW #if LWIP_PACKET , NETCONN_PACKET_RAW, NETCONN_PACKET_DGRAM #endif }; enum netconn_state { NETCONN_NONE, NETCONN_WRITE, NETCONN_ACCEPT, NETCONN_RECV, NETCONN_CONNECT, NETCONN_CLOSE }; enum netconn_evt { NETCONN_EVT_RCVPLUS, NETCONN_EVT_RCVMINUS, NETCONN_EVT_SENDPLUS, NETCONN_EVT_SENDMINUS, NETCONN_EVT_ACCEPTPLUS }; struct netbuf { struct pbuf *p, *ptr; struct ip_addr fromaddr; u16_t fromport; err_t err; }; struct netconn { struct stack *stack; /* enum netconn_type */ u8_t type; /* enum netconn_state */ u8_t state; u8_t ack_pending; u8_t connected; err_t err; union { struct common_pcb *common; struct tcp_pcb *tcp; struct udp_pcb *udp; struct raw_pcb *raw; } pcb; sys_mbox_t mbox; sys_mbox_t recvmbox; sys_mbox_t acceptmbox; sys_sem_t sem; int socket; u16_t recv_avail; void (* callback)(struct netconn *, enum netconn_evt, u16_t len); }; /* Network buffer functions: */ struct netbuf * netbuf_new (void); void netbuf_delete (struct netbuf *buf); void * netbuf_alloc (struct netbuf *buf, u16_t size); void netbuf_free (struct netbuf *buf); void netbuf_ref (struct netbuf *buf, void *dataptr, u16_t size); void netbuf_chain (struct netbuf *head, struct netbuf *tail); u16_t netbuf_len (struct netbuf *buf); err_t netbuf_data (struct netbuf *buf, void **dataptr, u16_t *len); s8_t netbuf_next (struct netbuf *buf); void netbuf_first (struct netbuf *buf); void netbuf_copy (struct netbuf *buf, void *dataptr, u16_t len); void netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset); struct ip_addr * netbuf_fromaddr (struct netbuf *buf); u16_t netbuf_fromport (struct netbuf *buf); /* Network connection functions: */ struct netconn * netconn_new (struct stack *stack, enum netconn_type type); struct netconn *netconn_new_with_callback(struct stack *stack, enum netconn_type type, void (*callback)(struct netconn *, enum netconn_evt, u16_t len)); struct netconn *netconn_new_with_proto_and_callback(struct stack *stack, enum netconn_type type, u16_t proto, void (*callback)(struct netconn *, enum netconn_evt, u16_t len)); err_t netconn_delete (struct netconn *conn); enum netconn_type netconn_type (struct netconn *conn); struct stack * netconn_stack (struct netconn *conn); err_t netconn_peer (struct netconn *conn, struct ip_addr *addr, u16_t *port); err_t netconn_addr (struct netconn *conn, struct ip_addr *addr, u16_t *port); err_t netconn_bind (struct netconn *conn, struct ip_addr *addr, u16_t port); err_t netconn_connect (struct netconn *conn, struct ip_addr *addr, u16_t port); err_t netconn_disconnect (struct netconn *conn); err_t netconn_listen (struct netconn *conn); struct netconn * netconn_accept (struct netconn *conn); struct netbuf * netconn_recv (struct netconn *conn); err_t netconn_send (struct netconn *conn, struct netbuf *buf); err_t netconn_write (struct netconn *conn, void *dataptr, u16_t size, u8_t copy); err_t netconn_close (struct netconn *conn); err_t netconn_callback(struct netconn *conn, err_t (*fun)(struct netconn *conn, void *), void *arg); err_t netconn_err (struct netconn *conn); #endif /* __LWIP_API_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/pbuf.h0000644000175000017500000001023611671615005017625 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_PBUF_H__ #define __LWIP_PBUF_H__ #include "arch/cc.h" /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT #include "lwip/nat/nat.h" //struct nat_info; #endif #define PBUF_TRANSPORT_HLEN 20 #define PBUF_IP_HLEN IP_HLEN typedef enum { PBUF_TRANSPORT, PBUF_IP, PBUF_LINK, PBUF_RAW } pbuf_layer; typedef enum { PBUF_RAM, PBUF_ROM, PBUF_REF, PBUF_POOL } pbuf_flag; /* Definitions for the pbuf flag field. These are NOT the flags that * are passed to pbuf_alloc(). */ #define PBUF_FLAG_RAM 0x00U /* Flags that pbuf data is stored in RAM */ #define PBUF_FLAG_ROM 0x01U /* Flags that pbuf data is stored in ROM */ #define PBUF_FLAG_POOL 0x02U /* Flags that the pbuf comes from the pbuf pool */ #define PBUF_FLAG_REF 0x04U /* Flags thet the pbuf payload refers to RAM */ /** indicates this packet was broadcast on the link */ #define PBUF_FLAG_LINK_BROADCAST 0x80U struct pbuf { /** next pbuf in singly linked pbuf chain */ struct pbuf *next; /** pointer to the actual data in the buffer */ void *payload; /** * total length of this buffer and all next buffers in chain * belonging to the same packet. * * For non-queue packet chains this is the invariant: * p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ u16_t tot_len; /** length of this buffer */ u16_t len; /** flags telling the type of pbuf, see PBUF_FLAG_ */ u16_t flags; /** * the reference count always equals the number of pointers * that refer to this pbuf. This can be pointers from an application, * the stack itself, or pbuf->next pointers from a chain. */ u16_t ref; /* added by Diego Billi */ #if LWIP_USERFILTER && LWIP_NAT struct nat_info nat; #endif }; void pbuf_init(void); struct pbuf *pbuf_alloc(pbuf_layer l, u16_t size, pbuf_flag flag); void pbuf_realloc(struct pbuf *p, u16_t size); u8_t pbuf_header(struct pbuf *p, s16_t header_size); void pbuf_ref(struct pbuf *p); void pbuf_ref_chain(struct pbuf *p); /* #define pbuf_free(X) ({printf ("FREE %p %d %s\n",X,__LINE__,__FILE__);\ pbuf_freex(X);}) */ u8_t pbuf_free(struct pbuf *p); u8_t pbuf_clen(struct pbuf *p); void pbuf_cat(struct pbuf *h, struct pbuf *t); void pbuf_chain(struct pbuf *h, struct pbuf *t); struct pbuf *pbuf_take(struct pbuf *f); struct pbuf *pbuf_dechain(struct pbuf *p); void pbuf_queue(struct pbuf *p, struct pbuf *n); struct pbuf * pbuf_dequeue(struct pbuf *p); /* Added by Diego Billi */ struct pbuf * pbuf_clone(pbuf_layer l, struct pbuf *p, pbuf_flag flag); struct pbuf * pbuf_make_writable(struct pbuf *p); #endif /* __LWIP_PBUF_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/lwslirp.h0000644000175000017500000001066011671615005020366 0ustar renzorenzo/* This is part of Slirpvde6 * Developed for the VDE project * Virtual Distributed Ethernet * * Copyright 2010 Renzo Davoli * based on the work of Andrea Forni 2005 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _LWSLIRP_H_ #define _LWSLIRP_H_ #ifdef LWSLIRP #include #include #include "lwip/ip_addr.h" #include "lwip/tcp.h" #include "lwip/udp.h" #include "lwip/err.h" #if 0 #ifndef SOCKETVDE_DEBUG #define SOCKETVDE_DEBUG 0x00U #endif #endif /* * Converts the struct in6_addr "from" to a the LWIP struct ip_addr "to". * * from: struct in6_addr * * to: struct ip_addr * */ #define SO_IN6_ADDR2IP_ADDR(from, to) IP6_ADDR((to), \ (((from)->s6_addr[0] << 8) | ((from)->s6_addr[1])), \ (((from)->s6_addr[2] << 8) | ((from)->s6_addr[3])), \ (((from)->s6_addr[4] << 8) | ((from)->s6_addr[5])), \ (((from)->s6_addr[6] << 8) | ((from)->s6_addr[7])), \ (((from)->s6_addr[8] << 8) | ((from)->s6_addr[9])), \ (((from)->s6_addr[10] << 8) | ((from)->s6_addr[11])), \ (((from)->s6_addr[12] << 8) | ((from)->s6_addr[13])), \ (((from)->s6_addr[14] << 8) | ((from)->s6_addr[15]))) /* * Converts the struct ip_addr "from" to a the struct in6_addr "to". * * from: struct ip_addr * * to: struct in6_addr * */ #define SO_IP_ADDR2IN6_ADDR(from, to) do { \ (to)->s6_addr[0] = (from)->addr[0] & 0xffff; \ (to)->s6_addr[1] = ((from)->addr[0] >> 8) & 0xffff; \ (to)->s6_addr[2] = ((from)->addr[0] >> 16) & 0xffff; \ (to)->s6_addr[3] = ((from)->addr[0] >> 24) & 0xffff; \ \ (to)->s6_addr[4] = (from)->addr[1] & 0xffff; \ (to)->s6_addr[5] = ((from)->addr[1] >> 8) & 0xffff; \ (to)->s6_addr[6] = ((from)->addr[1] >> 16) & 0xffff; \ (to)->s6_addr[7] = ((from)->addr[1] >> 24) & 0xffff; \ \ (to)->s6_addr[8] = (from)->addr[2] & 0xffff; \ (to)->s6_addr[9] = ((from)->addr[2] >> 8) & 0xffff; \ (to)->s6_addr[10] = ((from)->addr[2] >> 16) & 0xffff; \ (to)->s6_addr[11] = ((from)->addr[2] >> 24) & 0xffff; \ \ (to)->s6_addr[12] = (from)->addr[3] & 0xffff; \ (to)->s6_addr[13] = ((from)->addr[3] >> 8) & 0xffff; \ (to)->s6_addr[14] = ((from)->addr[3] >> 16) & 0xffff; \ (to)->s6_addr[15] = ((from)->addr[3] >> 24) & 0xffff; \ }while(0) /* * Converts the struct in_addr "from" to a the LWIP struct ip_addr "to". * * from: struct in_addr * * to: struct ip_addr * */ #define SO_IN_ADDR2IP_ADDR(from, to) IP64_ADDR((to), \ (((from)->s_addr) & 0x000000ff), \ ((((from)->s_addr) >> 8) & 0x000000ff), \ ((((from)->s_addr) >> 16) & 0x000000ff), \ ((((from)->s_addr) >> 24) & 0x000000ff)) int slirp_tcp_fconnect(struct tcp_pcb_listen *lpcb, u16_t dest_port, struct ip_addr *dest_addr, struct netif *slirpif); void slirp_tcp_update_listen2data(struct tcp_pcb *pcb); void slirp_tcp_close(struct tcp_pcb *pcb); err_t slirp_tcp_accept(void *arg, struct tcp_pcb *pcb, err_t err); err_t slirp_tcp_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); err_t slirp_tcp_sent(void *arg, struct tcp_pcb *pcb, u16_t len); /* Callback function registered into the UDP pcbs */ #define UDP_PERMANENT 1 int slirp_udp_bind(struct udp_pcb *pcb, struct netif *slirpif, int flags); void slirp_udp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port); /* lwipv6 keeps slirp listen items as args for netif_fd structure (as there is an open socket per forwarded port */ #define SLIRP_LISTEN_UDP 0x1000 #define SLIRP_LISTEN_TCP 0x2000 #define SLIRP_LISTEN_UNIXSTREAM 0x3000 #define SLIRP_LISTEN_TYPEMASK 0x7000 #define SLIRP_LISTEN_ONCE 0x8000 int lwip_slirp_listen_add(struct netif *slirpif, struct ip_addr *dest, int destport, void *src, int srcport, int flags); int lwip_slirp_listen_del(struct netif *slirpif, struct ip_addr *dest, int destport, void *src, int srcport, int flags); #endif #endif lwipv6-1.5a/lwip-v6/src/include/lwip/dhcp.h.no0000644000175000017500000001615711671615005020232 0ustar renzorenzo/** @file */ #ifndef __LWIP_DHCP_H__ #define __LWIP_DHCP_H__ #include "lwip/opt.h" #include "lwip/netif.h" #include "lwip/udp.h" /** period (in seconds) of the application calling dhcp_coarse_tmr() */ #define DHCP_COARSE_TIMER_SECS 60 /** period (in milliseconds) of the application calling dhcp_fine_tmr() */ #define DHCP_FINE_TIMER_MSECS 500 struct dhcp { /** current DHCP state machine state */ u8_t state; /** retries of current request */ u8_t tries; /** transaction identifier of last sent request */ u32_t xid; /** our connection to the DHCP server */ struct udp_pcb *pcb; /** (first) pbuf of incoming msg */ struct pbuf *p; /** incoming msg */ struct dhcp_msg *msg_in; /** incoming msg options */ struct dhcp_msg *options_in; /** ingoing msg options length */ u16_t options_in_len; struct pbuf *p_out; /* pbuf of outcoming msg */ struct dhcp_msg *msg_out; /* outgoing msg */ u16_t options_out_len; /* outgoing msg options length */ u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */ u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */ u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */ struct ip_addr server_ip_addr; /* dhcp server address that offered this lease */ struct ip_addr offered_ip_addr; struct ip_addr offered_sn_mask; struct ip_addr offered_gw_addr; struct ip_addr offered_bc_addr; #define DHCP_MAX_DNS 2 u32_t dns_count; /* actual number of DNS servers obtained */ struct ip_addr offered_dns_addr[DHCP_MAX_DNS]; /* DNS server addresses */ u32_t offered_t0_lease; /* lease period (in seconds) */ u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */ u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */ /** Patch #1308 * TODO: See dhcp.c "TODO"s */ #if 0 struct ip_addr offered_si_addr; u8_t *boot_file_name; #endif }; /* MUST be compiled with "pack structs" or equivalent! */ #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/bpstruct.h" #endif PACK_STRUCT_BEGIN /** minimum set of fields of any DHCP message */ struct dhcp_msg { PACK_STRUCT_FIELD(u8_t op); PACK_STRUCT_FIELD(u8_t htype); PACK_STRUCT_FIELD(u8_t hlen); PACK_STRUCT_FIELD(u8_t hops); PACK_STRUCT_FIELD(u32_t xid); PACK_STRUCT_FIELD(u16_t secs); PACK_STRUCT_FIELD(u16_t flags); PACK_STRUCT_FIELD(struct ip_addr ciaddr); PACK_STRUCT_FIELD(struct ip_addr yiaddr); PACK_STRUCT_FIELD(struct ip_addr siaddr); PACK_STRUCT_FIELD(struct ip_addr giaddr); #define DHCP_CHADDR_LEN 16U PACK_STRUCT_FIELD(u8_t chaddr[DHCP_CHADDR_LEN]); #define DHCP_SNAME_LEN 64U PACK_STRUCT_FIELD(u8_t sname[DHCP_SNAME_LEN]); #define DHCP_FILE_LEN 128U PACK_STRUCT_FIELD(u8_t file[DHCP_FILE_LEN]); PACK_STRUCT_FIELD(u32_t cookie); #define DHCP_MIN_OPTIONS_LEN 68U /** make sure user does not configure this too small */ #if ((defined(DHCP_OPTIONS_LEN)) && (DHCP_OPTIONS_LEN < DHCP_MIN_OPTIONS_LEN)) # undef DHCP_OPTIONS_LEN #endif /** allow this to be configured in lwipopts.h, but not too small */ #if (!defined(DHCP_OPTIONS_LEN)) /** set this to be sufficient for your options in outgoing DHCP msgs */ # define DHCP_OPTIONS_LEN DHCP_MIN_OPTIONS_LEN #endif PACK_STRUCT_FIELD(u8_t options[DHCP_OPTIONS_LEN]); } PACK_STRUCT_STRUCT; PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif /** start DHCP configuration */ err_t dhcp_start(struct netif *netif); /** enforce early lease renewal (not needed normally)*/ err_t dhcp_renew(struct netif *netif); /** release the DHCP lease, usually called before dhcp_stop()*/ err_t dhcp_release(struct netif *netif); /** stop DHCP configuration */ void dhcp_stop(struct netif *netif); /** inform server of our manual IP address */ void dhcp_inform(struct netif *netif); /** if enabled, check whether the offered IP address is not in use, using ARP */ #if DHCP_DOES_ARP_CHECK void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr); #endif /** to be called every minute */ void dhcp_coarse_tmr(void); /** to be called every half second */ void dhcp_fine_tmr(void); /** DHCP message item offsets and length */ #define DHCP_MSG_OFS (UDP_DATA_OFS) #define DHCP_OP_OFS (DHCP_MSG_OFS + 0) #define DHCP_HTYPE_OFS (DHCP_MSG_OFS + 1) #define DHCP_HLEN_OFS (DHCP_MSG_OFS + 2) #define DHCP_HOPS_OFS (DHCP_MSG_OFS + 3) #define DHCP_XID_OFS (DHCP_MSG_OFS + 4) #define DHCP_SECS_OFS (DHCP_MSG_OFS + 8) #define DHCP_FLAGS_OFS (DHCP_MSG_OFS + 10) #define DHCP_CIADDR_OFS (DHCP_MSG_OFS + 12) #define DHCP_YIADDR_OFS (DHCP_MSG_OFS + 16) #define DHCP_SIADDR_OFS (DHCP_MSG_OFS + 20) #define DHCP_GIADDR_OFS (DHCP_MSG_OFS + 24) #define DHCP_CHADDR_OFS (DHCP_MSG_OFS + 28) #define DHCP_SNAME_OFS (DHCP_MSG_OFS + 44) #define DHCP_FILE_OFS (DHCP_MSG_OFS + 108) #define DHCP_MSG_LEN 236 #define DHCP_COOKIE_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN) #define DHCP_OPTIONS_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN + 4) #define DHCP_CLIENT_PORT 68 #define DHCP_SERVER_PORT 67 /** DHCP client states */ #define DHCP_REQUESTING 1 #define DHCP_INIT 2 #define DHCP_REBOOTING 3 #define DHCP_REBINDING 4 #define DHCP_RENEWING 5 #define DHCP_SELECTING 6 #define DHCP_INFORMING 7 #define DHCP_CHECKING 8 #define DHCP_PERMANENT 9 #define DHCP_BOUND 10 /** not yet implemented #define DHCP_RELEASING 11 */ #define DHCP_BACKING_OFF 12 #define DHCP_OFF 13 #define DHCP_BOOTREQUEST 1 #define DHCP_BOOTREPLY 2 #define DHCP_DISCOVER 1 #define DHCP_OFFER 2 #define DHCP_REQUEST 3 #define DHCP_DECLINE 4 #define DHCP_ACK 5 #define DHCP_NAK 6 #define DHCP_RELEASE 7 #define DHCP_INFORM 8 #define DHCP_HTYPE_ETH 1 #define DHCP_HLEN_ETH 6 #define DHCP_BROADCAST_FLAG 15 #define DHCP_BROADCAST_MASK (1 << DHCP_FLAG_BROADCAST) /** BootP options */ #define DHCP_OPTION_PAD 0 #define DHCP_OPTION_SUBNET_MASK 1 /* RFC 2132 3.3 */ #define DHCP_OPTION_ROUTER 3 #define DHCP_OPTION_DNS_SERVER 6 #define DHCP_OPTION_HOSTNAME 12 #define DHCP_OPTION_IP_TTL 23 #define DHCP_OPTION_MTU 26 #define DHCP_OPTION_BROADCAST 28 #define DHCP_OPTION_TCP_TTL 37 #define DHCP_OPTION_END 255 /** DHCP options */ #define DHCP_OPTION_REQUESTED_IP 50 /* RFC 2132 9.1, requested IP address */ #define DHCP_OPTION_LEASE_TIME 51 /* RFC 2132 9.2, time in seconds, in 4 bytes */ #define DHCP_OPTION_OVERLOAD 52 /* RFC2132 9.3, use file and/or sname field for options */ #define DHCP_OPTION_MESSAGE_TYPE 53 /* RFC 2132 9.6, important for DHCP */ #define DHCP_OPTION_MESSAGE_TYPE_LEN 1 #define DHCP_OPTION_SERVER_ID 54 /* RFC 2132 9.7, server IP address */ #define DHCP_OPTION_PARAMETER_REQUEST_LIST 55 /* RFC 2132 9.8, requested option types */ #define DHCP_OPTION_MAX_MSG_SIZE 57 /* RFC 2132 9.10, message size accepted >= 576 */ #define DHCP_OPTION_MAX_MSG_SIZE_LEN 2 #define DHCP_OPTION_T1 58 /* T1 renewal time */ #define DHCP_OPTION_T2 59 /* T2 rebinding time */ #define DHCP_OPTION_CLIENT_ID 61 #define DHCP_OPTION_TFTP_SERVERNAME 66 #define DHCP_OPTION_BOOTFILE 67 /** possible combinations of overloading the file and sname fields with options */ #define DHCP_OVERLOAD_NONE 0 #define DHCP_OVERLOAD_FILE 1 #define DHCP_OVERLOAD_SNAME 2 #define DHCP_OVERLOAD_SNAME_FILE 3 #endif /*__LWIP_DHCP_H__*/ lwipv6-1.5a/lwip-v6/src/include/lwip/snmp.h0000644000175000017500000001365411671615005017655 0ustar renzorenzo/* * Copyright (c) 2001, 2002 Leon Woestenberg * Copyright (c) 2001, 2002 Axon Digital Design B.V., The Netherlands. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Leon Woestenberg * */ #ifndef __LWIP_SNMP_H__ #define __LWIP_SNMP_H__ #include "lwip/opt.h" /* SNMP support available? */ #if defined(LWIP_SNMP) && (LWIP_SNMP > 0) /* network interface */ void snmp_add_ifinoctets(unsigned long value); void snmp_inc_ifinucastpkts(void); void snmp_inc_ifinnucastpkts(void); void snmp_inc_ifindiscards(void); void snmp_add_ifoutoctets(unsigned long value); void snmp_inc_ifoutucastpkts(void); void snmp_inc_ifoutnucastpkts(void); void snmp_inc_ifoutdiscards(void); /* IP */ void snmp_inc_ipinreceives(void); void snmp_inc_ipindelivers(void); void snmp_inc_ipindiscards(void); void snmp_inc_ipoutdiscards(void); void snmp_inc_ipoutrequests(void); void snmp_inc_ipunknownprotos(void); void snmp_inc_ipnoroutes(void); void snmp_inc_ipforwdatagrams(void); /* ICMP */ void snmp_inc_icmpinmsgs(void); void snmp_inc_icmpinerrors(void); void snmp_inc_icmpindestunreachs(void); void snmp_inc_icmpintimeexcds(void); void snmp_inc_icmpinparmprobs(void); void snmp_inc_icmpinsrcquenchs(void); void snmp_inc_icmpinredirects(void); void snmp_inc_icmpinechos(void); void snmp_inc_icmpinechoreps(void); void snmp_inc_icmpintimestamps(void); void snmp_inc_icmpintimestampreps(void); void snmp_inc_icmpinaddrmasks(void); void snmp_inc_icmpinaddrmaskreps(void); void snmp_inc_icmpoutmsgs(void); void snmp_inc_icmpouterrors(void); void snmp_inc_icmpoutdestunreachs(void); void snmp_inc_icmpouttimeexcds(void); void snmp_inc_icmpoutparmprobs(void); void snmp_inc_icmpoutsrcquenchs(void); void snmp_inc_icmpoutredirects(void); void snmp_inc_icmpoutechos(void); void snmp_inc_icmpoutechoreps(void); void snmp_inc_icmpouttimestamps(void); void snmp_inc_icmpouttimestampreps(void); void snmp_inc_icmpoutaddrmasks(void); void snmp_inc_icmpoutaddrmaskreps(void); /* TCP */ void snmp_inc_tcpactiveopens(void); void snmp_inc_tcppassiveopens(void); void snmp_inc_tcpattemptfails(void); void snmp_inc_tcpestabresets(void); void snmp_inc_tcpcurrestab(void); void snmp_inc_tcpinsegs(void); void snmp_inc_tcpoutsegs(void); void snmp_inc_tcpretranssegs(void); void snmp_inc_tcpinerrs(void); void snmp_inc_tcpoutrsts(void); /* UDP */ void snmp_inc_udpindatagrams(void); void snmp_inc_udpnoports(void); void snmp_inc_udpinerrors(void); void snmp_inc_udpoutdatagrams(void); /* LWIP_SNMP support not available */ /* define everything to be empty */ #else /* network interface */ #define snmp_add_ifinoctets(value) #define snmp_inc_ifinucastpkts() #define snmp_inc_ifinnucastpkts() #define snmp_inc_ifindiscards() #define snmp_add_ifoutoctets(value) #define snmp_inc_ifoutucastpkts() #define snmp_inc_ifoutnucastpkts() #define snmp_inc_ifoutdiscards() /* IP */ #define snmp_inc_ipinreceives() #define snmp_inc_ipindelivers() #define snmp_inc_ipindiscards() #define snmp_inc_ipoutdiscards() #define snmp_inc_ipoutrequests() #define snmp_inc_ipunknownprotos() #define snmp_inc_ipnoroutes() #define snmp_inc_ipforwdatagrams() /* ICMP */ #define snmp_inc_icmpinmsgs() #define snmp_inc_icmpinerrors() #define snmp_inc_icmpindestunreachs() #define snmp_inc_icmpintimeexcds() #define snmp_inc_icmpinparmprobs() #define snmp_inc_icmpinsrcquenchs() #define snmp_inc_icmpinredirects() #define snmp_inc_icmpinechos() #define snmp_inc_icmpinechoreps() #define snmp_inc_icmpintimestamps() #define snmp_inc_icmpintimestampreps() #define snmp_inc_icmpinaddrmasks() #define snmp_inc_icmpinaddrmaskreps() #define snmp_inc_icmpoutmsgs() #define snmp_inc_icmpouterrors() #define snmp_inc_icmpoutdestunreachs() #define snmp_inc_icmpouttimeexcds() #define snmp_inc_icmpoutparmprobs() #define snmp_inc_icmpoutsrcquenchs() #define snmp_inc_icmpoutredirects() #define snmp_inc_icmpoutechos() #define snmp_inc_icmpoutechoreps() #define snmp_inc_icmpouttimestamps() #define snmp_inc_icmpouttimestampreps() #define snmp_inc_icmpoutaddrmasks() #define snmp_inc_icmpoutaddrmaskreps() /* TCP */ #define snmp_inc_tcpactiveopens() #define snmp_inc_tcppassiveopens() #define snmp_inc_tcpattemptfails() #define snmp_inc_tcpestabresets() #define snmp_inc_tcpcurrestab() #define snmp_inc_tcpinsegs() #define snmp_inc_tcpoutsegs() #define snmp_inc_tcpretranssegs() #define snmp_inc_tcpinerrs() #define snmp_inc_tcpoutrsts() /* UDP */ #define snmp_inc_udpindatagrams() #define snmp_inc_udpnoports() #define snmp_inc_udpinerrors() #define snmp_inc_udpoutdatagrams() #endif #endif /* __LWIP_SNMP_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/stack.h0000644000175000017500000000612711671615005020002 0ustar renzorenzo/* * Copyright (c) 2008 Renzo Davoli University of Bologna * * Author: Renzo Davoli * */ #ifndef __LWIP_STACK_H__ #define __LWIP_STACK_H__ #include "lwip/pbuf.h" #include "lwip/tcp.h" #include "lwip/netif.h" #include "lwip/ip_frag.h" #include "lwip/tcpip.h" #include struct pbuf; struct ip_route_list; /* needs def */ struct ip_addr_list; /* needs def */ #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION struct ip_reassbuf; #endif struct raw_pcb; #define packet_pcb raw_pcb struct udp_pcb; struct tcp_pcb; struct tcp_seg; /* needs def */ struct tcp_hdr; struct tcp_pcb; /* IP_ROUTE_POOL_SIZE IP_ADDR_POOL_SIZE IP_REASS_POOL_SIZE need defs*/ #define NETIF_POS2FD(stack,fpos) ((stack)->numif_pfd[(fpos)].fd) #define LWIP_STACK_FLAG_FORWARDING 0x1 #define LWIP_STACK_FLAG_USERFILTER 0x2 #define LWIP_STACK_FLAG_UF_NAT 0x10000 #if LWIP_USERFILTER struct stack_userfilter; #if LWIP_NAT struct stack_nat; #endif #endif /* Allows binding to TCP/UDP sockets below 1024 */ #define LWIP_CAP_NET_BIND_SERVICE 1<<10 /* Allow broadcasting, listen to multicast */ #define LWIP_CAP_NET_BROADCAST 1<<11 /* Allow interface configuration */ #define LWIP_CAP_NET_ADMIN 1<<12 /* Allow use of RAW sockets */ /* Allow use of PACKET sockets */ #define LWIP_CAP_NET_RAW 1<<13 struct stack { /* global */ u32_t stack_flags; #if LWIP_CAPABILITIES lwip_capfun stack_capfun; #endif /* lwip-v6/src/core/netif.c */ struct netif *netif_list; sys_sem_t netif_cleanup_mutex; int netif_pipe[2]; /* lwip-v6/src/core/ipv6/ip6.c */ u16_t ip_id; /* lwip-v6/src/core/ipv6/ip6_route.c */ struct ip_route_list *ip_route_head; #if IPv4_FRAGMENTATION || IPv6_FRAGMENTATION /* lwip-v6/src/core/ipv6/ip6_frag.c */ struct ip_reassbuf ip_reassembly_pools[IP_REASS_POOL_SIZE]; #endif /* lwip-v6/src/core/raw.c */ struct raw_pcb *raw_pcbs; /* lwip-v6/src/core/tcp_in.c */ struct tcp_seg inseg ; struct tcp_hdr *tcphdr ; u32_t seqno ; u32_t ackno ; u8_t flags ; u16_t tcplen ; u8_t recv_flags; struct pbuf *recv_data ; struct tcp_pcb *tcp_input_pcb; u16_t uniqueid; /* lwip-v6/src/core/packet.c */ u16_t active_pfpacket; struct packet_pcb *packet_pcbs; /* lwip-v6/src/core/udp.c */ struct udp_pcb *udp_pcbs; struct udp_pcb *pcb_cache; /* lwip-v6/src/core/tcp.c */ u32_t tcp_ticks; union tcp_listen_pcbs_t tcp_listen_pcbs; struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a */ struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */ u8_t tcp_timer; /* lwip-v6/src/api/tcpip.c */ sys_mbox_t stack_queue; sys_sem_t tcpip_init_sem; tcpip_handler tcpip_init_done; void * tcpip_init_done_arg; sys_sem_t tcpip_shutdown_sem; tcpip_handler tcpip_shutdown_done; void * tcpip_shutdown_done_arg; int tcpip_tcp_timer_active; /* lwip-v6/src/netif/loopif.c */ int netif_num[NETIF_NUMIF]; #if LWIP_USERFILTER struct stack_userfilter *stack_userfilter; #if LWIP_NAT struct stack_nat *stack_nat; #endif #endif }; #endif lwipv6-1.5a/lwip-v6/src/include/lwip/def.h0000644000175000017500000000353411671615005017432 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_DEF_H__ #define __LWIP_DEF_H__ /* this might define NULL already */ #include "arch/cc.h" #define LWIP_MAX(x , y) (x) > (y) ? (x) : (y) #define LWIP_MIN(x , y) (x) < (y) ? (x) : (y) #ifndef NULL #define NULL ((void *)0) #endif #endif /* __LWIP_DEF_H__ */ lwipv6-1.5a/lwip-v6/src/include/lwip/packet.h0000644000175000017500000000633311671615005020143 0ustar renzorenzo/* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */ #ifndef __LWIP_PACKET_H__ #define __LWIP_PACKET_H__ #include "lwip/arch.h" #include "lwip/pbuf.h" ///#include "lwip/inet.h" #include "lwip/ip.h" #include "lwip/raw.h" struct stack; //#include #include #define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ #define packet_pcb raw_pcb #define MEMP_PACKET_PCB MEMP_RAW_PCB /* The following functions is the application layer interface to the PACKET code. */ struct packet_pcb * packet_new (struct stack *stack, u16_t proto,u16_t dgramflag); void packet_remove (struct packet_pcb *pcb); err_t packet_bind (struct packet_pcb *pcb, struct ip_addr *ipaddr, u16_t protocol); err_t packet_connect (struct packet_pcb *pcb, struct ip_addr *ipaddr, u16_t protocol); void packet_recv (struct packet_pcb *pcb, void (* recv)(void *arg, struct packet_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t proto), void *recv_arg); err_t packet_sendto (struct packet_pcb *pcb, struct pbuf *p, struct ip_addr *ipaddr, u16_t protocol); err_t packet_send (struct packet_pcb *pcb, struct pbuf *p); /* The following functions are the lower layer interface to PACKET. */ u8_t packet_input (struct stack *stack, struct pbuf *p,struct sockaddr_ll *sll,u16_t link_header_size); void packet_init (struct stack *stack); #endif /* __LWIP_PACKET_H__ */ lwipv6-1.5a/lwip-v6/src/FILES0000644000175000017500000000106411671615010014702 0ustar renzorenzoapi/ - The code for the high-level wrapper API. Not needed if you use the lowel-level call-back/raw API. core/ - The core of the TPC/IP stack; protocol implementations, memory and buffer management, and the low-level raw API. include/ - lwIP include files. netif/ - Generic network interface device drivers are kept here, as well as the ARP module. userfilter/ - The TCP/IP stack's hooks system. For more information on the various subdirectories, check the FILES file in each directory. lwipv6-1.5a/lwip-v6/FILES0000644000175000017500000000021611671615010014111 0ustar renzorenzosrc/ - The source code for the lwIP TCP/IP stack. doc/ - The documentation for lwIP. See also the FILES file in each subdirectory. lwipv6-1.5a/lwip-v6/CHANGELOG0000644000175000017500000004344611671615010014552 0ustar renzorenzoFUTURE * TODO: The lwIP source code makes some invalid assumptions on processor word-length, storage sizes and alignment. See the mailing lists for problems with exoteric (/DSP) architectures showing these problems. We still have to fix some of these issues neatly. * TODO: the ARP layer is not protected against concurrent access. If you run from a multitasking OS, serialize access to ARP (called from your network device driver and from a timeout thread.) HISTORY 2005-02-04 Leon Woestenberg * tcp_out.c: Fixed uninitialized 'queue' referenced in memerr branch. * tcp_{out|in}.c: Applied patch fixing unaligned access. 2005-01-04 Leon Woestenberg * pbuf.c: Fixed missing semicolon after LWIP_DEBUG statement. 2005-01-03 Leon Woestenberg * udp.c: UDP pcb->recv() was called even when it was NULL. (STABLE-1_1_0) 2004-12-28 Leon Woestenberg * etharp.*: Disabled multiple packets on the ARP queue. This clashes with TCP queueing. 2004-11-28 Leon Woestenberg * etharp.*: Fixed race condition from ARP request to ARP timeout. Halved the ARP period, doubled the period counts. ETHARP_MAX_PENDING now should be at least 2. This prevents the counter from reaching 0 right away (which would allow too little time for ARP responses to be received). 2004-11-25 Leon Woestenberg * dhcp.c: Decline messages were not multicast but unicast. * etharp.c: ETHARP_CREATE is renamed to ETHARP_TRY_HARD. Do not try hard to insert arbitrary packet's source address, etharp_ip_input() now calls etharp_update() without ETHARP_TRY_HARD. etharp_query() now always DOES call ETHARP_TRY_HARD so that users querying an address will see it appear in the cache (DHCP could suffer from this when a server invalidly gave an in-use address.) * ipv4/ip_addr.h: Renamed ip_addr_maskcmp() to _netcmp() as we are comparing network addresses (identifiers), not the network masks themselves. * ipv4/ip_addr.c: ip_addr_isbroadcast() now checks that the given IP address actually belongs to the network of the given interface. 2004-11-24 Kieran Mansley * tcp.c: Increment pcb->snd_buf when ACK is received in SYN_SENT state. (STABLE-1_1_0-RC1) 2004-10-16 Kieran Mansley * tcp.c: Add code to tcp_recved() to send an ACK (window update) immediately, even if one is already pending, if the rcv_wnd is above a threshold (currently TCP_WND/2). This avoids waiting for a timer to expire to send a delayed ACK in order to open the window if the stack is only receiving data. 2004-09-12 Kieran Mansley * tcp*.*: Retransmit time-out handling improvement by Sam Jansen. 2004-08-20 Tony Mountifield * etharp.c: Make sure the first pbuf queued on an ARP entry is properly ref counted. 2004-07-27 Tony Mountifield * debug.h: Added (int) cast in LWIP_DEBUGF() to avoid compiler warnings about comparison. * pbuf.c: Stopped compiler complaining of empty if statement when LWIP_DEBUGF() empty. Closed an unclosed comment. * tcp.c: Stopped compiler complaining of empty if statement when LWIP_DEBUGF() empty. * ip.h Corrected IPH_TOS() macro: returns a byte, so doesn't need htons(). * inet.c: Added a couple of casts to quiet the compiler. No need to test isascii(c) before isdigit(c) or isxdigit(c). 2004-07-22 Tony Mountifield * inet.c: Made data types consistent in inet_ntoa(). Added casts for return values of checksum routines, to pacify compiler. * ip_frag.c, tcp_out.c, sockets.c, pbuf.c Small corrections to some debugging statements, to pacify compiler. 2004-07-21 Tony Mountifield * etharp.c: Removed spurious semicolon and added missing end-of-comment. * ethernetif.c Updated low_level_output() to match prototype for netif->linkoutput and changed low_level_input() similarly for consistency. * api_msg.c: Changed recv_raw() from int to u8_t, to match prototype of raw_recv() in raw.h and so avoid compiler error. * sockets.c: Added trivial (int) cast to keep compiler happier. * ip.c, netif.c Changed debug statements to use the tidier ip4_addrN() macros. (STABLE-1_0_0) ++ Changes: 2004-07-05 Leon Woestenberg * sockets.*: Restructured LWIP_PRIVATE_TIMEVAL. Make sure your cc.h file defines this either 1 or 0. If non-defined, defaults to 1. * .c: Added and includes where used. * etharp.c: Made some array indices unsigned. 2004-06-27 Leon Woestenberg * netif.*: Added netif_set_up()/down(). * dhcp.c: Changes to restart program flow. 2004-05-07 Leon Woestenberg * etharp.c: In find_entry(), instead of a list traversal per candidate, do a single-pass lookup for different candidates. Should exploit locality. 2004-04-29 Leon Woestenberg * tcp*.c: Cleaned up source comment documentation for Doxygen processing. * opt.h: ETHARP_ALWAYS_INSERT option removed to comply with ARP RFC. * etharp.c: update_arp_entry() only adds new ARP entries when adviced to by the caller. This deprecates the ETHARP_ALWAYS_INSERT overrule option. ++ Bug fixes: 2004-04-27 Leon Woestenberg * etharp.c: Applied patch of bug #8708 by Toni Mountifield with a solution suggested by Timmy Brolin. Fix for 32-bit processors that cannot access non-aligned 32-bit words, such as soms 32-bit TCP/IP header fields. Fix is to prefix the 14-bit Ethernet headers with two padding bytes. 2004-04-23 Leon Woestenberg * ip_addr.c: Fix in the ip_addr_isbroadcast() check. * etharp.c: Fixed the case where the packet that initiates the ARP request is not queued, and gets lost. Fixed the case where the packets destination address is already known; we now always queue the packet and perform an ARP request. (STABLE-0_7_0) ++ Bug fixes: * Fixed TCP bug for SYN_SENT to ESTABLISHED state transition. * Fixed TCP bug in dequeueing of FIN from out of order segment queue. * Fixed two possible NULL references in rare cases. (STABLE-0_6_6) ++ Bug fixes: * Fixed DHCP which did not include the IP address in DECLINE messages. ++ Changes: * etharp.c has been hauled over a bit. (STABLE-0_6_5) ++ Bug fixes: * Fixed TCP bug induced by bad window resizing with unidirectional TCP traffic. * Packets sent from ARP queue had invalid source hardware address. ++ Changes: * Pass-by ARP requests do now update the cache. ++ New features: * No longer dependent on ctype.h. * New socket options. * Raw IP pcb support. (STABLE-0_6_4) ++ Bug fixes: * Some debug formatters and casts fixed. * Numereous fixes in PPP. ++ Changes: * DEBUGF now is LWIP_DEBUGF * pbuf_dechain() has been re-enabled. * Mentioned the changed use of CVS branches in README. (STABLE-0_6_3) ++ Bug fixes: * Fixed pool pbuf memory leak in pbuf_alloc(). Occured if not enough PBUF_POOL pbufs for a packet pbuf chain. Reported by Savin Zlobec. * PBUF_POOL chains had their tot_len field not set for non-first pbufs. Fixed in pbuf_alloc(). ++ New features: * Added PPP stack contributed by Marc Boucher ++ Changes: * Now drops short packets for ICMP/UDP/TCP protocols. More robust. * ARP queueuing now queues the latest packet instead of the first. This is the RFC recommended behaviour, but can be overridden in lwipopts.h. (0.6.2) ++ Bugfixes: * TCP has been fixed to deal with the new use of the pbuf->ref counter. * DHCP dhcp_inform() crash bug fixed. ++ Changes: * Removed pbuf_pool_free_cache and pbuf_pool_alloc_cache. Also removed pbuf_refresh(). This has sped up pbuf pool operations considerably. Implemented by David Haas. (0.6.1) ++ New features: * The packet buffer implementation has been enhanced to support zero-copy and copy-on-demand for packet buffers which have their payloads in application-managed memory. Implemented by David Haas. Use PBUF_REF to make a pbuf refer to RAM. lwIP will use zero-copy if an outgoing packet can be directly sent on the link, or perform a copy-on-demand when necessary. The application can safely assume the packet is sent, and the RAM is available to the application directly after calling udp_send() or similar function. ++ Bugfixes: * ARP_QUEUEING should now correctly work for all cases, including PBUF_REF. Implemented by Leon Woestenberg. ++ Changes: * IP_ADDR_ANY is no longer a NULL pointer. Instead, it is a pointer to a '0.0.0.0' IP address. * The packet buffer implementation is changed. The pbuf->ref counter meaning has changed, and several pbuf functions have been adapted accordingly. * netif drivers have to be changed to set the hardware address length field that must be initialized correctly by the driver (hint: 6 for Ethernet MAC). See the contrib/ports/c16x cs8900 driver as a driver example. * netif's have a dhcp field that must be initialized to NULL by the driver. See the contrib/ports/c16x cs8900 driver as a driver example. (0.5.x) This file has been unmaintained up to 0.6.1. All changes are logged in CVS but have not been explained here. (0.5.3) Changes since version 0.5.2 ++ Bugfixes: * memp_malloc(MEMP_API_MSG) could fail with multiple application threads because it wasn't protected by semaphores. ++ Other changes: * struct ip_addr now packed. * The name of the time variable in arp.c has been changed to ctime to avoid conflicts with the time() function. (0.5.2) Changes since version 0.5.1 ++ New features: * A new TCP function, tcp_tmr(), now handles both TCP timers. ++ Bugfixes: * A bug in tcp_parseopt() could cause the stack to hang because of a malformed TCP option. * The address of new connections in the accept() function in the BSD socket library was not handled correctly. * pbuf_dechain() did not update the ->tot_len field of the tail. * Aborted TCP connections were not handled correctly in all situations. ++ Other changes: * All protocol header structs are now packed. * The ->len field in the tcp_seg structure now counts the actual amount of data, and does not add one for SYN and FIN segments. (0.5.1) Changes since version 0.5.0 ++ New features: * Possible to run as a user process under Linux. * Preliminary support for cross platform packed structs. * ARP timer now implemented. ++ Bugfixes: * TCP output queue length was badly initialized when opening connections. * TCP delayed ACKs were not sent correctly. * Explicit initialization of BSS segment variables. * read() in BSD socket library could drop data. * Problems with memory alignment. * Situations when all TCP buffers were used could lead to starvation. * TCP MSS option wasn't parsed correctly. * Problems with UDP checksum calculation. * IP multicast address tests had endianess problems. * ARP requests had wrong destination hardware address. ++ Other changes: * struct eth_addr changed from u16_t[3] array to u8_t[6]. * A ->linkoutput() member was added to struct netif. * TCP and UDP ->dest_* struct members where changed to ->remote_*. * ntoh* macros are now null definitions for big endian CPUs. (0.5.0) Changes since version 0.4.2 ++ New features: * Redesigned operating system emulation layer to make porting easier. * Better control over TCP output buffers. * Documenation added. ++ Bugfixes: * Locking issues in buffer management. * Bugfixes in the sequential API. * IP forwarding could cause memory leakage. This has been fixed. ++ Other changes: * Directory structure somewhat changed; the core/ tree has been collapsed. (0.4.2) Changes since version 0.4.1 ++ New features: * Experimental ARP implementation added. * Skeleton Ethernet driver added. * Experimental BSD socket API library added. ++ Bugfixes: * In very intense situations, memory leakage could occur. This has been fixed. ++ Other changes: * Variables named "data" and "code" have been renamed in order to avoid name conflicts in certain compilers. * Variable++ have in appliciable cases been translated to ++variable since some compilers generate better code in the latter case. (0.4.1) Changes since version 0.4 ++ New features: * TCP: Connection attempts time out earlier than data transmissions. Nagle algorithm implemented. Push flag set on the last segment in a burst. * UDP: experimental support for UDP-Lite extensions. ++ Bugfixes: * TCP: out of order segments were in some cases handled incorrectly, and this has now been fixed. Delayed acknowledgements was broken in 0.4, has now been fixed. Binding to an address that is in use now results in an error. Reset connections sometimes hung an application; this has been fixed. * Checksum calculation sometimes failed for chained pbufs with odd lengths. This has been fixed. * API: a lot of bug fixes in the API. The UDP API has been improved and tested. Error reporting and handling has been improved. Logical flaws and race conditions for incoming TCP connections has been found and removed. * Memory manager: alignment issues. Reallocating memory sometimes failed, this has been fixed. * Generic library: bcopy was flawed and has been fixed. ++ Other changes: * API: all datatypes has been changed from generic ones such as ints, to specified ones such as u16_t. Functions that return errors now have the correct type (err_t). * General: A lot of code cleaned up and debugging code removed. Many portability issues have been fixed. * The license was changed; the advertising clause was removed. * C64 port added. * Thanks: Huge thanks go to Dagan Galarneau, Horst Garnetzke, Petri Kosunen, Mikael Caleres, and Frits Wilmink for reporting and fixing bugs! (0.4) Changes since version 0.3.1 * Memory management has been radically changed; instead of allocating memory from a shared heap, memory for objects that are rapidly allocated and deallocated is now kept in pools. Allocation and deallocation from those memory pools is very fast. The shared heap is still present but is used less frequently. * The memory, memory pool, and packet buffer subsystems now support 4-, 2-, or 1-byte alignment. * "Out of memory" situations are handled in a more robust way. * Stack usage has been reduced. * Easier configuration of lwIP parameters such as memory usage, TTLs, statistics gathering, etc. All configuration parameters are now kept in a single header file "lwipopts.h". * The directory structure has been changed slightly so that all architecture specific files are kept under the src/arch hierarchy. * Error propagation has been improved, both in the protocol modules and in the API. * The code for the RTXC architecture has been implemented, tested and put to use. * Bugs have been found and corrected in the TCP, UDP, IP, API, and the Internet checksum modules. * Bugs related to porting between a 32-bit and a 16-bit architecture have been found and corrected. * The license has been changed slightly to conform more with the original BSD license, including the advertisement clause. (0.3.1) Changes since version 0.3 * Fix of a fatal bug in the buffer management. Pbufs with allocated RAM never returned the RAM when the pbuf was deallocated. * TCP congestion control, window updates and retransmissions did not work correctly. This has now been fixed. * Bugfixes in the API. (0.3) Changes since version 0.2 * New and improved directory structure. All include files are now kept in a dedicated include/ directory. * The API now has proper error handling. A new function, netconn_err(), now returns an error code for the connection in case of errors. * Improvements in the memory management subsystem. The system now keeps a pointer to the lowest free memory block. A new function, mem_malloc2() tries to allocate memory once, and if it fails tries to free some memory and retry the allocation. * Much testing has been done with limited memory configurations. lwIP now does a better job when overloaded. * Some bugfixes and improvements to the buffer (pbuf) subsystem. * Many bugfixes in the TCP code: - Fixed a bug in tcp_close(). - The TCP receive window was incorrectly closed when out of sequence segments was received. This has been fixed. - Connections are now timed-out of the FIN-WAIT-2 state. - The initial congestion window could in some cases be too large. This has been fixed. - The retransmission queue could in some cases be screwed up. This has been fixed. - TCP RST flag now handled correctly. - Out of sequence data was in some cases never delivered to the application. This has been fixed. - Retransmitted segments now contain the correct acknowledgment number and advertised window. - TCP retransmission timeout backoffs are not correctly computed (ala BSD). After a number of retransmissions, TCP now gives up the connection. * TCP connections now are kept on three lists, one for active connections, one for listening connections, and one for connections that are in TIME-WAIT. This greatly speeds up the fast timeout processing for sending delayed ACKs. * TCP now provides proper feedback to the application when a connection has been successfully set up. * More comments have been added to the code. The code has also been somewhat cleaned up. (0.2) Initial public release. lwipv6-1.5a/configure0000755000175000017500000152437611671615055013763 0ustar renzorenzo#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68 for lwipv6 1.5a. # # Report bugs to . # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and $0: info@v2.cs.unibo.it about your system, including any $0: error possibly output before this message. Then install $0: a modern shell, or manually run the script under such a $0: shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='lwipv6' PACKAGE_TARNAME='lwipv6' PACKAGE_VERSION='1.5a' PACKAGE_STRING='lwipv6 1.5a' PACKAGE_BUGREPORT='info@v2.cs.unibo.it' PACKAGE_URL='' ac_unique_file="lwip-contrib/ports/unix/include/lwipv6.h" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_dependency_tracking enable_shared enable_static with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures lwipv6 1.5a to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/lwipv6] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of lwipv6 1.5a:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] build static libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to . _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF lwipv6 configure 1.5a generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ---------------------------------- ## ## Report this to info@v2.cs.unibo.it ## ## ---------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ # Finds an unsigned integer type with width BITS, setting cache variable VAR # accordingly. ac_fn_c_find_uintX_t () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 $as_echo_n "checking for uint$2_t... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" # Order is important - never check a type that is potentially smaller # than half of the expected target width. for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : case $ac_type in #( uint$2_t) : eval "$3=yes" ;; #( *) : eval "$3=\$ac_type" ;; esac fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if eval test \"x\$"$3"\" = x"no"; then : else break fi done fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_find_uintX_t cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by lwipv6 $as_me 1.5a, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='lwipv6' VERSION='1.5a' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_config_headers="$ac_config_headers config.h" # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4.2' macro_revision='1.3337' ltmain="$ac_aux_dir/ltmain.sh" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&5 # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&5 elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' if test -n "$lt_prog_compiler_pic"; then lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ F* | *Sun*Fortran*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; *Intel*\ [CF]*Compiler*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; *Portland\ Group*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&6; } hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*' # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[23].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[01]* | freebsdelf3.[01]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&6; } if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&6; } test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: # Checks for libraries. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcap_open_offline in -lpcap" >&5 $as_echo_n "checking for pcap_open_offline in -lpcap... " >&6; } if ${ac_cv_lib_pcap_pcap_open_offline+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpcap $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pcap_open_offline (); int main () { return pcap_open_offline (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pcap_pcap_open_offline=yes else ac_cv_lib_pcap_pcap_open_offline=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcap_pcap_open_offline" >&5 $as_echo "$ac_cv_lib_pcap_pcap_open_offline" >&6; } if test "x$ac_cv_lib_pcap_pcap_open_offline" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPCAP 1 _ACEOF LIBS="-lpcap $LIBS" else as_fn_error $? "libpcap missing" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for forkpty in -lutil" >&5 $as_echo_n "checking for forkpty in -lutil... " >&6; } if ${ac_cv_lib_util_forkpty+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lutil $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char forkpty (); int main () { return forkpty (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_util_forkpty=yes else ac_cv_lib_util_forkpty=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_forkpty" >&5 $as_echo "$ac_cv_lib_util_forkpty" >&6; } if test "x$ac_cv_lib_util_forkpty" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBUTIL 1 _ACEOF LIBS="-lutil $LIBS" else as_fn_error $? "libutil missing" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for vde_close in -lvdeplug" >&5 $as_echo_n "checking for vde_close in -lvdeplug... " >&6; } if ${ac_cv_lib_vdeplug_vde_close+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lvdeplug $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char vde_close (); int main () { return vde_close (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_vdeplug_vde_close=yes else ac_cv_lib_vdeplug_vde_close=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_vdeplug_vde_close" >&5 $as_echo "$ac_cv_lib_vdeplug_vde_close" >&6; } if test "x$ac_cv_lib_vdeplug_vde_close" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBVDEPLUG 1 _ACEOF LIBS="-lvdeplug $LIBS" else as_fn_error $? "libvdeplug missing" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5 $as_echo_n "checking for pthread_create in -lpthread... " >&6; } if ${ac_cv_lib_pthread_pthread_create+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pthread_create (); int main () { return pthread_create (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_pthread_pthread_create=yes else ac_cv_lib_pthread_pthread_create=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_pthread_create" >&5 $as_echo "$ac_cv_lib_pthread_pthread_create" >&6; } if test "x$ac_cv_lib_pthread_pthread_create" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBPTHREAD 1 _ACEOF LIBS="-lpthread $LIBS" else as_fn_error $? "libpthread missing" "$LINENO" 5 fi # Checks for header files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi for ac_header in arpa/inet.h fcntl.h limits.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h termios.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Checks for typedefs, structures, and compiler characteristics. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99" >&5 $as_echo_n "checking for stdbool.h that conforms to C99... " >&6; } if ${ac_cv_header_stdbool_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #ifndef bool "error: bool is not defined" #endif #ifndef false "error: false is not defined" #endif #if false "error: false is not 0" #endif #ifndef true "error: true is not defined" #endif #if true != 1 "error: true is not 1" #endif #ifndef __bool_true_false_are_defined "error: __bool_true_false_are_defined is not defined" #endif struct s { _Bool s: 1; _Bool t; } s; char a[true == 1 ? 1 : -1]; char b[false == 0 ? 1 : -1]; char c[__bool_true_false_are_defined == 1 ? 1 : -1]; char d[(bool) 0.5 == true ? 1 : -1]; /* See body of main program for 'e'. */ char f[(_Bool) 0.0 == false ? 1 : -1]; char g[true]; char h[sizeof (_Bool)]; char i[sizeof s.t]; enum { j = false, k = true, l = false * true, m = true * 256 }; /* The following fails for HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ _Bool n[m]; char o[sizeof n == m * sizeof n[0] ? 1 : -1]; char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; /* Catch a bug in an HP-UX C compiler. See http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html */ _Bool q = true; _Bool *pq = &q; int main () { bool e = &s; *pq |= q; *pq |= ! q; /* Refer to every declared value, to avoid compiler optimizations. */ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + !m + !n + !o + !p + !q + !pq); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdbool_h=yes else ac_cv_header_stdbool_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE__BOOL 1 _ACEOF fi if test $ac_cv_header_stdbool_h = yes; then $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then $as_echo "#define const /**/" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" if test "x$ac_cv_type_off_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define off_t long int _ACEOF fi ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" if test "x$ac_cv_type_pid_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define pid_t int _ACEOF fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" if test "x$ac_cv_type_size_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define size_t unsigned int _ACEOF fi ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" if test "x$ac_cv_type_ssize_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define ssize_t int _ACEOF fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then $as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) $as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF #define uint32_t $ac_cv_c_uint32_t _ACEOF ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 $as_echo_n "checking for working volatile... " >&6; } if ${ac_cv_c_volatile+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { volatile int x; int * volatile y = (int *) 0; return !x && !y; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_volatile=yes else ac_cv_c_volatile=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 $as_echo "$ac_cv_c_volatile" >&6; } if test $ac_cv_c_volatile = no; then $as_echo "#define volatile /**/" >>confdefs.h fi # Checks for library functions. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for error_at_line" >&5 $as_echo_n "checking for error_at_line... " >&6; } if ${ac_cv_lib_error_at_line+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { error_at_line (0, 0, "", 0, "an error occurred"); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_error_at_line=yes else ac_cv_lib_error_at_line=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_error_at_line" >&5 $as_echo "$ac_cv_lib_error_at_line" >&6; } if test $ac_cv_lib_error_at_line = no; then case " $LIBOBJS " in *" error.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS error.$ac_objext" ;; esac fi if test $ac_cv_c_compiler_gnu = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 $as_echo_n "checking whether $CC needs -traditional... " >&6; } if ${ac_cv_prog_gcc_traditional+:} false; then : $as_echo_n "(cached) " >&6 else ac_pattern="Autoconf.*'x'" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then : ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 $as_echo "$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_malloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *malloc (); #endif int main () { return ! malloc (0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else ac_cv_func_malloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } if test $ac_cv_func_malloc_0_nonnull = yes; then : $as_echo "#define HAVE_MALLOC 1" >>confdefs.h else $as_echo "#define HAVE_MALLOC 0" >>confdefs.h case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS malloc.$ac_objext" ;; esac $as_echo "#define malloc rpl_malloc" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5 $as_echo_n "checking for working memcmp... " >&6; } if ${ac_cv_func_memcmp_working+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_memcmp_working=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int main () { /* Some versions of memcmp are not 8-bit clean. */ char c0 = '\100', c1 = '\200', c2 = '\201'; if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) return 1; /* The Next x86 OpenStep bug shows up only when comparing 16 bytes or more and with at least one buffer not starting on a 4-byte boundary. William Lewis provided this test program. */ { char foo[21]; char bar[21]; int i; for (i = 0; i < 4; i++) { char *a = foo + i; char *b = bar + i; strcpy (a, "--------01111111"); strcpy (b, "--------10000000"); if (memcmp (a, b, 16) >= 0) return 1; } return 0; } ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_memcmp_working=yes else ac_cv_func_memcmp_working=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_memcmp_working" >&5 $as_echo "$ac_cv_func_memcmp_working" >&6; } test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in *" memcmp.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" ;; esac for ac_header in stdlib.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDLIB_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible realloc" >&5 $as_echo_n "checking for GNU libc compatible realloc... " >&6; } if ${ac_cv_func_realloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : ac_cv_func_realloc_0_nonnull=no else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include #else char *realloc (); #endif int main () { return ! realloc (0, 0); ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_realloc_0_nonnull=yes else ac_cv_func_realloc_0_nonnull=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_realloc_0_nonnull" >&5 $as_echo "$ac_cv_func_realloc_0_nonnull" >&6; } if test $ac_cv_func_realloc_0_nonnull = yes; then : $as_echo "#define HAVE_REALLOC 1" >>confdefs.h else $as_echo "#define HAVE_REALLOC 0" >>confdefs.h case " $LIBOBJS " in *" realloc.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS realloc.$ac_objext" ;; esac $as_echo "#define realloc rpl_realloc" >>confdefs.h fi for ac_header in sys/select.h sys/socket.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for select" >&5 $as_echo_n "checking types of arguments for select... " >&6; } if ${ac_cv_func_select_args+:} false; then : $as_echo_n "(cached) " >&6 else for ac_arg234 in 'fd_set *' 'int *' 'void *'; do for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #ifdef HAVE_SYS_SELECT_H # include #endif #ifdef HAVE_SYS_SOCKET_H # include #endif int main () { extern int select ($ac_arg1, $ac_arg234, $ac_arg234, $ac_arg234, $ac_arg5); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done done done # Provide a safe default value. : "${ac_cv_func_select_args=int,int *,struct timeval *}" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_select_args" >&5 $as_echo "$ac_cv_func_select_args" >&6; } ac_save_IFS=$IFS; IFS=',' set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` IFS=$ac_save_IFS shift cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG1 $1 _ACEOF cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG234 ($2) _ACEOF cat >>confdefs.h <<_ACEOF #define SELECT_TYPE_ARG5 ($3) _ACEOF rm -f conftest* for ac_func in vprintf do : ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" if test "x$ac_cv_func_vprintf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VPRINTF 1 _ACEOF ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" if test "x$ac_cv_func__doprnt" = xyes; then : $as_echo "#define HAVE_DOPRNT 1" >>confdefs.h fi fi done for ac_func in bzero gethostbyname gettimeofday inet_ntoa isascii memset select socket strchr strerror strtol do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done ac_config_files="$ac_config_files Makefile lwip-contrib/ports/unix/proj/lib/Makefile" #AC_CONFIG_FILES([Makefile # lwip-contrib/ports/unix/proj/lib/Makefile # lwip-contrib/ports/unix/proj/minimal/Makefile # lwip-contrib/ports/unix/proj/unixsim/Makefile]) cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by lwipv6 $as_me 1.5a, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ lwipv6 config.status 1.5a configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ PATH_SEPARATOR \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "lwip-contrib/ports/unix/proj/lib/Makefile") CONFIG_FILES="$CONFIG_FILES lwip-contrib/ports/unix/proj/lib/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The PATH separator for the build system. PATH_SEPARATOR=$lt_PATH_SEPARATOR # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # Do we need the "lib" prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # Set to "yes" if using the -LDIR flag during linking hardcodes DIR # into the resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR # into the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi lwipv6-1.5a/configure.ac0000644000175000017500000000326511671615010014315 0ustar renzorenzo# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ(2.60) AC_INIT([lwipv6], [1.5a], [info@v2.cs.unibo.it]) AM_INIT_AUTOMAKE([foreign dist-bzip2]) AC_CONFIG_SRCDIR([lwip-contrib/ports/unix/include/lwipv6.h]) AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_MAKE_SET AC_PROG_LIBTOOL # Checks for libraries. AC_CHECK_LIB([pcap], [pcap_open_offline],,AC_MSG_ERROR([libpcap missing])) AC_CHECK_LIB([util], [forkpty],,AC_MSG_ERROR([libutil missing])) AC_CHECK_LIB([vdeplug], [vde_close],,AC_MSG_ERROR([libvdeplug missing])) AC_CHECK_LIB([pthread], [pthread_create],,AC_MSG_ERROR([libpthread missing])) # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h stdint.h stdlib.h string.h sys/ioctl.h sys/socket.h sys/time.h termios.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_HEADER_STDBOOL AC_C_CONST AC_C_INLINE AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_HEADER_TIME AC_TYPE_UINT32_T AC_C_VOLATILE # Checks for library functions. AC_FUNC_ERROR_AT_LINE AC_PROG_GCC_TRADITIONAL AC_FUNC_MALLOC AC_FUNC_MEMCMP AC_FUNC_REALLOC AC_FUNC_SELECT_ARGTYPES AC_FUNC_VPRINTF AC_CHECK_FUNCS([bzero gethostbyname gettimeofday inet_ntoa isascii memset select socket strchr strerror strtol]) AC_CONFIG_FILES([Makefile lwip-contrib/ports/unix/proj/lib/Makefile]) #AC_CONFIG_FILES([Makefile # lwip-contrib/ports/unix/proj/lib/Makefile # lwip-contrib/ports/unix/proj/minimal/Makefile # lwip-contrib/ports/unix/proj/unixsim/Makefile]) AC_OUTPUT lwipv6-1.5a/missing0000755000175000017500000002623311671615056013440 0ustar renzorenzo#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: lwipv6-1.5a/aclocal.m40000644000175000017500000123756411671615054013713 0ustar renzorenzo# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as # published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2011 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi _LT_EOF ;; esac _LT_PROG_LTMAIN # We use sed instead of cat because bash on DJGPP gets confused if # if finds mixed CR/LF and LF-only lines. Since sed operates in # text mode, it properly converts lines to CR/LF. This bash problem # is reportedly fixed, but why not run on old versions too? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Go], [_LT_LANG(GO)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG m4_ifndef([AC_PROG_GO], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_GO. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_GO], [AC_LANG_PUSH(Go)dnl AC_ARG_VAR([GOC], [Go compiler command])dnl AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl _AC_ARG_VAR_LDFLAGS()dnl AC_CHECK_TOOL(GOC, gccgo) if test -z "$GOC"; then if test -n "$ac_tool_prefix"; then AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) fi fi if test -z "$GOC"; then AC_CHECK_PROG(GOC, gccgo, gccgo, false) fi ])#m4_defun ])#m4_ifndef # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([AC_PROG_GO], [LT_LANG(GO)], [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? # If there is a non-empty error log, and "single_module" # appears in it, assume the flag caused a linker warning if test -s conftest.err && $GREP single_module conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD # Otherwise, if the output was created with a 0 exit code from # the compiler, it worked. elif test -f libconftest.dylib && test $_lt_result -eq 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -s conftest.err && $GREP force_load conftest.err; then cat conftest.err >&AS_MESSAGE_LOG_FD elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES([TAG]) # --------------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; *-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) case $host in i?86-*-solaris*) LD="${LD-ld} -m elf_x86_64" ;; sparc*-*-solaris*) LD="${LD-ld} -m elf64_sparc" ;; esac # GNU ld 2.21 introduced _sol2 emulations. Use them if available. if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then LD="${LD-ld}_sol2" fi ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; os2*) # The test takes a long time on OS/2. lt_cv_sys_max_cmd_len=8192 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux # correct to gnu/linux during the next big refactor need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[23]].*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2.*) shlibpath_overrides_runpath=yes ;; freebsd3.[[01]]* | freebsdelf3.[[01]]*) shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux # correct to gnu/linux during the next big refactor else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.3*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux # correct to gnu/linux during the next big refactor need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux # correct to gnu/linux during the next big refactor library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[List of archive names. First name is the real one, the rest are links. The last name is the one that the linker finds with -lNAME]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be glibc/ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" fi ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ F* | *Sun*Fortran*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; *Intel*\ [[CF]]*Compiler*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; *Portland\ Group*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2.*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd2.*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF package foo func foo() { } _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; *\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_GO_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Go compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GO_CONFIG], [AC_REQUIRE([LT_PROG_GO])dnl AC_LANG_SAVE # Source file extension for Go test sources. ac_ext=go # Object file extension for compiled Go test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="package main; func main() { }" # Code to be used in simple link tests lt_simple_link_test_code='package main; func main() { }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GOC-"gccgo"} CFLAGS=$GOFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # Go did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GO_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_GO # ---------- AC_DEFUN([LT_PROG_GO], [AC_CHECK_TOOL(GOC, gccgo,) ]) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS # Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [lt_p=${PACKAGE-default} case $withval in yes|no) pic_mode=$withval ;; *) pic_mode=default # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for lt_pkg in $withval; do IFS="$lt_save_ifs" if test "X$lt_pkg" = "X$lt_p"; then pic_mode=yes fi done IFS="$lt_save_ifs" ;; esac], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) # ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) # ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3337 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4.2]) m4_define([LT_PACKAGE_REVISION], [1.3337]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4.2' macro_revision='1.3337' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) # lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 10 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR lwipv6-1.5a/Makefile.am0000644000175000017500000000046711671615010014064 0ustar renzorenzoEXTRA_DIST = README.LICENSE LWIPv6_Programming_Guide SUBDIRS = lwip-contrib/ports/unix/proj/lib extraclean: distclean rm -rf ltmain.sh config.sub config.guess aclocal.m4 configure config.h.in autom4te.cache install-sh missing compile depcomp Makefile.in rm -rf lwip-contrib/ports/unix/proj/lib/Makefile.in lwipv6-1.5a/INSTALL0000644000175000017500000000122011671615010013045 0ustar renzorenzo Requirements ============ Operating System: Any GNU/Linux distribution. Linux kernel 2.6.X with Tuntap driver. Development tools: GNU C Compiler GNU Make automake autoconf Subversion (client) Patch Further tools: iproute tools (if you are going to use LwIPv6 with View-OS) tunctl (for Tuntap driver configuration) vde (if you are going to use LwIPv6 with VDE) Installation ============ Move inside LwIPv6 source directory and type: $ autoreconf --install $ ./configure $ make You can install the library with the following command: # make install lwipv6-1.5a/Makefile.in0000644000175000017500000005415111671615056014106 0ustar renzorenzo# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure COPYING INSTALL config.guess \ config.sub depcomp install-sh ltmain.sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz $(distdir).tar.bz2 GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GREP = @GREP@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = README.LICENSE LWIPv6_Programming_Guide SUBDIRS = lwip-contrib/ports/unix/proj/lib all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @$(am__cd) '$(distuninstallcheck_dir)' \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile config.h installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ ctags-recursive install-am install-strip tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-generic distclean-hdr \ distclean-libtool distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-recursive uninstall uninstall-am extraclean: distclean rm -rf ltmain.sh config.sub config.guess aclocal.m4 configure config.h.in autom4te.cache install-sh missing compile depcomp Makefile.in rm -rf lwip-contrib/ports/unix/proj/lib/Makefile.in # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: lwipv6-1.5a/depcomp0000755000175000017500000004426711671615056013425 0ustar renzorenzo#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free # Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u="sed s,\\\\\\\\,/,g" depmode=msvisualcpp fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: lwipv6-1.5a/README.LICENSE0000644000175000017500000000403211671615010013761 0ustar renzorenzoLWIPV6 has been released under the GPL. Code taken from LwIP has been used inside Ale4NET. The original licence provided by lwip team is compatible with the GPL thus it was possible to include their code. For the sake of completeness and correctness you can find here the original license. When code has been included all the original headers in the source files have been kept (just after the header for the new license). LwIP: ---------------------------- /* * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels * */