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. bootstrap table导出功能无效报错Uncaught INVALID_CHARACTER_ERR: DOM Exception 5和导出中文乱码问题

    由于表格数据中含有中文导致的,在网页的开发者选项中报一个 Uncaught INVALID_CHARACTER_ERR: DOM Exception 5 问题.这个问题是由于BootStrap tab ...

  2. mybatis*中DefaultVFS的logger乱码问题

    从网上下的Java Persistence with MyBatis 3的源码 出现这个问题的原因是logback记日志的时候乱码 ResolverUtil - Not a JAR: file:... ...

  3. [LightOJ 1287] Where to Run

    Where to Run Last night you robbed a bank but couldn't escape and when you just got outside today, t ...

  4. K-Means ++ 和 kmeans 区别

    Kmeans算法的缺陷 聚类中心的个数K 需要事先给定,但在实际中这个 K 值的选定是非常难以估计的,很多时候,事先并不知道给定的数据集应该分成多少个类别才最合适Kmeans需要人为地确定初始聚类中心 ...

  5. VCG(VisualCodeGrepper)安装使用教程

    一.说明 代码审计工具看来还是比较难做,一是开源的代码审计工具少,二是原本的一些开源审计工具很多都不更新甚至不能使用了. VCG支持审计C++.Java.C#.PHP和VB,但其“审计”基本相当于函数 ...

  6. windows开机锁定小键盘

    1.启动注册表编缉器 按下windows+R键,输入regedit回车启动注册表编缉器 2.修改注册表默认值 展开HKEY_USERS\.DEFAULT\Control Panel\Keyboard将 ...

  7. CentOS安装JDK-tar.gz文件

    1.下载JDK,下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. 测试 ...

  8. python 关闭垃圾回收

    import gc gc.disable() http://blog.csdn.net/aixiaohei/article/details/6446869

  9. linux网络操作 netstat命令

    关闭与启动网卡 ifdown 网卡设备名 #禁用该网卡设备 ifup网卡设备名 #启用该网卡设备 查看网络状态 netstat  命令 ​ -t 列出tcp协议端口 -u 列出udp协议端口 -n 不 ...

  10. java倒计时使用ScheduledExecutor实现,使用两个线程,以秒为单位

    public class Countdown2 { private volatile int lin; private int curSec; public Countdown2(int lin) t ...