Sponsored Content
Full Discussion: Validating IP address.
Top Forums Shell Programming and Scripting Validating IP address. Post 302217160 by fpmurphy on Tuesday 22nd of July 2008 04:47:36 AM
Old 07-22-2008
Note that this regular expression validates the format of an IPv4 address but does not work for an IPv6 address.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

validating dates

This is what I have to check date entries in an interactive script with the end users... I use this to build control cards for a reporting utility supplied by a software vendor. I also want to check to make sure its a valid day based on the month (ie 30days has sept, april, june and Nov..)... ... (2 Replies)
Discussion started by: MizzGail
2 Replies

2. Programming

validating input

how do i validate y script so that it only accepts values between 1 and 3 and against any character input, cause at the moment i can only validate against numbers outside 1 and 3 but not characters cheers (4 Replies)
Discussion started by: ruffenator
4 Replies

3. UNIX for Dummies Questions & Answers

validating userid

What's wrong with this syntax? It's part of my 'if' statement but it doesn't seem to pass and it keeps going to the 'else' part. I thought it says that userid must start with a non-numeric character and is between 6 and 10 characters long (alphanumeric). $userid|grep -Eq '^?\{6,10\}+$' if... (2 Replies)
Discussion started by: giannicello
2 Replies

4. Shell Programming and Scripting

Validating $1 and $2 before using

Hi there, I'm trying to validate my $1 and $2 before I use them in the sqlplus update, I think I have the validation rules set correctly??? however when I test my script, it jumps straight into the sql. It doesn't seem to validate the vars....even when I know they are incorrect. if ; then ... (6 Replies)
Discussion started by: nhatch
6 Replies

5. Shell Programming and Scripting

validating 10. IP address any way possible

HELP: validating IP addresses any way possible -------------------------------------------------------------------------------- I am trying to validate input from the user in a script. I thought is was easy to do using regular expressions but I can't figure out how to use REs in a... (1 Reply)
Discussion started by: nrodolfich
1 Replies

6. UNIX for Dummies Questions & Answers

Panic kernal-mode address fault on user address 0x14

:) Firstly Hi all!!, im NEW!! and on here hoping that someone might be able to offer me some help... i have a server that keeps crashing every few days with the error message: PANIC KERNAL-MODE ADDRESS FAULT ON USER ADDRESS 0X14 KERNAL PAGE FAULT FROM (CS:EIP)=(100:EF71B5BD) EAX=EF822000... (10 Replies)
Discussion started by: Twix
10 Replies

7. UNIX for Dummies Questions & Answers

Validating a file

Pardon my ignorance but I am lost on how to do this I have a file called "Sample.txt", it is pipe delimited, it should have 13 fields. But some of the records do not, I would like to set up a shell script where I can pass in a parameter "Sample.txt" and it would split the file into records... (2 Replies)
Discussion started by: dgeehot
2 Replies

8. Shell Programming and Scripting

awk for validating

HI, I am trying to write a validation script as below awk '($1=="ABC"&&$2="XYZ" ,then check the value in $8,$10 these columns should not be null. so their should be some corresponding value n the $8 and $10 column,if their is no value the script has to give error saying that at a... (2 Replies)
Discussion started by: gaur.deepti
2 Replies

9. Shell Programming and Scripting

validating(pingable or not) remote ip address in shell script

i need to verify whether the ip adress given as input to the shell script is pingable or not... that is whether the ip is alive and responding.. ping $ip_adress the above wont work in script because the execution is continuous... so the shell script keeps will dwell in this pinging process...... (8 Replies)
Discussion started by: vivek d r
8 Replies

10. UNIX for Advanced & Expert Users

C program to detect duplicate ip address if any after assigning ip address to ethernet interface

Hi , Could someone let me know how to detect duplicate ip address after assigning ip address to ethernet interface using c program (3 Replies)
Discussion started by: Gopi Krishna P
3 Replies
inet6(3N)																 inet6(3N)

NAME
inet_pton(), inet_ntop() - Internet address manipulation routines for IP Version 4 and later SYNOPSIS
DESCRIPTION
The functions and are new with IP Version 6 (IPv6) and work with both IP Version 4 (IPv4) and IPv6 addresses. The letters "p" and "n" stand for and The presentation format for an address is often an ASCII string and the numeric format is the binary value that goes into a socket address structure. The ASCII string is either the IPv4 address in dot notation or an IPv6 address in colon notation. An example of an ASCII string is or The binary value is the hex representation of the IPv4/IPv6 address. This binary value resides in the structure for IPv4 address and in the structure for IPv6 address. (Refer to the inet(3N) manpage for more details.) The functions and are opposite of each other. The function converts an ASCII address string to binary address, and the function converts a binary address into ASCII address string. Also, these are equivalent to and respectively. The inet_pton() Function The function converts an address in its standard text presentation form into its numeric binary form. The af argument specifies the family of the address. Currently, the and address families are supported. The src argument points to the IPv6/IPv4 address string being passed in. The argument points to a buffer in which the function stores the numeric address. The address is returned in network byte order. returns if the conversion succeeds, if the input is not a valid IPv4 dotted-decimal string or a valid IPv6 address string, or with errno set to if the af argument is unknown. The calling application must ensure that the buffer referred to by dst is large enough to hold the numeric address (e.g., 4 bytes for or 16 bytes for If the af argument is the function accepts a string in the standard IPv4 dotted-decimal form: ddd.ddd.ddd.ddd where ddd is a one to three digit decimal number between 0 and 255. Note that many implementations of the existing and functions accept nonstandard input: octal numbers, hexadecimal numbers, and fewer than four numbers. does not accept these formats. If the af argument is then the function accepts a string in one of the standard IPv6 text forms. (Refer to the IPv6 address notation below for more details). The inet_ntop() Function The function converts a numeric address into a text string suitable for presentation. The af argument specifies the family of the address. This can be or The src argument points to a buffer holding an IPv4 address if the af argument is or an IPv6 address if the af argument is The dst argument points to a buffer where the function will store the resulting text string. The size argument specifies the size of this buffer. The application must specify a non-NULL dst argument. For IPv6 addresses, the buffer must be at least 46-octets. For IPv4 addresses, the buffer must be at least 16-octets. In order to allow applications to easily declare buffers of the proper size to store IPv4 and IPv6 addresses in string form, the following two constants are defined in The function returns a pointer to the buffer containing the text string if the conversion succeeds, and NULL otherwise. Upon failure, errno is set to if the af argument is invalid, or if the size of the result buffer is inadequate. IPv6 Address Notation The IPv6 address is bytes long. Example of an IPv6 address is as shown below: The 128 bits are written as eight 16-bit integers separated by colons. Each integer is represented by four hexadecimal digits. In the initial stages all the 128 bits will not be used, hence, it is very likely that there will be many zeros. Hence the IP address in such a scenario will look like this: The above address can be represented in a compact fashion, by replacing a set of consecutive null 16-bit numbers by two colons. The above address can now be re-written as follows: Expanding the abbreviation is very simple. Align whatever is at the left of the double colon to the left of the address: these are the leading 16-bit words. Then align whatever is at the right of the colons to the right of the address and fill up with zeros. The double-colon convention can be used only once inside an address. To support the transition from IPv4, two special IPv6 addresses are supported. They are addresses and addresses. IPv4-Compatible Addresses Description and Example IPv4-compatible addresses can be converted to and from the older IPv4 network address format. They are used when IPv6 systems need to com- municate with each other, but are separated by an IPv4 network. IPv4-compatible addresses are formed by prepending 96 bits of zero, to a valid, 32-bit IPv4 address. For example, the IPv4 address of can be converted to the IPv6 address by first converting each decimal number separated by dots (".") to a 2-digit hexadecimal value, and concatenate into 4-digit hex values between colons (":") as listed below. In addition, leading zeros may be omitted for each hex number between the colons. Therefore, this may be written as the following IPv6 address: We can retain the dot-decimal format and re-write the above address as The above address is also a valid IPv4-compatible IPv6 address. IPv4-Mapped Addresses Description and Example IPv4-mapped addresses indicate systems that do not support IPv6. They are limited to IPv4. An IPv6 host can communicate with an IPv4-only host using the IPv4-mapped IPv6 address. IPv4-mapped addresses are formed by prepending 80 bits of zero, and 16 bits of one's, to a valid 32 bit IPv4 address. An IPv4 address of when mapped to IPv6, it becomes: or AUTHOR
These routines were developed by the University of California, Berkeley. SEE ALSO
gethostent(3N), getnetent(3N), inet(3N), hosts(4), networks(4). inet6(3N)
All times are GMT -4. The time now is 07:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy