Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/act365/net/ip/IP4Message.java


1   /*
2     * JSocket Wrench
3     * 
4     * Copyright (C) act365.com October 2003
5     * 
6     * Web site: http://www.act365.com/wrench
7     * E-mail: developers@act365.com
8     * 
9     * The JSocket Wrench library adds support for low-level Internet protocols
10    * to the Java programming language.
11    * 
12    * This program is free software; you can redistribute it and/or modify it 
13    * under the terms of the GNU General Public License as published by the Free 
14    * Software Foundation; either version 2 of the License, or (at your option) 
15    * any later version.
16    *  
17    * This program is distributed in the hope that it will be useful, 
18    * but WITHOUT ANY WARRANTY; without even the implied warranty of 
19    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 
20    * Public License for more details.
21    * 
22    * You should have received a copy of the GNU General Public License along with 
23    * this program; if not, write to the Free Software Foundation, Inc., 
24    * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25    */
26  
27  package com.act365.net.ip ;
28  
29  /**
30   Stores the contents of an IP4 message.
31  */
32  
33  public class IP4Message {
34   
35    public byte version ;
36    public byte headerlength ;
37    public byte typeofservice ;
38    public short length ;
39    public short identifier ;
40    public byte flags ;
41    public short offset ;
42    public short timetolive ;
43    public byte protocol ;
44    public short checksum ;
45    public byte[] source ;
46    public byte[] destination ;
47    public int[] options ;
48    public byte[] data ;
49  
50    /**
51     Writes the message to a string.
52    */
53  
54    public String toString() {
55  
56      StringBuffer sb = new StringBuffer();
57  
58      sb.append("IP: source-");
59      sb.append( source[0] );
60      sb.append('.');
61      sb.append( source[1] );
62      sb.append('.');
63      sb.append( source[2] );
64      sb.append('.');
65      sb.append( source[3] );
66      sb.append(" destination-");
67      sb.append( destination[0] );
68      sb.append('.');
69      sb.append( destination[1] );
70      sb.append('.');
71      sb.append( destination[2] );
72      sb.append('.');
73      sb.append( destination[3] );
74      sb.append(" length-");
75      sb.append( length );
76      sb.append(" bytes");
77  
78      return sb.toString();
79    } 
80  }
81