资源简介
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));
相关资源
- Bootstrap使用手册(操作手册)
- 一套响应式的bootstrap产品展示页面模
- CoreUIVue是基于Bootstrap4的免费Vue管理模
- SpringBoot+H2+mybatis-plus59130
- uboot到linux logo显示不间断 补丁
- Bootloader源码分析(好东西).rar
- atmega64bootload
- BootLoader和BSP
- Cellular automata Model: an Adaptive Approach
- 易语言Bootstrap类模块2.13源码
- web开发舔狗日记 框架bootstrap
- bootstrap demo 源码大全
- springboot+rabbitmq项目demo(亲测可正常运
- springboot整合RabbitMQ实现延时队列的两
- 基于S32K144的CANbootloader
- 2017年-传智播客-张志君老师-SpringBoo
- ARM7TDMI-S在嵌入式系统中的Bootloader代码
- springboot+mybatis整合实现注册登录
- springboot+webflux+mongodb+freemarker
- springboot整合activiti完整demo
- SpringBoot实战(第4版)清晰版.pdf.zip
- SpringBoot 中文文档
- springboot+jpa+thymeleaf实现增删改查分页
- es(elasticsearch)整合SpringCloudSpringBo
- Springboot日志开启SLF4J过程解析
- STM32的IAP-Bootloader程序
- STM32例程之Bootloader
- springboot全套教程2018年2.0版本
- 官网springboot项目
- 史上最经典的Bootstrap前台模板
评论
共有 条评论