summaryrefslogtreecommitdiffstats
path: root/dhcp/dhcp-api/src/main/yang/dhcp.yang
blob: 4fa0a61f8a8540d033f3bbb00649e5873d840821 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module dhcp {

    yang-version 1;
    namespace "urn:opendaylight:params:xml:ns:yang:vpp:dhcp";
    prefix "dhcp";

    description
        "This YANG module defines the generic configuration and
        operational data for dhcp in VPP";

    revision "2017-03-15" {
        description
            "Initial revision of dhcp model";
    }

    import ietf-inet-types {
        prefix inet;
    }

    identity address-family {
        description
            "Base identity from which identities describing address
            families are derived.";
    }

    identity ipv4 {
        base address-family;
        description
            "This identity represents IPv4 address family.";
    }

    identity ipv6 {
        base address-family;
        description
            "This identity represents IPv6 address family.";
    }

    typedef address-type {
        type identityref {
            base address-family;
        }
    }

    grouping relay-attributes {
        list server {
          key "vrf-id address";
          leaf address {
            // FIXME(HC2VPP-79): change to ip-address-no-zone after https://bugs.opendaylight.org/show_bug.cgi?id=6413 is resolved
            type inet:ip-address;
            description
              "IP address of the server DHCP packets will be forwarded to.";
          }
          leaf vrf-id {
            type uint32;
            description
              "Used to send DHCP messages to the server";
          }
        }

        leaf gateway-address {
          // FIXME(HC2VPP-79): change to ip-address-no-zone after https://bugs.opendaylight.org/show_bug.cgi?id=6413 is resolved
          type inet:ip-address;
            mandatory true;
            description
                "IP address of the relay agent.";
        }
        // TODO(HC2VPP-44): add configurable circut-id (option-82/remote-id)
    }

    grouping dhcp-attributes {
        container relays {
            list relay {
                key "address-type rx-vrf-id";
                leaf address-type {
                    type address-type;
                }
                leaf rx-vrf-id {
                    type uint32;
                    description
                        "Used to receive DHCP messages from clients.";
                }
                uses relay-attributes;
            }
        }
    }

    container dhcp {
        uses dhcp-attributes;
    }
}
pan> * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef VPP_VCL_EVENT_H #define VPP_VCL_EVENT_H /** * @file * @brief VPP Communications Library (VCL) event handler. * * Declarations for generic event handling in VCL. */ #include <vppinfra/types.h> #include <vppinfra/lock.h> #include <pthread.h> typedef union vce_event_key_ { struct { u32 eid; u32 session_index; }; u64 as_u64; } vce_event_key_t; typedef struct vce_event_ { vce_event_key_t evk; u32 refcnt; void *data; } vce_event_t; typedef void (*vce_event_callback_t) (void *reg /*vce_event_handler_reg_t* */); typedef struct vce_event_handler_reg_ { vce_event_callback_t handler_fn; pthread_mutex_t handler_lock; pthread_cond_t handler_cond; u32 ev_idx; u64 evk; //Event key u32 replaced_handler_idx; void *handler_fn_args; } vce_event_handler_reg_t; typedef struct vce_event_thread_ { pthread_t thread; pthread_mutex_t generator_lock; pthread_cond_t generator_cond; u32 *event_index_fifo; u8 recycle_event; clib_spinlock_t events_lockp; vce_event_t *vce_events; //pool clib_spinlock_t handlers_lockp; vce_event_handler_reg_t *vce_event_handlers; //pool uword *handlers_index_by_event_key; //hash } vce_event_thread_t; /** * @brief vce_generate_event * - used to trigger an event in the event thread so that registered * handlers are notified * * @param evt - vce_event_thread_t - event system state * @param ev_idx - index to vce_event_thread_t vce_event pool * * @return success/failure rv */ int vce_generate_event (vce_event_thread_t *evt, u32 ev_idx); /** * @brief vce_clear_event() * - removes event from event_pool * * @param evt - vce_event_thread_t - event system state * @param ev - vce_event_t - event to remove */ void vce_clear_event (vce_event_thread_t *evt, vce_event_t *ev); /** * @brief vce_get_event_from_index() * * @param evt - vce_event_thread_t - event system state * @param ev_idx - index to vce_event_thread_t vce_event pool * * @return vce_event_t * */ vce_event_t * vce_get_event_from_index(vce_event_thread_t *evt, u32 ev_idx); /** * @brief vce_get_event_handler() * - returns handler if exists or 0 * @param evt - vce_event_thread_t - event system state * @param evk - event key * @return vce_event_handler_reg_t * */ vce_event_handler_reg_t * vce_get_event_handler (vce_event_thread_t *evt, vce_event_key_t *evk); /** * @brief vce_register_handler * - used by functions who need to be notified that an event has occurred * on a vce_event_key_t (i.e. event type (enum) and sessionID) * - if a handler already exists, the index to the old handler is stored * inside the new handler for re-instatement on vce_unregister_handler() * @param evt - vce_event_thread_t - event system state * @param evk - vce_event_key_t current an eventID from enum in consumer and * sessionID * @param cb - vce_event_callback_t function to handle event * @param cb_args - args that the callback needs passed back to it. * @return vce_handler_reg_t - the function that needs event notification * needs to block on a condvar mutex to reduce spin. That is in here. */ vce_event_handler_reg_t * vce_register_handler (vce_event_thread_t *evt, vce_event_key_t *evk, vce_event_callback_t cb, void *cb_args); /** * @brief vce_unregister_handler * - used by functions to remove need to be notified that an event has occurred * on a vce_event_key_t (i.e. event type (enum) and sessionID) * - if this handler replaced an existing one, re-instate it. * * @param evt - vce_event_thread_t - event system state * @param handler - handler to be unregistered * @return success/failure rv */ int vce_unregister_handler (vce_event_thread_t *evt, vce_event_handler_reg_t *handler); /** * @brief vce_event_thread_fn * - main event thread that waits on a generic condvar/mutex that a signal * has been generated. * - loops through all registered handlers for that vce_event_key_t * (event enum + sessionID) * * @param arg - cast to type of event defined in consuming program. * @return */ extern void * vce_event_thread_fn (void *arg); /** * @brief vce_start_event_thread * - as name suggests. What is important is that vce_event_thread_t is allocated * on the same heap as "everything else". ie use clib_mem_alloc. * @param evt - vce_event_thread_t - event system state * @param max_events - depth of event FIFO for max number of outstanding events. * @return succes/failure */ int vce_start_event_thread (vce_event_thread_t *evt, u8 max_events); #endif //VPP_VCL_EVENT_H