notifier.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Routines to manage notifier chains for passing status changes to any
  3. * interested routines. We need this instead of hard coded call lists so
  4. * that modules can poke their nose into the innards. The network devices
  5. * needed them so here they are for the rest of you.
  6. *
  7. * Alan Cox <Alan.Cox@linux.org>
  8. */
  9. #ifndef _LINUX_NOTIFIER_H
  10. #define _LINUX_NOTIFIER_H
  11. #include <linux/errno.h>
  12. struct notifier_block
  13. {
  14. int (*notifier_call)(struct notifier_block *self, unsigned long, void *);
  15. struct notifier_block *next;
  16. int priority;
  17. };
  18. #ifdef __KERNEL__
  19. extern int notifier_chain_register(struct notifier_block **list, struct notifier_block *n);
  20. extern int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n);
  21. extern int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v);
  22. #define NOTIFY_DONE 0x0000 /* Don't care */
  23. #define NOTIFY_OK 0x0001 /* Suits me */
  24. #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */
  25. #define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) /* Bad/Veto action */
  26. /*
  27. * Clean way to return from the notifier and stop further calls.
  28. */
  29. #define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK)
  30. /*
  31. * Declared notifiers so far. I can imagine quite a few more chains
  32. * over time (eg laptop power reset chains, reboot chain (to clean
  33. * device units up), device [un]mount chain, module load/unload chain,
  34. * low memory chain, screenblank chain (for plug in modular screenblankers)
  35. * VC switch chains (for loadable kernel svgalib VC switch helpers) etc...
  36. */
  37. /* netdevice notifier chain */
  38. #define NETDEV_UP 0x0001 /* For now you can't veto a device up/down */
  39. #define NETDEV_DOWN 0x0002
  40. #define NETDEV_REBOOT 0x0003 /* Tell a protocol stack a network interface
  41. detected a hardware crash and restarted
  42. - we can use this eg to kick tcp sessions
  43. once done */
  44. #define NETDEV_CHANGE 0x0004 /* Notify device state change */
  45. #define NETDEV_REGISTER 0x0005
  46. #define NETDEV_UNREGISTER 0x0006
  47. #define NETDEV_CHANGEMTU 0x0007
  48. #define NETDEV_CHANGEADDR 0x0008
  49. #define NETDEV_GOING_DOWN 0x0009
  50. #define NETDEV_CHANGENAME 0x000A
  51. #define NETDEV_FEAT_CHANGE 0x000B
  52. #define SYS_DOWN 0x0001 /* Notify of system down */
  53. #define SYS_RESTART SYS_DOWN
  54. #define SYS_HALT 0x0002 /* Notify of system halt */
  55. #define SYS_POWER_OFF 0x0003 /* Notify of system power off */
  56. #define NETLINK_URELEASE 0x0001 /* Unicast netlink socket released */
  57. #define CPU_ONLINE 0x0002 /* CPU (unsigned)v is up */
  58. #define CPU_UP_PREPARE 0x0003 /* CPU (unsigned)v coming up */
  59. #define CPU_UP_CANCELED 0x0004 /* CPU (unsigned)v NOT coming up */
  60. #define CPU_DOWN_PREPARE 0x0005 /* CPU (unsigned)v going down */
  61. #define CPU_DOWN_FAILED 0x0006 /* CPU (unsigned)v NOT going down */
  62. #define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */
  63. #endif /* __KERNEL__ */
  64. #endif /* _LINUX_NOTIFIER_H */