the problem with the code

DÔ Phan-Cam-Thach dophancamthach at yahoo.co.uk
Wed Aug 6 14:33:50 UTC 2008


Hi everybody,
I have a problem while reading the code. I dont understand much of struct universe which is copied below.  I find that there are the functions in this structure, ex:
        struct option_cache *(*lookup_func) (struct universe *,
                         struct option_state *,
                         unsigned);
I dont understand this model much (there are functions in a structure). And i dont understand why dont they put these functions out of the structure instead of in the structure? Besides, i dont understand what this function is used for?

Is there someone who can help me?
Thanks in advance.

This is the structure (in tree.h):

struct universe {
    const char *name;
    struct option_cache *(*lookup_func) (struct universe *,
                         struct option_state *,
                         unsigned);
    void (*save_func) (struct universe *, struct option_state *,
               struct option_cache *, isc_boolean_t);
    void (*foreach) (struct packet *,
             struct lease *, struct client_state *,
             struct option_state *, struct option_state *,
             struct binding_scope **, struct universe *, void *,
             void (*) (struct option_cache *, struct packet *,
                   struct lease *, struct client_state *,
                   struct option_state *,
                   struct option_state *,
                   struct binding_scope **,
                   struct universe *, void *));
    void (*delete_func) (struct universe *universe,
                 struct option_state *, int);
    int (*option_state_dereference) (struct universe *,
                     struct option_state *,
                     const char *, int);
    int (*decode) (struct option_state *,
               const unsigned char *, unsigned, struct universe *);
    int (*encapsulate) (struct data_string *, struct packet *,
                struct lease *, struct client_state *,
                struct option_state *, struct option_state *,
                struct binding_scope **,
                struct universe *);
    u_int32_t (*get_tag) (const unsigned char *);
    void (*store_tag) PROTO ((unsigned char *, u_int32_t));
    u_int32_t (*get_length) (const unsigned char *);
    void (*store_length) PROTO ((unsigned char *, u_int32_t));
    int tag_size, length_size;
    unsigned end;
    option_name_hash_t *name_hash;
    option_code_hash_t *code_hash;
    struct option *enc_opt;
    int index;

    /* Flags should probably become condensed. */
    int concat_duplicates;
};


      __________________________________________________________
Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at Yahoo! http://uk.docs.yahoo.com/ymail/new.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20080806/1f15633d/attachment.html>


More information about the dhcp-users mailing list