473,471 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to code such function, thanks for any comments

HI :

The following code is
typedef struct nlpPkt
{
int source:4;
int destin:4;
unsigned int control:1;
unsigned int contype:5;
int length:10;
int checksum:16;
char nlpData[1500];
} NLPPKT; //same size

typedef struct tlpPkt
{
int sequence:7;
int ack:8;
int lenghth:10;
int blankbit:5;
int End:1;
char tlpData[1469];
} TLPPKT;

What I want to realize it to pack the whole TLPPKT into the NLPPKT
->nlpData [1500],
what confused me is the TLPPKT is a structure and includes different
type of variable.So how to put all these infor to just one char
*nlpData ?

Thanks for any comments.

bin YE

Nov 15 '05 #1
1 1133

"yezi" <ye*****@hotmail.com> wrote

The following code is
typedef struct nlpPkt
{
int source:4;
int destin:4;
unsigned int control:1;
unsigned int contype:5;
int length:10;
int checksum:16;
char nlpData[1500];
} NLPPKT; //same size

typedef struct tlpPkt
{
int sequence:7;
int ack:8;
int lenghth:10;
int blankbit:5;
int End:1;
char tlpData[1469];
} TLPPKT;

What I want to realize it to pack the whole TLPPKT into the NLPPKT
->nlpData [1500],
what confused me is the TLPPKT is a structure and includes different
type of variable.So how to put all these infor to just one char
*nlpData ?

The cheeze way

memcpy( nlppkt.nlpData, &tlppkt, sizeof(TLPPKT));

( nlppkt and tlppkt structures)

The better way - define function to convert the bitfields, which could have
any layout in memory, to a serial sequence of unsigned chars.
Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: lawrence | last post by:
Right now, over at www.monkeyclaus.org, the following script is getting to the 9th run through and dying after the line: echo "..."; You'll admit that is a strange place to die. I've hit...
4
by: lawrence | last post by:
Maybe its late and I'm tired but I don't understand what I'm seeing on the screen. I have this block of code: $choiceMade = $_GET; if ($simpleMode == "y" && $choiceMade == "") {...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
22
by: Illya Havsiyevych | last post by:
Hello How easily parse VB/VBA code by VB/VBA code ? Is any ready solutions ? Thank's, illya
28
by: Steve Jorgensen | last post by:
I often come up with logic like this somewhere in a function: .... If Not IsNull(<some expression>) Then <default action> Else <alternative action> End If ....
192
by: Vortex Soft | last post by:
http://www.junglecreatures.com/ Try it and tell me what's happenning in the Microsoft Corporation. Notes: VB, C# are CLS compliant
18
by: Marian F. | last post by:
The 12 years old genius function to count english words in a sentence: ' This is my function to count english words in your string ' s is the string with your words to be counted ' Returns an...
26
by: Martin Jørgensen | last post by:
Hi, I don't understand these errors I get: g++ Persort.cpp Persort.cpp: In function 'int main()': Persort.cpp:43: error: name lookup of 'j' changed for new ISO 'for' scoping Persort.cpp:37:...
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
11
by: Daniel Norden | last post by:
Hello. Can you give me some feedback on my code layout? I have everything organized in an object, "NRL", that's used as a namespace, and there are other subobjects/modules below that, for...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.