Lines Matching +full:- +full:e
2 * Based on LiMon - BOOTP.
8 * Copyright 2000-2004 Wolfgang Denk, wd@denx.de
29 * counter of fixed-length timeout periods. TIMEOUT_COUNT represents
97 size_t size = sizeof(bootp_ids) - sizeof(id); in bootp_add_id()
100 bootp_ids[bootp_num_ids - 1] = id; in bootp_add_id()
125 retval = -1; in check_reply_packet()
126 else if (len < sizeof(struct bootp_hdr) - OPT_FIELD_SIZE) in check_reply_packet()
127 retval = -2; in check_reply_packet()
128 else if (bp->bp_op != OP_BOOTREPLY) in check_reply_packet()
129 retval = -3; in check_reply_packet()
130 else if (bp->bp_htype != HWT_ETHER) in check_reply_packet()
131 retval = -4; in check_reply_packet()
132 else if (bp->bp_hlen != HWL_ETHER) in check_reply_packet()
133 retval = -5; in check_reply_packet()
134 else if (!bootp_match_id(net_read_u32(&bp->bp_id))) in check_reply_packet()
135 retval = -6; in check_reply_packet()
136 else if (memcmp(bp->bp_chaddr, net_ethaddr, HWL_ETHER) != 0) in check_reply_packet()
137 retval = -7; in check_reply_packet()
152 net_copy_ip(&tmp_ip, &bp->bp_siaddr); in store_net_params()
154 net_copy_ip(&net_server_ip, &bp->bp_siaddr); in store_net_params()
156 ((struct ethernet_hdr *)net_rx_packet)->et_src, 6); in store_net_params()
161 (strlen(bp->bp_file) > 0)) { in store_net_params()
162 copy_filename(net_boot_file_name, bp->bp_file, in store_net_params()
175 net_copy_ip(&net_ip, &bp->bp_yiaddr); in store_net_params()
181 printf("*** WARNING: %s is too long (%d - max: %d)" in truncate_sz()
182 " - truncated\n", name, curlen, maxlen); in truncate_sz()
183 curlen = maxlen - 1; in truncate_sz()
205 case 2: /* Time offset - Not yet supported */ in bootp_process_vendor_field()
212 case 4: /* Time server - Not yet supported */ in bootp_process_vendor_field()
214 case 5: /* IEN-116 name server - Not yet supported */ in bootp_process_vendor_field()
226 case 7: /* Log server - Not yet supported */ in bootp_process_vendor_field()
228 case 8: /* Cookie/Quote server - Not yet supported */ in bootp_process_vendor_field()
230 case 9: /* LPR server - Not yet supported */ in bootp_process_vendor_field()
232 case 10: /* Impress server - Not yet supported */ in bootp_process_vendor_field()
234 case 11: /* RPL server - Not yet supported */ in bootp_process_vendor_field()
252 case 14: /* Merit dump file - Not yet supported */ in bootp_process_vendor_field()
254 case 15: /* Domain name - Not yet supported */ in bootp_process_vendor_field()
256 case 16: /* Swap server - Not yet supported */ in bootp_process_vendor_field()
266 case 18: /* Extension path - Not yet supported */ in bootp_process_vendor_field()
288 case 43: /* Vendor specific info - Not yet supported */ in bootp_process_vendor_field()
369 if (net_read_u32((u32 *)&bp->bp_vend[0]) == htonl(BOOTP_VENDOR_MAGIC)) in bootp_handler()
370 bootp_process_vendor((uchar *)&bp->bp_vend[4], len); in bootp_handler()
405 #define put_vci(e, str) \ argument
408 *e++ = 60; /* Vendor Class Identifier */ \
409 *e++ = vci_strlen; \
410 memcpy(e, str, vci_strlen); \
411 e += vci_strlen; \
414 static u8 *add_vci(u8 *e) in add_vci() argument
429 put_vci(e, vci); in add_vci()
431 return e; in add_vci()
438 static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip, in dhcp_extended() argument
441 u8 *start = e; in dhcp_extended()
446 int clientarch = -1; in dhcp_extended()
455 *e++ = 99; /* RFC1048 Magic Cookie */ in dhcp_extended()
456 *e++ = 130; in dhcp_extended()
457 *e++ = 83; in dhcp_extended()
458 *e++ = 99; in dhcp_extended()
460 *e++ = 53; /* DHCP Message Type */ in dhcp_extended()
461 *e++ = 1; in dhcp_extended()
462 *e++ = message_type; in dhcp_extended()
464 *e++ = 57; /* Maximum DHCP Message Size */ in dhcp_extended()
465 *e++ = 2; in dhcp_extended()
466 *e++ = (576 - 312 + OPT_FIELD_SIZE) >> 8; in dhcp_extended()
467 *e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff; in dhcp_extended()
472 *e++ = 54; /* ServerID */ in dhcp_extended()
473 *e++ = 4; in dhcp_extended()
474 *e++ = tmp >> 24; in dhcp_extended()
475 *e++ = tmp >> 16; in dhcp_extended()
476 *e++ = tmp >> 8; in dhcp_extended()
477 *e++ = tmp & 0xff; in dhcp_extended()
483 *e++ = 50; /* Requested IP */ in dhcp_extended()
484 *e++ = 4; in dhcp_extended()
485 *e++ = tmp >> 24; in dhcp_extended()
486 *e++ = tmp >> 16; in dhcp_extended()
487 *e++ = tmp >> 8; in dhcp_extended()
488 *e++ = tmp & 0xff; in dhcp_extended()
495 *e++ = 12; /* Hostname */ in dhcp_extended()
496 *e++ = hostnamelen; in dhcp_extended()
497 memcpy(e, hostname, hostnamelen); in dhcp_extended()
498 e += hostnamelen; in dhcp_extended()
510 *e++ = 93; /* Client System Architecture */ in dhcp_extended()
511 *e++ = 2; in dhcp_extended()
512 *e++ = (clientarch >> 8) & 0xff; in dhcp_extended()
513 *e++ = clientarch & 0xff; in dhcp_extended()
516 *e++ = 94; /* Client Network Interface Identifier */ in dhcp_extended()
517 *e++ = 3; in dhcp_extended()
518 *e++ = 1; /* type field for UNDI */ in dhcp_extended()
519 *e++ = 0; /* major revision */ in dhcp_extended()
520 *e++ = 0; /* minor revision */ in dhcp_extended()
527 *e++ = 97; /* Client Machine Identifier */ in dhcp_extended()
528 *e++ = 17; in dhcp_extended()
529 *e++ = 0; /* type 0 - UUID */ in dhcp_extended()
531 uuid_str_to_bin(uuid, e, UUID_STR_FORMAT_STD); in dhcp_extended()
532 e += 16; in dhcp_extended()
539 e = add_vci(e); in dhcp_extended()
542 x = dhcp_vendorex_prep(e); in dhcp_extended()
544 return x - start; in dhcp_extended()
547 *e++ = 55; /* Parameter Request List */ in dhcp_extended()
548 cnt = e++; /* Pointer to count of requested items */ in dhcp_extended()
551 *e++ = 1; /* Subnet Mask */ in dhcp_extended()
555 *e++ = 2; in dhcp_extended()
559 *e++ = 3; /* Router Option */ in dhcp_extended()
563 *e++ = 6; /* DNS Server(s) */ in dhcp_extended()
567 *e++ = 12; /* Hostname */ in dhcp_extended()
571 *e++ = 13; /* Boot File Size */ in dhcp_extended()
575 *e++ = 17; /* Boot path */ in dhcp_extended()
579 *e++ = 40; /* NIS Domain name request */ in dhcp_extended()
583 *e++ = 42; in dhcp_extended()
588 e -= 2; in dhcp_extended()
590 *e++ = 255; /* End of the list */ in dhcp_extended()
594 while ((e - start) < CONFIG_DHCP_MIN_EXT_LEN) in dhcp_extended()
595 *e++ = 0; in dhcp_extended()
598 return e - start; in dhcp_extended()
603 * Warning: no field size check - change CONFIG_BOOTP_* at your own risk!
605 static int bootp_extended(u8 *e) in bootp_extended() argument
607 u8 *start = e; in bootp_extended()
609 *e++ = 99; /* RFC1048 Magic Cookie */ in bootp_extended()
610 *e++ = 130; in bootp_extended()
611 *e++ = 83; in bootp_extended()
612 *e++ = 99; in bootp_extended()
615 *e++ = 53; /* DHCP Message Type */ in bootp_extended()
616 *e++ = 1; in bootp_extended()
617 *e++ = DHCP_DISCOVER; in bootp_extended()
619 *e++ = 57; /* Maximum DHCP Message Size */ in bootp_extended()
620 *e++ = 2; in bootp_extended()
621 *e++ = (576 - 312 + OPT_FIELD_SIZE) >> 16; in bootp_extended()
622 *e++ = (576 - 312 + OPT_FIELD_SIZE) & 0xff; in bootp_extended()
625 add_vci(e); in bootp_extended()
628 *e++ = 1; /* Subnet mask request */ in bootp_extended()
629 *e++ = 4; in bootp_extended()
630 e += 4; in bootp_extended()
634 *e++ = 3; /* Default gateway request */ in bootp_extended()
635 *e++ = 4; in bootp_extended()
636 e += 4; in bootp_extended()
640 *e++ = 6; /* Domain Name Server */ in bootp_extended()
641 *e++ = 4; in bootp_extended()
642 e += 4; in bootp_extended()
646 *e++ = 12; /* Host name request */ in bootp_extended()
647 *e++ = 32; in bootp_extended()
648 e += 32; in bootp_extended()
652 *e++ = 13; /* Boot file size */ in bootp_extended()
653 *e++ = 2; in bootp_extended()
654 e += 2; in bootp_extended()
658 *e++ = 17; /* Boot path */ in bootp_extended()
659 *e++ = 32; in bootp_extended()
660 e += 32; in bootp_extended()
664 *e++ = 40; /* NIS Domain name request */ in bootp_extended()
665 *e++ = 32; in bootp_extended()
666 e += 32; in bootp_extended()
669 *e++ = 42; in bootp_extended()
670 *e++ = 4; in bootp_extended()
671 e += 4; in bootp_extended()
674 *e++ = 255; /* End of the list */ in bootp_extended()
680 if (e == start + 3) { in bootp_extended()
682 e -= 3; in bootp_extended()
685 return e - start; in bootp_extended()
727 rand_ms = rand() >> (22 - bootp_try); in bootp_request()
756 bp->bp_op = OP_BOOTREQUEST; in bootp_request()
757 bp->bp_htype = HWT_ETHER; in bootp_request()
758 bp->bp_hlen = HWL_ETHER; in bootp_request()
759 bp->bp_hops = 0; in bootp_request()
764 bp->bp_secs = htons(get_timer(bootp_start) / 1000); in bootp_request()
766 net_write_ip(&bp->bp_ciaddr, zero_ip); in bootp_request()
767 net_write_ip(&bp->bp_yiaddr, zero_ip); in bootp_request()
768 net_write_ip(&bp->bp_siaddr, zero_ip); in bootp_request()
769 net_write_ip(&bp->bp_giaddr, zero_ip); in bootp_request()
770 memcpy(bp->bp_chaddr, net_ethaddr, 6); in bootp_request()
771 copy_filename(bp->bp_file, net_boot_file_name, sizeof(bp->bp_file)); in bootp_request()
775 extlen = dhcp_extended((u8 *)bp->bp_vend, DHCP_DISCOVER, zero_ip, in bootp_request()
778 extlen = bootp_extended((u8 *)bp->bp_vend); in bootp_request()
792 net_copy_u32(&bp->bp_id, &bootp_id); in bootp_request()
798 iplen = BOOTP_HDR_SIZE - OPT_FIELD_SIZE + extlen; in bootp_request()
825 oplen = -1; /* Pad omits len byte */ in dhcp_process_options()
906 uchar *popt = (uchar *)&bp->bp_vend[4]; in dhcp_packet_process_options()
909 if (net_read_u32((u32 *)&bp->bp_vend[0]) != htonl(BOOTP_VENDOR_MAGIC)) in dhcp_packet_process_options()
921 popt = (uchar *)bp->bp_file; in dhcp_packet_process_options()
922 end = popt + sizeof(bp->bp_file); in dhcp_packet_process_options()
927 popt = (uchar *)bp->bp_sname; in dhcp_packet_process_options()
928 end = popt + sizeof(bp->bp_sname); in dhcp_packet_process_options()
936 return -1; in dhcp_message_type()
950 return -1; in dhcp_message_type()
974 bp->bp_op = OP_BOOTREQUEST; in dhcp_send_request_packet()
975 bp->bp_htype = HWT_ETHER; in dhcp_send_request_packet()
976 bp->bp_hlen = HWL_ETHER; in dhcp_send_request_packet()
977 bp->bp_hops = 0; in dhcp_send_request_packet()
978 bp->bp_secs = htons(get_timer(bootp_start) / 1000); in dhcp_send_request_packet()
987 net_write_ip(&bp->bp_giaddr, zero_ip); in dhcp_send_request_packet()
989 memcpy(bp->bp_chaddr, net_ethaddr, 6); in dhcp_send_request_packet()
990 copy_filename(bp->bp_file, net_boot_file_name, sizeof(bp->bp_file)); in dhcp_send_request_packet()
996 net_copy_u32(&bp->bp_id, &bp_offer->bp_id); in dhcp_send_request_packet()
1003 net_copy_ip(&offered_ip, &bp_offer->bp_yiaddr); in dhcp_send_request_packet()
1004 extlen = dhcp_extended((u8 *)bp->bp_vend, DHCP_REQUEST, in dhcp_send_request_packet()
1007 iplen = BOOTP_HDR_SIZE - OPT_FIELD_SIZE + extlen; in dhcp_send_request_packet()
1037 if (net_read_ip(&bp->bp_yiaddr).s_addr == 0) in dhcp_handler()
1048 debug("DHCP: state=SELECTING bp_file: \"%s\"\n", bp->bp_file); in dhcp_handler()
1050 if (strncmp(bp->bp_file, in dhcp_handler()
1071 if (dhcp_message_type((u8 *)bp->bp_vend) == DHCP_ACK) { in dhcp_handler()