02-19-2007
for gcc try to define your structure like this:
struct gtpp_hdr6 {
unsigned char flag; // 1 byte
unsigned char message_type; // 1 byte
unsigned short length; // 2 bytes
unsigned short sequence; // 2 bytes
} __attribute__((__packed__));
and check again.
This attribute shows compiler that this structure used for data packets and compiler will not do padding
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi
Can anyone tell me how to pad zeroes on the left side to a numeric string in unix shell scripting
Your answer is very much appreciated
Thanks
Vijay (2 Replies)
Discussion started by: vijaygopalsk
2 Replies
2. Programming
Is there a function in c that will allow me to pad variables?
I have an int that can't be longer than 10. I need to pad a numeric value with leading zeros
314
0000000314 (1 Reply)
Discussion started by: flounder
1 Replies
3. Shell Programming and Scripting
I have a file with different character counts on each line
how do i make it with unique character counts.
example:
1st line : ABCD 011 XYZ 0000 YYYY BBB TEADINGDA
2nd line: ABCD 011 xys 0010 YYYY BBB TEAD
3rd line : ABCD 022 YXU 000 UUU BBB TE
1st line is 43... (3 Replies)
Discussion started by: rudoraj
3 Replies
4. Shell Programming and Scripting
In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server.
For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match.
Please... (4 Replies)
Discussion started by: krishmaths
4 Replies
5. Shell Programming and Scripting
Hi All
Can anyone please suggest me how to remove the last byte from a falt file .This is from the last line's last BYTE.
Please suggest me something.
Thank's and regards
Vinay (1 Reply)
Discussion started by: vinayrao
1 Replies
6. UNIX for Dummies Questions & Answers
I have a file with records containing dates like:
SMPBR|DUP-DO NOT USE|NEW YORK||16105|BA5270715|2007-6-6|MWERNER|109||||JOHN||SMITH|MD|72211118||||||74559|21 WILMINGTON RD||D|2003-11-6|SL# MD CONTACT-LIZ RICHARDS|||0|Y|N||1411458|
How can I get the date fields in each of my records to be... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies
7. Shell Programming and Scripting
Hi Friends,
I would like to left pad with "0's" on first column say (width six)
I have a large file with the format:
FILE:
1: ALFRED 84378 NY
8385: JAMES 88385 FL
323: SMITH 00850 TX
My output needs to be like:
000001: ALFRED 84378 NY
008385: JAMES 88385 FL
000323: SMITH... (10 Replies)
Discussion started by: sbasetty
10 Replies
8. Shell Programming and Scripting
hi All
i am new to linux...
source txt ..
281-BUM-5M BUM-5M 0 0
282-BUM-5M BUM-5M 0 0
83-BUM-5M BUM-5M 0 0
is it possible to use bash script to convert to
(remove the "-" and fill up to 4 digit" ?
0281 BUM-5M BUM-5M 0 0
0282 BUM-5M BUM-5M 0 0
0083 BUM-5M BUM-5M 0 0
thanks a ... (5 Replies)
Discussion started by: samoptimus
5 Replies
9. Shell Programming and Scripting
Hi all
Is there a way to pad the output of a bash script
see that code below
for i in `sed -n '/Start Printer/,/End Printer/p' /u/ab/scripts/hosts.conf | awk '!/^#/ {print $2}' | egrep -v 'broke|primera' `; do
pages=`snmpget -Ov -v1 -c public $i sysLocation.0 | awk '{print $2}'`
... (3 Replies)
Discussion started by: ab52
3 Replies
10. Shell Programming and Scripting
I have this csv file that I would like to sort on the 20th and 21st field. They are high lighted below. My challenge is that when I sort on those fields they are not in order as I would have liked. It seems like I have to pad those fields to the longest value in that fields data.
... (6 Replies)
Discussion started by: GroveTuckey
6 Replies
LEARN ABOUT REDHAT
inet_network
INET(3) Linux Programmer's Manual INET(3)
NAME
inet_aton, inet_addr, inet_network, inet_ntoa, inet_makeaddr, inet_lnaof, inet_netof - Internet address manipulation routines
SYNOPSIS
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int inet_aton(const char *cp, struct in_addr *inp);
in_addr_t inet_addr(const char *cp);
in_addr_t inet_network(const char *cp);
char *inet_ntoa(struct in_addr in);
struct in_addr inet_makeaddr(int net, int host);
in_addr_t inet_lnaof(struct in_addr in);
in_addr_t inet_netof(struct in_addr in);
DESCRIPTION
inet_aton() converts the Internet host address cp from the standard numbers-and-dots notation into binary data and stores it in the struc-
ture that inp points to. inet_aton returns nonzero if the address is valid, zero if not.
The inet_addr() function converts the Internet host address cp from numbers-and-dots notation into binary data in network byte order. If
the input is invalid, INADDR_NONE (usually -1) is returned. This is an obsolete interface to inet_aton, described immediately above; it is
obsolete because -1 is a valid address (255.255.255.255), and inet_aton provides a cleaner way to indicate error return.
The inet_network() function extracts the network number in host byte order from the address cp in numbers-and-dots notation. If the input
is invalid, -1 is returned.
The inet_ntoa() function converts the Internet host address in given in network byte order to a string in standard numbers-and-dots nota-
tion. The string is returned in a statically allocated buffer, which subsequent calls will overwrite.
The inet_makeaddr() function makes an Internet host address in network byte order by combining the network number net with the local
address host in network net, both in local host byte order.
The inet_lnaof() function returns the local host address part of the Internet address in. The local host address is returned in local host
byte order.
The inet_netof() function returns the network number part of the Internet Address in. The network number is returned in local host byte
order.
The structure in_addr as used in inet_ntoa(), inet_makeaddr(), inet_lnoaf() and inet_netof() is defined in netinet/in.h as:
struct in_addr {
unsigned long int s_addr;
}
Note that on the i80x86 the host byte order is Least Significant Byte first, whereas the network byte order, as used on the Internet, is
Most Significant Byte first.
CONFORMING TO
BSD 4.3
SEE ALSO
gethostbyname(3), getnetent(3), inet_ntop(3), inet_pton(3), hosts(5), networks(5)
BSD
2001-07-25 INET(3)