2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * Shim library which should be LD_PRELOADed before running applications 2N/A * that interact with NCA but do not explicitly use the AF_NCA family. 2N/A * This library overloads AF_INET's version of bind(3SOCKET) with AF_NCA's 2N/A * version. The new version of bind checks to see if that the port is one 2N/A * NCA is listening on, closes the socket(3SOCKET), and opens a new one 2N/A * the family AF_NCA. Afterwards, the real bind(3SOCKET) is called 2N/A * descriptors, etc. * 2N/A * It is used to represent an address NCA is willing to handle. 2N/A * It loads all NCA addresses from a configuration file. A NCA address 2N/A * entry is: ncaport=IPaddress:port. The line above can be repeatly for other 2N/A * addresses. If IPaddress is '*', then it is translated into INADDR_ANY. 2N/A /* remove '\n' at the end from fgets() */ 2N/A /* remove spaces from the front */ 2N/A if (*s ==
'\0' || *s ==
'#')
2N/A /* it should start with ncaport= */ 2N/A "NCA does not support IPv6\n");
2N/A "Invalid IP address: %s\n", p);
2N/A /* array is full, expand it */ 2N/A * It destroys memory at the end of program. 2N/A * If the bind is happening on a port NCA is listening on, close 2N/A * the socket and open a new one with family AF_NCA. 2N/A * If it is one of the addresses NCA is handling, convert it 2N/A /* convert to NCA socket */