コード例 #1
0
/*
 * FUNCTION:		iso_netof
 *
 * PURPOSE:		Extract the network portion of the iso address.
 *			The network portion of the iso address varies depending
 *			on the type of address. The network portion of the
 *			address will include the IDP. The network portion is:
 *
 *			TYPE			DESC
 *			t37			The AFI and x.121 (IDI)
 *			osinet			The AFI, orgid, snetid
 *			rfc986			The AFI, vers and network part
 *						of internet address.
 *
 * RETURNS:		number of bytes placed into buf.
 *
 * SIDE EFFECTS:
 *
 * NOTES:		Buf is assumed to be big enough
 */
u_int
iso_netof(
	struct iso_addr *isoa,	/* address */
	void *        buf)	/* RESULT: network portion of address here */
{
	u_int           len = 1;/* length of afi */

	switch (isoa->isoa_afi) {
	case AFI_37:
		/*
		 * Due to classic x.25 tunnel vision, there is no
		 * net portion of an x.121 address.  For our purposes
		 * the AFI will do, so that all x.25 -type addresses
		 * map to the single x.25 SNPA. (Cannot have more than
		 * one, obviously).
		 */

		break;

		/* case AFI_OSINET: */
	case AFI_RFC986:{
			u_short         idi;	/* value of idi */

			/* osinet and rfc986 have idi in the same place */
			CTOH(isoa->rfc986_idi[0], isoa->rfc986_idi[1], idi);

			if (idi == IDI_OSINET)
				/*
				 * Network portion of OSINET address can only
				 * be the IDI. Clearly, with one x25 interface,
				 * one could get to several orgids, and
				 * several snetids.
				 */
#if 0
				len += (ADDROSINET_IDI_LEN +
					OVLOSINET_ORGID_LEN +
					OVLOSINET_SNETID_LEN);
#endif
				len += ADDROSINET_IDI_LEN;
			else if (idi == IDI_RFC986) {
				struct ovl_rfc986 *o986 =
					(struct ovl_rfc986 *) isoa;

				/*
				 * bump len to include idi and version (1
				 * byte)
				 */
				len += ADDRRFC986_IDI_LEN + 1;

#ifdef ARGO_DEBUG
				if (argo_debug[D_ROUTE]) {
					printf("iso_netof: isoa ");
					dump_buf(isoa, sizeof(*isoa));
					printf("iso_netof: inetaddr 0x%x ",
					    inetaddr);
				}
#endif

				/*
				 * bump len by size of network portion of
				 * inet address
				 */
				if (IN_CLASSA(o986->o986_inetaddr)) {
					len += 4 - IN_CLASSA_NSHIFT / 8;
#ifdef ARGO_DEBUG
					if (argo_debug[D_ROUTE]) {
						printf("iso_netof: class A net len is now %d\n", len);
					}
#endif
				} else if (IN_CLASSB(o986->o986_inetaddr)) {
					len += 4 - IN_CLASSB_NSHIFT / 8;
#ifdef ARGO_DEBUG
					if (argo_debug[D_ROUTE]) {
						printf("iso_netof: class B net len is now %d\n", len);
					}
#endif
				} else {
					len += 4 - IN_CLASSC_NSHIFT / 8;
#ifdef ARGO_DEBUG
					if (argo_debug[D_ROUTE]) {
						printf("iso_netof: class C net len is now %d\n", len);
					}
#endif
				}
			} else
				len = 0;
		} break;

	default:
		len = 0;
	}
コード例 #2
0
char *
clnp_iso_addrp(const struct iso_addr *isoa)
{
	char           *cp;
#ifdef notdef
	u_short         idi;
#endif

	/* print length */
	snprintf(iso_addr_b, sizeof(iso_addr_b), "[%d] ", isoa->isoa_len);

	/* set cp to end of what we have */
	cp = iso_addr_b;
	while (*cp)
		cp++;

	/* print afi */
	cp = clnp_hexp(isoa->isoa_genaddr, (int) isoa->isoa_len, cp);
#ifdef notdef
	*cp++ = DELIM;

	/* print type specific part */
	switch (isoa->isoa_afi) {
	case AFI_37:
		cp = clnp_hexp(isoa->t37_idi, ADDR37_IDI_LEN, cp);
		*cp++ = DELIM;
		cp = clnp_hexp(isoa->t37_dsp, ADDR37_DSP_LEN, cp);
		break;

		/* case AFI_OSINET: */
	case AFI_RFC986:

		/* osinet and rfc986 have idi in the same place */
		/* print idi */
		cp = clnp_hexp(isoa->rfc986_idi,
			       ADDROSINET_IDI_LEN, cp);
		*cp++ = DELIM;
		CTOH(isoa->rfc986_idi[0], isoa->rfc986_idi[1], idi);

		if (idi == IDI_OSINET) {
			struct ovl_osinet *oosi = (struct ovl_osinet *) isoa;
			cp = clnp_hexp(oosi->oosi_orgid,
				       OVLOSINET_ORGID_LEN, cp);
			*cp++ = DELIM;
			cp = clnp_hexp(oosi->oosi_snetid,
				       OVLOSINET_SNETID_LEN, cp);
			*cp++ = DELIM;
			cp = clnp_hexp(oosi->oosi_snpa, OVLOSINET_SNPA_LEN, cp);
			*cp++ = DELIM;
			cp = clnp_hexp(oosi->oosi_nsap, OVLOSINET_NSAP_LEN, cp);
		} else if (idi == IDI_RFC986) {
			struct ovl_rfc986 *o986 = (struct ovl_rfc986 *) isoa;
			cp = clnp_hexp(&o986->o986_vers, 1, cp);
			*cp++ = DELIM;
#ifdef  __vax__
			sprintf(cp, "%d.%d.%d.%d.%d",
			    o986->o986_inetaddr[0] & 0xff,
			    o986->o986_inetaddr[1] & 0xff,
			    o986->o986_inetaddr[2] & 0xff,
			    o986->o986_inetaddr[3] & 0xff,
			    o986->o986_upid & 0xff);
			return (iso_addr_b);
#else
			cp = clnp_hexp(&o986->o986_inetaddr[0], 1, cp);
			*cp++ = DELIM;
			cp = clnp_hexp(&o986->o986_inetaddr[1], 1, cp);
			*cp++ = DELIM;
			cp = clnp_hexp(&o986->o986_inetaddr[2], 1, cp);
			*cp++ = DELIM;
			cp = clnp_hexp(&o986->o986_inetaddr[3], 1, cp);
			*cp++ = DELIM;
			cp = clnp_hexp(&o986->o986_upid, 1, cp);
#endif				/* vax */
		}
		break;

	default:
		*cp++ = '?';
		break;
	}
#endif /* notdef */
	*cp = (char) 0;

	return (iso_addr_b);
}