Annotation of embedaddon/bird2/nest/locks.h, revision 1.1
1.1 ! misho 1: /*
! 2: * BIRD Object Locks
! 3: *
! 4: * (c) 1999 Martin Mares <mj@ucw.cz>
! 5: *
! 6: * Can be freely distributed and used under the terms of the GNU GPL.
! 7: */
! 8:
! 9: #ifndef _BIRD_LOCKS_H_
! 10: #define _BIRD_LOCKS_H_
! 11:
! 12: #include "lib/resource.h"
! 13: #include "lib/event.h"
! 14:
! 15: /*
! 16: * The object locks are used for controlling exclusive access
! 17: * to various physical resources like UDP ports on specific devices.
! 18: * When you want to access such resource, you ask for a object lock
! 19: * structure, fill in specification of the object and your function
! 20: * you want to have called when the object is available and invoke
! 21: * olock_acquire() afterwards. When the object becomes free, the lock
! 22: * manager calls your function. To free the object lock, just call rfree
! 23: * on its resource.
! 24: */
! 25:
! 26: struct object_lock {
! 27: resource r;
! 28: ip_addr addr; /* Identification of a object: IP address */
! 29: uint type; /* ... object type (OBJLOCK_xxx) */
! 30: uint port; /* ... port number */
! 31: uint inst; /* ... instance ID */
! 32: struct iface *iface; /* ... interface */
! 33: struct iface *vrf; /* ... or VRF (if iface is unknown) */
! 34: void (*hook)(struct object_lock *); /* Called when the lock succeeds */
! 35: void *data; /* User data */
! 36: /* ... internal to lock manager, don't touch ... */
! 37: node n; /* Node in list of olocks */
! 38: int state; /* OLOCK_STATE_xxx */
! 39: list waiters; /* Locks waiting for the same resource */
! 40: };
! 41:
! 42: struct object_lock *olock_new(pool *);
! 43: void olock_acquire(struct object_lock *);
! 44: void olock_init(void);
! 45:
! 46: #define OBJLOCK_UDP 1 /* UDP port */
! 47: #define OBJLOCK_TCP 2 /* TCP port */
! 48: #define OBJLOCK_IP 3 /* IP protocol */
! 49:
! 50: #define OLOCK_STATE_FREE 0
! 51: #define OLOCK_STATE_LOCKED 1
! 52: #define OLOCK_STATE_WAITING 2
! 53: #define OLOCK_STATE_EVENT 3 /* waiting for unlock processing */
! 54:
! 55: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>