资源简介
xsbase270开发板boot,可运行,pxa270intel最后一款ARM,性能强劲,这是XSBASE270-EDR实验箱的BOOT
代码片段和文件信息
#include
#include
#include
#include
#include
#include
#define PORT_BOOTPS 67 // BOOTP server UDP port.
#define PORT_BOOTPC 68 // BOOTP client UDP port.
static void bootp_usage(void);
static bool do_bootp(int argc char **argv);
static int set_bootp_header(void *packet);
static bool wait = false;
static uint32 bootp_id;
struct command_t cmd_bootp = {
.name = “bootp“
.run = do_bootp
.usage = bootp_usage
};
static void bootp_usage(void){
usage_format(“bootp“ “run bootp. get ip and host infomation“);
return;
}
static bool do_bootp(int argc char **argv){
int i n len;
bool res;
uchar pktbuff[1024] *txpkt;
time_t start now;
const uchar broadcast_mac[] = { 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF };
const uint32 broadcast_ip = 0xFFFFFFFF;
/* create boop packet */
memset(pktbuff 0 sizeof(pktbuff));
txpkt = pktbuff + 100;
len = set_bootp_header(txpkt);
n = set_udp_header(txpkt PORT_BOOTPS PORT_BOOTPC len);
txpkt -= n; len += n;
n = set_ip_header(txpkt 0x00 broadcast_ip IP_P_UDP len);
txpkt -= n; len += n;
n = set_ether_header(txpkt broadcast_mac PROT_IP);
txpkt -= n; len += n;
/* view information */
printf(“ my mac address is %s\n“ mac_ntoa(setup->myhaddr));
printf(“ try to send bootp packet“);
/* send request packet and wait reply packet */
wait = true;
setup->myipaddr = 0;
for (i=0; i < 5; i++){
res = net_send_packet(txpkt len);
if (!res) break;
printf(“.“);
time(&start);
while (time(&now) - start < 1){
net_recv_poll();
if (!wait) return true;
}
}
printf(“\n failed : bootp packet is not received.\n“);
wait = false;
return false;
}
extern bool bootp_recv(void *packet int len){
struct bootp *bhp = (struct bootp *)packet;
if (len < sizeof(struct bootp)) goto invalid;
if (!wait) goto invalid;
if (bhp->bh_opcode != OP_BOOTREPLY) goto invalid;
if (bhp->bh_htype != HWT_ETHER) goto invalid;
if (bhp->bh_hlen != HWL_ETHER) goto invalid;
if (memcmp(&bhp->bh_tid &bootp_id 4)) goto invalid;
//if (memcmp(&bhp->bh_chaddr net_get_mac_addr(0) 6)) goto invalid;
if (memcmp(&bhp->bh_chaddr setup->myhaddr 6)) goto invalid;
printf(“\n“);
printf(“ reply packet is received from %s (%s)\n“ bhp->bh_sname inet_ntoa(bhp->bh_siaddr));
printf(“ my ip address is %s\n“ inet_ntoa(bhp->bh_yiaddr));
// printf(“the ip is 0x%08x serip is 0x%08x\n“ bhp->bh_yiaddr bhp->bh_siaddr);
setup->myipaddr = bhp->bh_yiaddr;
setup->destipaddr = bhp->bh_siaddr;
wait = false;
return true;
invalid :
return false;
}
static int set_bootp_header(void *packet){
uchar *smac;
time_t now;
struct bootp *bhp = (struct bootp *)packet;
bhp->bh_opcode = OP_BOOTREQUEST; // 1 : request 2 : reply.
bhp->bh_htype = HWT_ETHER; // 10 base Ethernet : 1.
bhp->bh_hlen = HWL_ETHER; // 10 base Ethernet : 6.
bhp->bh_hops = 0; // client俊辑 0栏肺 setting. gateway啊 荤侩.
bhp->bh_secs = htons(time(&now));
相关资源
- 微信小程序增删改查简单Demo
- 微信小程序后端Springboot
- springboot导入Excel文件并入库
- SpringBoot文件上传源码
- SpringBoot开发小而美的个人博客
- bootstrap select 下拉框通过拼音搜索汉字
- web3j 基础功能实现 以太坊客户端 we
- guns 完整视频(未加密)
- ar9341_uboot支持HTTPD
- 小程序+springboot开发
- keycloak应用于rest资源保护的springboot端
- SpringBoot整合Shiro,实现从数据库加载
- BootStrap3.37
- springboot集成hibernate
- bootstrap-table-export.js和tableExport.js
- Spring Boot自定义错误页面
- guns 后台管理技术文档含收费部分
- CANoe写bootloader上位机代码
- STM32F103 ucLinux 开发BOOT源码
- windows下fastboot工具
- bootstrap-3.3.7-dist.zip
- springboot+mybatis+pagehelper、web前端到后台
- bootia32.efi
- mini2440的u-boot.bin 2012.04.01版
- bootstrap-table动态加载json数据并且支持
- SSM+Shiro+BootStrap框架整合源码
- Spring Boot多模块配置文件读取
- bootstrap可编辑表格完整代码
- springboot使用rabbitmq工具类
- SpringBootFile
评论
共有 条评论