Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-17-2009, 11:36 PM   #1
Senior Member
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 211Reputation: 211Reputation: 211
New for 2.6.31: net_device_ops structure. How do I set function pointers?


In kernel 2.6.31 it appears that a bunch of the function pointers to net_device operations disappeared from the net_device structure, and were put into a new net_device_ops structure which is a const member of the new copy of net_device.

...If netdev_ops is declared const (and unitialized) in net_device, how am I supposed to do things like:

mynet_device->netdev_ops->ndo_open = my_drivers_open_function();
Thanks for any ideas!!
Old 10-19-2009, 03:17 AM   #2
Senior Member
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Original Poster
Rep: Reputation: 211Reputation: 211Reputation: 211
I was able to resolve this.

In the net_device struct (2.6.31+) the mew net_device_ops member is declared as:
const struct net_device_ops *netdev_ops;
As such, you can easily instantiate a net_device_ops struct with whatever function pointer assignments you desire, and then change the pointer reference to the new struct. Suppose that your net_device_opts struct is instantiated as "mynetdev_ops." The solution is:

mynet_dev->netdev_ops = &mynetdev_ops;
I felt silly having to reference this again, but this is relevant:

Last edited by jhwilliams; 10-19-2009 at 03:19 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using C function pointers in C++ Hexstatic Programming 3 09-26-2006 06:58 PM
Matrix of function pointers kvtournh Programming 9 03-20-2006 05:38 AM
problem with function returning pointers ***func() mlaich Programming 5 01-19-2006 10:17 PM
Function pointers, calling, and templates The_Nerd Programming 2 10-09-2005 08:08 PM
Function pointers in C. Matir Programming 2 03-15-2005 04:10 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:52 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration