Package org.openxri.xri3.impl.parser

Examples of org.openxri.xri3.impl.parser.Rule$IPv4address


    }

    @Override
    protected IPv4Address doAccept(Token value, int flags) throws CommandSyntaxException {
        if (value.text.equals("default")) {
            return new IPv4Address(new byte[]{0, 0, 0, 0}, 0);
        }
        final StringTokenizer tok = new StringTokenizer(value.text, ".");
        if (tok.countTokens() != 4) {
            throw new CommandSyntaxException("wrong number of components for an IPv4 address");
        }
        try {
            final byte b1 = parseUnsignedByte(tok.nextToken());
            final byte b2 = parseUnsignedByte(tok.nextToken());
            final byte b3 = parseUnsignedByte(tok.nextToken());
            final byte b4 = parseUnsignedByte(tok.nextToken());
            return new IPv4Address(new byte[]{b1, b2, b3, b4}, 0);
        } catch (NumberFormatException ex) {
            throw new CommandSyntaxException("invalid component in IPv4 address");
        }
    }
View Full Code Here


        try {
            cfg = InitialNaming.lookup(IPv4ConfigurationService.NAME);
        } catch (NameNotFoundException ex) {
            throw new NetworkException(ex);
        }
        cfg.configureDeviceStatic(device, new IPv4Address(hdr.getYourIPAddress()), null, false);

        final IPv4Address serverAddr = new IPv4Address(hdr.getServerIPAddress());
        final IPv4Address networkAddress = serverAddr.and(serverAddr.getDefaultSubnetmask());

        if (hdr.getGatewayIPAddress().isAnyLocalAddress()) {
            cfg.addRoute(serverAddr, null, device, false);
            cfg.addRoute(networkAddress, null, device, false);
        } else {
            cfg.addRoute(networkAddress, new IPv4Address(hdr.getGatewayIPAddress()), device, false);
        }
    }
View Full Code Here

        super(skbuf);
        final ICMPType type = getType();
        if ((type != ICMPType.ICMP_ADDRESS) && (type != ICMPType.ICMP_ADDRESSREPLY)) {
            throw new IllegalArgumentException("Invalid type " + type);
        }
        this.subnetMask = new IPv4Address(skbuf, 8);
    }
View Full Code Here

            return;
        }

        final int tos = 0;
        final int ttl = 0xFF;
        final IPv4Address dstAddr = origIpHdr.getSource();

        // Build the response ICMP header
        final ICMPHeader icmpHdr = new ICMPUnreachableHeader(code);
        // Build the response IP header
        final IPv4Header ipHdr = new IPv4Header(tos, ttl, IPv4Constants.IPPROTO_ICMP, dstAddr, 0);
View Full Code Here

    return(super.toIRINormalForm());
  }

  public boolean isValidXRI() {

    XRI xri;
   
    try {
     
      xri = this.toXRI();
    } catch (Exception ex) {
View Full Code Here

    return(super.toIRINormalForm());
  }

  public boolean isValidXRI() {

    XRI xri;
   
    try {
     
      xri = this.toXRI();
    } catch (Exception ex) {
View Full Code Here

    // The XRI is: =parity*markus/+contact
    // The resolver needs to know the following:
    // - list of subsegments
    // - path

    XRI xri = new XRI3("=parity*markus/+contact");
    XRIAuthority xriAuthority = xri.getAuthority();
    XRIPath xriPath = xri.getPath();

    System.out.println("Resolving XRI " + xri.toString());
    System.out.println("Listing " + xriAuthority.getNumSubSegments() + " subsegments...");

    for (int i=0; i<xriAuthority.getNumSubSegments(); i++) {

      XRISubSegment subSegment = xriAuthority.getSubSegment(i);
View Full Code Here

    // We want to know the following
    // - XDI subject
    // - XDI predicate
    // - XDI reference

    XRI xri = new XRI3("+name+first/$is/+!3");
    XRIAuthority xriAuthority = xri.getAuthority();
    XRIPath xriPath = xri.getPath();

    System.out.println("Checking XDI address " + xri.toString());
   
    System.out.println("XDI Subject: " + xriAuthority.toString());
    System.out.println("XDI Predicate: " + xriPath.getSegment(0).toString());
    System.out.println("XDI Reference: " + xriPath.getSegment(1).toString());
  }
View Full Code Here

    // The library can also construct new XRIs or XRI components.
    // For example, if we have an XRI +name, and a relative XRI reference +first,
    // we can construct a new XRI +name+first

    XRI xri = new XRI3("+name");
    XRIReference xriReference = new XRI3Reference("+first");

    System.out.println("Got XRI " + xri.toString());
    System.out.println("Got XRI reference " + xriReference.toString());

    XRI xriNew = new XRI3(xri, xriReference);
   
    System.out.println("Constructed new XRI " + xriNew.toString());
  }
View Full Code Here

    return(super.toIRINormalForm());
  }

  public boolean isValidXRI() {

    XRI xri;
   
    try {
     
      xri = this.toXRI();
    } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of org.openxri.xri3.impl.parser.Rule$IPv4address

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.