private boolean
validateAnIpAddressWithRegularExpression(String iPaddress){
final Pattern IP_PATTERN =
Pattern.compile("b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).)"
+ "{3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)b");
return IP_PATTERN.matcher(iPaddress).matches();
}
Tuesday, August 18, 2009
Importing outlook contacts in evolution
1. Open outlook
2. Go to File -> Import and export
3. Select "Export to a file" from the menu and click "Next"
4. Select "Comma separated values" and click "Next"
5. Write down the file name and select "Allow duplicates to be created"
6. Select the folder you want to transfer ("Contacts" in this regard)
7. Click "Next" and click "Finish"
Now boot in Linux and run Evolution.
1. Go to File -> Import
2. Click "Forward"
3. Select "Import a single file" and click " Forward"
4. Browse for the file in the file menu and select it and click "Forward"
5. Select "Personal" and click "Forward"
6. Finally click "Import"
2. Go to File -> Import and export
3. Select "Export to a file" from the menu and click "Next"
4. Select "Comma separated values" and click "Next"
5. Write down the file name and select "Allow duplicates to be created"
6. Select the folder you want to transfer ("Contacts" in this regard)
7. Click "Next" and click "Finish"
Now boot in Linux and run Evolution.
1. Go to File -> Import
2. Click "Forward"
3. Select "Import a single file" and click " Forward"
4. Browse for the file in the file menu and select it and click "Forward"
5. Select "Personal" and click "Forward"
6. Finally click "Import"
Friday, July 03, 2009
Generating SNMP Traps Using SNMP4j
SNMP V1 Trap Generation
-------------------------------------------------------------------------------------------------
import java.io.ByteArrayOutputStream;
import java.net.InetAddress;
import org.snmp4j.CommunityTarget;
import org.snmp4j.PDU;
import org.snmp4j.PDUv1;
import org.snmp4j.Snmp;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.IpAddress;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.DefaultPDUFactory;
public class TrapGeneraterV1 {
public static void main(String args[]) {
try {
PDUv1 pdu = (PDUv1) DefaultPDUFactory.createPDU(SnmpConstants.version1);
pdu.setType(PDU.V1TRAP);
VariableBinding vb = new VariableBinding();
VariableBinding vb1 = new VariableBinding();
//OID oid=new OID(arg0);
vb.setOid(new OID("1.2.3.3.25.22.1"));
Variable v = new OctetString("Test Trap");
vb.setVariable(v);
vb1.setOid(new OID("1.2.3.3.25.22.1"));
Variable v1 = new OctetString("System 192.168.1.5 is Down ");
vb1.setVariable(v1);
pdu.setAgentAddress(new IpAddress(InetAddress.getLocalHost()));
pdu.add(vb);
pdu.add(vb1);
ByteArrayOutputStream out = new ByteArrayOutputStream();
pdu.encodeBER(out);
DefaultUdpTransportMapping tm = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(tm);
tm.listen();
OctetString community = new OctetString("public");
Address add = GenericAddress.parse("udp" + ":" + "192.168.1.246" + "/" + 162);
CommunityTarget target = new CommunityTarget(add, community);
target.setVersion(SnmpConstants.version1);
target.setRetries(0);
target.setTimeout(5000);
snmp.send(pdu, target);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
------------------------------------------------------------------------------------------------
import java.io.ByteArrayOutputStream;
import java.net.InetAddress;
import org.snmp4j.CommunityTarget;
import org.snmp4j.PDU;
import org.snmp4j.PDUv1;
import org.snmp4j.Snmp;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.IpAddress;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.DefaultPDUFactory;
public class TrapGeneraterV2 {
public static void main(String args[]) {
try {
PDU pdu = (PDU) DefaultPDUFactory.createPDU(SnmpConstants.version2c);
pdu.setType(PDU.TRAP);
VariableBinding vb = new VariableBinding();
//OID oid=new OID(arg0);
vb.setOid(new OID("1.2.3.3.25.22.1"));
Variable v = new OctetString("Test Trap");
vb.setVariable(v);
VariableBinding vb1 = new VariableBinding();
//OID oid=new OID(arg0);
vb1.setOid(new OID("1.2.3.3.25.22.1"));
Variable v1 = new OctetString("Device Unavailable IP : 192.168.1.61");
vb1.setVariable(v1);
pdu.add(vb1);
pdu.add(vb);
.setGenericTrap(SnmpConstants.getGenericTrapID(SnmpConstants.coldStart));
ByteArrayOutputStream out = new ByteArrayOutputStream();
pdu.encodeBER(out);
DefaultUdpTransportMapping tm = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(tm);
tm.listen();
OctetString community = new OctetString("public");
Address add = GenericAddress.parse("udp" + ":" + "192.168.1.246" + "/" + 162);
CommunityTarget target = new CommunityTarget(add, community);
target.setVersion(SnmpConstants.version2c);
target.setRetries(0);
target.setTimeout(5000);
snmp.send(pdu, target);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
import java.io.ByteArrayOutputStream;
import java.net.InetAddress;
import org.snmp4j.CommunityTarget;
import org.snmp4j.PDU;
import org.snmp4j.PDUv1;
import org.snmp4j.Snmp;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.IpAddress;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.DefaultPDUFactory;
public class TrapGeneraterV1 {
public static void main(String args[]) {
try {
PDUv1 pdu = (PDUv1) DefaultPDUFactory.createPDU(SnmpConstants.version1);
pdu.setType(PDU.V1TRAP);
VariableBinding vb = new VariableBinding();
VariableBinding vb1 = new VariableBinding();
//OID oid=new OID(arg0);
vb.setOid(new OID("1.2.3.3.25.22.1"));
Variable v = new OctetString("Test Trap");
vb.setVariable(v);
vb1.setOid(new OID("1.2.3.3.25.22.1"));
Variable v1 = new OctetString("System 192.168.1.5 is Down ");
vb1.setVariable(v1);
pdu.setAgentAddress(new IpAddress(InetAddress.getLocalHost()));
pdu.add(vb);
pdu.add(vb1);
ByteArrayOutputStream out = new ByteArrayOutputStream();
pdu.encodeBER(out);
DefaultUdpTransportMapping tm = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(tm);
tm.listen();
OctetString community = new OctetString("public");
Address add = GenericAddress.parse("udp" + ":" + "192.168.1.246" + "/" + 162);
CommunityTarget target = new CommunityTarget(add, community);
target.setVersion(SnmpConstants.version1);
target.setRetries(0);
target.setTimeout(5000);
snmp.send(pdu, target);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
------------------------------------------------------------------------------------------------
SNMP V2 Traps Generation
import java.io.ByteArrayOutputStream;
import java.net.InetAddress;
import org.snmp4j.CommunityTarget;
import org.snmp4j.PDU;
import org.snmp4j.PDUv1;
import org.snmp4j.Snmp;
import org.snmp4j.mp.SnmpConstants;
import org.snmp4j.smi.Address;
import org.snmp4j.smi.GenericAddress;
import org.snmp4j.smi.IpAddress;
import org.snmp4j.smi.OID;
import org.snmp4j.smi.OctetString;
import org.snmp4j.smi.Variable;
import org.snmp4j.smi.VariableBinding;
import org.snmp4j.transport.DefaultUdpTransportMapping;
import org.snmp4j.util.DefaultPDUFactory;
public class TrapGeneraterV2 {
public static void main(String args[]) {
try {
PDU pdu = (PDU) DefaultPDUFactory.createPDU(SnmpConstants.version2c);
pdu.setType(PDU.TRAP);
VariableBinding vb = new VariableBinding();
//OID oid=new OID(arg0);
vb.setOid(new OID("1.2.3.3.25.22.1"));
Variable v = new OctetString("Test Trap");
vb.setVariable(v);
VariableBinding vb1 = new VariableBinding();
//OID oid=new OID(arg0);
vb1.setOid(new OID("1.2.3.3.25.22.1"));
Variable v1 = new OctetString("Device Unavailable IP : 192.168.1.61");
vb1.setVariable(v1);
pdu.add(vb1);
pdu.add(vb);
.setGenericTrap(SnmpConstants.getGenericTrapID(SnmpConstants.coldStart));
ByteArrayOutputStream out = new ByteArrayOutputStream();
pdu.encodeBER(out);
DefaultUdpTransportMapping tm = new DefaultUdpTransportMapping();
Snmp snmp = new Snmp(tm);
tm.listen();
OctetString community = new OctetString("public");
Address add = GenericAddress.parse("udp" + ":" + "192.168.1.246" + "/" + 162);
CommunityTarget target = new CommunityTarget(add, community);
target.setVersion(SnmpConstants.version2c);
target.setRetries(0);
target.setTimeout(5000);
snmp.send(pdu, target);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Tuesday, April 07, 2009
SNMP DataTypes
SNMP version 1 uses this following datatypes :
A few primitive datatypes , specific to SNMP applications, were added to the built-in primitives. These included :
- INTEGER : a whole number (number of interfaces on a system).
OCTET STRING : a string of octets which is used to represent hexadecimal data (physical address of an interface).
OBJECT IDENTIFIER : a string of numbers derived for a naming tree, used to identify an object.
NULL : an empty placeholder.
ENUMERATED : a limited set of integers with an assigned meaning.
BOOLEAN : an integer with values true (1) or false (2).
A few primitive datatypes , specific to SNMP applications, were added to the built-in primitives. These included :
- Counter (integer which increases until a maximum value and goes back to zero)
Gauge (integer which increases and decreases)
TimeTicks
IpAddress
NetworkAddress
...
- BIT STRING : hold enumerated lists of flags
Integer32 : identical to INTEGER, range is -2 31 to 2 31 -1
Counter32 : identical to COUNTER, range is 0 to 2 32 -1
Gauge32 : identical to GAUGE, range is 0 to 2 32 -1
NsapAddress : for OSI addresses
Counter64 : range is 0 to 2 64
Uinteger32 : unsigned integer, range is 0 to 2 32 -1
Tuesday, March 17, 2009
TCP/IP module missing in npqtplugin4.dll.it may be infected by virus
TCP/IP module missing in npqtplugin4.dll.it may be infected by virus
Step1 : download mbam from www.malwarebytes.org ,install it and get updates.
Step2 : start scan using mbean ,it shows infected files and registry enties and removes them .
Step3 : it asks for restart ,click ok.
Step4: go to c drive ,tools->folderoptions->
view->select show hidden files and folders


Step5: delete autorun.bat and thb.ico .
some times show hidden files and files option will not work though you selected option .
so in this case u need to delete above files using dos commands.
Step6: Restart you machine .
Step1 : download mbam from www.malwarebytes.org ,install it and get updates.
Step2 : start scan using mbean ,it shows infected files and registry enties and removes them .
Step3 : it asks for restart ,click ok.
Step4: go to c drive ,tools->folderoptions->
view->select show hidden files and folders
Step5: delete autorun.bat and thb.ico .
some times show hidden files and files option will not work though you selected option .
so in this case u need to delete above files using dos commands.
Step6: Restart you machine .
Sunday, February 22, 2009
Good java learning site :
http://www.javapassion.com/
http://www.javapassion.com/
Sunday, November 02, 2008
Performing Inserts, Updates, and Deletes Im JSF
Please See The Following Link:
http://www.netbeans.org/kb/60/web/inserts-updates-deletes.html
http://www.netbeans.org/kb/60/web/inserts-updates-deletes.html
Subscribe to:
Posts (Atom)
