dhcp.txt 82.1 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962
; generated by Component: ARM Compiler 5.06 update 6 (build 750) Tool: ArmCC [4d3637]
; commandline ArmCC [--c99 --list --split_sections --debug -c --asm --interleave -o.\flash\obj\dhcp.o --asm_dir=.\Flash\List\ --list_dir=.\Flash\List\ --depend=.\flash\obj\dhcp.d --cpu=Cortex-M4.fp --apcs=interwork -O1 --diag_suppress=9931,870 -I..\..\Libraries\CMSIS\Include -I..\..\Libraries\CMSIS\Device\ST\STM32F4xx\Include -I..\..\Libraries\STM32F4xx_StdPeriph_Driver\inc -I..\..\uCOS-III\uC-CPU -I..\..\uCOS-III\uC-LIB -I..\..\uCOS-III\uCOS-III\Ports -I..\..\uCOS-III\uCOS-III\Source -I..\..\uCOS-III\uC-CPU\ARM-Cortex-M4\RealView -I..\..\uCOS-III\uC-LIB\Ports\ARM-Cortex-M4\RealView -I..\..\uCOS-III\uCOS-III\Ports\ARM-Cortex-M4\Generic\RealView -I..\..\User -I..\..\User\bsp -I..\..\User\bsp\inc -I..\..\User\libapp -I..\..\RL-ARM\Config -I..\..\RL-ARM\Driver -I..\..\RL-ARM\RL-RTX\inc -I..\..\User\bsp\BSP -I..\..\RL-ARM\RL-CAN -I..\..\Libraries\DSP_LIB\Include -I..\..\MODBUS\modbus\rtu -I..\..\MODBUS\BARE\port -I..\..\MODBUS\modbus\include -I..\..\User\bsp\BSP -I..\..\PLC -I..\..\Avoid -I..\..\User\parameter -I..\..\User\LaserMotionCtr -I..\..\User\W5100S -I..\..\User\bsp -I..\..\User\CHASSIS -I..\..\User\CONTROLFUNCTION -I..\..\User\DATAUPDATE -I..\..\User\HARAWARE -I..\..\User\MOTORDRIVER -I..\..\User\NAVAGATION -I..\..\User\PLATFORM -I..\..\User\SENSOR -I.\RTE\_Flash -IC:\Users\YDJ\AppData\Local\Arm\Packs\ARM\CMSIS\5.5.1\CMSIS\Core\Include -IC:\Users\YDJ\AppData\Local\Arm\Packs\Keil\STM32F4xx_DFP\2.13.0\Drivers\CMSIS\Device\ST\STM32F4xx\Include -D__UVISION_VERSION=527 -D_RTE_ -DSTM32F407xx -DUSE_STDPERIPH_DRIVER -DSTM32F40_41xxx -D__RTX -D__FPU_USED=1 --omf_browse=.\flash\obj\dhcp.crf ..\..\User\W5100S\dhcp.c]
                          THUMB

                          AREA ||i.DHCP_timer_handler||, CODE, READONLY, ALIGN=2

                  DHCP_timer_handler PROC
;;;740    */
;;;741    void DHCP_timer_handler(void)
000000  4906              LDR      r1,|L1.28|
;;;742    {
;;;743      if(dhcp_tick_cnt++ > 1000)
000002  6a88              LDR      r0,[r1,#0x28]  ; dhcp_tick_cnt
000004  1c42              ADDS     r2,r0,#1
000006  628a              STR      r2,[r1,#0x28]  ; dhcp_tick_cnt
000008  f5b07f7a          CMP      r0,#0x3e8
00000c  d905              BLS      |L1.26|
;;;744      {
;;;745        dhcp_tick_cnt = 0;
00000e  2000              MOVS     r0,#0
000010  6288              STR      r0,[r1,#0x28]  ; dhcp_tick_cnt
;;;746        dhcp_time++;
000012  4803              LDR      r0,|L1.32|
000014  6801              LDR      r1,[r0,#0]  ; dhcp_time
000016  1c49              ADDS     r1,r1,#1
000018  6001              STR      r1,[r0,#0]  ; dhcp_time
                  |L1.26|
;;;747      }
;;;748    }
00001a  4770              BX       lr
;;;749    
                          ENDP

                  |L1.28|
                          DCD      ||.data||
                  |L1.32|
                          DCD      dhcp_time

                          AREA ||i.check_DHCP_Timeout||, CODE, READONLY, ALIGN=2

                  check_DHCP_Timeout PROC
;;;651    */
;;;652    void check_DHCP_Timeout(void)
000000  b570              PUSH     {r4-r6,lr}
;;;653    {
;;;654      if(dhcp_retry_count < MAX_DHCP_RETRY) 
000002  4c15              LDR      r4,|L2.88|
000004  7860              LDRB     r0,[r4,#1]  ; dhcp_retry_count
000006  2803              CMP      r0,#3
000008  d21d              BCS      |L2.70|
;;;655      {
;;;656        if(dhcp_time > next_dhcp_time) 
00000a  4914              LDR      r1,|L2.92|
00000c  6a63              LDR      r3,[r4,#0x24]  ; next_dhcp_time
00000e  680a              LDR      r2,[r1,#0]  ; dhcp_time
000010  429a              CMP      r2,r3
000012  d91f              BLS      |L2.84|
;;;657        {
;;;658          dhcp_time = 0;
000014  2200              MOVS     r2,#0
000016  600a              STR      r2,[r1,#0]  ; dhcp_time
;;;659          next_dhcp_time = dhcp_time + DHCP_WAIT_TIME;
000018  2105              MOVS     r1,#5
00001a  6261              STR      r1,[r4,#0x24]  ; next_dhcp_time
;;;660          dhcp_retry_count++;
00001c  1c40              ADDS     r0,r0,#1
00001e  7060              STRB     r0,[r4,#1]
;;;661          switch ( dhcp_state ) 
000020  7820              LDRB     r0,[r4,#0]  ; dhcp_state
000022  2801              CMP      r0,#1
000024  d007              BEQ      |L2.54|
000026  2802              CMP      r0,#2
000028  d009              BEQ      |L2.62|
00002a  2804              CMP      r0,#4
00002c  d112              BNE      |L2.84|
;;;662          {
;;;663            case STATE_DHCP_DISCOVER :
;;;664              #ifdef DHCP_DEBUG         
;;;665              printf(" <<timeout>> state : STATE_DHCP_DISCOVER\r\n");
;;;666              #endif        
;;;667              send_DHCP_DISCOVER();
;;;668              break;
;;;669            
;;;670            case STATE_DHCP_REQUEST :
;;;671              #ifdef DHCP_DEBUG         
;;;672              printf(" <<timeout>> state : STATE_DHCP_REQUEST\r\n");
;;;673              #endif        
;;;674              send_DHCP_REQUEST();
;;;675              break;    
;;;676            
;;;677            case STATE_DHCP_REREQUEST :
;;;678              #ifdef DHCP_DEBUG         
;;;679              printf(" <<timeout>> state : STATE_DHCP_REREQUEST\r\n");
;;;680              #endif        
;;;681              send_DHCP_REQUEST();
00002e  e8bd4070          POP      {r4-r6,lr}
000032  f7ffbffe          B.W      send_DHCP_REQUEST
                  |L2.54|
000036  e8bd4070          POP      {r4-r6,lr}            ;667
00003a  f7ffbffe          B.W      send_DHCP_DISCOVER
                  |L2.62|
00003e  e8bd4070          POP      {r4-r6,lr}            ;674
000042  f7ffbffe          B.W      send_DHCP_REQUEST
                  |L2.70|
;;;682              break;
;;;683            
;;;684            default :
;;;685              break;
;;;686          }
;;;687        }
;;;688      } 
;;;689      else 
;;;690      {
;;;691        reset_DHCP_time();
000046  f7fffffe          BL       reset_DHCP_time
;;;692        DHCP_timeout = 1;
00004a  2501              MOVS     r5,#1
00004c  70a5              STRB     r5,[r4,#2]
;;;693      
;;;694        send_DHCP_DISCOVER();
00004e  f7fffffe          BL       send_DHCP_DISCOVER
;;;695        dhcp_state = STATE_DHCP_DISCOVER;
000052  7025              STRB     r5,[r4,#0]
                  |L2.84|
;;;696        #ifdef DHCP_DEBUG    
;;;697        printf(" timeout : state : STATE_DHCP_DISCOVER\r\n");
;;;698        #endif    
;;;699      }
;;;700    }
000054  bd70              POP      {r4-r6,pc}
;;;701    
                          ENDP

000056  0000              DCW      0x0000
                  |L2.88|
                          DCD      ||.data||
                  |L2.92|
                          DCD      dhcp_time

                          AREA ||i.check_DHCP_state||, CODE, READONLY, ALIGN=2

                  check_DHCP_state PROC
;;;499    */
;;;500    uint8 check_DHCP_state(SOCKET s) 
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;501    {
000004  4605              MOV      r5,r0
;;;502      uint16 len;                                 // 定义一个表示接收数据大小变量
;;;503      uint8  type;                                // 定义一个表示接收封包类型变量
;;;504      
;;;505      type = 0;
000006  2400              MOVS     r4,#0
;;;506      if(getSn_SR(s)!=SOCK_CLOSED)                // socket处于打开状态
000008  f2404003          MOV      r0,#0x403
00000c  eb002005          ADD      r0,r0,r5,LSL #8
000010  f7fffffe          BL       WIZCHIP_READ
000014  b138              CBZ      r0,|L3.38|
;;;507      {
;;;508        if ((len = getSn_RX_RSR(s)) > 0)          // 接收到数据
000016  4628              MOV      r0,r5
000018  f7fffffe          BL       getSn_RX_RSR
00001c  b150              CBZ      r0,|L3.52|
;;;509        {
;;;510          type = parseDHCPMSG(len);               // 解析收到的封包类型
00001e  f7fffffe          BL       parseDHCPMSG
000022  4604              MOV      r4,r0
000024  e006              B        |L3.52|
                  |L3.38|
;;;511        }
;;;512      }
;;;513      else                                        // socket处于关闭状态,重新初始化socket
;;;514      {
;;;515        if(dhcp_state == STATE_DHCP_READY)
;;;516        {
;;;517          #ifdef DHCP_DEBUG      
;;;518          printf(" state : STATE_DHCP_READY\r\n");
;;;519          #endif       
;;;520        }  
;;;521        if(!socket(SOCK_DHCP,Sn_MR_UDP,DHCP_CLIENT_PORT,0x00))          // 初始化socket和端口
000026  2300              MOVS     r3,#0
000028  2244              MOVS     r2,#0x44
00002a  2102              MOVS     r1,#2
00002c  2003              MOVS     r0,#3
00002e  f7fffffe          BL       socket
000032  b160              CBZ      r0,|L3.78|
                  |L3.52|
;;;522        {
;;;523          #ifdef DHCP_DEBUG     
;;;524          printf(" Fail to create the DHCPC_SOCK(%u)\r\n",SOCK_DHCP);
;;;525          #endif   
;;;526          return DHCP_RET_ERR;                    // socket初始化错误
;;;527        }
;;;528      }
;;;529      switch ( dhcp_state )
000034  4d38              LDR      r5,|L3.280|
000036  2601              MOVS     r6,#1                 ;526
000038  2700              MOVS     r7,#0                 ;526
00003a  7828              LDRB     r0,[r5,#0]  ; dhcp_state
00003c  f04f0803          MOV      r8,#3                 ;521
000040  2805              CMP      r0,#5
000042  d260              BCS      |L3.262|
000044  e8dff000          TBB      [pc,r0]
000048  060e1a31          DCB      0x06,0x0e,0x1a,0x31
00004c  4600              DCB      0x46,0x00
                  |L3.78|
00004e  2001              MOVS     r0,#1                 ;526
                  |L3.80|
;;;530      {
;;;531        case STATE_DHCP_READY:                    // DHCP初始化状态
;;;532          DHCP_timeout = 0;                       // DHCP超时标志设置为1
;;;533          reset_DHCP_time();                      // 复位超时时间
;;;534          send_DHCP_DISCOVER();                   // 发送DISCOVER包
;;;535      
;;;536          DHCP_timer = 0;                         // set_timer0(DHCP_timer_handler);     
;;;537          dhcp_state = STATE_DHCP_DISCOVER;       // DHCP的DISCOVER状态
;;;538          break;   
;;;539      
;;;540        case STATE_DHCP_DISCOVER:
;;;541          if (type == DHCP_OFFER) 
;;;542          {
;;;543            reset_DHCP_time();                    // 复位超时时间
;;;544            send_DHCP_REQUEST();                  // 发送REQUEST包
;;;545            dhcp_state = STATE_DHCP_REQUEST;
;;;546            #ifdef DHCP_DEBUG      
;;;547            printf(" state : STATE_DHCP_REQUEST\r\n");
;;;548            #endif      
;;;549          }
;;;550          else 
;;;551            check_DHCP_Timeout();                 // 检查是否超时
;;;552          break;
;;;553        
;;;554        case STATE_DHCP_REQUEST :                 // DHCP的REQUEST状态
;;;555          if (type == DHCP_ACK)                   // 接收到DHCP服务器回应的off封包
;;;556          {
;;;557            reset_DHCP_time();
;;;558            if (check_leasedIP()) 
;;;559            {
;;;560              #ifdef DHCP_DEBUG          
;;;561              printf(" state : STATE_DHCP_LEASED\r\n");
;;;562              #endif    
;;;563              dhcp_state = STATE_DHCP_LEASED;
;;;564              return DHCP_RET_UPDATE;
;;;565            } 
;;;566            else 
;;;567            {
;;;568              #ifdef DHCP_DEBUG          
;;;569              printf(" state : STATE_DHCP_DISCOVER\r\n");
;;;570              #endif        
;;;571              dhcp_state = STATE_DHCP_DISCOVER;
;;;572              return DHCP_RET_CONFLICT;
;;;573            }
;;;574          }  
;;;575          else if (type == DHCP_NAK) 
;;;576          {
;;;577            reset_DHCP_time();                    // 复位超时时间
;;;578            dhcp_state = STATE_DHCP_DISCOVER;
;;;579            #ifdef DHCP_DEBUG        
;;;580            printf(" state : STATE_DHCP_DISCOVER\r\n");
;;;581            #endif      
;;;582          }
;;;583          else 
;;;584            check_DHCP_Timeout();                 // 检查是否超时
;;;585          break;
;;;586          
;;;587        case STATE_DHCP_LEASED :
;;;588          if ((dhcp_lease_time != 0xffffffff) && (dhcp_time>(dhcp_lease_time/2))) 
;;;589          {
;;;590            type = 0;
;;;591            memcpy(OLD_SIP,GET_SIP,4);
;;;592            DHCP_XID++;
;;;593            send_DHCP_REQUEST();
;;;594            dhcp_state = STATE_DHCP_REREQUEST;
;;;595            #ifdef DHCP_DEBUG
;;;596            printf(" state : STATE_DHCP_REREQUEST\r\n");
;;;597            #endif
;;;598            reset_DHCP_time();
;;;599          }
;;;600          break;
;;;601        case STATE_DHCP_REREQUEST :
;;;602          if (type == DHCP_ACK) 
;;;603          {
;;;604            if(memcmp(OLD_SIP,GET_SIP,4)!=0)  
;;;605            {
;;;606              #ifdef DHCP_DEBUG
;;;607              printf(" The IP address from the DHCP server is updated.\r\n");
;;;608              printf(" OLD_SIP=%u.%u.%u.%u",OLD_SIP[0],OLD_SIP[1],OLD_SIP[2],OLD_SIP[3]);
;;;609              printf(" GET_SIP=%u.%u.%u.%u\r\n",GET_SIP[0],GET_SIP[1],GET_SIP[2],GET_SIP[3]);
;;;610              #endif
;;;611              return DHCP_RET_UPDATE;
;;;612            }
;;;613            #ifdef DHCP_DEBUG
;;;614            else
;;;615            {
;;;616              printf(" state : STATE_DHCP_LEASED : same IP\r\n");
;;;617            }
;;;618            #endif
;;;619            reset_DHCP_time();
;;;620            dhcp_state = STATE_DHCP_LEASED;
;;;621          } 
;;;622          else if (type == DHCP_NAK) 
;;;623          {
;;;624            reset_DHCP_time();
;;;625            dhcp_state = STATE_DHCP_DISCOVER;
;;;626            #ifdef DHCP_DEBUG
;;;627            printf(" state : STATE_DHCP_DISCOVER\r\n");
;;;628            #endif
;;;629          } 
;;;630          else 
;;;631            check_DHCP_Timeout();
;;;632          break;
;;;633          
;;;634          default :
;;;635            dhcp_state = STATE_DHCP_READY;
;;;636            break;
;;;637      }
;;;638      if (DHCP_timeout == 1)
;;;639      {
;;;640        //kill_timer0(DHCP_timer);
;;;641        dhcp_state = STATE_DHCP_READY;
;;;642        return DHCP_RET_TIMEOUT;
;;;643      }
;;;644      return DHCP_RET_NONE;
;;;645    }
000050  e8bd81f0          POP      {r4-r8,pc}
000054  70af              STRB     r7,[r5,#2]            ;532
000056  f7fffffe          BL       reset_DHCP_time
00005a  f7fffffe          BL       send_DHCP_DISCOVER
00005e  712f              STRB     r7,[r5,#4]            ;536
000060  702e              STRB     r6,[r5,#0]            ;537
000062  e051              B        |L3.264|
000064  2c02              CMP      r4,#2                 ;541
000066  d002              BEQ      |L3.110|
000068  f7fffffe          BL       check_DHCP_Timeout
00006c  e04c              B        |L3.264|
                  |L3.110|
00006e  f7fffffe          BL       reset_DHCP_time
000072  f7fffffe          BL       send_DHCP_REQUEST
000076  2002              MOVS     r0,#2                 ;545
000078  7028              STRB     r0,[r5,#0]            ;545
00007a  e045              B        |L3.264|
00007c  2c05              CMP      r4,#5                 ;555
00007e  d004              BEQ      |L3.138|
000080  2c06              CMP      r4,#6                 ;575
000082  d00e              BEQ      |L3.162|
000084  f7fffffe          BL       check_DHCP_Timeout
000088  e03e              B        |L3.264|
                  |L3.138|
00008a  f7fffffe          BL       reset_DHCP_time
00008e  f7fffffe          BL       check_leasedIP
000092  b118              CBZ      r0,|L3.156|
000094  f8858000          STRB     r8,[r5,#0]            ;563
000098  2003              MOVS     r0,#3                 ;564
00009a  e7d9              B        |L3.80|
                  |L3.156|
00009c  702e              STRB     r6,[r5,#0]            ;571
00009e  2004              MOVS     r0,#4                 ;572
0000a0  e7d6              B        |L3.80|
                  |L3.162|
0000a2  f7fffffe          BL       reset_DHCP_time
0000a6  702e              STRB     r6,[r5,#0]            ;578
0000a8  e02e              B        |L3.264|
0000aa  6ba8              LDR      r0,[r5,#0x38]         ;588  ; dhcp_lease_time
0000ac  1c41              ADDS     r1,r0,#1              ;588
0000ae  d02b              BEQ      |L3.264|
0000b0  491a              LDR      r1,|L3.284|
0000b2  6809              LDR      r1,[r1,#0]            ;588  ; dhcp_time
0000b4  ebb10f50          CMP      r1,r0,LSR #1          ;588
0000b8  d926              BLS      |L3.264|
0000ba  69a8              LDR      r0,[r5,#0x18]         ;591  ; GET_SIP
0000bc  6800              LDR      r0,[r0,#0]            ;591
0000be  6368              STR      r0,[r5,#0x34]         ;591  ; OLD_SIP
0000c0  6ae8              LDR      r0,[r5,#0x2c]         ;592  ; DHCP_XID
0000c2  1c40              ADDS     r0,r0,#1              ;592
0000c4  62e8              STR      r0,[r5,#0x2c]         ;592  ; DHCP_XID
0000c6  f7fffffe          BL       send_DHCP_REQUEST
0000ca  2004              MOVS     r0,#4                 ;594
0000cc  7028              STRB     r0,[r5,#0]            ;594
0000ce  f7fffffe          BL       reset_DHCP_time
0000d2  e019              B        |L3.264|
0000d4  2c05              CMP      r4,#5                 ;602
0000d6  d004              BEQ      |L3.226|
0000d8  2c06              CMP      r4,#6                 ;622
0000da  d010              BEQ      |L3.254|
0000dc  f7fffffe          BL       check_DHCP_Timeout
0000e0  e012              B        |L3.264|
                  |L3.226|
0000e2  480d              LDR      r0,|L3.280|
0000e4  2204              MOVS     r2,#4                 ;604
0000e6  3034              ADDS     r0,r0,#0x34           ;604
0000e8  69a9              LDR      r1,[r5,#0x18]         ;604  ; GET_SIP
0000ea  f7fffffe          BL       memcmp
0000ee  b108              CBZ      r0,|L3.244|
0000f0  2003              MOVS     r0,#3                 ;611
0000f2  e7ad              B        |L3.80|
                  |L3.244|
0000f4  f7fffffe          BL       reset_DHCP_time
0000f8  f8858000          STRB     r8,[r5,#0]            ;620
0000fc  e004              B        |L3.264|
                  |L3.254|
0000fe  f7fffffe          BL       reset_DHCP_time
000102  702e              STRB     r6,[r5,#0]            ;625
000104  e000              B        |L3.264|
                  |L3.262|
000106  702f              STRB     r7,[r5,#0]            ;635
                  |L3.264|
000108  78a8              LDRB     r0,[r5,#2]            ;638  ; DHCP_timeout
00010a  2801              CMP      r0,#1                 ;638
00010c  d001              BEQ      |L3.274|
00010e  2000              MOVS     r0,#0                 ;644
000110  e79e              B        |L3.80|
                  |L3.274|
000112  702f              STRB     r7,[r5,#0]            ;641
000114  2002              MOVS     r0,#2                 ;642
000116  e79b              B        |L3.80|
;;;646    
                          ENDP

                  |L3.280|
                          DCD      ||.data||
                  |L3.284|
                          DCD      dhcp_time

                          AREA ||i.check_leasedIP||, CODE, READONLY, ALIGN=2

                  check_leasedIP PROC
;;;706    */
;;;707    uint8 check_leasedIP(void)
000000  b538              PUSH     {r3-r5,lr}
;;;708    {
;;;709      uint8_t tmp;
;;;710      int32_t ret;
;;;711    
;;;712      //WIZchip RCR value changed for ARP Timeout count control
;;;713      tmp = getRCR();
000002  2019              MOVS     r0,#0x19
000004  f7fffffe          BL       WIZCHIP_READ
000008  4605              MOV      r5,r0
;;;714      setRCR(0x03);
00000a  2103              MOVS     r1,#3
00000c  2019              MOVS     r0,#0x19
00000e  f7fffffe          BL       WIZCHIP_WRITE
;;;715    
;;;716      // IP conflict detection : ARP request - ARP reply
;;;717        
;;;718      ret = sendto(SOCK_DHCP, (uint8_t *)"CHECK_IP_CONFLICT", 17, GET_SIP, 5000);
000012  f2413088          MOV      r0,#0x1388
000016  9000              STR      r0,[sp,#0]
000018  4808              LDR      r0,|L4.60|
00001a  2211              MOVS     r2,#0x11
00001c  a108              ADR      r1,|L4.64|
00001e  6983              LDR      r3,[r0,#0x18]  ; GET_SIP
000020  2003              MOVS     r0,#3
000022  f7fffffe          BL       sendto
000026  4604              MOV      r4,r0
;;;719    
;;;720      // RCR value restore
;;;721      setRCR(tmp);
000028  4629              MOV      r1,r5
00002a  2019              MOVS     r0,#0x19
00002c  f7fffffe          BL       WIZCHIP_WRITE
;;;722    
;;;723      if(ret == SOCKERR_TIMEOUT) {
000030  340d              ADDS     r4,r4,#0xd
000032  d001              BEQ      |L4.56|
;;;724        // UDP send Timeout occurred : allocated IP address is unique, DHCP Success
;;;725    
;;;726    #ifdef _DHCP_DEBUG_
;;;727        printf("\r\n> Check leased IP - OK\r\n");
;;;728    #endif
;;;729    
;;;730        return 1;
;;;731      }
;;;732      else
;;;733        return 0;
000034  2000              MOVS     r0,#0
;;;734    }
000036  bd38              POP      {r3-r5,pc}
                  |L4.56|
000038  2001              MOVS     r0,#1                 ;730
00003a  bd38              POP      {r3-r5,pc}
;;;735      
                          ENDP

                  |L4.60|
                          DCD      ||.data||
                  |L4.64|
000040  43484543          DCB      "CHECK_IP_CONFLICT",0
000044  4b5f4950
000048  5f434f4e
00004c  464c4943
000050  5400    
000052  00                DCB      0
000053  00                DCB      0

                          AREA ||i.do_dhcp||, CODE, READONLY, ALIGN=2

                  do_dhcp PROC
;;;779    */
;;;780    void do_dhcp(void)
000000  e92d41f0          PUSH     {r4-r8,lr}
;;;781    {
;;;782      uint8 dhcpret=0;
;;;783      ip_from=IP_FROM_DHCP;                                // IP配置方法选择为DHCP
000004  4815              LDR      r0,|L5.92|
000006  2601              MOVS     r6,#1
000008  7006              STRB     r6,[r0,#0]
;;;784      dhcp_timer_init();                                   // 初始化DHCP定时器
00000a  f7fffffe          BL       dhcp_timer_init
;;;785      if(Conflict_flag == 1)
00000e  4c14              LDR      r4,|L5.96|
000010  2500              MOVS     r5,#0
000012  78e0              LDRB     r0,[r4,#3]  ; Conflict_flag
000014  2801              CMP      r0,#1
000016  d102              BNE      |L5.30|
;;;786      {
;;;787        init_dhcp_client();                                // 初始化DHCP客户端 
000018  f7fffffe          BL       init_dhcp_client
;;;788        Conflict_flag =0;
00001c  70e5              STRB     r5,[r4,#3]
                  |L5.30|
;;;789      }
;;;790      
;;;791      dhcpret = check_DHCP_state(SOCK_DHCP);               // 获取DHCP服务状态
00001e  2003              MOVS     r0,#3
000020  f7fffffe          BL       check_DHCP_state
;;;792      
;;;793      switch(dhcpret)
000024  2800              CMP      r0,#0
000026  d00e              BEQ      |L5.70|
000028  2802              CMP      r0,#2
00002a  d00c              BEQ      |L5.70|
;;;794      {
;;;795        case DHCP_RET_NONE:                                // IP地址获取不成功 
;;;796    //      printf(" IP地址获取不成功\r\n");
;;;797          break;
;;;798        
;;;799        case DHCP_RET_TIMEOUT:                             // IP地址获取超时 
;;;800    //      printf(" IP地址获取超时\r\n");
;;;801          break;
;;;802        
;;;803        case DHCP_RET_UPDATE:                              // 成功获取到IP地址  
;;;804          dhcp_ok=1; 
00002c  4f0d              LDR      r7,|L5.100|
00002e  2803              CMP      r0,#3                 ;793
000030  d00b              BEQ      |L5.74|
000032  2804              CMP      r0,#4                 ;793
000034  d107              BNE      |L5.70|
;;;805          set_w5100s_netinfo();                            // 将获取到的IP地址写入W5100S寄存器
;;;806          printf(" 已从DHCP服务器成功获得IP地址\r\n");
;;;807          
;;;808          break;
;;;809        
;;;810        case DHCP_RET_CONFLICT:                            // IP地址获取冲突 
;;;811          printf(" IP地址获取冲突\r\n");
000036  a00c              ADR      r0,|L5.104|
000038  f7fffffe          BL       __2printf
;;;812          dhcp_state = STATE_DHCP_READY; 
00003c  7025              STRB     r5,[r4,#0]
;;;813          printf(" 重试中\r\n");
00003e  a00f              ADR      r0,|L5.124|
000040  f7fffffe          BL       __2printf
;;;814          dhcp_ok=0; 
000044  703d              STRB     r5,[r7,#0]
                  |L5.70|
;;;815          break;     
;;;816    
;;;817        default:
;;;818          break;
;;;819      }
;;;820    }
000046  e8bd81f0          POP      {r4-r8,pc}
                  |L5.74|
00004a  703e              STRB     r6,[r7,#0]            ;804
00004c  f7fffffe          BL       set_w5100s_netinfo
000050  e8bd41f0          POP      {r4-r8,lr}            ;806
000054  a00c              ADR      r0,|L5.136|
000056  f7ffbffe          B.W      __2printf
;;;821    
                          ENDP

00005a  0000              DCW      0x0000
                  |L5.92|
                          DCD      ip_from
                  |L5.96|
                          DCD      ||.data||
                  |L5.100|
                          DCD      dhcp_ok
                  |L5.104|
000068  204950b5          DCB      " IP",181,216,214,183,187,241,200,161,179,229,205,187,"\r"
00006c  d8d6b7bb
000070  f1c8a1b3
000074  e5cdbb0d
000078  0a00              DCB      "\n",0
00007a  00                DCB      0
00007b  00                DCB      0
                  |L5.124|
00007c  20d6d8ca          DCB      " ",214,216,202,212,214,208,"\r\n",0
000080  d4d6d00d
000084  0a00    
000086  00                DCB      0
000087  00                DCB      0
                  |L5.136|
000088  20d2d1b4          DCB      " ",210,209,180,211,"DHCP",183,254,206,241,198,247,179,201
00008c  d3444843
000090  50b7fece
000094  f1c6f7b3
000098  c9      
000099  b9a6bbf1          DCB      185,166,187,241,181,195,"IP",181,216,214,183,"\r\n",0
00009d  b5c34950
0000a1  b5d8d6b7
0000a5  0d0a00  

                          AREA ||i.iinchip_init||, CODE, READONLY, ALIGN=1

                  iinchip_init PROC
;;;826    */
;;;827    void iinchip_init(void)
000000  2180              MOVS     r1,#0x80
;;;828    {
;;;829      setMR( MR_RST );
000002  2000              MOVS     r0,#0
000004  f7ffbffe          B.W      WIZCHIP_WRITE
;;;830      #ifdef __DEF_IINCHIP_DBG__
;;;831        printf(" MR value is %02x \r\n",IINCHIP_READ_COMMON(MR));
;;;832      #endif
;;;833    }
                          ENDP


                          AREA ||i.init_dhcp_client||, CODE, READONLY, ALIGN=2

                          REQUIRE _printf_pre_padding
                          REQUIRE _printf_percent
                          REQUIRE _printf_flags
                          REQUIRE _printf_widthprec
                          REQUIRE _printf_x
                          REQUIRE _printf_longlong_hex
                  init_dhcp_client PROC
;;;754    */
;;;755    void init_dhcp_client(void)
000000  b57f              PUSH     {r0-r6,lr}
;;;756    {
;;;757      uint8 ip_0[4]={0,};
000002  2500              MOVS     r5,#0
000004  9503              STR      r5,[sp,#0xc]
;;;758      DHCP_XID = 0x12345678;
000006  4c14              LDR      r4,|L7.88|
000008  4812              LDR      r0,|L7.84|
00000a  62e0              STR      r0,[r4,#0x2c]  ; DHCP_XID
;;;759      memset(OLD_SIP,0,sizeof(OLD_SIP));
00000c  6365              STR      r5,[r4,#0x34]  ; OLD_SIP
;;;760      memset(DHCP_SIP,0,sizeof(DHCP_SIP));
00000e  61e5              STR      r5,[r4,#0x1c]  ; DHCP_SIP
;;;761      memset(DHCP_REAL_SIP,0,sizeof(GET_SN_MASK));
000010  6225              STR      r5,[r4,#0x20]  ; DHCP_REAL_SIP
;;;762      
;;;763      // clear ip setted flag 
;;;764      iinchip_init();
000012  f7fffffe          BL       iinchip_init
;;;765      setSUBR(ip_0);
000016  2204              MOVS     r2,#4
000018  a903              ADD      r1,sp,#0xc
00001a  2005              MOVS     r0,#5
00001c  f7fffffe          BL       WIZCHIP_WRITE_BUF
;;;766      setGAR(ip_0);
000020  2204              MOVS     r2,#4
000022  a903              ADD      r1,sp,#0xc
000024  2001              MOVS     r0,#1
000026  f7fffffe          BL       WIZCHIP_WRITE_BUF
;;;767      setSIPR(ip_0);
00002a  2204              MOVS     r2,#4
00002c  a903              ADD      r1,sp,#0xc
00002e  200f              MOVS     r0,#0xf
000030  f7fffffe          BL       WIZCHIP_WRITE_BUF
;;;768      printf(" mac=%02x:%02x:%02x:%02x:%02x:%02x\r\n",SRC_MAC_ADDR[0],SRC_MAC_ADDR[1],SRC_MAC_ADDR[2],SRC_MAC_ADDR[3],SRC_MAC_ADDR[4],SRC_MAC_ADDR[5]);  
000034  68a0              LDR      r0,[r4,#8]  ; SRC_MAC_ADDR
000036  7902              LDRB     r2,[r0,#4]
000038  7941              LDRB     r1,[r0,#5]
00003a  78c3              LDRB     r3,[r0,#3]
00003c  e9cd3200          STRD     r3,r2,[sp,#0]
000040  9102              STR      r1,[sp,#8]
000042  7883              LDRB     r3,[r0,#2]
000044  7842              LDRB     r2,[r0,#1]
000046  7801              LDRB     r1,[r0,#0]
000048  a004              ADR      r0,|L7.92|
00004a  f7fffffe          BL       __2printf
;;;769      
;;;770      dhcp_state = STATE_DHCP_READY;
00004e  7025              STRB     r5,[r4,#0]
;;;771      #ifdef DHCP_DEBUG
;;;772      printf(" init_dhcp_client:%u\r\n",SOCK_DHCP);
;;;773      #endif   
;;;774    }
000050  bd7f              POP      {r0-r6,pc}
;;;775    /**
                          ENDP

000052  0000              DCW      0x0000
                  |L7.84|
                          DCD      0x12345678
                  |L7.88|
                          DCD      ||.data||
                  |L7.92|
00005c  206d6163          DCB      " mac=%02x:%02x:%02x:%02x:%02x:%02x\r\n",0
000060  3d253032
000064  783a2530
000068  32783a25
00006c  3032783a
000070  25303278
000074  3a253032
000078  783a2530
00007c  32780d0a
000080  00      
000081  00                DCB      0
000082  00                DCB      0
000083  00                DCB      0

                          AREA ||i.parseDHCPMSG||, CODE, READONLY, ALIGN=2

                  parseDHCPMSG PROC
;;;337    */
;;;338    uint8 parseDHCPMSG(uint16 length)
000000  e92d47ff          PUSH     {r0-r10,lr}
;;;339    {
;;;340      uint8  svr_addr[6];
;;;341      uint16 svr_port;
;;;342      uint16 len;
;;;343      uint8  * p;
;;;344      uint8  * e;
;;;345      uint8  type;
;;;346      uint8  opt_len = 0;
000004  2500              MOVS     r5,#0
;;;347      
;;;348      len = recvfrom(SOCK_DHCP, (uint8 *)pRIPMSG, length, svr_addr, &svr_port);
000006  4e47              LDR      r6,|L8.292|
000008  a901              ADD      r1,sp,#4
00000a  4602              MOV      r2,r0
00000c  9100              STR      r1,[sp,#0]
00000e  ab02              ADD      r3,sp,#8
000010  2003              MOVS     r0,#3
000012  6b31              LDR      r1,[r6,#0x30]  ; pRIPMSG
000014  f7fffffe          BL       recvfrom
000018  fa1ff880          UXTH     r8,r0
;;;349      
;;;350      #ifdef DHCP_DEBUG
;;;351        printf(" DHCP_SIP:%u.%u.%u.%u\r\n",DHCP_SIP[0],DHCP_SIP[1],DHCP_SIP[2],DHCP_SIP[3]);
;;;352        printf(" DHCP_RIP:%u.%u.%u.%u\r\n",DHCP_REAL_SIP[0],DHCP_REAL_SIP[1],DHCP_REAL_SIP[2],DHCP_REAL_SIP[3]);
;;;353        printf(" svr_addr:%u.%u.%u.%u\r\n",svr_addr[0],svr_addr[1],svr_addr[2],svr_addr[3]);
;;;354      #endif  
;;;355      
;;;356      if(pRIPMSG->op != DHCP_BOOTREPLY || svr_port != DHCP_SERVER_PORT)
00001c  6b30              LDR      r0,[r6,#0x30]  ; pRIPMSG
00001e  7801              LDRB     r1,[r0,#0]
000020  2902              CMP      r1,#2
000022  d103              BNE      |L8.44|
000024  f8bd1004          LDRH     r1,[sp,#4]
000028  2943              CMP      r1,#0x43
00002a  d003              BEQ      |L8.52|
                  |L8.44|
;;;357      {
;;;358        #ifdef DHCP_DEBUG     
;;;359        printf(" DHCP : NO DHCP MSG\r\n");
;;;360        #endif    
;;;361        return 0;
00002c  2000              MOVS     r0,#0
                  |L8.46|
;;;362      }
;;;363      if(memcmp(pRIPMSG->chaddr,SRC_MAC_ADDR,6) != 0 || pRIPMSG->xid != htonl(DHCP_XID))
;;;364      {
;;;365        #ifdef DHCP_DEBUG
;;;366        printf(" No My DHCP Message. This message is ignored.\r\n");
;;;367        printf(" \tSRC_MAC_ADDR(%02X.%02X.%02X.",SRC_MAC_ADDR[0],SRC_MAC_ADDR[1],SRC_MAC_ADDR[2]);
;;;368        printf(" %02X.%02X.%02X)",SRC_MAC_ADDR[3],SRC_MAC_ADDR[4],SRC_MAC_ADDR[5]);
;;;369        printf(" , pRIPMSG->chaddr(%02X.%02X.%02X.",(char)pRIPMSG->chaddr[0],(char)pRIPMSG->chaddr[1],(char)pRIPMSG->chaddr[2]);
;;;370        printf(" %02X.%02X.%02X)",pRIPMSG->chaddr[3],pRIPMSG->chaddr[4],pRIPMSG->chaddr[5]);
;;;371        printf(" \tpRIPMSG->xid(%08X), DHCP_XID(%08X)",pRIPMSG->xid,(DHCP_XID));
;;;372        printf(" \tpRIMPMSG->yiaddr:%d.%d.%d.%d\r\n",pRIPMSG->yiaddr[0],pRIPMSG->yiaddr[1],pRIPMSG->yiaddr[2],pRIPMSG->yiaddr[3]);
;;;373        #endif        
;;;374        return 0;
;;;375      }
;;;376      
;;;377      if( *((uint32*)DHCP_SIP) != 0x00000000 )
;;;378      {
;;;379        if( *((uint32*)DHCP_REAL_SIP) != *((uint32*)svr_addr) && 
;;;380        *((uint32*)DHCP_SIP) != *((uint32*)svr_addr) ) 
;;;381        {
;;;382          #ifdef DHCP_DEBUG    
;;;383          printf(" Another DHCP sever send a response message. This is ignored.\r\n");
;;;384          printf(" \tIP:%u.%u.%u.%u\r\n",svr_addr[0],svr_addr[1],svr_addr[2],svr_addr[3]);
;;;385          #endif        
;;;386          return 0;                
;;;387        }
;;;388      }  
;;;389      memcpy(GET_SIP,pRIPMSG->yiaddr,4);
;;;390      
;;;391      #ifdef DHCP_DEBUG  
;;;392      printf(" DHCP MSG received\r\n");
;;;393      printf(" yiaddr : %u.%u.%u.%u\r\n",GET_SIP[0],GET_SIP[1],GET_SIP[2],GET_SIP[3]);
;;;394      #endif  
;;;395      type = 0;
;;;396      p = (uint8 *)(&pRIPMSG->op);
;;;397      p = p + 240;
;;;398      e = p + (len - 240);
;;;399      #ifdef DHCP_DEBUG
;;;400      printf(" p : %08X  e : %08X  len : %d\r\n", (uint32)p, (uint32)e, len);
;;;401      #endif
;;;402      while ( p < e ) 
;;;403      {
;;;404        switch ( *p++ ) 
;;;405        {
;;;406          case endOption :
;;;407            return type;
;;;408        
;;;409          case padOption :
;;;410            break;
;;;411          
;;;412          case dhcpMessageType :
;;;413            opt_len = *p++;
;;;414            type = *p;
;;;415            #ifdef DHCP_DEBUG      
;;;416            printf(" dhcpMessageType : %02X\r\n", type);
;;;417            #endif      
;;;418            break;
;;;419          
;;;420          case subnetMask :
;;;421            opt_len =* p++;
;;;422            memcpy(GET_SN_MASK,p,4);
;;;423            #ifdef DHCP_DEBUG
;;;424            printf(" subnetMask : ");
;;;425            printf(" %u.%u.%u.%u\r\n",GET_SN_MASK[0],GET_SN_MASK[1],GET_SN_MASK[2],GET_SN_MASK[3]);
;;;426            #endif      
;;;427            break;
;;;428          
;;;429          case routersOnSubnet :
;;;430            opt_len = *p++;
;;;431            memcpy(GET_GW_IP,p,4);
;;;432            #ifdef DHCP_DEBUG
;;;433            printf(" routersOnSubnet : ");
;;;434            printf(" %u.%u.%u.%u\r\n",GET_GW_IP[0],GET_GW_IP[1],GET_GW_IP[2],GET_GW_IP[3]);
;;;435            #endif      
;;;436            break;
;;;437          
;;;438          case dns :
;;;439            opt_len = *p++;
;;;440            memcpy(GET_DNS_IP,p,4);
;;;441            break;
;;;442          
;;;443          case dhcpIPaddrLeaseTime :
;;;444            opt_len = *p++;
;;;445            dhcp_lease_time = ntohl(*((uint32*)p));
;;;446            #ifdef DHCP_DEBUG      
;;;447            printf(" dhcpIPaddrLeaseTime : %d\r\n", dhcp_lease_time);
;;;448            #endif      
;;;449            break;
;;;450          
;;;451          case dhcpServerIdentifier :
;;;452            opt_len = *p++;
;;;453            #ifdef DHCP_DEBUG            
;;;454            printf(" DHCP_SIP : %u.%u.%u.%u\r\n", DHCP_SIP[0], DHCP_SIP[1], DHCP_SIP[2], DHCP_SIP[3]);
;;;455            #endif      
;;;456            if( *((uint32*)DHCP_SIP) == 0 || 
;;;457            *((uint32*)DHCP_REAL_SIP) == *((uint32*)svr_addr) || 
;;;458            *((uint32*)DHCP_SIP) == *((uint32*)svr_addr) )
;;;459            {
;;;460              memcpy(DHCP_SIP,p,4);
;;;461              memcpy(DHCP_REAL_SIP,svr_addr,4);  // Copy the real ip address of my DHCP server
;;;462              #ifdef DHCP_DEBUG            
;;;463              printf(" My dhcpServerIdentifier : ");
;;;464              printf(" %u.%u.%u.%u\r\n", DHCP_SIP[0], DHCP_SIP[1], DHCP_SIP[2], DHCP_SIP[3]);
;;;465              printf(" My DHCP server real IP address : ");
;;;466              printf(" %u.%u.%u.%u\r\n", DHCP_REAL_SIP[0], DHCP_REAL_SIP[1], DHCP_REAL_SIP[2], DHCP_REAL_SIP[3]);
;;;467              #endif            
;;;468            }
;;;469            else
;;;470            {
;;;471            #ifdef DHCP_DEBUG         
;;;472            printf(" Another dhcpServerIdentifier : \r\n");
;;;473            printf(" \tMY(%u.%u.%u.%u) ", DHCP_SIP[0], DHCP_SIP[1], DHCP_SIP[2], DHCP_SIP[3]);
;;;474            printf(" Another(%u.%u.%u.%u)\r\n", svr_addr[0], svr_addr[1], svr_addr[2], svr_addr[3]);
;;;475            #endif        
;;;476            }
;;;477            break;
;;;478            
;;;479          default :
;;;480            opt_len = *p++;
;;;481            #ifdef DHCP_DEBUG      
;;;482            printf(" opt_len : %u\r\n", opt_len);
;;;483            #endif      
;;;484            break;
;;;485        } // switch
;;;486        p+=opt_len;
;;;487      } // while  
;;;488      return 0;
;;;489    }
00002e  b004              ADD      sp,sp,#0x10
000030  e8bd87f0          POP      {r4-r10,pc}
                  |L8.52|
000034  2206              MOVS     r2,#6                 ;363
000036  301c              ADDS     r0,r0,#0x1c           ;363
000038  68b1              LDR      r1,[r6,#8]            ;363  ; SRC_MAC_ADDR
00003a  f7fffffe          BL       memcmp
00003e  b930              CBNZ     r0,|L8.78|
000040  6af0              LDR      r0,[r6,#0x2c]         ;363  ; DHCP_XID
000042  f7fffffe          BL       htonl
000046  6b31              LDR      r1,[r6,#0x30]         ;363  ; pRIPMSG
000048  684a              LDR      r2,[r1,#4]            ;363
00004a  4290              CMP      r0,r2                 ;363
00004c  d001              BEQ      |L8.82|
                  |L8.78|
00004e  2000              MOVS     r0,#0                 ;374
000050  e7ed              B        |L8.46|
                  |L8.82|
000052  f8df90d0          LDR      r9,|L8.292|
000056  f109091c          ADD      r9,r9,#0x1c           ;377
00005a  f1090a04          ADD      r10,r9,#4             ;379
00005e  f8d90000          LDR      r0,[r9,#0]            ;377  ; DHCP_SIP
000062  b148              CBZ      r0,|L8.120|
000064  f8da2000          LDR      r2,[r10,#0]           ;379  ; DHCP_REAL_SIP
000068  9b02              LDR      r3,[sp,#8]            ;379
00006a  429a              CMP      r2,r3                 ;379
00006c  d004              BEQ      |L8.120|
00006e  9a02              LDR      r2,[sp,#8]            ;380
000070  4290              CMP      r0,r2                 ;380
000072  d001              BEQ      |L8.120|
000074  2000              MOVS     r0,#0                 ;386
000076  e7da              B        |L8.46|
                  |L8.120|
000078  69b0              LDR      r0,[r6,#0x18]         ;389  ; GET_SIP
00007a  6909              LDR      r1,[r1,#0x10]         ;389
00007c  6001              STR      r1,[r0,#0]            ;389
00007e  2700              MOVS     r7,#0                 ;395
000080  6b34              LDR      r4,[r6,#0x30]         ;396  ; pRIPMSG
000082  34f0              ADDS     r4,r4,#0xf0           ;397
000084  44a0              ADD      r8,r8,r4              ;398
000086  f1a808f0          SUB      r8,r8,#0xf0           ;398
00008a  e015              B        |L8.184|
                  |L8.140|
00008c  f8140b01          LDRB     r0,[r4],#1            ;404
000090  2833              CMP      r0,#0x33              ;404
000092  d02d              BEQ      |L8.240|
000094  dc07              BGT      |L8.166|
000096  b170              CBZ      r0,|L8.182|
000098  2801              CMP      r0,#1                 ;404
00009a  d017              BEQ      |L8.204|
00009c  2803              CMP      r0,#3                 ;404
00009e  d01b              BEQ      |L8.216|
0000a0  2806              CMP      r0,#6                 ;404
0000a2  d106              BNE      |L8.178|
0000a4  e01e              B        |L8.228|
                  |L8.166|
0000a6  2835              CMP      r0,#0x35              ;404
0000a8  d00c              BEQ      |L8.196|
0000aa  2836              CMP      r0,#0x36              ;404
0000ac  d027              BEQ      |L8.254|
0000ae  28ff              CMP      r0,#0xff              ;404
0000b0  d006              BEQ      |L8.192|
                  |L8.178|
0000b2  f8145b01          LDRB     r5,[r4],#1            ;480
                  |L8.182|
0000b6  442c              ADD      r4,r4,r5              ;486
                  |L8.184|
0000b8  4544              CMP      r4,r8                 ;402
0000ba  d3e7              BCC      |L8.140|
0000bc  2000              MOVS     r0,#0                 ;488
0000be  e7b6              B        |L8.46|
                  |L8.192|
0000c0  4638              MOV      r0,r7                 ;407
0000c2  e7b4              B        |L8.46|
                  |L8.196|
0000c4  f8145b01          LDRB     r5,[r4],#1            ;413
0000c8  7827              LDRB     r7,[r4,#0]            ;414
0000ca  e7f4              B        |L8.182|
                  |L8.204|
0000cc  f8145b01          LDRB     r5,[r4],#1            ;421
0000d0  68f0              LDR      r0,[r6,#0xc]          ;422  ; GET_SN_MASK
0000d2  6821              LDR      r1,[r4,#0]            ;422
0000d4  6001              STR      r1,[r0,#0]            ;422
0000d6  e7ee              B        |L8.182|
                  |L8.216|
0000d8  f8145b01          LDRB     r5,[r4],#1            ;430
0000dc  6930              LDR      r0,[r6,#0x10]         ;431  ; GET_GW_IP
0000de  6821              LDR      r1,[r4,#0]            ;431
0000e0  6001              STR      r1,[r0,#0]            ;431
0000e2  e7e8              B        |L8.182|
                  |L8.228|
0000e4  f8145b01          LDRB     r5,[r4],#1            ;439
0000e8  6970              LDR      r0,[r6,#0x14]         ;440  ; GET_DNS_IP
0000ea  6821              LDR      r1,[r4,#0]            ;440
0000ec  6001              STR      r1,[r0,#0]            ;440
0000ee  e7e2              B        |L8.182|
                  |L8.240|
0000f0  f8145b01          LDRB     r5,[r4],#1            ;444
0000f4  6820              LDR      r0,[r4,#0]            ;445
0000f6  f7fffffe          BL       ntohl
0000fa  63b0              STR      r0,[r6,#0x38]         ;445  ; dhcp_lease_time
0000fc  e7db              B        |L8.182|
                  |L8.254|
0000fe  f8145b01          LDRB     r5,[r4],#1            ;452
000102  f8d90000          LDR      r0,[r9,#0]            ;456  ; DHCP_SIP
000106  b138              CBZ      r0,|L8.280|
000108  f8da1000          LDR      r1,[r10,#0]           ;457  ; DHCP_REAL_SIP
00010c  9a02              LDR      r2,[sp,#8]            ;457
00010e  4291              CMP      r1,r2                 ;457
000110  d002              BEQ      |L8.280|
000112  9902              LDR      r1,[sp,#8]            ;458
000114  4288              CMP      r0,r1                 ;458
000116  d1ce              BNE      |L8.182|
                  |L8.280|
000118  6820              LDR      r0,[r4,#0]            ;460
00011a  61f0              STR      r0,[r6,#0x1c]         ;460  ; DHCP_SIP
00011c  9802              LDR      r0,[sp,#8]            ;461
00011e  6230              STR      r0,[r6,#0x20]         ;461  ; DHCP_REAL_SIP
000120  e7c9              B        |L8.182|
;;;490    
                          ENDP

000122  0000              DCW      0x0000
                  |L8.292|
                          DCD      ||.data||

                          AREA ||i.reset_DHCP_time||, CODE, READONLY, ALIGN=2

                  reset_DHCP_time PROC
;;;63     */
;;;64     void reset_DHCP_time(void)
000000  4904              LDR      r1,|L9.20|
;;;65     {
;;;66       dhcp_time = 0;
000002  2000              MOVS     r0,#0
000004  6008              STR      r0,[r1,#0]  ; dhcp_time
;;;67       dhcp_tick_cnt = 0;
000006  4904              LDR      r1,|L9.24|
000008  6288              STR      r0,[r1,#0x28]  ; dhcp_tick_cnt
;;;68       next_dhcp_time = dhcp_time + DHCP_WAIT_TIME;
00000a  2205              MOVS     r2,#5
00000c  624a              STR      r2,[r1,#0x24]  ; next_dhcp_time
;;;69       dhcp_retry_count = 0;
00000e  7048              STRB     r0,[r1,#1]
;;;70     }
000010  4770              BX       lr
;;;71     
                          ENDP

000012  0000              DCW      0x0000
                  |L9.20|
                          DCD      dhcp_time
                  |L9.24|
                          DCD      ||.data||

                          AREA ||i.send_DHCP_DISCOVER||, CODE, READONLY, ALIGN=2

                          REQUIRE _printf_pre_padding
                          REQUIRE _printf_percent
                          REQUIRE _printf_flags
                          REQUIRE _printf_widthprec
                          REQUIRE _printf_x
                          REQUIRE _printf_s
                          REQUIRE _printf_longlong_hex
                          REQUIRE _printf_str
                  send_DHCP_DISCOVER PROC
;;;76     */
;;;77     void send_DHCP_DISCOVER(void)
000000  b570              PUSH     {r4-r6,lr}
;;;78     {
000002  b086              SUB      sp,sp,#0x18
;;;79       uint8 ip[4] = {255,255,255,255};
000004  a05c              ADR      r0,|L10.376|
000006  6800              LDR      r0,[r0,#0]
000008  9005              STR      r0,[sp,#0x14]
;;;80       uint16 i=0;
;;;81       //the host name modified
;;;82       uint8 host_name[12];
;;;83       *((uint32*)DHCP_SIP)=0;
00000a  485c              LDR      r0,|L10.380|
00000c  2600              MOVS     r6,#0
00000e  6006              STR      r6,[r0,#0]  ; DHCP_SIP
;;;84       *((uint32*)DHCP_REAL_SIP)=0;
000010  1d00              ADDS     r0,r0,#4
000012  6006              STR      r6,[r0,#0]  ; DHCP_REAL_SIP
;;;85       memset((void*)pRIPMSG,0,sizeof(RIP_MSG));         // 清空pRIPMSG的 sizeof(RIP_MSG) 个空间
000014  f1a00420          SUB      r4,r0,#0x20
000018  f44f7109          MOV      r1,#0x224
00001c  6b20              LDR      r0,[r4,#0x30]  ; pRIPMSG
00001e  f7fffffe          BL       __aeabi_memclr4
;;;86       
;;;87       pRIPMSG->op = DHCP_BOOTREQUEST;
000022  6b20              LDR      r0,[r4,#0x30]  ; pRIPMSG
000024  2501              MOVS     r5,#1
000026  7005              STRB     r5,[r0,#0]
;;;88       pRIPMSG->htype = DHCP_HTYPE10MB;
000028  7045              STRB     r5,[r0,#1]
;;;89       pRIPMSG->hlen = DHCP_HLENETHERNET;
00002a  2106              MOVS     r1,#6
00002c  7081              STRB     r1,[r0,#2]
;;;90       pRIPMSG->hops = DHCP_HOPS;
00002e  70c6              STRB     r6,[r0,#3]
;;;91       pRIPMSG->xid = htonl(DHCP_XID);
000030  6ae0              LDR      r0,[r4,#0x2c]  ; DHCP_XID
000032  f7fffffe          BL       htonl
000036  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
000038  6048              STR      r0,[r1,#4]
;;;92       pRIPMSG->secs = htons(DHCP_SECS);
00003a  2000              MOVS     r0,#0
00003c  f7fffffe          BL       htons
000040  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
000042  8108              STRH     r0,[r1,#8]
;;;93       pRIPMSG->flags =htons(DHCP_FLAGSBROADCAST);
000044  03e8              LSLS     r0,r5,#15
000046  f7fffffe          BL       htons
00004a  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
00004c  31dd              ADDS     r1,r1,#0xdd
00004e  f8210cd3          STRH     r0,[r1,#-0xd3]
;;;94       pRIPMSG->chaddr[0] = SRC_MAC_ADDR[0];
000052  68a0              LDR      r0,[r4,#8]  ; SRC_MAC_ADDR
000054  7802              LDRB     r2,[r0,#0]
000056  f8012cc1          STRB     r2,[r1,#-0xc1]
;;;95       pRIPMSG->chaddr[1] = SRC_MAC_ADDR[1];
00005a  7842              LDRB     r2,[r0,#1]
00005c  f8012cc0          STRB     r2,[r1,#-0xc0]
;;;96       pRIPMSG->chaddr[2] = SRC_MAC_ADDR[2];
000060  7882              LDRB     r2,[r0,#2]
000062  f8012cbf          STRB     r2,[r1,#-0xbf]
;;;97       pRIPMSG->chaddr[3] = SRC_MAC_ADDR[3];
000066  78c2              LDRB     r2,[r0,#3]
000068  f8012cbe          STRB     r2,[r1,#-0xbe]
;;;98       pRIPMSG->chaddr[4] = SRC_MAC_ADDR[4];
00006c  7902              LDRB     r2,[r0,#4]
00006e  f8012cbd          STRB     r2,[r1,#-0xbd]
;;;99       pRIPMSG->chaddr[5] = SRC_MAC_ADDR[5];    
000072  7942              LDRB     r2,[r0,#5]
000074  f8012cbc          STRB     r2,[r1,#-0xbc]
;;;100      
;;;101      
;;;102      //  MAGIC_COOKIE 
;;;103      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 24)& 0xFF);
000078  2263              MOVS     r2,#0x63
00007a  73ca              STRB     r2,[r1,#0xf]
;;;104      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 16)& 0xFF);
00007c  2282              MOVS     r2,#0x82
00007e  740a              STRB     r2,[r1,#0x10]
;;;105      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 8)& 0xFF);
000080  2253              MOVS     r2,#0x53
000082  744a              STRB     r2,[r1,#0x11]
;;;106      pRIPMSG->OPT[i++] = (uint8)(MAGIC_COOKIE& 0xFF);
000084  2263              MOVS     r2,#0x63
000086  748a              STRB     r2,[r1,#0x12]
;;;107      
;;;108      //  Option Request Param. 
;;;109      pRIPMSG->OPT[i++] = dhcpMessageType;
000088  2235              MOVS     r2,#0x35
00008a  74ca              STRB     r2,[r1,#0x13]
;;;110      pRIPMSG->OPT[i++] = 0x01;
00008c  750d              STRB     r5,[r1,#0x14]
;;;111      pRIPMSG->OPT[i++] = DHCP_DISCOVER;
00008e  2207              MOVS     r2,#7
000090  754d              STRB     r5,[r1,#0x15]
;;;112      
;;;113      // Client identifier
;;;114      pRIPMSG->OPT[i++] = dhcpClientIdentifier;
000092  233d              MOVS     r3,#0x3d
000094  758b              STRB     r3,[r1,#0x16]
;;;115      pRIPMSG->OPT[i++] = 0x07;
000096  75ca              STRB     r2,[r1,#0x17]
;;;116      pRIPMSG->OPT[i++] = 0x01;
000098  760d              STRB     r5,[r1,#0x18]
;;;117      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[0];
00009a  7802              LDRB     r2,[r0,#0]
00009c  764a              STRB     r2,[r1,#0x19]
;;;118      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[1];
00009e  7843              LDRB     r3,[r0,#1]
0000a0  220c              MOVS     r2,#0xc
0000a2  768b              STRB     r3,[r1,#0x1a]
;;;119      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[2];
0000a4  7883              LDRB     r3,[r0,#2]
0000a6  76cb              STRB     r3,[r1,#0x1b]
;;;120      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[3];
0000a8  78c3              LDRB     r3,[r0,#3]
0000aa  770b              STRB     r3,[r1,#0x1c]
;;;121      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[4];
0000ac  7903              LDRB     r3,[r0,#4]
0000ae  260f              MOVS     r6,#0xf
0000b0  774b              STRB     r3,[r1,#0x1d]
;;;122      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[5];
0000b2  7943              LDRB     r3,[r0,#5]
0000b4  778b              STRB     r3,[r1,#0x1e]
;;;123      
;;;124      // host name
;;;125      pRIPMSG->OPT[i++] = hostName;
0000b6  77ca              STRB     r2,[r1,#0x1f]
;;;126      // set the host name
;;;127      sprintf((char*)host_name,"%.4s-%02X%02X%02X",DEVICE_ID,SRC_MAC_ADDR[3],SRC_MAC_ADDR[4],SRC_MAC_ADDR[5]);
0000b8  7941              LDRB     r1,[r0,#5]
0000ba  7902              LDRB     r2,[r0,#4]
0000bc  e9cd2100          STRD     r2,r1,[sp,#0]
0000c0  78c3              LDRB     r3,[r0,#3]
0000c2  a22f              ADR      r2,|L10.384|
0000c4  a130              ADR      r1,|L10.392|
0000c6  a802              ADD      r0,sp,#8
0000c8  f7fffffe          BL       __2sprintf
;;;128    
;;;129      pRIPMSG->OPT[i++] = (uint8)strlen((char*)host_name);
0000cc  a802              ADD      r0,sp,#8
0000ce  f7fffffe          BL       strlen
0000d2  6b22              LDR      r2,[r4,#0x30]  ; pRIPMSG
0000d4  f88200fd          STRB     r0,[r2,#0xfd]
;;;130      
;;;131      strcpy((char*)(&(pRIPMSG->OPT[i])),(char*)host_name);
0000d8  f10200fe          ADD      r0,r2,#0xfe
0000dc  a902              ADD      r1,sp,#8
0000de  f7fffffe          BL       strcpy
;;;132      
;;;133      i+=(uint16)strlen((char*)host_name);  
0000e2  a802              ADD      r0,sp,#8
0000e4  f7fffffe          BL       strlen
0000e8  3012              ADDS     r0,r0,#0x12
0000ea  b280              UXTH     r0,r0
;;;134      
;;;135      pRIPMSG->OPT[i++] = dhcpParamRequest;
0000ec  2237              MOVS     r2,#0x37
0000ee  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
0000f0  1c41              ADDS     r1,r0,#1
0000f2  4418              ADD      r0,r0,r3
0000f4  b289              UXTH     r1,r1
0000f6  f88020ec          STRB     r2,[r0,#0xec]
;;;136      pRIPMSG->OPT[i++] = 0x06;
0000fa  2206              MOVS     r2,#6
0000fc  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
0000fe  1c48              ADDS     r0,r1,#1
000100  4419              ADD      r1,r1,r3
000102  b280              UXTH     r0,r0
000104  f88120ec          STRB     r2,[r1,#0xec]
;;;137      pRIPMSG->OPT[i++] = subnetMask;
000108  6b22              LDR      r2,[r4,#0x30]  ; pRIPMSG
00010a  1c41              ADDS     r1,r0,#1
00010c  4410              ADD      r0,r0,r2
00010e  b289              UXTH     r1,r1
000110  f88050ec          STRB     r5,[r0,#0xec]
;;;138      pRIPMSG->OPT[i++] = routersOnSubnet;
000114  2203              MOVS     r2,#3
000116  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
000118  1c48              ADDS     r0,r1,#1
00011a  4419              ADD      r1,r1,r3
00011c  b280              UXTH     r0,r0
00011e  f88120ec          STRB     r2,[r1,#0xec]
;;;139      pRIPMSG->OPT[i++] = dns;
000122  2206              MOVS     r2,#6
000124  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
000126  1c41              ADDS     r1,r0,#1
000128  4418              ADD      r0,r0,r3
00012a  b289              UXTH     r1,r1
00012c  f88020ec          STRB     r2,[r0,#0xec]
;;;140      pRIPMSG->OPT[i++] = domainName;
000130  6b22              LDR      r2,[r4,#0x30]  ; pRIPMSG
000132  1c48              ADDS     r0,r1,#1
000134  4411              ADD      r1,r1,r2
000136  b280              UXTH     r0,r0
000138  f88160ec          STRB     r6,[r1,#0xec]
;;;141      pRIPMSG->OPT[i++] = dhcpT1value;
00013c  223a              MOVS     r2,#0x3a
00013e  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
000140  1c41              ADDS     r1,r0,#1
000142  4418              ADD      r0,r0,r3
000144  b289              UXTH     r1,r1
000146  f88020ec          STRB     r2,[r0,#0xec]
;;;142      pRIPMSG->OPT[i++] = dhcpT2value;
00014a  223b              MOVS     r2,#0x3b
00014c  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
00014e  1c48              ADDS     r0,r1,#1
000150  4419              ADD      r1,r1,r3
000152  b280              UXTH     r0,r0
000154  f88120ec          STRB     r2,[r1,#0xec]
;;;143      pRIPMSG->OPT[i++] = endOption;
000158  6b22              LDR      r2,[r4,#0x30]  ; pRIPMSG
00015a  21ff              MOVS     r1,#0xff
00015c  4410              ADD      r0,r0,r2
00015e  f88010ec          STRB     r1,[r0,#0xec]
;;;144      
;;;145      //send broadcasting packet 
;;;146      //printf(" send dhcp discover %s\r\n",EXTERN_DHCPBUF);
;;;147      //for(uint8 i=0; i<3; i++)
;;;148      //Delay_ms(800);
;;;149      sendto(SOCK_DHCP, (uint8 *)pRIPMSG, sizeof(RIP_MSG), ip, DHCP_SERVER_PORT);
000162  2043              MOVS     r0,#0x43
000164  9000              STR      r0,[sp,#0]
000166  ab05              ADD      r3,sp,#0x14
000168  f44f7209          MOV      r2,#0x224
00016c  2003              MOVS     r0,#3
00016e  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
000170  f7fffffe          BL       sendto
;;;150      #ifdef DHCP_DEBUG  
;;;151      printf(" sent DHCP_DISCOVER\r\n");
;;;152      #endif  
;;;153    }
000174  b006              ADD      sp,sp,#0x18
000176  bd70              POP      {r4-r6,pc}
;;;154    
                          ENDP

                  |L10.376|
000178  ffffffff          DCB      255,255,255,255
                  |L10.380|
                          DCD      ||.data||+0x1c
                  |L10.384|
000180  57353130          DCB      "W5100S",0
000184  305300  
000187  00                DCB      0
                  |L10.392|
000188  252e3473          DCB      "%.4s-%02X%02X%02X",0
00018c  2d253032
000190  58253032
000194  58253032
000198  5800    
00019a  00                DCB      0
00019b  00                DCB      0

                          AREA ||i.send_DHCP_RELEASE_DECLINE||, CODE, READONLY, ALIGN=2

                  send_DHCP_RELEASE_DECLINE PROC
;;;258    */
;;;259    void send_DHCP_RELEASE_DECLINE(char msgtype)
000000  e92d41fc          PUSH     {r2-r8,lr}
;;;260    {
000004  4607              MOV      r7,r0
;;;261      uint16 i =0;
;;;262      uint8  ip[4];
;;;263      
;;;264      memset((void*)pRIPMSG,0,sizeof(RIP_MSG));
000006  4e4b              LDR      r6,|L11.308|
000008  f44f7809          MOV      r8,#0x224
00000c  4641              MOV      r1,r8
00000e  6b30              LDR      r0,[r6,#0x30]  ; pRIPMSG
000010  f7fffffe          BL       __aeabi_memclr4
;;;265      
;;;266      pRIPMSG->op = DHCP_BOOTREQUEST;
000014  6b30              LDR      r0,[r6,#0x30]  ; pRIPMSG
000016  2501              MOVS     r5,#1
000018  7005              STRB     r5,[r0,#0]
;;;267      pRIPMSG->htype = DHCP_HTYPE10MB;
00001a  7045              STRB     r5,[r0,#1]
;;;268      pRIPMSG->hlen = DHCP_HLENETHERNET;
00001c  2106              MOVS     r1,#6
00001e  7081              STRB     r1,[r0,#2]
;;;269      pRIPMSG->hops = DHCP_HOPS;
000020  2400              MOVS     r4,#0
000022  70c4              STRB     r4,[r0,#3]
;;;270      pRIPMSG->xid = htonl(DHCP_XID);
000024  6af0              LDR      r0,[r6,#0x2c]  ; DHCP_XID
000026  f7fffffe          BL       htonl
00002a  6b31              LDR      r1,[r6,#0x30]  ; pRIPMSG
00002c  6048              STR      r0,[r1,#4]
;;;271      pRIPMSG->secs = htons(DHCP_SECS);
00002e  2000              MOVS     r0,#0
000030  f7fffffe          BL       htons
000034  6b33              LDR      r3,[r6,#0x30]  ; pRIPMSG
000036  8118              STRH     r0,[r3,#8]
;;;272      pRIPMSG->flags =0;// DHCP_FLAGSBROADCAST;
000038  815c              STRH     r4,[r3,#0xa]
;;;273      
;;;274      memcpy(pRIPMSG->chaddr,SRC_MAC_ADDR,6);
00003a  68b4              LDR      r4,[r6,#8]  ; SRC_MAC_ADDR
00003c  6820              LDR      r0,[r4,#0]
00003e  61d8              STR      r0,[r3,#0x1c]
000040  88a0              LDRH     r0,[r4,#4]
000042  8418              STRH     r0,[r3,#0x20]
;;;275      
;;;276      //  MAGIC_COOKIE 
;;;277      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 24) & 0xFF);
000044  2063              MOVS     r0,#0x63
000046  f88300ec          STRB     r0,[r3,#0xec]
;;;278      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 16) & 0xFF);
00004a  2182              MOVS     r1,#0x82
00004c  f88310ed          STRB     r1,[r3,#0xed]
;;;279      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 8) & 0xFF);
000050  2153              MOVS     r1,#0x53
000052  f88310ee          STRB     r1,[r3,#0xee]
;;;280      pRIPMSG->OPT[i++] = (uint8)(MAGIC_COOKIE & 0xFF);
000056  2104              MOVS     r1,#4
000058  f88300ef          STRB     r0,[r3,#0xef]
;;;281      
;;;282      //  Option Request Param. 
;;;283      pRIPMSG->OPT[i++] = dhcpMessageType;
00005c  2035              MOVS     r0,#0x35
00005e  f88300f0          STRB     r0,[r3,#0xf0]
;;;284      pRIPMSG->OPT[i++] = 0x01;
000062  f88350f1          STRB     r5,[r3,#0xf1]
;;;285      pRIPMSG->OPT[i++] = ((!msgtype) ? DHCP_RELEASE : DHCP_DECLINE);
000066  2f00              CMP      r7,#0
000068  d053              BEQ      |L11.274|
00006a  f04f0004          MOV      r0,#4
                  |L11.110|
00006e  f04f0207          MOV      r2,#7
000072  f8030ff2          STRB     r0,[r3,#0xf2]!
;;;286      
;;;287      pRIPMSG->OPT[i++] = dhcpClientIdentifier;
000076  f04f003d          MOV      r0,#0x3d
00007a  7058              STRB     r0,[r3,#1]
;;;288      pRIPMSG->OPT[i++] = 0x07;
00007c  709a              STRB     r2,[r3,#2]
;;;289      pRIPMSG->OPT[i++] = 0x01;
00007e  70dd              STRB     r5,[r3,#3]
;;;290      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[0];
000080  7820              LDRB     r0,[r4,#0]
000082  7118              STRB     r0,[r3,#4]
;;;291      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[1];
000084  7860              LDRB     r0,[r4,#1]
000086  7158              STRB     r0,[r3,#5]
;;;292      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[2];
000088  78a0              LDRB     r0,[r4,#2]
00008a  7198              STRB     r0,[r3,#6]
;;;293      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[3];
00008c  78e0              LDRB     r0,[r4,#3]
00008e  71d8              STRB     r0,[r3,#7]
;;;294      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[4];
000090  7920              LDRB     r0,[r4,#4]
000092  7218              STRB     r0,[r3,#8]
;;;295      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[5];  
000094  7960              LDRB     r0,[r4,#5]
000096  7258              STRB     r0,[r3,#9]
;;;296      
;;;297      pRIPMSG->OPT[i++] = dhcpServerIdentifier;
000098  f04f0036          MOV      r0,#0x36
00009c  7298              STRB     r0,[r3,#0xa]
;;;298      pRIPMSG->OPT[i++] = 0x04;
00009e  72d9              STRB     r1,[r3,#0xb]
;;;299      pRIPMSG->OPT[i++] = DHCP_SIP[0];
0000a0  4824              LDR      r0,|L11.308|
0000a2  f100001c          ADD      r0,r0,#0x1c
0000a6  7800              LDRB     r0,[r0,#0]  ; DHCP_SIP
0000a8  7318              STRB     r0,[r3,#0xc]
;;;300      pRIPMSG->OPT[i++] = DHCP_SIP[1];
0000aa  4822              LDR      r0,|L11.308|
0000ac  f100001c          ADD      r0,r0,#0x1c
0000b0  7840              LDRB     r0,[r0,#1]  ; DHCP_SIP
0000b2  7358              STRB     r0,[r3,#0xd]
;;;301      pRIPMSG->OPT[i++] = DHCP_SIP[2];
0000b4  481f              LDR      r0,|L11.308|
0000b6  f100001c          ADD      r0,r0,#0x1c
0000ba  7880              LDRB     r0,[r0,#2]  ; DHCP_SIP
0000bc  7398              STRB     r0,[r3,#0xe]
;;;302      pRIPMSG->OPT[i++] = DHCP_SIP[3];
0000be  481d              LDR      r0,|L11.308|
0000c0  f100001c          ADD      r0,r0,#0x1c
0000c4  78c2              LDRB     r2,[r0,#3]  ; DHCP_SIP
0000c6  73da              STRB     r2,[r3,#0xf]
0000c8  f04f0016          MOV      r0,#0x16
0000cc  f1a303f2          SUB      r3,r3,#0xf2
;;;303      
;;;304      if(msgtype)
0000d0  d012              BEQ      |L11.248|
;;;305      {
;;;306      pRIPMSG->OPT[i++] = dhcpRequestedIPaddr;
0000d2  f5037381          ADD      r3,r3,#0x102
0000d6  f04f0032          MOV      r0,#0x32
0000da  7018              STRB     r0,[r3,#0]
;;;307      pRIPMSG->OPT[i++] = 0x04;
0000dc  7059              STRB     r1,[r3,#1]
;;;308      pRIPMSG->OPT[i++] = GET_SIP[0];
0000de  69b0              LDR      r0,[r6,#0x18]  ; GET_SIP
0000e0  7801              LDRB     r1,[r0,#0]
0000e2  7099              STRB     r1,[r3,#2]
;;;309      pRIPMSG->OPT[i++] = GET_SIP[1];
0000e4  7841              LDRB     r1,[r0,#1]
0000e6  70d9              STRB     r1,[r3,#3]
;;;310      pRIPMSG->OPT[i++] = GET_SIP[2];
0000e8  7881              LDRB     r1,[r0,#2]
0000ea  7119              STRB     r1,[r3,#4]
;;;311      pRIPMSG->OPT[i++] = GET_SIP[3];    
0000ec  78c1              LDRB     r1,[r0,#3]
0000ee  7159              STRB     r1,[r3,#5]
0000f0  f04f001c          MOV      r0,#0x1c
0000f4  f5a37381          SUB      r3,r3,#0x102
                  |L11.248|
;;;312      #ifdef DHCP_DEBUG    
;;;313      printf(" sent DHCP_DECLINE\r\n");
;;;314      #endif    
;;;315      }
;;;316      #ifdef DHCP_DEBUG  
;;;317      else
;;;318      {
;;;319      printf(" sent DHCP_RELEASE\r\n");
;;;320      }
;;;321      #endif  
;;;322      
;;;323      pRIPMSG->OPT[i++] = endOption;  
0000f8  4418              ADD      r0,r0,r3
0000fa  f04f01ff          MOV      r1,#0xff
0000fe  f88010ec          STRB     r1,[r0,#0xec]
;;;324      
;;;325      
;;;326      if(msgtype) memset(ip,0xFF,4);
000102  d009              BEQ      |L11.280|
000104  460a              MOV      r2,r1
000106  f04f0104          MOV      r1,#4
00010a  a801              ADD      r0,sp,#4
00010c  f7fffffe          BL       __aeabi_memset
000110  e004              B        |L11.284|
                  |L11.274|
000112  f04f0007          MOV      r0,#7                 ;285
000116  e7aa              B        |L11.110|
                  |L11.280|
;;;327      else 
;;;328      memcpy(ip,DHCP_SIP,4);
000118  69f0              LDR      r0,[r6,#0x1c]  ; DHCP_SIP
00011a  9001              STR      r0,[sp,#4]
                  |L11.284|
;;;329      // printf(" send dhcp decline\r\n");
;;;330      sendto(SOCK_DHCP, (uint8 *)pRIPMSG, sizeof(RIP_MSG), ip, DHCP_SERVER_PORT);
00011c  f04f0043          MOV      r0,#0x43
000120  9000              STR      r0,[sp,#0]
000122  ab01              ADD      r3,sp,#4
000124  4642              MOV      r2,r8
000126  f04f0003          MOV      r0,#3
00012a  6b31              LDR      r1,[r6,#0x30]  ; pRIPMSG
00012c  f7fffffe          BL       sendto
;;;331    }
000130  e8bd81fc          POP      {r2-r8,pc}
;;;332    
                          ENDP

                  |L11.308|
                          DCD      ||.data||

                          AREA ||i.send_DHCP_REQUEST||, CODE, READONLY, ALIGN=2

                          REQUIRE _printf_pre_padding
                          REQUIRE _printf_percent
                          REQUIRE _printf_flags
                          REQUIRE _printf_widthprec
                          REQUIRE _printf_x
                          REQUIRE _printf_s
                          REQUIRE _printf_longlong_hex
                          REQUIRE _printf_str
                  send_DHCP_REQUEST PROC
;;;159    */
;;;160    void send_DHCP_REQUEST(void)
000000  e92d43f0          PUSH     {r4-r9,lr}
;;;161    {
000004  b087              SUB      sp,sp,#0x1c
;;;162      uint8  ip[4];
;;;163      uint16 i = 0;
;;;164      //uint16 len=0;
;;;165      uint8  host_name[12];
;;;166      
;;;167      memset((void*)pRIPMSG,0,sizeof(RIP_MSG));
000006  4c7c              LDR      r4,|L12.504|
000008  f44f7709          MOV      r7,#0x224
00000c  4639              MOV      r1,r7
00000e  6b20              LDR      r0,[r4,#0x30]  ; pRIPMSG
000010  f7fffffe          BL       __aeabi_memclr4
;;;168      
;;;169      pRIPMSG->op = DHCP_BOOTREQUEST;
000014  6b20              LDR      r0,[r4,#0x30]  ; pRIPMSG
000016  2501              MOVS     r5,#1
000018  7005              STRB     r5,[r0,#0]
;;;170      pRIPMSG->htype = DHCP_HTYPE10MB;
00001a  7045              STRB     r5,[r0,#1]
;;;171      pRIPMSG->hlen = DHCP_HLENETHERNET;
00001c  2606              MOVS     r6,#6
00001e  7086              STRB     r6,[r0,#2]
;;;172      pRIPMSG->hops = DHCP_HOPS;
000020  f04f0800          MOV      r8,#0
000024  f8808003          STRB     r8,[r0,#3]
;;;173      pRIPMSG->xid = htonl(DHCP_XID);
000028  6ae0              LDR      r0,[r4,#0x2c]  ; DHCP_XID
00002a  f7fffffe          BL       htonl
00002e  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
000030  6048              STR      r0,[r1,#4]
;;;174      pRIPMSG->secs = htons(DHCP_SECS);
000032  2000              MOVS     r0,#0
000034  f7fffffe          BL       htons
000038  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
00003a  8108              STRH     r0,[r1,#8]
;;;175      
;;;176      if(dhcp_state < STATE_DHCP_LEASED)
00003c  7820              LDRB     r0,[r4,#0]  ; dhcp_state
00003e  2803              CMP      r0,#3
000040  d205              BCS      |L12.78|
;;;177        pRIPMSG->flags = htons(DHCP_FLAGSBROADCAST);
000042  03e8              LSLS     r0,r5,#15
000044  f7fffffe          BL       htons
000048  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
00004a  8148              STRH     r0,[r1,#0xa]
00004c  e004              B        |L12.88|
                  |L12.78|
;;;178      else
;;;179      {
;;;180        pRIPMSG->flags = 0;                               // For Unicast
00004e  f8a1800a          STRH     r8,[r1,#0xa]
;;;181        memcpy(pRIPMSG->ciaddr,GET_SIP,4);
000052  69a0              LDR      r0,[r4,#0x18]  ; GET_SIP
000054  6800              LDR      r0,[r0,#0]
000056  60c8              STR      r0,[r1,#0xc]
                  |L12.88|
;;;182      }    
;;;183      
;;;184      memcpy(pRIPMSG->chaddr,SRC_MAC_ADDR,6);
000058  68a3              LDR      r3,[r4,#8]  ; SRC_MAC_ADDR
00005a  6b20              LDR      r0,[r4,#0x30]  ; pRIPMSG
00005c  30dc              ADDS     r0,r0,#0xdc
00005e  6819              LDR      r1,[r3,#0]
000060  f8401cc0          STR      r1,[r0,#-0xc0]
000064  8899              LDRH     r1,[r3,#4]
000066  f8201cbc          STRH     r1,[r0,#-0xbc]
;;;185      
;;;186      //  MAGIC_COOKIE 
;;;187      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 24) & 0xFF);
00006a  2163              MOVS     r1,#0x63
00006c  7401              STRB     r1,[r0,#0x10]
;;;188      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 16) & 0xFF);
00006e  2182              MOVS     r1,#0x82
000070  7441              STRB     r1,[r0,#0x11]
;;;189      pRIPMSG->OPT[i++] = (uint8)((MAGIC_COOKIE >> 8) & 0xFF);
000072  2253              MOVS     r2,#0x53
000074  2103              MOVS     r1,#3
000076  7482              STRB     r2,[r0,#0x12]
;;;190      pRIPMSG->OPT[i++] = (uint8)(MAGIC_COOKIE & 0xFF);
000078  2263              MOVS     r2,#0x63
00007a  74c2              STRB     r2,[r0,#0x13]
;;;191      
;;;192      //  Option Request Param. 
;;;193      pRIPMSG->OPT[i++] = dhcpMessageType;
00007c  2235              MOVS     r2,#0x35
00007e  7502              STRB     r2,[r0,#0x14]
;;;194      pRIPMSG->OPT[i++] = 0x01;
000080  7545              STRB     r5,[r0,#0x15]
;;;195      pRIPMSG->OPT[i++] = DHCP_REQUEST;
000082  2207              MOVS     r2,#7
000084  7581              STRB     r1,[r0,#0x16]
;;;196      
;;;197      pRIPMSG->OPT[i++] = dhcpClientIdentifier;
000086  213d              MOVS     r1,#0x3d
000088  75c1              STRB     r1,[r0,#0x17]
;;;198      pRIPMSG->OPT[i++] = 0x07;
00008a  7602              STRB     r2,[r0,#0x18]
;;;199      pRIPMSG->OPT[i++] = 0x01;
00008c  7645              STRB     r5,[r0,#0x19]
;;;200      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[0];
00008e  7819              LDRB     r1,[r3,#0]
000090  7681              STRB     r1,[r0,#0x1a]
;;;201      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[1];
000092  7859              LDRB     r1,[r3,#1]
000094  76c1              STRB     r1,[r0,#0x1b]
;;;202      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[2];
000096  7899              LDRB     r1,[r3,#2]
000098  7701              STRB     r1,[r0,#0x1c]
;;;203      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[3];
00009a  78d9              LDRB     r1,[r3,#3]
00009c  7741              STRB     r1,[r0,#0x1d]
;;;204      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[4];
00009e  7919              LDRB     r1,[r3,#4]
0000a0  7781              STRB     r1,[r0,#0x1e]
;;;205      pRIPMSG->OPT[i++] = SRC_MAC_ADDR[5];  
0000a2  795a              LDRB     r2,[r3,#5]
0000a4  2110              MOVS     r1,#0x10
0000a6  77c2              STRB     r2,[r0,#0x1f]
0000a8  38dc              SUBS     r0,r0,#0xdc
;;;206      
;;;207      if(dhcp_state < STATE_DHCP_LEASED)
0000aa  7822              LDRB     r2,[r4,#0]  ; dhcp_state
0000ac  2a03              CMP      r2,#3
0000ae  d21c              BCS      |L12.234|
;;;208      {
;;;209        pRIPMSG->OPT[i++] = dhcpRequestedIPaddr;
0000b0  2132              MOVS     r1,#0x32
0000b2  f8001ffc          STRB     r1,[r0,#0xfc]!
;;;210        pRIPMSG->OPT[i++] = 0x04;
0000b6  2204              MOVS     r2,#4
0000b8  7042              STRB     r2,[r0,#1]
;;;211        pRIPMSG->OPT[i++] = GET_SIP[0];
0000ba  69a1              LDR      r1,[r4,#0x18]  ; GET_SIP
0000bc  780b              LDRB     r3,[r1,#0]
0000be  7083              STRB     r3,[r0,#2]
;;;212        pRIPMSG->OPT[i++] = GET_SIP[1];
0000c0  784b              LDRB     r3,[r1,#1]
0000c2  70c3              STRB     r3,[r0,#3]
;;;213        pRIPMSG->OPT[i++] = GET_SIP[2];
0000c4  788b              LDRB     r3,[r1,#2]
0000c6  7103              STRB     r3,[r0,#4]
;;;214        pRIPMSG->OPT[i++] = GET_SIP[3];
0000c8  78c9              LDRB     r1,[r1,#3]
0000ca  7141              STRB     r1,[r0,#5]
;;;215      
;;;216        pRIPMSG->OPT[i++] = dhcpServerIdentifier;
0000cc  2136              MOVS     r1,#0x36
0000ce  7181              STRB     r1,[r0,#6]
;;;217        pRIPMSG->OPT[i++] = 0x04;
0000d0  71c2              STRB     r2,[r0,#7]
;;;218        pRIPMSG->OPT[i++] = DHCP_SIP[0];
0000d2  4949              LDR      r1,|L12.504|
0000d4  311c              ADDS     r1,r1,#0x1c
0000d6  780a              LDRB     r2,[r1,#0]  ; DHCP_SIP
0000d8  7202              STRB     r2,[r0,#8]
;;;219        pRIPMSG->OPT[i++] = DHCP_SIP[1];
0000da  784a              LDRB     r2,[r1,#1]  ; DHCP_SIP
0000dc  7242              STRB     r2,[r0,#9]
;;;220        pRIPMSG->OPT[i++] = DHCP_SIP[2];
0000de  788a              LDRB     r2,[r1,#2]  ; DHCP_SIP
0000e0  7282              STRB     r2,[r0,#0xa]
;;;221        pRIPMSG->OPT[i++] = DHCP_SIP[3];
0000e2  78ca              LDRB     r2,[r1,#3]  ; DHCP_SIP
0000e4  211c              MOVS     r1,#0x1c
0000e6  72c2              STRB     r2,[r0,#0xb]
0000e8  38fc              SUBS     r0,r0,#0xfc
                  |L12.234|
;;;222      }
;;;223      
;;;224      // host name
;;;225      pRIPMSG->OPT[i++] = hostName;
0000ea  230c              MOVS     r3,#0xc
0000ec  4408              ADD      r0,r0,r1
0000ee  1c4a              ADDS     r2,r1,#1
0000f0  fa1ff882          UXTH     r8,r2
0000f4  f88030ec          STRB     r3,[r0,#0xec]
;;;226      //set the host name
;;;227      sprintf((char*)host_name,(char*)"%.4s-%02X%02X%02X",DEVICE_ID,SRC_MAC_ADDR[3],SRC_MAC_ADDR[4],SRC_MAC_ADDR[5]);
0000f8  68a0              LDR      r0,[r4,#8]  ; SRC_MAC_ADDR
0000fa  7941              LDRB     r1,[r0,#5]
0000fc  7902              LDRB     r2,[r0,#4]
0000fe  e9cd2100          STRD     r2,r1,[sp,#0]
000102  78c3              LDRB     r3,[r0,#3]
000104  a23d              ADR      r2,|L12.508|
000106  a13f              ADR      r1,|L12.516|
000108  a803              ADD      r0,sp,#0xc
00010a  f7fffffe          BL       __2sprintf
;;;228      pRIPMSG->OPT[i++] = (uint8)strlen((char*)host_name);  
00010e  a803              ADD      r0,sp,#0xc
000110  f7fffffe          BL       strlen
000114  f1080101          ADD      r1,r8,#1
000118  fa1ff981          UXTH     r9,r1
00011c  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
00011e  4441              ADD      r1,r1,r8
000120  f88100ec          STRB     r0,[r1,#0xec]
;;;229      strcpy((char*)&(pRIPMSG->OPT[i]),(char*)host_name);
000124  6b20              LDR      r0,[r4,#0x30]  ; pRIPMSG
000126  a903              ADD      r1,sp,#0xc
000128  4448              ADD      r0,r0,r9
00012a  30ec              ADDS     r0,r0,#0xec
00012c  f7fffffe          BL       strcpy
;;;230      i+=strlen((char*)host_name);
000130  a803              ADD      r0,sp,#0xc
000132  f7fffffe          BL       strlen
000136  4448              ADD      r0,r0,r9
000138  b280              UXTH     r0,r0
;;;231        
;;;232      pRIPMSG->OPT[i++] = dhcpParamRequest;
00013a  2237              MOVS     r2,#0x37
00013c  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
00013e  1c41              ADDS     r1,r0,#1
000140  4418              ADD      r0,r0,r3
000142  b289              UXTH     r1,r1
000144  f88020ec          STRB     r2,[r0,#0xec]
;;;233      pRIPMSG->OPT[i++] = 0x08;
000148  2208              MOVS     r2,#8
00014a  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
00014c  1c48              ADDS     r0,r1,#1
00014e  4419              ADD      r1,r1,r3
000150  b280              UXTH     r0,r0
000152  f88120ec          STRB     r2,[r1,#0xec]
;;;234      pRIPMSG->OPT[i++] = subnetMask;
000156  6b22              LDR      r2,[r4,#0x30]  ; pRIPMSG
000158  1c41              ADDS     r1,r0,#1
00015a  4410              ADD      r0,r0,r2
00015c  b289              UXTH     r1,r1
00015e  f88050ec          STRB     r5,[r0,#0xec]
;;;235      pRIPMSG->OPT[i++] = routersOnSubnet;
000162  2203              MOVS     r2,#3
000164  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
000166  1c48              ADDS     r0,r1,#1
000168  4419              ADD      r1,r1,r3
00016a  b280              UXTH     r0,r0
00016c  f88120ec          STRB     r2,[r1,#0xec]
;;;236      pRIPMSG->OPT[i++] = dns;
000170  6b22              LDR      r2,[r4,#0x30]  ; pRIPMSG
000172  1c41              ADDS     r1,r0,#1
000174  4410              ADD      r0,r0,r2
000176  b289              UXTH     r1,r1
000178  f88060ec          STRB     r6,[r0,#0xec]
;;;237      pRIPMSG->OPT[i++] = domainName;
00017c  220f              MOVS     r2,#0xf
00017e  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
000180  1c48              ADDS     r0,r1,#1
000182  4419              ADD      r1,r1,r3
000184  b280              UXTH     r0,r0
000186  f88120ec          STRB     r2,[r1,#0xec]
;;;238      pRIPMSG->OPT[i++] = dhcpT1value;
00018a  223a              MOVS     r2,#0x3a
00018c  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
00018e  1c41              ADDS     r1,r0,#1
000190  4418              ADD      r0,r0,r3
000192  b289              UXTH     r1,r1
000194  f88020ec          STRB     r2,[r0,#0xec]
;;;239      pRIPMSG->OPT[i++] = dhcpT2value;
000198  223b              MOVS     r2,#0x3b
00019a  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
00019c  1c48              ADDS     r0,r1,#1
00019e  4419              ADD      r1,r1,r3
0001a0  b280              UXTH     r0,r0
0001a2  f88120ec          STRB     r2,[r1,#0xec]
;;;240      pRIPMSG->OPT[i++] = performRouterDiscovery;
0001a6  221f              MOVS     r2,#0x1f
0001a8  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
0001aa  1c41              ADDS     r1,r0,#1
0001ac  4418              ADD      r0,r0,r3
0001ae  b289              UXTH     r1,r1
0001b0  f88020ec          STRB     r2,[r0,#0xec]
;;;241      pRIPMSG->OPT[i++] = staticRoute;
0001b4  2221              MOVS     r2,#0x21
0001b6  6b23              LDR      r3,[r4,#0x30]  ; pRIPMSG
0001b8  1c48              ADDS     r0,r1,#1
0001ba  4419              ADD      r1,r1,r3
0001bc  b280              UXTH     r0,r0
0001be  f88120ec          STRB     r2,[r1,#0xec]
;;;242      pRIPMSG->OPT[i++] = endOption;
0001c2  6b22              LDR      r2,[r4,#0x30]  ; pRIPMSG
0001c4  21ff              MOVS     r1,#0xff
0001c6  4410              ADD      r0,r0,r2
0001c8  f88010ec          STRB     r1,[r0,#0xec]
;;;243      
;;;244      //  send broadcasting packet 
;;;245      if(dhcp_state < STATE_DHCP_LEASED) memset(ip,0xFF,4);
0001cc  7820              LDRB     r0,[r4,#0]  ; dhcp_state
0001ce  2803              CMP      r0,#3
0001d0  d205              BCS      |L12.478|
0001d2  22ff              MOVS     r2,#0xff
0001d4  2104              MOVS     r1,#4
0001d6  a806              ADD      r0,sp,#0x18
0001d8  f7fffffe          BL       __aeabi_memset
0001dc  e001              B        |L12.482|
                  |L12.478|
;;;246      else 
;;;247      memcpy(ip,DHCP_SIP,4);
0001de  69e0              LDR      r0,[r4,#0x1c]  ; DHCP_SIP
0001e0  9006              STR      r0,[sp,#0x18]
                  |L12.482|
;;;248      sendto(SOCK_DHCP, (uint8 *)pRIPMSG, sizeof(RIP_MSG), ip, DHCP_SERVER_PORT);
0001e2  2043              MOVS     r0,#0x43
0001e4  9000              STR      r0,[sp,#0]
0001e6  ab06              ADD      r3,sp,#0x18
0001e8  463a              MOV      r2,r7
0001ea  2003              MOVS     r0,#3
0001ec  6b21              LDR      r1,[r4,#0x30]  ; pRIPMSG
0001ee  f7fffffe          BL       sendto
;;;249    #ifdef DHCP_DEBUG
;;;250      printf(" sent DHCP_REQUEST\r\n");
;;;251    #endif
;;;252    }
0001f2  b007              ADD      sp,sp,#0x1c
0001f4  e8bd83f0          POP      {r4-r9,pc}
;;;253    
                          ENDP

                  |L12.504|
                          DCD      ||.data||
                  |L12.508|
0001fc  57353130          DCB      "W5100S",0
000200  305300  
000203  00                DCB      0
                  |L12.516|
000204  252e3473          DCB      "%.4s-%02X%02X%02X",0
000208  2d253032
00020c  58253032
000210  58253032
000214  5800    
000216  00                DCB      0
000217  00                DCB      0

                          AREA ||.bss||, DATA, NOINIT, ALIGN=0

                  DHCP_GET
                          %        22

                          AREA ||area_number.15||, DATA, NOINIT, ALIGN=0

                          EXPORTAS ||area_number.15||, ||.bss||
                  EXTERN_DHCPBUF
                          %        1024

                          AREA ||.conststring||, DATA, READONLY, MERGE=1, STRINGS, ALIGN=2

000000  69776562          DCB      "iweb",0
000004  00      

                          AREA ||.data||, DATA, ALIGN=2

                  dhcp_state
000000  00                DCB      0x00
                  dhcp_retry_count
000001  00                DCB      0x00
                  DHCP_timeout
000002  00                DCB      0x00
                  Conflict_flag
000003  00                DCB      0x00
                  DHCP_timer
000004  00000000          DCB      0x00,0x00,0x00,0x00
                  SRC_MAC_ADDR
                          DCD      DHCP_GET
                  GET_SN_MASK
                          DCD      DHCP_GET+0xa
                  GET_GW_IP
                          DCD      DHCP_GET+0xe
                  GET_DNS_IP
                          DCD      DHCP_GET+0x12
                  GET_SIP
                          DCD      DHCP_GET+0x6
                  DHCP_SIP
00001c  00000000          DCB      0x00,0x00,0x00,0x00
                  DHCP_REAL_SIP
000020  00000000          DCB      0x00,0x00,0x00,0x00
                  next_dhcp_time
                          DCD      0x00000000
                  dhcp_tick_cnt
                          DCD      0x00000000
                  DHCP_XID
                          DCD      0x12345678
                  pRIPMSG
                          DCD      EXTERN_DHCPBUF
                  OLD_SIP
                          DCD      0x00000000
                  dhcp_lease_time
                          DCD      0x00000000

                          AREA ||area_number.19||, DATA, ALIGN=2

                          EXPORTAS ||area_number.19||, ||.data||
                  DHCP_HOST_NAME
                          DCD      ||.conststring||

;*** Start embedded assembler ***

#line 1 "..\\..\\User\\W5100S\\dhcp.c"
	AREA ||.rev16_text||, CODE
	THUMB
	EXPORT |__asm___6_dhcp_c_eea431c6____REV16|
#line 129 "..\\..\\Libraries\\CMSIS\\Include\\core_cmInstr.h"
|__asm___6_dhcp_c_eea431c6____REV16| PROC
#line 130

 rev16 r0, r0
 bx lr
	ENDP
	AREA ||.revsh_text||, CODE
	THUMB
	EXPORT |__asm___6_dhcp_c_eea431c6____REVSH|
#line 144
|__asm___6_dhcp_c_eea431c6____REVSH| PROC
#line 145

 revsh r0, r0
 bx lr
	ENDP
	AREA ||.rrx_text||, CODE
	THUMB
	EXPORT |__asm___6_dhcp_c_eea431c6____RRX|
#line 300
|__asm___6_dhcp_c_eea431c6____RRX| PROC
#line 301

 rrx r0, r0
 bx lr
	ENDP

;*** End   embedded assembler ***