mywiki:linux:ip_kernel
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| mywiki:linux:ip_kernel [2014/09/12 14:11] – shaoguoh | mywiki:linux:ip_kernel [2022/04/02 17:30] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 12: | Line 12: | ||
| </ | </ | ||
| - | ====== Example ====== | + | ====== Example |
| <file c get_ip.c> | <file c get_ip.c> | ||
| Line 61: | Line 61: | ||
| module_init(test_startup); | module_init(test_startup); | ||
| module_exit(test_exit); | module_exit(test_exit); | ||
| + | </ | ||
| + | |||
| + | ====== Example 2 ====== | ||
| + | <file get_ip2.c> | ||
| + | int get_ifaddr_by_name(const char *ifname, __u32 * addr) | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | | ||
| + | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, | ||
| + | | ||
| + | #else | ||
| + | | ||
| + | #endif | ||
| + | while (pnet_device != NULL) | ||
| + | { | ||
| + | if ((netif_running(pnet_device)) | ||
| + | && | ||
| + | && | ||
| + | { | ||
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| + | { | ||
| + | | ||
| + | | ||
| + | } | ||
| + | /* ifa_local: ifa_address is the remote point in ppp */ | ||
| + | *addr = (inet_ifaddr-ifa_local); | ||
| + | | ||
| + | | ||
| + | } | ||
| + | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, | ||
| + | | ||
| + | #else | ||
| + | | ||
| + | #endif | ||
| + | |||
| + | } | ||
| + | |||
| + | | ||
| + | | ||
| + | } | ||
| + | |||
| </ | </ | ||
mywiki/linux/ip_kernel.1410502309.txt.gz · Last modified: (external edit)
