diff --git a/Makefile b/Makefile index 075c5a3..d58a3b7 100644 --- a/Makefile +++ b/Makefile @@ -1 +1,7 @@ obj-m += postage.o + +all: + bash build.sh + +clean: + bash clean.sh diff --git a/postage.c b/postage.c index 19091d6..8cae403 100644 --- a/postage.c +++ b/postage.c @@ -10,8 +10,8 @@ struct net_device *dev; static int my_eth_init(struct net_device *dev) { // Initialize device - printk(KERN_INFO "My Ethernet device initialized\n"); netif_start_queue(dev); + printk(KERN_INFO "Postens initades\n"); return 0; } @@ -19,7 +19,7 @@ static int my_eth_init(struct net_device *dev) static void my_eth_exit(struct net_device *dev) { // Cleanup device - pr_info(KERN_INFO "My Ethernet device exited\n"); + pr_info(KERN_INFO "Posten slutade\n"); netif_stop_queue(dev); } @@ -27,7 +27,7 @@ static netdev_tx_t my_eth_start_xmit(struct sk_buff *skb, struct net_device *dev) { // Start xmit - printk(KERN_INFO "My Ethernet device start xmit\n"); + printk(KERN_INFO "Posten ska skicka nåt\n"); printk("len: %d\n", skb->len); for (int i = 0; i < skb->len; i++) { printk("data: %c\n", skb->data[i]); @@ -45,30 +45,28 @@ static struct net_device_ops my_netdev_ops = { .ndo_start_xmit = my_eth_start_xmit }; -void init_testcard(struct net_device *dev) +void init_poster(struct net_device *dev) { dev->netdev_ops = &my_netdev_ops; - printk("Init testcard\n"); + printk(KERN_INFO "Postens allokerades\n"); } struct net_device testcard; int register_device(void) { - dev = alloc_netdev(0, "myeth%d", NET_NAME_UNKNOWN, init_testcard); + printk(KERN_INFO "Posten skapas\n"); + + dev = alloc_netdev(0, "post%d", NET_NAME_UNKNOWN, init_poster); if (!dev) return -ENOMEM; - printk("Registering\n"); - if (register_netdev(dev)) { - printk("Failed :(\n"); + printk(KERN_ERR "Men vafan Linux vill inte registrera postjävel :(\n"); free_netdev(dev); return -ENODEV; } - printk("Registered\n"); - return 0; } @@ -76,7 +74,7 @@ int __init custom_init(void) { int err; if ((err = register_device())) { - printk("Error loading postage\n"); + printk(KERN_ERR "Postjävel funkar inte\n"); return err; } @@ -86,15 +84,13 @@ int __init custom_init(void) void __exit custom_exit(void) { if (!dev) { - printk(KERN_ERR "Ethernet device not found\n"); + printk(KERN_ERR "Postjävel finns inte :/\n"); return; } unregister_netdev(dev); - printk(KERN_INFO "Ethernet device unregistered\n"); - free_netdev(dev); - printk(KERN_INFO "Ethernet device freed\n"); + printk(KERN_INFO "Posten försvann :,)\n"); } module_init(custom_init);