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/

wewqe的更多相关文章

随机推荐

  1. Maximum sub array

    Here I post a way to solve maximum sub array problem: The problem described like this: here is an ar ...

  2. Linux -- 基于zookeeper的java api(一)

    Linux -- 基于zookeeper的java api 首先启动你所有的 zkService.sh 查看状态:检查是否启动正确 [root@hu-hadoop2 ~]# zkServer.sh s ...

  3. <Closing connections idle longer than 60000 MILLISECONDS> <Closing expired connections>

    日志信息如下: 2017-07-05 18:28:34 -18705 [idle_connection_reaper] DEBUG   - Closing expired connections 20 ...

  4. summary_16th Nov, 2018

    一. 编程语言的分类: a. 机器语言:直接使用二进制指令去编写程序,必须考虑硬件细节 b:汇编语言:用英文标签取代二进制指令去编写程序,必须考虑硬件细节 c:高级语言:用人类能理解的方式编写程序,通 ...

  5. c++ count函数

    count函数 algorithm头文件(#include <algorithm>)定义了一个count的函数,其功能类似于find.这个函数使用一对迭代器和一个值做参数,返回这个值出现次 ...

  6. linux nat style

      1● nat style 2● link style    

  7. 【SQL】glob 和 like 的区别

    LIKE 和 GLOB 都可以用来匹配通配符指定模式的文本值.如果搜索表达式与模式表达式匹配,LIKE 运算符将返回真(true),也就是 1 区别: (1)使用的通配符不一样 like:  百分号( ...

  8. centos6.5 安装PHP7.0支持nginx

    1.安装PHP所需要的扩展           yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel ...

  9. sql2008r2安装失败的解决办法

    setup fails with: '.', hexadecimal value 0x00, is an invalid character.SQL 2012 Setup issues - hexad ...

  10. js作用域及闭包

    作用域 执行环境是js最为重要的一个概念.执行环境定义了变量或函数有权访问的其他数据,决定了它们各自的行为. 1.全局执行环境就是最外围的一个执行环境,每一个函数都有自己的作用域 2.简单的说局部作用 ...