Last active
March 18, 2021 13:56
-
-
Save ao-kenji/bf347bed902a7343d4fa7195a619db46 to your computer and use it in GitHub Desktop.
isibootd(8) patch for OpenBSD. The original source is at: NetBSD:src/usr.sbin/isibootd .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: usr.sbin/isibootd/Makefile | |
| =================================================================== | |
| RCS file: /cvsroot/src/usr.sbin/isibootd/Makefile,v | |
| retrieving revision 1.1 | |
| diff -u -r1.1 Makefile | |
| --- usr.sbin/isibootd/Makefile 17 Dec 2011 13:24:18 -0000 1.1 | |
| +++ usr.sbin/isibootd/Makefile 18 Mar 2021 13:42:58 -0000 | |
| @@ -1,13 +1,9 @@ | |
| # $NetBSD: Makefile,v 1.1 2011/12/17 13:24:18 tsutsui Exp $ | |
| -USE_FORT?= yes # network server | |
| - | |
| PROG= isibootd | |
| SRCS= isibootd.c | |
| MAN= isibootd.8 | |
| LDADD+= -lutil | |
| -DPADD+= ${LIBUTIL} | |
| -.include <bsd.own.mk> | |
| .include <bsd.prog.mk> | |
| Index: usr.sbin/isibootd/isibootd.c | |
| =================================================================== | |
| RCS file: /cvsroot/src/usr.sbin/isibootd/isibootd.c,v | |
| retrieving revision 1.4 | |
| diff -u -r1.4 isibootd.c | |
| --- usr.sbin/isibootd/isibootd.c 30 Jan 2021 11:34:28 -0000 1.4 | |
| +++ usr.sbin/isibootd/isibootd.c 18 Mar 2021 13:42:58 -0000 | |
| @@ -39,9 +39,11 @@ | |
| #include <net/bpf.h> | |
| #include <net/if.h> | |
| #include <net/if_dl.h> | |
| -#include <net/if_ether.h> | |
| +#include <netinet/in.h> | |
| +#include <netinet/if_ether.h> | |
| #include <err.h> | |
| +#include <errno.h> | |
| #include <fcntl.h> | |
| #include <ifaddrs.h> | |
| #include <netdb.h> | |
| @@ -111,6 +113,8 @@ | |
| static char *etheraddr(uint8_t *); | |
| static int pickif(char *, uint8_t *); | |
| static __dead void usage(void); | |
| +static __inline uint32_t be32dec(const void *); | |
| +static __inline void be32enc(void *, uint32_t); | |
| #define ISIBOOT_FRAME(buf) ((buf) + ((struct bpf_hdr *)(buf))->bh_hdrlen) | |
| @@ -172,7 +176,7 @@ | |
| if (!dflag) { | |
| if (daemon(0, 0)) | |
| err(EXIT_FAILURE, "can not start daemon"); | |
| -#ifdef __NetBSD__ | |
| +#if defined(__NetBSD__) || defined (__OpenBSD__) | |
| pidfile(NULL); | |
| #endif | |
| } | |
| @@ -465,3 +469,22 @@ | |
| getprogname()); | |
| exit(0); | |
| } | |
| + | |
| +static __inline uint32_t | |
| +be32dec(const void *pp) | |
| +{ | |
| + uint8_t const *p = (uint8_t const *)pp; | |
| + | |
| + return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); | |
| +} | |
| + | |
| +static __inline void | |
| +be32enc(void *pp, uint32_t u) | |
| +{ | |
| + uint8_t *p = (uint8_t *)pp; | |
| + | |
| + p[0] = (u >> 24) & 0xff; | |
| + p[1] = (u >> 16) & 0xff; | |
| + p[2] = (u >> 8) & 0xff; | |
| + p[3] = u & 0xff; | |
| +} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment