ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i compile using
# gcc -c testing.c
its ok
when i isseu the command
# insmod testing.o
the error appears "unresolved symbol htons"
***********************************
/*************C O D E **************/
int My_EthernetRxPacket(struct sk_buff* r_poSocketBuffer,struct net_device* r_poNetworkDevice,struct packet_type* r_poPacketType)
{
//here i receive the EAPOL packet
return(0);
}
/****************** E N D *******************/
The fact that you get the runtime error "unresolved symbol htons" means that your compiler incorrectly treated it like a function. Which in turn means that your compile (despite the lack of warnings) is broken.
2. The solution to problem 1) is to include the correct header (e.g. "#include "netinet/ih.h>").
3. That fact that you're getting lots of errors when you try to do so means that something ELSE is terribly wrong.
In all likelihood, you're probably missing *OTHER* headers as well.
4. itsme86, too, is absolutely correct: "-Wall" is your friend.
The more warnings you get, the more potential problems you're discovering at precisely the time when it's easiest to fix them.
It looks like the header you want is linux/byteorder/generic.h
I don't think netinet/in.h exists in the kernel tree so yeah, including it would be a really bad idea.
Since you're building a kernel module you probably need to either build using the kernel's build system (2.6) or #define some things, I think __KERNEL__ and __MODULE__ for 2.4.
i have included linux\byteorder\generic.h
now the error is not appearing,
another problem faced by me. when i use i.e a= htons(0x888e) the value returned by the htons() is suppose 32764 ,now removing htons()
i.e a= 0x888e
the output remains 32764
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.