Beispiel #1
0
/*
 * Read a list of gateways from /etc/gateways and add them to our tables.
 *
 * This file contains a list of "remote" gateways.  That is usually
 * a gateway which we cannot immediately determine if it is present or
 * not as we can do for those provided by directly connected hardware.
 *
 * If a gateway is marked "passive" in the file, then we assume it
 * does not understand RIP and assume it is always present.  Those
 * not marked passive are treated as if they were directly connected
 * and assumed to be broken if they do not send us advertisements.
 * All remote interfaces are added to our list, and those not marked
 * passive are sent routing updates.
 *
 * A passive interface can also be local, hardware interface exempt
 * from RIP.
 */
void
gwkludge(void)
{
#define	STR2(x)	#x
#define	STR(x)	STR2(x)

#define	NETHOST_LEN	4
#define	DNAME_LEN	MAXHOSTNAMELEN
#define	GNAME_LEN	MAXHOSTNAMELEN
#define	QUAL_LEN	8

	FILE *fp;
	char *p, *lptr;
	const char *cp;
	char lbuf[PARMS_MAXLINELEN], net_host[NETHOST_LEN + 1];
	char dname[MAXHOSTNAMELEN + 1];
	char gname[MAXHOSTNAMELEN + 1], qual[QUAL_LEN +1];
	struct interface *ifp;
	uint32_t dst, netmask, gate;
	int n;
	uint32_t lnum;
	struct stat sb;
	uint32_t state, metric;
	boolean_t default_dst;


	fp = fopen(PATH_GATEWAYS, "r");
	if (fp == NULL)
		return;

	if (0 > fstat(fileno(fp), &sb)) {
		msglog("fstat() failed: %s for  "PATH_GATEWAYS,
		    rip_strerror(errno));
		(void) fclose(fp);
		return;
	}

	for (lnum = 1; ; lnum++) {
		if (NULL == fgets(lbuf, sizeof (lbuf), fp))
			break;

		/* Eliminate the /n character at the end of the lbuf */
		if (strlen(lbuf) > 0)
			lbuf[strlen(lbuf) - 1] = '\0';

		/* Move lptr to the first non-space character */
		for (lptr = lbuf; isspace(*lptr); lptr++)
			;

		if (*lptr == '#' || *lptr == '\0')
			continue;

		/* Move p to the end of the line */
		p = lptr + strlen(lptr) - 1;

		/* Skip all trailing spaces except escaped space */
		while (p > lptr && (isspace(*p) && *(p-1) != '\\'))
			p--;

		/* truncate the line to remove trailing spaces */
		*++p = '\0';

		/* notice newfangled parameter lines */
		if (strncasecmp("net", lptr, 3) != 0 &&
		    strncasecmp("host", lptr, 4) != 0) {
			cp = parse_parms(lptr, (sb.st_uid == 0 &&
			    !(sb.st_mode&(S_IRWXG|S_IRWXO))));
			if (cp != 0)
				msglog("%s in line %u of "PATH_GATEWAYS,
				    cp, lnum);
			continue;
		}

		/*
		 * Processes lines of the follwoing format:
		 * net|host <name>[/mask] gateway <Gname> metric <value>
		 * passive|active|extern
		 */
		qual[0] = '\0';
		n = sscanf(lptr, "%"STR(NETHOST_LEN)"s %"STR(DNAME_LEN)
		    "[^ \t] gateway %"STR(GNAME_LEN)"[^ / \t] metric %u %"
		    STR(QUAL_LEN)"s\n", net_host, dname, gname, &metric, qual);
		if (n != 4 && n != 5) {
			msglog("bad "PATH_GATEWAYS" entry \"%s\"; %d values",
			    lptr, n);
			continue;
		}
		if (metric >= HOPCNT_INFINITY) {
			msglog("bad metric in "PATH_GATEWAYS" entry \"%s\"",
			    lptr);
			continue;
		}
		default_dst = _B_FALSE;
		if (strcasecmp(net_host, "host") == 0) {
			if (!gethost(dname, &dst)) {
				msglog("bad host \"%s\" in "PATH_GATEWAYS
				    " entry \"%s\"", dname, lptr);
				continue;
			}
			netmask = HOST_MASK;
		} else if (strcasecmp(net_host, "net") == 0) {
			if (!getnet(dname, &dst, &netmask)) {
				msglog("bad net \"%s\" in "PATH_GATEWAYS
				    " entry \"%s\"", dname, lptr);
				continue;
			}
			default_dst = (dst == RIP_DEFAULT);
			dst = htonl(dst); /* make network # into IP address */
		} else {
			msglog("bad \"%s\" in "PATH_GATEWAYS
			    " entry \"%s\"", net_host, lptr);
			continue;
		}

		if (!gethost(gname, &gate)) {
			msglog("bad gateway \"%s\" in "PATH_GATEWAYS
			    " entry \"%s\"", gname, lptr);
			continue;
		}

		if (strcasecmp(qual, "passive") == 0) {
			/*
			 * Passive entries are not placed in our tables,
			 * only the kernel's, so we don't copy all of the
			 * external routing information within a net.
			 * Internal machines should use the default
			 * route to a suitable gateway (like us).
			 */
			state = IS_REMOTE | IS_PASSIVE;
			if (metric == 0)
				metric = 1;

		} else if (strcasecmp(qual, "external") == 0) {
			/*
			 * External entries are handled by other means
			 * such as EGP, and are placed only in the daemon
			 * tables to prevent overriding them with something
			 * else.
			 */
			(void) strlcpy(qual, "external", sizeof (qual));
			state = IS_REMOTE | IS_PASSIVE | IS_EXTERNAL;
			if (metric == 0)
				metric = 1;

		} else if (strcasecmp(qual, "active") == 0 ||
		    qual[0] == '\0') {

			if (default_dst) {
				msglog("bad net \"%s\" in "PATH_GATEWAYS
				    " entry \"%s\"-- cannot be default",
				    dname, lptr);
				continue;
			}

			if (metric != 0) {
				/*
				 * Entries that are neither "passive" nor
				 * "external" are "remote" and must behave
				 * like physical interfaces.  If they are not
				 * heard from regularly, they are deleted.
				 */
				state = IS_REMOTE;
			} else {
				/*
				 * "remote" entries with a metric of 0
				 * are aliases for our own interfaces
				 */
				state = IS_REMOTE | IS_PASSIVE | IS_ALIAS;
			}

		} else {
			msglog("bad "PATH_GATEWAYS" entry \"%s\";"
			    " unknown type %s", lptr, qual);
			continue;
		}

		if (0 != (state & (IS_PASSIVE | IS_REMOTE)))
			state |= IS_NO_RDISC;
		if (state & IS_PASSIVE)
			state |= IS_NO_RIP;


		if (default_dst) {
			addroutefordefault(dst, gate, netmask, metric,
			    ((state & IS_EXTERNAL)? RTS_EXTERNAL : 0));
			continue;
		}

		ifp = check_dup(NULL, gate, dst, netmask, 0, _B_FALSE);
		if (ifp != NULL) {
			msglog("duplicate "PATH_GATEWAYS" entry \"%s\"", lptr);
			continue;
		}

		ifp = rtmalloc(sizeof (*ifp), "gwkludge()");
		(void) memset(ifp, 0, sizeof (*ifp));

		ifp->int_state = state;
		if (netmask == HOST_MASK)
			ifp->int_if_flags = IFF_POINTOPOINT | IFF_UP;
		else
			ifp->int_if_flags = IFF_UP;
		ifp->int_act_time = NEVER;
		ifp->int_addr = gate;
		ifp->int_dstaddr = dst;
		ifp->int_mask = netmask;
		ifp->int_ripv1_mask = netmask;
		ifp->int_std_mask = std_mask(gate);
		ifp->int_net = ntohl(dst);
		ifp->int_std_net = ifp->int_net & ifp->int_std_mask;
		ifp->int_std_addr = htonl(ifp->int_std_net);
		ifp->int_metric = metric;
		if (!(state & IS_EXTERNAL) &&
		    ifp->int_mask != ifp->int_std_mask)
			ifp->int_state |= IS_SUBNET;
		(void) snprintf(ifp->int_name, sizeof (ifp->int_name),
		    "remote(%s)", gname);

		if_link(ifp, 0);
	}

	(void) fclose(fp);

	/*
	 * After all of the parameter lines have been read,
	 * apply them to any remote interfaces.
	 */
	for (ifp = ifnet; NULL != ifp; ifp = ifp->int_next) {
		get_parms(ifp);

		tot_interfaces++;
		if (!IS_RIP_OFF(ifp->int_state))
			rip_interfaces++;
		if (!IS_RIP_OUT_OFF(ifp->int_state))
			ripout_interfaces++;

		trace_if("Add", ifp);
	}

}
Beispiel #2
0
static void
Test_FontPresence(void)
{
    HDC hDC;

    hDC = CreateCompatibleDC(NULL);

    ok(is_truetype_font_installed(hDC, "Arial"), "'Arial' is not found\n");
    ok(is_truetype_font_installed(hDC, "Courier New"), "'Courier New' is not found\n");
    ok(is_truetype_font_installed(hDC, "Marlett"), "'Marlett' is not found\n");
    ok(is_truetype_font_installed(hDC, "MS Shell Dlg"), "'MS Shell Dlg' is not found\n");
    ok(is_truetype_font_installed(hDC, "Tahoma"), "'Tahoma' is not found\n");
    ok(is_truetype_font_installed(hDC, "Times New Roman"), "'Times New Roman' is not found\n");

    ok(is_charset_font_installed(hDC, ANSI_CHARSET), "ANSI_CHARSET fonts are not found\n");
    ok(is_charset_font_installed(hDC, SYMBOL_CHARSET), "SYMBOL_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, SHIFTJIS_CHARSET), "SHIFTJIS_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, HANGUL_CHARSET), "HANGUL_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, GB2312_CHARSET), "GB2312_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, CHINESEBIG5_CHARSET), "CHINESEBIG5_CHARSET fonts are not found\n");
    ok(is_charset_font_installed(hDC, OEM_CHARSET), "OEM_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, JOHAB_CHARSET), "JOHAB_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, HEBREW_CHARSET), "HEBREW_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, ARABIC_CHARSET), "ARABIC_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, GREEK_CHARSET), "GREEK_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, TURKISH_CHARSET), "TURKISH_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, VIETNAMESE_CHARSET), "VIETNAMESE_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, THAI_CHARSET), "THAI_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, EASTEUROPE_CHARSET), "EASTEUROPE_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, RUSSIAN_CHARSET), "RUSSIAN_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, MAC_CHARSET), "MAC_CHARSET fonts are not found\n");
    trace_if(is_charset_font_installed(hDC, BALTIC_CHARSET), "BALTIC_CHARSET fonts are not found\n");

    ok(is_fixed_charset_font_installed(hDC, ANSI_CHARSET), "fixed ANSI_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, SHIFTJIS_CHARSET), "fixed SHIFTJIS_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, HANGUL_CHARSET), "fixed HANGUL_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, GB2312_CHARSET), "fixed GB2312_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, CHINESEBIG5_CHARSET), "fixed CHINESEBIG5_CHARSET fonts are not found\n");
    ok(is_fixed_charset_font_installed(hDC, OEM_CHARSET), "fixed OEM_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, JOHAB_CHARSET), "fixed JOHAB_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, HEBREW_CHARSET), "fixed HEBREW_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, ARABIC_CHARSET), "fixed ARABIC_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, GREEK_CHARSET), "fixed GREEK_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, TURKISH_CHARSET), "fixed TURKISH_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, VIETNAMESE_CHARSET), "fixed VIETNAMESE_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, THAI_CHARSET), "fixed THAI_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, EASTEUROPE_CHARSET), "fixed EASTEUROPE_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, RUSSIAN_CHARSET), "fixed RUSSIAN_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, MAC_CHARSET), "fixed MAC_CHARSET fonts are not found\n");
    trace_if(is_fixed_charset_font_installed(hDC, BALTIC_CHARSET), "fixed BALTIC_CHARSET fonts are not found\n");

    DeleteDC(hDC);
}