zoukankan      html  css  js  c++  java
  • wewqe

    script.c
    script_runreason(const struct interface *ifp, const char *reason)
    elen = (size_t)make_env(ifp, reason, &env);
    pid = exec_script(ifp->ctx, argv, env);

    make_env(const struct interface *ifp, const char *reason, char ***argv)


    exec_script(const struct dhcpcd_ctx *ctx, char *const *argv, char *const *env)
    posix_spawn(&pid, argv[0], NULL, &attr, argv, env);

    posix_spawn.c
    intposix_spawn(pid_t *pid, const char *path,const posix_spawn_file_actions_t *file_actions,const posix_spawnattr_t *attrp,char *const argv[], char *const envp[])
    execve(path, argv, envp);










    dhcpcd.c
    eloop_event_add(ctx.eloop, ctx.link_fd, dhcpcd_handlelink, &ctx);


    dhcpcd.c
    static void dhcpcd_handlelink(void *arg)
    {
    struct dhcpcd_ctx *ctx;

    ctx = arg;
    if (if_handlelink(ctx) == -1) {
    logger(ctx, LOG_ERR, "if_handlelink: %m");
    eloop_event_delete(ctx->eloop, ctx->link_fd);
    close(ctx->link_fd);
    ctx->link_fd = -1;
    }
    }


    if-linux.c
    if_handlelink(struct dhcpcd_ctx *ctx)
    {

    return get_netlink(ctx, ctx->iov, NULL,
    ctx->link_fd, MSG_DONTWAIT, &link_netlink);
    }

    if-linux.c
    get_netlink(struct dhcpcd_ctx *ctx, struct iovec *iov,struct interface *ifp, int fd, int flags,int (*callback)(struct dhcpcd_ctx *, struct interface *, struct nlmsghdr *))
    if (callback && (r = callback(ctx, ifp, nlm)) != 0)
    break;


    dhcpcd.c
    949run_preinit(struct interface *ifp)

    netlink
    rtnetlink.h
    struct ifinfomsg {
    unsigned char ifi_family;
    unsigned char __ifi_pad;
    unsigned short ifi_type; /* ARPHRD_* */
    int ifi_index; /* Link index */
    unsigned ifi_flags; /* IFF_* flags */
    unsigned ifi_change; /* IFF_* change mask */
    };

    netlink.h
    struct nlmsghdr {
    __u32 nlmsg_len; /* Length of message including header */
    __u16 nlmsg_type; /* Message content */
    __u16 nlmsg_flags; /* Additional flags */
    __u32 nlmsg_seq; /* Sequence number */
    __u32 nlmsg_pid; /* Sending process port ID */
    };

    #define NLMSG_ALIGNTO 4U
    #define NLMSG_ALIGN(len) ( ((len)+NLMSG_ALIGNTO-1) & ~(NLMSG_ALIGNTO-1) )
    #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
    #define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
    #define NLMSG_SPACE(len) NLMSG_ALIGN(NLMSG_LENGTH(len))
    #define NLMSG_DATA(nlh) ((void*)(((char*)nlh) + NLMSG_LENGTH(0)))
    #define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len),
    (struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
    #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) &&
    (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) &&
    (nlh)->nlmsg_len <= (len))
    #define NLMSG_PAYLOAD(nlh,len) ((nlh)->nlmsg_len - NLMSG_SPACE((len)))

    #define NLMSG_NOOP 0x1 /* Nothing. */
    #define NLMSG_ERROR 0x2 /* Error */
    #define NLMSG_DONE 0x3 /* End of a dump */
    #define NLMSG_OVERRUN 0x4 /* Data lost */

    #define NLMSG_MIN_TYPE 0x10 /* < 0x10: reserved control messages */

    if.h
    #define IFF_UP 0x1 /* interface is up */
    #define IFF_BROADCAST 0x2 /* broadcast address valid */
    #define IFF_DEBUG 0x4 /* turn on debugging */
    #define IFF_LOOPBACK 0x8 /* is a loopback net */
    #define IFF_POINTOPOINT 0x10 /* interface is has p-p link */
    #define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
    #define IFF_RUNNING 0x40 /* interface RFC2863 OPER_UP */
    #define IFF_NOARP 0x80 /* no ARP protocol */
    #define IFF_PROMISC 0x100 /* receive all packets */
    #define IFF_ALLMULTI 0x200 /* receive all multicast packets*/

    #define IFF_MASTER 0x400 /* master of a load balancer */
    #define IFF_SLAVE 0x800 /* slave of a load balancer */

    #define IFF_MULTICAST 0x1000 /* Supports multicast */

    ./configure CC=/opt_gccarm/1295_toolchain/bin/aarch64-openwrt-linux-gcc --prefix=/home/jack/pratice/dhcpcd/dhcpcd-6.11.5/_install/

  • 相关阅读:
    1583: [Usaco2009 Mar]Moon Mooing 哞哞叫
    1734: [Usaco2005 feb]Aggressive cows 愤怒的牛
    1596: [Usaco2008 Jan]电话网络
    1589: [Usaco2008 Dec]Trick or Treat on the Farm 采集糖果
    机器学习笔记(2)单变量线性回归
    P4编程环境搭建遇到的问题与解决方法
    P4编程环境搭建
    机器学习笔记(1)监督学习和无监督学习
    阅读 用P4对数据平面进行编程
    Mininet实验 MAC地址学习分析
  • 原文地址:https://www.cnblogs.com/Malphite/p/8378776.html
Copyright © 2011-2022 走看看