/*
* Common (shared) DLPI test routines.
* Mostly pretty boring boilerplate sorta stuff.
* These can be split into individual library routines later
* but it's just convenient to keep them in a single file
* while they're being developed.
*
* Not supported:
* Connection Oriented stuff
* QOS stuff
*/
/*
typedef unsigned long ulong;
*/
#include <sys/types.h>
#include <sys/stream.h>
#include <sys/stropts.h>
#include <sys/dlpi.h>
#include <sys/signal.h>
#include <stdio.h>
#include <string.h>
#include "dltest.h"
#define CASERET(s) case s: return ("s")
char *dlprim();
char *dlstate();
char *dlerrno();
char *dlpromisclevel();
char *dlservicemode();
char *dlstyle();
char *dlmactype();
int putmsg(int, const struct strbuf *, const struct strbuf *, int);
void syserr(char *);
void strgetmsg(int, struct strbuf *, struct strbuf *, int *, char *);
void expecting(int, union DL_primitives *);
void (*signal (int sig, void (*disp)(int)))(int);
unsigned alarm(unsigned sec);
int getmsg(int, struct strbuf *, struct strbuf *, int *);
void expecting(int, union DL_primitives *);
void printdlprim(union DL_primitives *dlp);
void printdlinforeq(union DL_primitives *dlp);
void printdlinfoack(union DL_primitives *dlp);
void printdlattachreq(union DL_primitives *dlp);
void printdlokack(union DL_primitives *dlp);
void printdlerrorack(union DL_primitives *dlp);
void printdldetachreq(union DL_primitives *dlp);
void printdlbindreq(union DL_primitives *dlp);
void printdlbindack(union DL_primitives *dlp);
void printdlunbindreq(union DL_primitives *dlp);
void printdlsubsbindreq(union DL_primitives *dlp);
void printdlsubsbindack(union DL_primitives *dlp);
void printdlsubsunbindreq(union DL_primitives *dlp);
void printdlenabmultireq(union DL_primitives *dlp);
void printdldisabmultireq(union DL_primitives *dlp);
void printdlpromisconreq(union DL_primitives *dlp);
void printdlpromiscoffreq(union DL_primitives *dlp);
void printdlunitdatareq(union DL_primitives *dlp);
void printdlunitdataind(union DL_primitives *dlp);
void printdluderrorind(union DL_primitives *dlp);
void printdludqosreq(union DL_primitives *dlp);
void printdlphysaddrreq(union DL_primitives *dlp);
void printdlphysaddrack(union DL_primitives *dlp);
void printdlsetphysaddrreq(union DL_primitives *dlp);
void addrtostring(u_char *addr, u_long length, u_char *s);
int ioctl(int fildes, int request, /* arg */ ...);
/*VARARGS1*/
void err(fmt, a1, a2, a3, a4)
char *fmt;
char *a1, *a2, *a3, *a4;
{
(void) fprintf(stderr, fmt, a1, a2, a3, a4);
(void) fprintf(stderr, "\n");
(void) exit(1);
}
void dlinforeq(fd)
int fd;
{
dl_info_req_t info_req;
struct strbuf ctl;
int flags;
info_req.dl_primitive = DL_INFO_REQ;
ctl.maxlen = 0;
ctl.len = sizeof (info_req);
ctl.buf = (char *) &info_req;
flags = RS_HIPRI;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dlinforeq: putmsg");
}
void dlinfoack(fd, bufp)
int fd;
char *bufp;
{
union DL_primitives *dlp;
struct strbuf ctl;
int flags;
ctl.maxlen = MAXDLBUF;
ctl.len = 0;
ctl.buf = bufp;
strgetmsg(fd, &ctl, (struct strbuf*)NULL, &flags, "dlinfoack");
dlp = (union DL_primitives *) ctl.buf;
expecting(DL_INFO_ACK, dlp);
if (ctl.len < sizeof (dl_info_ack_t))
err("dlinfoack: response ctl.len too short: %d", ctl.len);
if (flags != RS_HIPRI)
err("dlinfoack: DL_INFO_ACK was not M_PCPROTO");
if (ctl.len < sizeof (dl_info_ack_t))
err("dlinfoack: short response ctl.len: %d", ctl.len);
}
void dlattachreq(fd, ppa)
int fd;
u_long ppa;
{
dl_attach_req_t attach_req;
struct strbuf ctl;
int flags;
attach_req.dl_primitive = DL_ATTACH_REQ;
attach_req.dl_ppa = ppa;
ctl.maxlen = 0;
ctl.len = sizeof (attach_req);
ctl.buf = (char *) &attach_req;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dlattachreq: putmsg");
}
void dlenabmultireq(fd, addr, length)
int fd;
char *addr;
int length;
{
long buf[MAXDLBUF];
union DL_primitives *dlp;
struct strbuf ctl;
int flags;
dlp = (union DL_primitives*) buf;
dlp->enabmulti_req.dl_primitive = DL_ENABMULTI_REQ;
dlp->enabmulti_req.dl_addr_length = length;
dlp->enabmulti_req.dl_addr_offset = sizeof (dl_enabmulti_req_t);
(void) memcpy((char*)OFFADDR(buf, sizeof (dl_enabmulti_req_t)), addr, length);
ctl.maxlen = 0;
ctl.len = sizeof (dl_enabmulti_req_t) + length;
ctl.buf = (char*) buf;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dlenabmultireq: putmsg");
}
void dldisabmultireq(fd, addr, length)
int fd;
char *addr;
int length;
{
long buf[MAXDLBUF];
union DL_primitives *dlp;
struct strbuf ctl;
int flags;
dlp = (union DL_primitives*) buf;
dlp->disabmulti_req.dl_primitive = DL_ENABMULTI_REQ;
dlp->disabmulti_req.dl_addr_length = length;
dlp->disabmulti_req.dl_addr_offset = sizeof (dl_disabmulti_req_t);
(void) memcpy((char*)OFFADDR(buf, sizeof (dl_disabmulti_req_t)), addr, length);
ctl.maxlen = 0;
ctl.len = sizeof (dl_disabmulti_req_t) + length;
ctl.buf = (char*) buf;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dldisabmultireq: putmsg");
}
void dlpromisconreq(fd, level)
int fd;
u_long level;
{
dl_promiscon_req_t promiscon_req;
struct strbuf ctl;
int flags;
promiscon_req.dl_primitive = DL_PROMISCON_REQ;
promiscon_req.dl_level = level;
ctl.maxlen = 0;
ctl.len = sizeof (promiscon_req);
ctl.buf = (char *) &promiscon_req;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dlpromiscon: putmsg");
}
void dlpromiscoff(fd, level)
int fd;
u_long level;
{
dl_promiscoff_req_t promiscoff_req;
struct strbuf ctl;
int flags;
promiscoff_req.dl_primitive = DL_PROMISCOFF_REQ;
promiscoff_req.dl_level = level;
ctl.maxlen = 0;
ctl.len = sizeof (promiscoff_req);
ctl.buf = (char *) &promiscoff_req;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dlpromiscoff: putmsg");
}
void dlphysaddrreq(fd, addrtype)
int fd;
u_long addrtype;
{
dl_phys_addr_req_t phys_addr_req;
struct strbuf ctl;
int flags;
phys_addr_req.dl_primitive = DL_PHYS_ADDR_REQ;
phys_addr_req.dl_addr_type = addrtype;
ctl.maxlen = 0;
ctl.len = sizeof (phys_addr_req);
ctl.buf = (char *) &phys_addr_req;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dlphysaddrreq: putmsg");
}
void dlsetphysaddrreq(fd, addr, length)
int fd;
char *addr;
int length;
{
long buf[MAXDLBUF];
union DL_primitives *dlp;
struct strbuf ctl;
int flags;
dlp = (union DL_primitives*) buf;
dlp->set_physaddr_req.dl_primitive = DL_ENABMULTI_REQ;
dlp->set_physaddr_req.dl_addr_length = length;
dlp->set_physaddr_req.dl_addr_offset = sizeof (dl_set_phys_addr_req_t);
(void) memcpy((char*)OFFADDR(buf, sizeof (dl_set_phys_addr_req_t)), addr, length);
ctl.maxlen = 0;
ctl.len = sizeof (dl_set_phys_addr_req_t) + length;
ctl.buf = (char*) buf;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dlsetphysaddrreq: putmsg");
}
void dldetachreq(fd)
int fd;
{
dl_detach_req_t detach_req;
struct strbuf ctl;
int flags;
detach_req.dl_primitive = DL_DETACH_REQ;
ctl.maxlen = 0;
ctl.len = sizeof (detach_req);
ctl.buf = (char *) &detach_req;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dldetachreq: putmsg");
}
void dlbindreq(fd, sap, max_conind, service_mode, conn_mgmt, xidtest)
int fd;
u_long sap;
u_long max_conind;
u_long service_mode;
u_long conn_mgmt;
u_long xidtest;
{
dl_bind_req_t bind_req;
struct strbuf ctl;
int flags;
bind_req.dl_primitive = DL_BIND_REQ;
bind_req.dl_sap = sap;
bind_req.dl_max_conind = max_conind;
bind_req.dl_service_mode = service_mode;
bind_req.dl_conn_mgmt = conn_mgmt;
bind_req.dl_xidtest_flg = xidtest;
ctl.maxlen = 0;
ctl.len = sizeof (bind_req);
ctl.buf = (char *) &bind_req;
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf*) NULL, flags) < 0)
syserr("dlbindreq: putmsg");
}
void dlunitdatareq(fd, addr
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
anti_sniff_v1-1-2.tar.gz (51个子文件)
anti_sniff
run_dnstest.c 3KB
linux_glue.c 875B
pingtime.c 10KB
run_icmptest.c 2KB
ip_icmp.h 5KB
CREDITS 631B
linux_etherping.c 6KB
main.c 1KB
flood_net.c 8KB
etherping.c 7KB
run_etherpingtest.c 1KB
ANTI_SNIFFER_DOCS 4KB
dltest.h 498B
arpreqtest.c 5KB
test_echotest.c 413B
bpf_readwrite.c 4KB
arputils.c 541B
bpf_watcharp.c 1KB
dlcommon.c 31KB
linux_rundnstest.c 3KB
dlpi_watcharp.c 1KB
LINUX_NOTES 1KB
raw_watchdns.c 5KB
anti_sniff.h 2KB
TODO 112B
LICENSE 9KB
dlpi_getetheraddr.c 2KB
README 603B
run_arptest.c 401B
includes.h 1KB
test_arpreq.c 454B
bpf_getetheraddr.c 6KB
linux_readwrite.c 2KB
result_routines.c 5KB
linux_arpreqtest.c 5KB
raw_watcharp.c 920B
echotime.c 4KB
linux_getetheraddr.c 2KB
linux_flood_net.h 895B
Makefile 14KB
dlpi_readwrite.c 3KB
NOTES 3KB
run_echotest.c 2KB
DSL_NOTES 1KB
linux_includes.h 631B
ip_util.c 2KB
ethertest.c 1KB
watch_dns_test.c 717B
linux_flood_net.c 8KB
anti_sniff.c 8KB
bpf_watchdns.c 5KB
共 51 条
- 1
APei
- 粉丝: 63
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0