第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如果注釋了第二個(gè)和第三個(gè)ioctl函數(shù),程序能運(yùn)行,但是程序沒(méi)法發(fā)出數(shù)據(jù)幀?

如果注釋了第二個(gè)和第三個(gè)ioctl函數(shù),程序能運(yùn)行,但是程序沒(méi)法發(fā)出數(shù)據(jù)幀?

#define SIOCAJSMODE SIOCDEVPRIVATE #define SIOCAJGMODE SIOCAJSMODE + 1int channel; char ifname[IFNAMSIZ]; int sockfd;static int get_socket (void){struct sockaddr_ll addr;struct ifreq req; struct aj_config aj_conf;int sockfd, flags;if((sockfd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0){return(-1);}/* get the interface index */memset(&req, 0, sizeof(struct ifreq));memset(&aj_conf, 0, sizeof(struct aj_config));strcpy(req.ifr_name, ifname);if(ioctl(sockfd, SIOCGIFINDEX, &req) < 0) // 第一個(gè){return(-2);}printf("interafce Index:%d\n",req.ifr_ifindex);/* bind the socket to the interface */memset(&addr, 0, sizeof(struct sockaddr_ll));addr.sll_ifindex = req.ifr_ifindex;addr.sll_protocol = htons(ETH_P_ALL);addr.sll_family = PF_PACKET;if(bind(sockfd, (struct sockaddr *)&addr, sizeof(struct sockaddr_ll)) < 0){return(-3);}req.ifr_data = (char *)&aj_conf;if(ioctl(sockfd, SIOCAJGMODE, &req) < 0) //第二個(gè) 參數(shù)SIOCAJGMODE定義見上方{return(-4);}if(channel != -1){aj_conf.channel = channel;}memcpy(aj_conf.ownmac, killedmac, 6);aj_conf.mode = 6;aj_conf.monitor = 0;if(ioctl(sockfd, SIOCAJSMODE, &req) < 0) //第三個(gè) 參數(shù)SIOCAJSMODE定義見上方{return(-4);}if((flags = fcntl(sockfd, F_GETFL)) < 0){return(-5);}if(fcntl(sockfd, F_SETFL, flags|O_NONBLOCK) < 0){return(-6);} return(sockfd);}上面的代碼是發(fā)送802.11無(wú)線數(shù)據(jù)幀程序的部分代碼,其中一共有三個(gè)ioctl函數(shù),但是運(yùn)行的時(shí)候會(huì)顯示get_socket: Operation not supported。
查看完整描述

1 回答

?
九州編程

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超4個(gè)贊

下面的清單介紹了一些最重要的結(jié)構(gòu),使用 ioctl 套接字命令時(shí)常常用到這些結(jié)構(gòu)。
清單 1. struct ifreq (/usr/include/net/if.h)

/* Interface request structure used for socket
* ioctl's. All interface ioctl's must have parameter
* definitions which begin with ifr_name. The
* remainder may be interface specific.
*/
struct ifreq {
#ifndef IFNAMSIZ
#define IFNAMSIZ 16
#endif
char ifr_name[IFNAMSIZ]; 
union {
struct sockaddr ifru_addr;
struct sockaddr ifru_dstaddr;
struct sockaddr ifru_broadaddr;
__ulong32_t ifru_flags;
int ifru_metric;
caddr_t ifru_data;
u_short ifru_site6;
__ulong32_t ifru_mtu;
int ifru_baudrate;
} ifr_ifru;
Following macros are provided for convenience
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_flags ifr_ifru.ifru_flags /* flags */
#define ifr_metric ifr_ifru.ifru_metric /* metric */
#define ifr_data ifr_ifru.ifru_data /* for use by interface */
#define ifr_site6 ifr_ifru.ifru_site6 /* IPv6 site index */
#define ifr_mtu ifr_ifru.ifru_mtu /* mtu of interface */
#define ifr_isno ifr_ifru.ifru_data /* pointer to if_netopts */
#define ifr_baudrate ifr_ifru.ifru_baudrate /* baudrate of interface */
};

清單 2. struct ifconf (/usr/include/net/if.h)

/*
* Structure used in SIOCGIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible).
*/
struct ifconf {
int ifc_len; /* size of associated buffer */
union {
caddr_t ifcu_buf;
struct ifreq *ifcu_req;
} ifc_ifcu;
Following macros are provided for convenience
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
};


查看完整回答
反對(duì) 回復(fù) 2023-03-22
  • 1 回答
  • 0 關(guān)注
  • 91 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)