[완료]컴파일시 invalid use of undefined type 에러
안녕하세요.
디바이스 공부 중 컴파일 에러가 나서 도움을 요청 합니다.
net_device 구조체가 정의 되어 있지 않다고 되어 있는데 linux/netdevice.h 파일에 정의 되어 있고
그 파일에 있는 다른 구조체 쓸 때는 문제가 없습니다. net_device_stats
단지 net_device 구조체에 접근 하면 이렇습니다. 도움을 요청 합니다.
커널 : 리눅스 2.6.29-6 입니다.
************************************************
원인
#define __KERNEL__ 이 빠져서 생긴 이유 였습니다.
************************************************
에러
---------------------------------------------------------
vvm_g5_network.c:51: error: invalid use of undefined type 'struct net_device'
소스
---------------------------------------------------------
#include
#include
#include
#include
#include
#include
#include "vm_g5_network.h"
#ifndef EPERM
#define EPERM 1
#endif
struct net_device vmg5_dev;
struct net_device_stats test;
/* --------------------------------------------------------------------------
* definition of the "private" data structure used by this interface
*/
#if 0
typedef struct vmg5_private {
struct net_device_stats priv_stats;
struct net_device *priv_device; /* interface used to xmit data */
int priv_mode; /* how to drop packets */
int priv_arg1; /* arguments to the dropping mode */
int priv_arg2;
}vmg5_private;
#endif
int vmg5_init(struct net_device *dev)
{
#ifdef CONFIG_NET_FASTROUTE
dev->accept_fastpath = vmg5_accept_fastpath;
#endif
return 0;
}
//module 등록
int vmg5_init_module(void)
{
int err;
test.rx_packets = 0;
vmg5_dev.init = vmg5_init; /* init()함수의 등록 */
SET_MODULE_OWNER(&vmg5_dev);
/* Find a name for this unit */
err=dev_alloc_name(&vmg5_dev,"vmg5%d");
if(err<0)
{
return err;
}
if (register_netdev(&vmg5_dev) != 0)
{
return -EIO;
}
return 0;
}
//module 해제
void vmg5_dev_cleanup_module(void)
{
unregister_netdev(&vmg5_dev);
kfree(vmg5_dev.priv);
memset(&vmg5_dev, 0, sizeof(vmg5_dev));
vmg5_dev.init = vmg5_init;
}
module_init(vmg5_init_module);
module_exit(vmg5_dev_cleanup_module);
댓글 달기