EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Questionable code in aToIPAddr
From: Andrew Johnson <[email protected]>
To: Eric Norum <[email protected]>
Cc: EPICS Tech-Talk <[email protected]>
Date: Mon, 3 Jun 2013 22:30:18 -0500 (CDT)
Hi Eric,

Take a look at this commit to the 3.15 branch from Michael; I think it probably does what you're after and a bit more:


On Jun 3, 2013, at 7:38 PM, Eric Norum <[email protected]> wrote:

I have a LAN/GPIB adapter that (stupidly) uses its MAC address as its hostname when getting an address from a DHCP server.   I find that I can't use such an address with the ASYN vxi11Configure command:
vxi11Configure("L0", "0-50-c2-83-43-92.dhcp.lbl.gov", 0, "0.0", "gpib0", 0, 0)

The problem is that the aToIPAddr routine sees a number as the first part of an address and gives up.   I think that the fix is to remove the first test after the first sscanf:
epicsShareFunc int epicsShareAPI
    aToIPAddr(const char *pAddrString, unsigned short defaultPort, struct sockaddr_in *pIP)
{
    int status;
    unsigned short addr[4];
    unsigned long rawAddr;
    char hostName[512]; /* !! change n elements here requires change in format below !! */
    unsigned short port;
    struct in_addr ina;

    /*
     * dotted ip addresses
     */
    status = sscanf (pAddrString, " %hu.%hu.%hu.%hu:%hu",
            addr, addr+1u, addr+2u, addr+3u, &port);
    if (status>0) {     <<<<<< I THINK THAT THIS TEST SHOULD JUST BE REMOVED
        if (status>=4) {
            if ( addrArrayToUL ( addr, NELEMENTS ( addr ), &ina ) < 0 ) {
                return -1;
            }
            if (status==4) {
                port = defaultPort;
            }
            return initIPAddr (ina, port, pIP);
        }
        else { <<<<<<AND THESE LINES, TOO
            return -1; <<<<<<AND THESE LINES, TOO
        } <<<<<<AND THESE LINES, TOO
    }

-- 
Eric Norum
[email protected]


References:
Questionable code in aToIPAddr Eric Norum

Navigate by Date:
Prev: RE: SEQ with dynamic assignment of PV in array variable Mark Rivers
Next: epicsqt 2.5.0 released Andrew Rhyder
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Questionable code in aToIPAddr Eric Norum
Next: epicsqt 2.5.0 released Andrew Rhyder
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·