diff --git a/.github/.cSpellWords.txt b/.github/.cSpellWords.txt new file mode 100644 index 0000000000..da3c4431f6 --- /dev/null +++ b/.github/.cSpellWords.txt @@ -0,0 +1,966 @@ + +A +AAIC +ackno +ACNS +ADDAR +ADDRH +ADDRL +AFECR +AMBA +amsdu +ANAR +ANARBMCR +ANCEN +ANEG +ANEGCAPABLE +ANEGCOMPLETE +ANENABLE +ANER +ANLPAR +ANLPNPAR +ANLPR +ANNPR +ANRESTART +arasikere +ARMA +ARMR +arpa +ARPNR +arpq +ASYMM +Atmel +ATSAM +ATSAME +Autonego +AUTONEGO +B +Bbuild +BCFR +BCFT +BCONFIG +BCONTROL +BCTRL +bdring +beginthreadex +Bernd +BESR +Bfail +Bfails +BFRX +BFTX +BHILL +BIST +BLENGTH +bmcr +BMSR +BPDG +BSTATUS +BTCR +BTSCR +BTSR +BUFEXH +Bufferx +BUFFNA +BUFNA +C +CAMEN +CAPAB +CARRIERSENCE +cbmc +CBMC +cbor +CBOR +CBSCR +CBSISQA +CBSISQB +CCRX +CDEE +Centralised +CGCR +CHECKSUMOFFLAOD +CKHSUMS +CLCD +CLTTO +cmock +Cmock +CMock +CMOCK +CMPEN +cntr +COL +CONTROLC +cortexa +coverity +Coverity +Cplt +Cpsif +CPSR +CPUID +CRSDV +CRVAL +CRXDSA +CSINDICATE +ctest +CTST +D +DAIF +DBOARD +DCFGR +DCHP +DCMAKE +DCOMPILER +DCOUNTER +DCPF +DCRCC +DCRS +DDRP +DEAS +DEBUGF +DEFFERRALCHECK +Deglitchers +DEVAD +DFREERTOS +DISTCPEF +DIVIDEBY +DIVIDEDBY +DMAARBITRATION +DMABD +DMABMR +DMAC +DMACCARBR +DMACCARDR +DMACCARXBR +DMACCATBR +DMACCATDR +DMACCATXBR +DMACCR +DMACIER +DMACR +DMACRCR +DMACRDLAR +DMACRDRLR +DMACRDTPR +DMACRIWTR +DMACRXCR +DMACRXDLAR +DMACRXDTPR +DMACRXIWTR +DMACRXRLR +DMACSR +DMACTCR +DMACTDLAR +DMACTDRLR +DMACTDTPR +DMACTXCR +DMACTXDLAR +DMACTXRLR +DMAIER +DMAISR +DMAMFBOCR +DMAMR +DMAOMR +DMAPTPRXDESC +DMAPTPTXDESC +DMARDLAR +DMARPDR +DMARSWTR +DMARXDESC +dmarxdesclist +DMARXNDESCRF +DMARXNDESCWBF +DMASBMR +DMASR +DMATDLAR +DMATPDR +DMATXCDESC +DMATXDESC +dmatxdesclist +DMATXNDESCWBF +DNDEBUG +dnsa +dnsq +DNVLAN +DPPSR +DRBS +DREQ +DRESP +DRQFR +DRQFT +DSTCE +DSTCM +Dstn +DTCM +DUID +DUNITY +DUPL +DUPLEXM +DVENDOR +DVLAN +DWITH +DZPQ +E +eabil +ECLOSED +ECONN +ECRSFD +ectrk +ectrl +EDCR +EDFE +Edlinger +EDMAC +EECS +EEDI +EEDO +EEPCR +EEPROM +EESK +eesr +EFRHD +EFRN +EFRS +EFTN +EIGRP +EINT +EIPG +emacps +EMACPS +emacpsif +emacro +EMIO +ENDRX +ENHRXDESC +ENHTXDESC +ENMFILE +ENOPKTS +ENPBPR +ENRXP +ENTXP +EPHY +ERCAP +ERDRR +ERDWR +ESMA +ESPA +Espressif +ESVLAN +ETHERC +ethernetif +ETHMACRX +ETHMACTX +ETIE +Evnt +evopopv +evpopov +EXCOL +EXDEF +EXINT +expc +exti +Exti +EXTI +EXTID +Exxx +Falseb +FBEE +FBLDO +FCBBPA +FCHWR +FCKR +FCLWR +fcolor +FCOWR +FCSCR +FCSE +fdiagnostics +FECF +ffee +ffnn +FLMSK +FORWARDALLEXCEPTPA +FPGAIO +FRAMERX +FRMFILTER +frms +FTSR +FUDUP +FULLDPLX +FULLDUPLX +GARP +GBPS +GIGE +Giveup +GLBLUCAST +gmac +GMACSA +GMII +GOSLEEP +gpio +GPIO +GPSL +GPSLCE +gptimer +gstate +GSWUTR +GTBFT +Hach +HASHH +HASHL +HCKER +hclk +HDFC +hein +Hresp +HRESP +HRESPNOK +HSREN +hwaddr +IACR +IADHR +IADLR +IAID +IAPD +IBEC +IBECV +ICER +ICMPN +ICSR +IDDUID +IDHW +IDRPQ +IDRPQs +IERPQ +IHCE +IMRPQ +IMSC +indet +INTEN +INTOE +IPCB +IPCE +IPCO +iperf +IPGS +IPGSEN +IPHDR +IPHE +IPIF +IPLLMNR +IPPE +IPPT +IPTCP +IPUDP +IRQOUT +irqs +IRXER +IRXFCS +ISER +ISRPQ +issocketconnected +ITCR +ITDT +ITEN +ITIP +ITOP +IVLTV +IVTIR +JABBR +JFRAME +jscott +jscotts +karkhaz +Karliner +KByte +kbytes +LBASE +LBRERROR +LCARR +lcatch +LCOL +lcov +LCSR +ldistance +Lebel +LEDCR +LEDCRR +LEDS +LENTGH +LFER +LFERD +LFFE +libslirp +Libslirp +LIBSLIRP +LLMNR +LLMNRDNS +LLMNRI +lmmnr +LOGD +LPACK +Lpback +LPIIE +LRCK +LSTATUS +ltry +lxip +MACA +macaddrhr +macaddrlr +MACAHR +MACB +MACCR +MACECR +MACFCR +MACHT +MACHTLR +MACISR +MACMDIOAR +MACMDIODR +MACMIIAR +MACMIIDR +MACPCSR +MACPMTCSR +MACRFCR +MACRWKPFR +MACSR +MACTFCR +MACVLANTR +MACWTR +MADRM +MAHTR +MAMPCE +MANAG +MARH +MARM +MAXFS +Maych +MBCR +MBIR +MBSR +MCASTHASHEN +MCFHP +MCOL +MCONTROL +MDCON +MDII +MDIO +MDIX +MDNS +MFPH +MFPL +MFRX +MFTX +MGKPKTEN +MGKPRCVD +MGMNT +MICR +miguelfreitas +MIIAR +MIIMCTL +MIIMDAT +MIMXRT +MISR +misra +Misra +MISRA +mlan +MLAN +MMCCR +MMCR +MMCRIMR +MMCT +MMCTIMR +MMIO +MNXIA +MQTT +MSPDEINIT +MSPINIT +MSTATUS +MTHREAD +MTIHEN +MTLRQOMR +MTLTQOMR +mydevice +myethaddr +mzef +MZEF +NAIAID +NBDGM +NBNS +NCARR +NCFGR +NCONFIG +NCPDT +Netif +Nett +netto +NFRX +NFTX +nmake +NOCRC +NOPIDEVAD +npacket +nstat +Nullpuc +Nullpx +numaker +Nuvoton +NVIC +NWAYTEST +NWCFG +NWCTRL +NXP's +OBCR +OFRX +OMSOR +OMSSR +ONREAD +OPMODE +optimise +optimised +ORDERD +ORHI +ORLO +OSTC +OTHI +OTLO +OVFLOW +ovres +pacap +PADEN +pbuff +pbufs +PCSR +pdecode +PDELAYREQ +PDELAYRESP +PDELAYRESPFOLLOWUP +PDIAID +PDOWN +PDREQ +PDRESP +PDRESPFUP +PDRQFR +PDRQFT +PDRSFR +PDRSFT +Pedersen +PEFRN +PEFRS +PEFTN +PEFTS +Perc +PERIPH +pfhandler +PFNZ +PFRX +PFTR +PFTX +phandler +phandlerxzvf +phelter +PHYA +PHYCR +PHYID +PHYIE +phyksz +PHYRR +picovolts +Picovolts +PIDEVAD +PIOA +PLIB +PMECR +PMTIE +PMTIM +pointee +popd +pparam +ppkt +Ppointer +ppuc +PRAS +PRDEP +PREAMB +ps +PSCNTR +psif +psps +PTCR +PTPFT +PTPMT +PTPV +pushd +PWRDWN +rahul +randomiser +RBQB +RBQBAPQ +RBQG +RBSRPQ +RBSZ +RBUE +RBUS +RCCPSR +RCOMP +RDES +RDUIEN +RDUIF +Realtek +RECR +REGA +REGCR +Renesas +RERRCOUNTER +resetrx +RESVDBIT +RFAE +RFAEM +RFAULT +RFCE +RFCEM +rgmii +RGMII +RGMIICON +RGMIICTL +RGMIIDCTL +RGUF +RGUFM +RLEX +RMDS +RMII +RMIIEN +RMIIMII +RORIC +RORIM +RORMIS +RORRIS +rovr +RPBL +RPSF +RRDPSR +RSTN +RTIC +RTIM +RTMIS +RTRIS +RTSAS +RTSH +RTSL +RTSR +RWKFILTRST +RWKPFE +RWKPKTEN +RWKPRCVD +RWTE +RXALGNERPIM +RXALGNERR +RXBD +RXBEIEN +RXBEIF +RXBMS +RXBP +RXBQBA +RXBUF +RXBUFF +rxbuffer +RXBUFNB +RXBUFO +RXCHKSUMEN +RXCNT +RXCOEN +RXCR +RXCRCERPIM +RXCRCERR +rxdata +RXDBCTR +RXDESC +RXDMA +RXDMABURSTLENGTH +RXDMAE +RXDSA +RXDTTR +RXDV +RXEN +RXER +RXERCR +RXERR +RXFCTFC +RXFD +RXFDPR +RXFHBCR +RXFHSR +rxfifo +RXFIFOCOUNTER +RXGD +RXGDIEN +RXIEN +RXIM +RXINTERRUPT +RXIRQ +RXIRQEN +RXLPITRC +RXLPITRCIM +RXLPIUSC +RXLPIUSCIM +RXMIS +RXOFFS +RXON +RXOVR +RXPOLLING +RXPRIORTX +RXQCR +RXRER +RXRIS +RXSE +RXSR +RXST +rxstate +RXSTSIE +RXTEN +RXTX +RXUBR +RXUCASTG +RXUCGPIM +RXWLVL +SACKP +SAIF +SAMB +SAMT +SARC +sayyadumar +SCLK +SCLMD +SCOL +scugic +sdata +SDIN +SDIO +SDMA +SDOUT +seqnr +SGMII +sguic +sinclude +sinit +sizet +SLCR +SLCT +SLEWCTL +Slirp +smsc +SODR +sovr +SPEEDEN +SPEN +Sqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq +SRDBL +SREVISION +SRST +SRTSM +SSPCLKOUT +SSPDMACR +SSPICR +SSPMIS +SSPRIS +SSPRORINTR +SSPRTINTR +SSPRXINTR +SSPTXINTR +ssynchronous +stamand +STARTTX +Stub +Stubpuc +StubpucStuby +Stubuc +Stubux +Stubv +Stubx +Stuby +submoduled +Submoduling +SUPPR +SVLAN +SWIER +SWIT +SWRESET +SYMM +synchronised +taskr +TBFR +TBFT +TBQB +TBQBAPQ +TBUE +TCKER +TCMSSV +TCOMP +TDES +temac +tempcntr +TGFM +TGFMSC +TGFMSCM +TGFSC +TGFSCM +THALT +THRES +TIDM +tmout +TMXBFR +totalappdescnbr +TPBL +TPFCP +TPSF +TSALMIEN +TSCTL +TSEN +TSIE +TSIEN +TSMODE +TSSN +TSSS +TSTIM +TTSAS +TTSE +TTSEN +TTSH +TTSL +TTSS +TXBD +TXBEIEN +TXBEIF +TXBQBA +TXBUF +TXBUFE +TXBUFF +txbuffer +TXBUFNB +txcmd +TXCOEN +TXCOMP +TXCOMPL +TXCP +TXCPIEN +TXCR +TXDESC +txdescs +TXDMA +TXDMABURSTLENGTH +TXDMAE +TXDSA +TXEN +TXERR +TXFD +TXFDPR +txfifo +TXFIFONOT +TXGO +TXGPKTIM +TXIEN +TXIM +TXIRQ +TXIRQEN +TXLPITRC +TXLPITRCIM +TXLPIUSC +TXLPIUSCIM +TXMCOLGPIM +txmir +TXMIS +txmit +TXMULTCOLG +TXNTFSR +TXON +TXPBMS +TXPBPF +TXPF +TXPKTG +TXPR +TXQBASE +TXQCR +TXRIS +txrx +TXSCOLGPIM +TXSE +TXSNGLCOLG +TXSR +TXST +TXSTSIE +TXTEN +TXUBR +TXUNR +TXWLVL +TXZQPF +UCKER +ucprefix +UDPE +UDPM +UDPV +UFRX +uncrustify +unifdef +uninitialised +URUN +USEND +USTCR +utest +uxindex +uxsource +vdhcp +vdnssearch +VLANE +VLANP +VLTV +vnetmask +vnetwork +VTIR +wakeon +WAKEON +wakeonxzvf +Wconversion +WDRV +Werror +WESTAT +Weverything +Wextra +WFCR +WKFRAME +wlanif +wmlog +wmprintf +WOLIEN +Wpedantic +Wpragma +wrdata +WSOPT +WUCSR +WUFF +WUFFRPR +WUFR +Wunused +x +xaxiemacif +XCOL +xemac +xemacps +XEMACPS +xemacpsp +xheader +xlength +xlltemacp +XPAR +XPBL +Xplorer +XPROT +xtopology +xtopologyp +xzvf +YA) +Zimperium +zipperowiec +Zosi +Zynq +zynqmp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cdef98a5ef..c21195c623 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,33 +7,66 @@ on: branches: ["**"] workflow_dispatch: +env: + bashPass: \033[32;1mPASSED - + bashWarn: \033[33;1mWARNING - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + jobs: unittest: runs-on: ubuntu-latest steps: - name: Clone This Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: recursive - - name: Build + - env: + stepName: Build Unit Tests + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group::Install Dependencies" git submodule update --checkout cd tools/CMock git submodule update --init vendor/unity cd ../.. sudo apt-get install -y lcov sudo apt-get install -y unifdef + echo "::endgroup::" + + echo "::group:: ${{ env.stepName }}" cmake -S test/unit-test -B test/unit-test/build/ make -C test/unit-test/build/ all - - name: Test + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Run Unit Tests + name: ${{ env.stepName }} + shell: bash run: | - cd test/unit-test/build/ - ctest -E system --output-on-failure - cd .. - - name: Coverage + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" + ctest --test-dir test/unit-test/build/ -E system --output-on-failure + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Test Line and Branch Coverage + name: ${{ env.stepName }} + shell: bash run: | + # ${{ env.stepName }} + echo "::group::Build Tests" make -C test/unit-test/build/ coverage + echo "::endgroup::" + echo -e "${{ env.bashPass }} Built Coverage Tests ${{ env.bashEnd }}" + lcov --list --rc lcov_branch_coverage=1 test/unit-test/build/coverage.info + + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + - name: Check Coverage uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main with: @@ -42,36 +75,17 @@ jobs: spell-check: runs-on: ubuntu-latest steps: - - name: Checkout Parent Repo - uses: actions/checkout@v2 - with: - ref: main - repository: aws/aws-iot-device-sdk-embedded-C - path: main - name: Clone This Repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 + - name: Run spellings check + uses: FreeRTOS/CI-CD-Github-Actions/spellings@main with: - path: ./tcp - - name: Install spell - run: | - sudo apt-get install spell - sudo apt-get install util-linux - - name: Check spelling - run: | - PATH=$PATH:main/tools/spell - # Make sure that the portable directory is not included in the spellcheck. - sed -i 's/find $DIRNAME/find $DIRNAME -not -path '*portable*'/g' main/tools/spell/find-unknown-comment-words - find-unknown-comment-words --directory tcp/ --lexicon tcp/lexicon.txt - if [ "$?" = "0" ]; then - exit 0 - else - exit 1 - fi + path: ./ formatting: runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Check formatting uses: FreeRTOS/CI-CD-Github-Actions/formatting@main with: @@ -80,7 +94,7 @@ jobs: doxygen: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Run doxygen build uses: FreeRTOS/CI-CD-Github-Actions/doxygen@main with: @@ -102,56 +116,130 @@ jobs: run: git submodule update --checkout --init --recursive - name: Run manifest verifier - uses: FreeRTOS/CI-CD-GitHub-Actions/manifest-verifier@v2 + uses: FreeRTOS/CI-CD-GitHub-Actions/manifest-verifier@main with: path: ./ fail-on-incorrect-version: true + link-verifier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Check Links + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: FreeRTOS/CI-CD-Github-Actions/link-verifier@main + build-checks: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Build Install Dependencies + - uses: actions/checkout@v3 + - env: + stepName: Build Install Dependencies + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" sudo apt-get install -y libpcap-dev - - name: Build checks (Enable all functionalities) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Enable all functionalities) + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL cmake --build build --target freertos_plus_tcp_build_test - - name: Build checks (Enable all functionalities IPv4) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Enable all functionalities IPv4) + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL_IPV4 cmake --build build --target clean cmake --build build --target freertos_plus_tcp_build_test - - name: Build checks (Enable all functionalities IPv6) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Enable all functionalities IPv6) + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL_IPV6 cmake --build build --target freertos_plus_tcp_build_test - - name: Build checks (Enable all functionalities IPv4 IPv6) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Enable all functionalities IPv4 IPv6) + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL_IPV4_IPV6 cmake --build build --target clean cmake --build build --target freertos_plus_tcp_build_test - - name: Build checks (Enable all functionalities IPv4 TCP) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Enable all functionalities IPv4 TCP) + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL_IPV4_TCP cmake --build build --target clean cmake --build build --target freertos_plus_tcp_build_test - - name: Build checks (Enable all functionalities IPv6 TCP) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Enable all functionalities IPv6 TCP) + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=ENABLE_ALL_IPV6_TCP cmake --build build --target freertos_plus_tcp_build_test - - name: Build checks (Disable all functionalities) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Disable all functionalities) + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DISABLE_ALL cmake --build build --target clean cmake --build build --target freertos_plus_tcp_build_test - - name: Build checks (Default configuration) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Default configuration) + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=DEFAULT_CONF cmake --build build --target clean cmake --build build --target freertos_plus_tcp_build_test - - name: Build checks (Header Self Contain) + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Build checks (Header Self Contain) + shell: bash run: | cmake -S . -B build -DFREERTOS_PLUS_TCP_TEST_CONFIGURATION=HEADER_SELF_CONTAIN cmake --build build --target clean @@ -167,13 +255,24 @@ jobs: complexity: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup - run: sudo apt-get install complexity - - name: Install Uncrustify - run: sudo apt-get install uncrustify - - name: Complexity + - uses: actions/checkout@v3 + - env: + stepName: Setup + name: ${{ env.stepName }} + run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" + sudo apt-get install complexity + sudo apt-get install uncrustify + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Complexity + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" COMPLEXITY_PARAMS="--scores --threshold=10 --horrid-threshold=283" TEMP_DIR=./temp mkdir -p ${TEMP_DIR} @@ -187,44 +286,71 @@ jobs: find ${TEMP_DIR} -iname '*.c' | xargs complexity ${COMPLEXITY_PARAMS} RESULT=$? rm -rf ${TEMP_DIR} + echo "::endgroup::" if [ "${RESULT}" = "0" ]; then - echo "All is good." + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" exit 0 else - echo "Sources are too complex, rc = " ${RESULT} + echo -e "${{ env.bashFail }} Sources are too complex, rc = ${RESULT} ${{ env.bashEnd }}" + echo -e "${{ env.bashFail }} ${{ env.stepName }} ${{ env.bashEnd }}" exit 1 fi git-secrets: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: submodules: recursive - name: Checkout awslabs/git-secrets - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: awslabs/git-secrets ref: master path: git-secrets - - name: Install git-secrets - run: cd git-secrets && sudo make install && cd .. - - name: Run git-secrets + - env: + stepName: Install git-secrets + name: ${{ env.stepName }} + run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" + cd git-secrets && sudo make install && cd .. + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + + - env: + stepName: Run git-secrets + name: ${{ env.stepName }} run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" git-secrets --register-aws git-secrets --scan + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" proof_ci: + if: ${{ github.event.pull_request }} runs-on: cbmc_ubuntu-latest_16-core steps: - name: Set up CBMC runner uses: FreeRTOS/CI-CD-Github-Actions/set_up_cbmc_runner@main with: cbmc_version: "5.61.0" - - run: | + + - env: + stepName: Install Dependencies + name: ${{ env.stepName }} + shell: bash + run: | + # ${{ env.stepName }} + echo "::group:: ${{ env.stepName }}" git submodule update --init --checkout --recursive sudo apt-get update sudo apt-get install --yes --no-install-recommends gcc-multilib + echo "::endgroup::" + echo -e "${{ env.bashPass }} ${{ env.stepName }} ${{ env.bashEnd }}" + - name: Run CBMC uses: FreeRTOS/CI-CD-Github-Actions/run_cbmc@main with: diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 0000000000..8257addac5 --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,23 @@ +name: Format Pull Request Files + +on: + issue_comment: + types: [created] + +env: + bashPass: \033[32;1mPASSED - + bashInfo: \033[33;1mINFO - + bashFail: \033[31;1mFAILED - + bashEnd: \033[0m + +jobs: + Formatting: + name: Run Formatting Check + if: ${{ github.event.issue.pull_request }} && + ( ( github.event.comment.body == '/bot run uncrustify' ) || + ( github.event.comment.body == '/bot run formatting' ) ) + runs-on: ubuntu-20.04 + steps: + - name: Apply Formatting Fix + uses: FreeRTOS/CI-CD-Github-Actions/formatting-bot@main + id: check-formatting diff --git a/.github/workflows/release-candidate.yml b/.github/workflows/release-candidate.yml index 832491ce5c..a839f30056 100644 --- a/.github/workflows/release-candidate.yml +++ b/.github/workflows/release-candidate.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.commit_id }} - name: Configure git identity diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eb8de66934..80a9316ed4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.commit_id }} - name: Configure git identity @@ -53,7 +53,7 @@ jobs: - name: Install ZIP tools run: sudo apt-get install zip unzip - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ github.event.inputs.commit_id }} path: FreeRTOS-Plus-TCP diff --git a/.github/workflows/uncrustify.yml b/.github/workflows/uncrustify.yml deleted file mode 100644 index e5b7035000..0000000000 --- a/.github/workflows/uncrustify.yml +++ /dev/null @@ -1,74 +0,0 @@ -name: Uncrustify the source code - -on: - issue_comment: - types: [created] - -jobs: - Uncrustify: - name: Run_Uncrustify - if: ${{ github.event.issue.pull_request && github.event.comment.body == '/bot run uncrustify' }} - runs-on: ubuntu-20.04 - steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - name: Install Utils - run: | - sudo apt-get update && sudo apt-get --assume-yes install software-properties-common curl jq sed - sudo add-apt-repository ppa:git-core/ppa - sudo apt-get update && sudo apt-get --assume-yes install git - git --version - - name: get pullrequest url - run: | - echo ${{ github.event.issue.pull_request.url }} - - name: get upstream repo - id: upstreamrepo - run: | - echo "RemoteRepo=$(curl -H "Accept: application/vnd.github.sailor-v-preview+json" --url ${{ github.event.issue.pull_request.url }} | jq '.head.repo.full_name' | sed 's/\"//g')" >> $GITHUB_OUTPUT - - name: get upstream branch - id: upstreambranch - run: | - echo "branchname=$(curl -H "Accept: application/vnd.github.sailor-v-preview+json" --url ${{ github.event.issue.pull_request.url }} | jq '.head.ref' | sed 's/\"//g')" >> $GITHUB_OUTPUT - - name: echo upstream repo:branch - run: | - echo ${{ steps.upstreamrepo.outputs.RemoteRepo }}:${{ steps.upstreambranch.outputs.branchname }} - - name: Checkout upstream repo - uses: actions/checkout@v3 - with: - repository: ${{ steps.upstreamrepo.outputs.RemoteRepo }} - ref: ${{ steps.upstreambranch.outputs.branchname }} - - name: Install Uncrustify - run: | - : # Install Uncrustify - echo "::group::Install Uncrustify" - sudo apt-get update && sudo apt-get --assume-yes install uncrustify - echo "::endgroup::" - - name: Run Uncrustify - run: | - : # Uncrustify on C files while ignoring symlinks. - : # Make a collapsible section in the log to run uncrustify - echo "::group::Uncrustify Check" - uncrustify --version - find . -iname "*.[ch]" | xargs uncrustify --no-backup --replace --if-changed -c tools/uncrustify.cfg -l C - echo "::endgroup::" - echo -e "\033[32;3mUncrustify Formatting Applied\033[0m" - - name: Push changes to upstream repository - run: | - : # Push changes to upstream repository - echo "::group::Push changes to upstream repository" - git config --global --add safe.directory '*' - git config --global user.name 'GitHub Action' - git config --global user.email 'action@github.com' - git add -A - git commit -m "Uncrustify: triggered by comment." - echo "::endgroup::" - git push - if [ "$?" = "0" ]; then - echo -e "\033[32;3mPushed formatting changes, don't forget to run 'git pull'!\033[0m" - exit 0 - else - echo -e "\033[32;31mFailed to push the formatting changes\033[0m" - exit 1 - fi diff --git a/.gitignore b/.gitignore index 3084e83556..838651a09a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,19 @@ +# Ignore MacOS file system related. +**/*.DS_Store* + +# Ignore build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Dd]ebug_with_Libslirp/ +[Rr]elease/ +[Rr]eleases/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ +[Bb]uild/ +__pycache__/ + **/*.d **/*.o **/*.su diff --git a/CMakeLists.txt b/CMakeLists.txt index c382b6656d..c5427d3743 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,7 @@ option(FREERTOS_PLUS_TCP_BUILD_TEST "Build the test for FreeRTOS Plus TCP" OFF) # Optional: set(FREERTOS_PLUS_TCP_COMPILER "" CACHE STRING "" FORCE) # Required: set(FREERTOS_PLUS_TCP_NETWORK_IF "POSIX" CACHE STRING "" FORCE) -# Select the appropriate buffer allocaiton method. +# Select the appropriate buffer allocation method. # See: https://freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/Embedded_Ethernet_Buffer_Management.html if (NOT FREERTOS_PLUS_TCP_BUFFER_ALLOCATION) message(STATUS "Using default FREERTOS_PLUS_TCP_BUFFER_ALLOCATION = 2") @@ -131,7 +131,7 @@ elseif((FREERTOS_PORT STREQUAL "A_CUSTOM_PORT") AND (NOT TARGET freertos_kernel_ " target_include_directories(freertos_plus_tcp_network_if\n" " PUBLIC\n" " .)\n\n" - " taget_link_libraries(freertos_plus_tcp_network_if\n" + " target_link_libraries(freertos_plus_tcp_network_if\n" " PUBLIC\n" " freertos_plus_tcp_port\n" " freertos_plus_tcp_network_if_common\n" diff --git a/History.txt b/History.txt index e39bff61b2..4717f554cd 100644 --- a/History.txt +++ b/History.txt @@ -120,7 +120,7 @@ Changes between V2.3.1 and V2.3.2 releases: instead of being given the eCLOSE_WAIT status. A client socket, which calls connect() to establish a connection, will receive the eCLOSE_WAIT status, just like before. - + Fixed a race condition in DHCP state machine which occured when the macro + + Fixed a race condition in DHCP state machine which occurred when the macro dhcpINITIAL_TIMER_PERIOD was set to a very low value. Changes between V2.3.0 and V2.3.1 releases: @@ -340,7 +340,7 @@ Changes between 141019 and 150825 + Introduced ipMAX_IP_TASK_SLEEP_TIME to allow the application writer to override the default value of 10 seconds. + Fix: Correct error in *pxUDPPayloadBuffer_to_NetworkBuffer(). - + FreeRTOS_recv() now recognises the FREERTOS_ZERO_COPY flag, which, when + + FreeRTOS_recv() now recognizes the FREERTOS_ZERO_COPY flag, which, when set, the void *pvBuffer parameter is interpreted as void **pvBuffer. + FreeRTOS_listen() now returns an error code. Previously it always returned 0. diff --git a/MISRA.md b/MISRA.md index 7a4f1ac519..defc1eca0d 100644 --- a/MISRA.md +++ b/MISRA.md @@ -1,190 +1,205 @@ # MISRA Compliance -The FreeRTOS-Plus-TCP library files conform to the [MISRA C:2012](https://www.misra.org.uk/MISRAHome/MISRAC2012/tabid/196/Default.aspx) -guidelines, with the deviations listed below. Compliance is checked with Coverity static analysis. -Since the FreeRTOS-Plus-TCP library is designed for small-embedded devices, it needs to have a very small memory footprint and has to -be efficient. To achieve that and to increase the performace of the IP-stack, it deviates from some MISRA rules. -The specific deviations, suppressed inline, are listed below. - -Additionally, [MISRA configuration file](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/test/Coverity/coverity_misra.config) contains the project wide deviations. +The FreeRTOS-Plus-TCP library files conform to the +[MISRA C:2012](https://www.misra.org.uk) +guidelines, with the deviations listed below. Compliance is checked with +Coverity static analysis. Since the FreeRTOS-Plus-TCP library is designed for +small-embedded devices, it needs to have a very small memory footprint and has +to be efficient. To achieve that and to increase the performace of the IP-stack, +it deviates from some MISRA rules. The specific deviations, suppressed inline, +are listed below. + +Additionally, +[MISRA configuration file](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/test/Coverity/coverity_misra.config) +contains the project wide deviations. ### Suppressed with Coverity Comments + To find the violation references in the source files run grep on the source code with ( Assuming rule 11.4 violation; with justification in point 2 ): + ``` grep 'MISRA Ref 11.4.2' . -rI ``` + #### Directive 4.12 _Ref 4.12.1_ - MISRA C:2012 Directive 4.12: Dynamic memory allocation shall not be used. - MISRA warns against the use of dynamic memory allocation as it might - lead to undefined behavior if not used properly. However, the - FreeRTOS-Plus-TCP library only uses the memory allocation primitives - defined by the FreeRTOS-Kernel, which are deterministic. Additionally, - proper care is taken in the code to not use free'd pointers and to check - the validity of malloc'd memory before it is dereferenced or used. + MISRA warns against the use of dynamic memory allocation as it might lead to + undefined behavior if not used properly. However, the FreeRTOS-Plus-TCP + library only uses the memory allocation primitives defined by the + FreeRTOS-Kernel, which are deterministic. Additionally, proper care is taken + in the code to not use free'd pointers and to check the validity of malloc'd + memory before it is dereferenced or used. #### Rule 2.2 _Ref 2.2.1_ - MISRA C-2012 Rule 2.2 Unions are used for checksum computation to speed up the - process by utilizing the full length of registers (32-bits). After this, - the 16-bit union members are used to then compute the final checksum. - Doing this is considered as 'overwriting the variable' by Coverity. - Thus, it marks some statements as dead code. This is a false positive. + process by utilizing the full length of registers (32-bits). After this, the + 16-bit union members are used to then compute the final checksum. Doing this + is considered as 'overwriting the variable' by Coverity. Thus, it marks some + statements as dead code. This is a false positive. #### Rule 8.9 + _Ref 8.9.1_ - MISRA C-2012 Rule 8.9 For unit-tests to be repeatable and independent of the - order of execution, some variables have file scope definitions rather - than function scope. + order of execution, some variables have file scope definitions rather than + function scope. #### Rule 8.13 + _Ref 8.13.1_ - MISRA C-2012 Rule 8.13 Parameter passed is never used, should be declared as - const. The argument passed to the `prvIPTask` function is left unused which is - considered as the variable not being used and thus warranting the use of `const`. - However, the FreeRTOS-kernel function `xTaskCreate` expects a function signature - of type `void vSomeFunction( void * pvArgs )`. To satisfy that requirement, the - function signature of `prvIPTask` does not have a `const` qualifier in the - parameter signature. + const. The argument passed to the `prvIPTask` function is left unused which is + considered as the variable not being used and thus warranting the use of + `const`. However, the FreeRTOS-kernel function `xTaskCreate` expects a + function signature of type `void vSomeFunction( void * pvArgs )`. To satisfy + that requirement, the function signature of `prvIPTask` does not have a + `const` qualifier in the parameter signature. #### Rule 10.5 + _Ref 10.5.1_ - MISRA C-2012 Rule 10.5 Converting from an unsigned to an enum type. The - operation is safe to perform in that case, as we are using a generic API - to send and receive data, in that case the exact data sent it is received + operation is safe to perform in that case, as we are using a generic API to + send and receive data, in that case the exact data sent it is received #### Rule 11.1 + _Ref 11.1.1_ - MISRA C-2012 Rule 11.1 Converting from a void pointer to a function pointer. - The `FreeRTOS_setsockopt` API allows users to configure sockets by setting - various options. In order to do so, the function must accept one parameter - which, based on the option value, can be casted to the corresponding socket - field. To that end, that parameter is of `void *` type to accommodate all values. - The caller of the API is responsible for providing correct function pointer to the - API. Thus, this violation can be safely suppressed. + The `FreeRTOS_setsockopt` API allows users to configure sockets by setting + various options. In order to do so, the function must accept one parameter + which, based on the option value, can be casted to the corresponding socket + field. To that end, that parameter is of `void *` type to accommodate all + values. The caller of the API is responsible for providing correct function + pointer to the API. Thus, this violation can be safely suppressed. #### Rule 11.3 + _Ref 11.3.1_ -- MISRA C-2012 Rule 11.3 The data received/sent by the IP stack is represent as a - byte stream. This byte stream needs to be casted to various data - structures to access certain fields of the packet. However, when casting - a byte stream to a structure, MISRA warns us that it can lead to - unaligned access. But, in case of FreeRTOS+TCP, the buffer in which the - packets are stored are always aligned to a 4 byte word boundary with an - offset of 2 bytes. The reason for this 2 byte offset is that the - ethernet header is of 14 (12 + 2) bytes. Thus, everything except the - ethernet header is properly aligned. There is one alignment exception, - which is the sender protocol address in the ARP Header. To combat that, - the sender protocol address field is declared as an array of 4 bytes - instead of a `uint32_t`. - More details can be found [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/pull/512#pullrequestreview-1035211706). +- MISRA C-2012 Rule 11.3 The data received/sent by the IP stack is represented + as a byte stream. This byte stream needs to be casted to various data + structures to access certain fields of the packet. However, when casting a + byte stream to a structure, MISRA warns us that it can lead to unaligned + access. But, in case of FreeRTOS+TCP, the buffer in which the packets are + stored are always aligned to a 4 byte word boundary with an offset of 2 + bytes. The reason for this 2byte offset is that the ethernet header is of + 14 (12 + 2) bytes. Thus,everything except the ethernet header is properly + aligned. There is one alignment exception, which is the sender protocol + address in the ARP Header. To combat that, the sender protocol address field + is declared as an array of 4 bytes instead of a `uint32_t`. More details can + be found + [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/pull/512#pullrequestreview-1035211706). #### Rule 11.4 + _Ref 11.4.1_ -- MISRA c-2012 Rule 11.4 Warns about conversion between a pointer and an integer. - Whenever a socket is created using the `FreeRTOS_Socket` API, either a - valid socket (a valid non-NULL pointer) is returned; or - `FREERTOS_INVALID_SOCKET` is returned (which is essentially ~0U) to - depict an error in the socket creation process. This conversion from ~0U - to a pointer is used to convey the error to various functions. If the - pointer is equal to `FREERTOS_INVALID_SOCKET`, then it is not - dereferenced. Thus, this violation can be safely suppressed. +- MISRA c-2012 Rule 11.4 Warns about conversion between a pointer and an + integer. Whenever a socket is created using the `FreeRTOS_Socket` API, either + a valid socket (a valid non-NULL pointer) is returned; or + `FREERTOS_INVALID_SOCKET` is returned (which is essentially ~0U) to depict an + error in the socket creation process. This conversion from ~0U to a pointer is + used to convey the error to various functions. If the pointer is equal to + `FREERTOS_INVALID_SOCKET`, then it is not dereferenced. Thus, this violation + can be safely suppressed. _Ref 11.4.2_ -- MISRA Rule 11.4 The following statement may trigger a: - warning: cast increases required alignment of target type [-Wcast-align]. - It has been programatically checked that the pointer is well aligned - before this point. +- MISRA Rule 11.4 The following statement may trigger a: warning: cast increases + required alignment of target type [-Wcast-align]. It has been programatically + checked that the pointer is well aligned before this point. _Ref 11.4.3_ - MISRA Rule 11.4 warns about casting pointer to an integer and vice versa. - Here, the poiner to the starting byte of the packet is cast to an - integer which is then used to see whether the pointer is well - aligned or not. It is not used to access any pointer values. Thus, this - violation can be safely suppressed. + Here, the pointer to the starting byte of the packet is cast to an integer + which is then used to see whether the pointer is well aligned or not. It is + not used to access any pointer values. Thus, this violation can be safely + suppressed. #### Rule 11.6 + _Ref 11.6.1_ - When sending and receiving a DHCP event to the IP-stack, the events are - converted to a void pointer and sent to the IP-task. The function used - to send the events handles various events for the IP-task and thus only - accepts void pointers. The IP-task converts the void pointer back to - the original event. Thus, this rule can be safely suppressed. + converted to a void pointer and sent to the IP-task. The function used to send + the events handles various events for the IP-task and thus only accepts void + pointers. The IP-task converts the void pointer back to the original event. + Thus, this rule can be safely suppressed. _Ref 11.6.2_ - MISRA Rule 11.6 `uintptr_t` is guaranteed by the implementation to fit a - pointer size of the platform. The pointer has to be moved backward by a - constant offset to get to a 'hidden' pointer which is not available for - the user to use. This conversion is done to achieve that while avoiding - pointer arithmetic. + pointer size of the platform. The pointer has to be moved backward by a + constant offset to get to a 'hidden' pointer which is not available for the + user to use. This conversion is done to achieve that while avoiding pointer + arithmetic. #### Rule 11.8 + _Ref 11.8.1_ - MISRA c-2012 Rule 11.8 warns about removing the `const` qualifier when - assigning one value to another. In this case however, a function - pointer is being copied. It doesn't make sense in case of function - pointers for the pointee to be const or mutable. Thus, this rule is - safe to suppress. -1 + assigning one value to another. In this case however, a function pointer is + being copied. It doesn't make sense in case of function pointers for the + pointee to be const or mutable. Thus, this rule is safe to suppress. 1 + #### Rule 14.3 + _Ref 14.3.1_ -- MISRA C-2012 Rule 14.3 False positive as the value might be changed - depending on the conditionally compiled code +- MISRA C-2012 Rule 14.3 False positive as the value might be changed depending + on the conditionally compiled code #### Rule 17.2 + _Ref 17.2.1_ -- MISRA C-2012 Rule 17.2 warns about using recursion in software as that can have - severe implications on the stack usage and can lead to a serious issue. - In this case however, the number of recursions are limited by design. - Any socket spawned (child) by a socket in listening state (parent) - cannot be in listening state. Thus it is not possible for the child to - have a secondary child socket thereby limiting the number of recursive - calls to one. +- MISRA C-2012 Rule 17.2 warns about using recursion in software as that can + have severe implications on the stack usage and can lead to a serious issue. + In this case however, the number of recursions are limited by design. Any + socket spawned (child) by a socket in listening state (parent) cannot be in + listening state. Thus it is not possible for the child to have a secondary + child socket thereby limiting the number of recursive calls to one. #### Rule 20.5 + _Ref 20.5.1_ -- MISRA C-2012 Rule 20.5 warns against the use of #undef. - FreeRTOS-Plus-TCP allows its users to set some configuration macros - to modify the behavior/performance of the library according to their - needs. However, the macros values must be within certain bounds. - To achieve that, if the macro values lie outside of the bounds, they - are undefined using `#undef` before being redefined to a proper - value. +- MISRA C-2012 Rule 20.5 warns against the use of #undef. FreeRTOS-Plus-TCP + allows its users to set some configuration macros to modify the + behavior/performance of the library according to their needs. However, the + macros values must be within certain bounds. To achieve that, if the macro + values lie outside of the bounds, they are undefined using `#undef` before + being redefined to a proper value. #### Rule 20.10 + _Ref 20.10.1_ -- MISRA C-2012 Rule 20.10 warns against the use of ## concatination operator. - However, in this case, it must be used to support compile time - assertions in case the preprocessor does not suppport sizeof. This - operation (assert) has no runtime execution. +- MISRA C-2012 Rule 20.10 warns against the use of ## concatenation operator. + However, in this case, it must be used to support compile time assertions in + case the preprocessor does not suppport sizeof. This operation (assert) has no + runtime execution. #### Rule 21.6 + _Ref 21.6.1_ - MISRA C-2012 Rule 21.6 warns about the use of standard library input/output - functions as they might have implementation defined or undefined - behaviour. The function `snprintf` is used to insert information in a - logging string. This is only used in a utility function which aids in - debugging and is not part of the 'core' code governing the - functionality of the TCP/IP stack. - + functions as they might have implementation defined or undefined behaviour. + The function `snprintf` is used to insert information in a logging string. + This is only used in a utility function which aids in debugging and is not + part of the 'core' code governing the functionality of the TCP/IP stack. diff --git a/README.md b/README.md index 5ea4c67304..9355d7e629 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ For running the script, you will need Python version > 3.7. You can download/ins Once python is downloaded and installed, you can verify the version from your terminal/command window by typing `python --version`. -To run the script, you should switch to the FreeRTOS-Plus-TCP directory that was created using the [Cloning this repository](#cloning-this-repository) step above. -And then run `python /GenerateOriginalFiles.py`. +To run the script, you should switch to the FreeRTOS-Plus-TCP directory +Then run `python /GenerateOriginalFiles.py`. ## To consume FreeRTOS+TCP diff --git a/cspell.config.yaml b/cspell.config.yaml new file mode 100644 index 0000000000..911ce1d8ff --- /dev/null +++ b/cspell.config.yaml @@ -0,0 +1,31 @@ +--- +$schema: https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json +version: '0.2' +# Allows things like stringLength +allowCompoundWords: true + +# Read files not to spell check from the git ignore +useGitignore: true + +# Language settings for C +languageSettings: + - caseSensitive: false + enabled: true + languageId: c + locale: "*" + +# Add a dictionary, and the path to the word list +dictionaryDefinitions: + - name: freertos-words + path: '.github/.cSpellWords.txt' + addWords: true + +dictionaries: + - freertos-words + +# Paths and files to ignore +ignorePaths: + - 'dependency' + - 'docs' + - 'ThirdParty' + - 'History.txt' diff --git a/lexicon.txt b/lexicon.txt deleted file mode 100644 index fc96db439e..0000000000 --- a/lexicon.txt +++ /dev/null @@ -1,2134 +0,0 @@ -aaa -aaaa -aaaaaaa -aal -ab -abcd -abuflen -ack -acked -ackno -acks -acount -acs -addr -addressalignedbeats -addrinfo -addrstart -addtogroup -afe -ahb -aindex -amba -analyse -analysed -analysing -ap -api -apis -april -aptime -arg -arp -arppacket -arpprocesspacket -arprefreshcacheentry -arps -ascii -asf -atmel -automaticpadcrcstrip -autonegotiation -aws -ba -backoff -backofflimit -backpressure -bactive -bafter -barry -baseaddress -bbbbbbb -bbefore -bcalldownevent -bcalldownhook -bcloseaftersend -bcloserequested -bconnpassed -bconnprepared -bds -bendpointup -berkeley -besr -bexpired -bfinaccepted -bfinacked -bfinlast -bfinrecv -bfinsent -bhasdot -bhasinit -binterfaceup -bipaddressinuse -bisdefault -bisforrx -bist -bitconfig_t -bitmask -bitscanreverse -bl -blowwater -bmallocerror -bmayconnect -bmsschange -bool -boolean -boutstanding -bpassaccept -bpassqueued -bpdg -breleaseaftersend -breusesocket -broadcastframesreception -brxstopped -bsd -bsendfullsize -bsendkeepalive -btimestamps -buf -buffermanagement -buffna -busershutdown -bwaitkeepalive -bwantdhcp -bwantra -bwinchange -bwinscaling -bytecount -callbacklist -calloc -cambridge -camen -caretline -carriersense -castingmacrofunctions -cbmc -ccfg -cchannel -cchar -cd -cdef -ce -centralised -ceo -cerrorbuffer -cgcr -ch -checkoptions -checkoptionsinner -checkoptionsouter -checksum -checksummode -checksumoffload -chextochar -cli -clk -cmd -cmock -co -col -com -cond -config -configassert -configprintf -const -controlbuffersize -copyallframe -coverity -cpu -cpus -cr -crc -cresult -crs -cseparator -csn -csr -csv -cten -ctrl -curtok -cwd -da -daif -datalen -dbf -dc -dcrs -dd -de -debounce -deferral -deferralcheck -defgroup -deglitchers -deinitializes -delayreq -delayrespm -demoiptrace -desc -desciptorskiplength -dest -destinationaddrfilter -deviceid -dff -dhcp -dhcpbroadcast -dhcpcookie -dhcpmsg -dhcpserveraddress -didn -diff -dm -dma -dmaarbitration -dmabmr -dmaconf -dmainit -dmaomr -dmatxdesctoclear -dmix -dns -dnsanswerrecord -doesn -don -dont -downshift -dr -drbs -droptcpipchecksumerrorframe -dsl -dt -duid -duplexmode -dw -dword -dzpq -eagain -eapplicationprocesscustomframehook -earpcachehit -earpcachemiss -earpgetcacheentry -earpgetcacheentrybymac -earpprocesspacket -earptimerevent -ec -ecantsendpacket -eclosed -eclosing -ecn -econn -econsiderframeforprocessing -ectrl -edfe -edhcpcontinue -edhcpevent -edhcpphaseprediscover -edhcpphaseprerequest -edhcpstate -edhcpstopnochanges -edhcpusedefaults -edmac -eecs -eedi -eedo -eepcr -eeprom -eesk -eestabl -eestablished -eevent -eeventtype -eexpectedstate -ef -eframeconsumed -eg -egetlinklayeraddress -ehertype -eigrp -einitialwait -einprogress -einval -einvalidchecksum -einvaliddata -eleasedaddress -elif -emac -emacfailed -emacinit -emacpass -emacpins -emacps -emacro -en -enablesolved -endcode -endcond -endgetcacheentry -endian -endianness -endif -endverbatim -enetworkdown -enetworkdownevent -enetworkrxevent -enetworktxevent -enetworkup -enhanceddescriptorformat -enoevent -enotconn -enotusingleasedaddress -enum -eof -eol -eprocessbuffer -erastateapply -erastateiptest -erastateipwait -erastatelease -erastateprelease -erastatewait -ereleasebuffer -ereturn -ereturned -ereturnethernetframe -errbuf -errno -esenddhcprequest -esocketbindevent -esocketcloseevent -esocketselectevent -esocketsetdeleteevent -esocketsignalevent -espressif -estacktxevent -estatus -esuccess -etcpacceptevent -etcpnetstat -etcpstate -etcptimerevent -eth -etherc -ethernet -ethernetif -ethertype -etv -etype -eunknown -eventbits -ewaitingacknowledge -ewaitingarpresolution -ewaitingoffer -ewaitingsendfirstdiscover -ewouldblock -exceptioninfo -ext -extendedstatus -exti -faq -faqhelp -fb -fc -fchwr -fclwr -fcowr -fcs -fd -fe -fecf -fef -fes -ff -ffab -ffee -fffe -ffff -ffnn -fifo -finalise -fixedburst -flushreceivedframe -fmc -fondnsevent -forwarderrorframes -forwardundersizedgoodframes -fr -framerx -freertos -freertos_sendto -freertosconfig -freertosip -freertosipconfig -freertosipconfigdefaults -fromisr -fsrxdesc -fuf -func -getaddrinfo -gethostbyname -getnetworkbuffer -getnetworkbufferwithdescriptor -github -gmac -gmacpins -gmacsa -gnw -gpio -gpl -gratuitous -greaterthan -grr -gswutr -gw -hal -hashtablehigh -hashtablelow -hasn -hclk -hd -heapdur -heapmin -hein -hmc -hp -hpf -href -hresp -ht -html -hton -http -https -huc -hw -hz -ia -iacr -iadhr -iadlr -icmp -ie -ieee -ier -ietf -ifdef -ifg -ifndef -igmp -ihl -inc -infos -init -initialisation -initialise -initialised -initialisenetwork -initialises -initialising -inlined -inlining -int -interframegap -intn -io -ip -ipaddress -ipc -ipco -ipg -ipif -ipsec -iptask -iptracemacrodefaults -irs -isdhcpsocket -isn -isnetworkup -isp -isr -isrs -iss -itemvalue -itimezone -jan -jd -json -jt -july -june -kahb -kbyte -kbytes -keepalive -knowns -lan -lastpacket -laststate -lbytes -lbytesleft -lc -lca -lco -lcount -lcurmss -ld -ldatalen -ldatalength -ldistance -leds -len -lendofframe -lessthan -lidsize -linkcurr -linklayer -linkmd -linksstatus -linkstatus -linux -ll -llevel -llmnr -llt -lm -lmax -lmaxlength -lminlength -lnetlength -localhost -loffset -longjmp -loopback -loopbackmode -loptionname -lpacketcount -lpback -lpcopen -lposition -lreceivelength -lrxbufsize -lrxspace -lrxwinsize -lsb -lsrtt -lsrxdesc -lstreampos -ltail -ltcpaddrxdata -ltcpwindowrxcheck -ltcpwindowtxadd -ltd -ltowrite -ltransmitted -ltxbufsize -ltxwinsize -lu -lwip -lx -lxip -mac -macaddr -macb -macclihandle -macconf -maccr -macfcr -macffr -machthr -machtlr -maclinkstatus -macmiiar -macobject -macobjhandle -macobjstatus -macvlantr -malformed -malloc -malloclarge -mallocsocket -marh -marl -marm -mbir -mbit -mbps -mcd -mck -mcu -mcus -md -mdc -mdi -mdio -mdix -mdns -mediainterface -memcmp -memcopy -memcpy -memset -mh -mhz -mib -micrel -microcontroller -microcontrollers -microsoft -mii -miiar -min -misra -mit -mmc -mo -mqtt -msb -msc -msec -msecs -msg -msl -msp -mss -msvc -mtu -multicastframesfilter -mutex -mutexes -mydevice -na -nack -nanosec -nbns -nc -neg -neighbour -netbios -netif -netmask -netstat -networkbuffer -networkbufferallocate -networkbufferdescriptor -networkdown -networkeventhook -networkinterface -nextidx -nic -nn -nnn -nnnn -noaddrsavail -nobroadcast -noevent -nondet -noninfringement -nontemporaryaddress -noop -nop -notnull -ntoh -ntohl -ntp -ntpclient -ntpdemo -nulling -nvic -nxt -obcr -oe -offsetof -ok -onconnect -onconnected -onreceive -onsent -op -opendns -openrtos -optimisation -optimise -optimised -optlen -ored -org -originatetimestamp -osf -outfile -outputarprequest -pacap -pace -param -parsednsreply -passcontrolframes -pauselowthreshold -pausetime -pbl -pbuf -pbufs -pc -pcallback -pcallbackfunction -pcap -pcapplicationhostnamehook -pcbuffer -pcdata -pcdestination -pce -pcendpointname -pcf -pcformat -pcfrom -pchost -pchostname -pcipaddress -pcmessage -pcmessagetype -pcname -pcnames -pcnetworkbuffer -pcremoteip -pcrequestedname -pcreturn -pcs -pcservername -pcservice -pcsource -pctarget -pcto -pctype -pd -pdata -pdc -pdecode -pdelay -pdelayreq -pdelayresp -pdfail -pdfalse -pdpass -pdtrue -perfectfilter -perfecthashtablefilter -pfc -pfgetphylinkstatus -pfhandler -pfinitialise -pfnz -pfoutput -phy -phyaddress -phyhandling -phyreg -phyrr -phys -pio -pioa -pll -plposition -plt -pm -pma -pmacobject -pmc -pme -pmecr -pmt -pointee -portinline -posix -pparam -ppkt -ppointer -ppucdata -ppucrecvdata -ppxaddressinfo -ppxendpoint -ppxlastaddress -ppxnetworkbuffer -ppxresult -pr -pragma -pre -preparereplydnsmessage -printf -printfs -processdhcpreplies -processethernetpacket -processicmppacket -processippacket -projdefs -promiscuousmode -prvallowippacket -prvcachelookup -prvchecknetworktimers -prvcheckoptions -prvcheckrxdata -prvclosedhcpsocket -prvcopydatatoqueue -prvcreatednsmessage -prvcreatesectors -prvdeterminesocketsize -prvdnsreply -prvechoclienttask -prvemacdeferredinterrupthandlertask -prvemachandlertask -prvfillsockaddress -prvfindcacheentry -prvfindendpointonnetmask -prvgetchecksumfrompacket -prvgethostbyname -prvgethostbynameop -prvgetpayloadbuffer -prvhandleestablished -prvhandlelisten -prvhandlesynreceived -prvinitialisedhcp -prviptask -prviptimercheck -prviptimerstart -prvlinkstatuschange -prvnotifyqueuesetcontainer -prvntptask -prvparsednsreply -prvprepareadvertise -prvprepareadvertiseiata -prvprepareadvertisenoserverid -prvprepareadvertisestatuscodelengthtoobig -prvprepareadvertisestatuscodelengthtoosmall -prvprepareadvertisestatuscodelongmessage -prvprepareadvertisesubstatuscodefail -prvprepareerroroption -prvprepareerrortransactionid -prvpreparelinklayeriplookup -prvpreparelookup -prvpreparereply -prvpreparereplyclientidcontentwrong -prvpreparereplyclientidlengthwrong -prvpreparereplyclientidpeekfalse -prvpreparereplyclientidtoobig -prvpreparereplyclientidtoosmall -prvpreparereplydifferentserverduid -prvpreparereplydifferentserverduidtype -prvpreparereplydifferentserverlength -prvpreparereplydnslengthnotallow -prvpreparereplydnslengthzero -prvpreparereplyserveridtoobig -prvpreparereplyserveridtoosmall -prvpreparereplywithdns -prvpreparereplywithdomainsearchlist -prvpreparereplywithmultipledns -prvpreparerequest -prvpreparesolicitation -prvprepareunknownmsgtype -prvpreparewrongtransactionid -prvprocessdhcpreplies -prvprocessdnscache -prvprocessethernetpacket -prvprocessicmpechorequest -prvprocessipeventsandtimers -prvprocessippacket -prvprocessnetworkdownevent -prvreadnamefield -prvreadsackoption -prvrxcallback -prvsendbuffer -prvsenddata -prvsenddhcpdiscover -prvsenddhcpmessage -prvsenddhcprequest -prvsendudppacket -prvsetaynackoptions -prvsetchecksuminpacket -prvsetoptions -prvsetsynackoptions -prvsinglesteptcpheaderoptions -prvskipnamefield -prvsocketprops -prvsocketsetmss -prvstatename -prvstorerxdata -prvstorexdata -prvtcpaddtxdata -prvtcpbufferresize -prvtcpflagmeaning -prvtcphandlefin -prvtcphandlestate -prvtcpmakesureprepared -prvtcpnexttimeout -prvtcpprepareconnect -prvtcppreparesend -prvtcpreturnpacket -prvtcpsendchallengeack -prvtcpsendcheck -prvtcpsendloop -prvtcpsendpacket -prvtcpsendrepeated -prvtcpsendreset -prvtcpsendspecialpackethelper -prvtcpsocketcopy -prvtcpsocketisactive -prvtcpstatusagecheck -prvtcptouchsocket -prvtcpwindowfastretransmit -prvtcpwindowtxcheckack -prvtcpwindowtxhasspace -prvtxcallback -prvvalidsocket -prvwinpcaprecvthread -prvwinpcapsendthread -prvwinscalefactor -prvwritepackets -ps -pt -pte -pthread -pthreads -ptp -ptxpkt -ptz -pucaddress -pucanswer -pucbase -pucbuffer -pucbyte -pucbytes -puccolon -pucdata -pucdescription -pucend -pucethernetbuffer -pucgetuncachedmemory -pucid -pucinterfacename -puciptype -pucname -pucnewbuffer -pucnextdata -pucoptionsarray -pucpayload -pucpayloadbuffer -pucprotocol -pucptr -pucrecvdata -pucreturn -pucsource -pucstart -puctarget -pucudppayload -pucudppayloadbuffer -pucusebuffer -puldelay -puldestination -puldnsserveraddress -pulgatewayaddress -pulip -pulipaddress -pullups -pulnetmask -pulnumber -pulskipcount -pulvalue -pusaddress -puschecksum -pv -pvargument -pvbuffer -pvdata -pvdestination -pvethernetbuffer -pvoptionvalue -pvparam -pvparameters -pvpointer -pvportmalloc -pvportmallocsocket -pvptr -pvsearchid -pvsocketid -pvsource -pxackmessage -pxaddr -pxaddress -pxaddresses -pxaddressinfo -pxaddresslength -pxaddresstolookup -pxallnetworkinterfaces -pxanswer -pxarpframe -pxarpwaitingnetworkbuffer -pxbindaddress -pxbuffer -pxbufferdescriptor -pxclientsocket -pxconfig -pxdescriptor -pxdest -pxdestinationaddress -pxdhcpmessage -pxdnsbuf -pxdnsmessageheader -pxdnsserveraddress -pxduplicatenetworkbufferwithdescriptor -pxeasyfit -pxendpoint -pxevent -pxeventbits -pxfrom -pxgatewayaddress -pxgetnetworkbuffer -pxgetnetworkbufferwithdescriptor -pxgetsocketendpoint -pxhandleconnected -pxhandlereceive -pxhandlesent -pxhead -pxheadsegment -pxhigherprioritytaskwoken -pxhints -pxicmpheader -pxicmppacket -pxindex -pxinfo -pxinterface -pxip -pxipaddress -pxipaddressfrom -pxipaddressto -pxipheader -pxippacket -pxiswaitingforarpresolution -pxiterator -pxlastaddress -pxleft -pxlength -pxlist -pxlistfindlistitemwithvalue -pxlocation -pxlostbuffer -pxmacaddress -pxmessage -pxnetprefix -pxnetworkbuffer -pxnetworkendpoints -pxnetworkinterface -pxnetworkinterfaces -pxnewaddress -pxnewbuffer -pxnewlistitem -pxnewsocket -pxnext -pxnextbuffer -pxnextnetworkbufferdescriptor -pxontcpconnected -pxontcpreceive -pxontcpsent -pxonudpreceive -pxonudpsent -pxopenedinterfacehandle -pxoptionsarraysize -pxpacket -pxparentsocket -pxpeersocket -pxphyobject -pxprefix -pxprevious -pxprops -pxprotocolheaders -pxprotpack -pxreceivebuffer -pxreplyendpoint -pxresizenetworkbufferwithdescriptor -pxresult -pxresults -pxreturngroupid -pxright -pxsegment -pxset -pxsocket -pxsocketlist -pxsocketset -pxsocketsize -pxsockettodelete -pxsourceaddress -pxsourceaddresslength -pxsourceendpoint -pxtargetendpoint -pxtcp -pxtcpheader -pxtcppacket -pxtcpsocketlookup -pxtcpwindow -pxtimer -pxudpsocketlookup -pxusersemaphore -pxuserwakecallback -pxwhere -pxwindow -qmu -queuegenericcreate -queuegenericsend -quickstart -ra -ramfunc -randomised -randomiser -rawdata -rbus -rcomp -rcv -rdu -readme -readnamefield -receiveall -receivedata -receiveflowcontrol -receiveown -receivestoreforward -receivethresholdcontrol -receivetime -receivetimestamp -recognised -recv -recvfrom -referenceid -referencetimestamp -reg -regist -regvalue -reinit -releaseaftersend -releaseudppayloadbuffer -renesas -reqlength -resetpins -resp -ret -retrytransmission -retval -revents -rexmit -rfc -rgmii -rhy -richard -rle -rlex -rmii -rng -ro -rollover -rootdelay -rootdispersion -roreg -rovr -rpbl -rsf -rst -rstn -rtc -rto -rtos -rtt -rw -rwreg -rwt -rx -rxbd -rxbuff -rxcoen -rxd -rxdbtcr -rxdesc -rxdma -rxdmaburstlength -rxdttr -rxdv -rxer -rxfctfc -rxfdpr -rxfhbcr -rxfhsr -rxfifo -rxframeinfos -rxhead -rxmid -rxmode -rxq -rxqcr -rxstream -rxtail -rxubr -sa -sackp -saf -safemalloc -safemallocsaif -safertos -sam -sck -sdio -sdma -sdram -sec -secondframeoperate -segcount -segload -segloadlen -segloadoffset -senddata -sendeventtoiptask -sendto -seq -setsockopt -shouldn -sht -shtml -si -signalled -sizeof -skipnamefield -slaac -snd -snprintf -sntptimestamp -sockaddr -socketid -socketset -sockopt -sof -sourceaddrfilter -spdx -spi -sprintf -squestions -sram -src -srdbl -srtt -ss -starttx -stdarg -stderr -stmicroelectronics -strcmp -streambuffer -streamsize -struct -structs -subdomain -sublicense -sw -swr -syn -synchronicity -synchronisation -synchronised -syscfg -sysclock -systemcoreclock -taskpool -tbd -tcomp -tcp -tcpflags -tcpipheapconfig -tcpwin -td -tds -te -temac -tfc -tfe -tibosch -timestamphigh -timestamplow -tmpreg -todo -tp -tpi -transmitflowcontrol -transmitstoreforward -transmitthresholdcontrol -trcrecorder -trunc -tsf -tsu -tt -ttc -ttl -tur -tx -txcompl -txcr -txd -txdesc -txdma -txdmaburstlength -txfdpr -txfifo -txmid -txmir -txntfsr -txpd -txq -txqcr -txsr -txstatus -txstream -txt -txtd -uart -ucaddress -ucaddresslength -ucaddresstype -ucage -ucarray -ucasciitohex -ucbootfilename -ucbytes -ucchildtext -ucclienthardwareaddress -uccontents -uccurrentipaddress -ucdifferentiatedservicescode -ucdnsindex -ucdnsserver -ucdnsserveraddress -ucdupackcount -ucduplex -ucflags -ucgatewayaddress -uchardwareaddresslength -uchasuid -ucheaderextlength -uchoplimit -uchops -ucidentifier -ucipaddress -uciptype -uciscachedmemory -uckeeprepcount -uclastpacket -uclen -uclength -uclinklayeripaddress -ucmacaddress -ucmaxresponsetime -ucmessagetype -ucmywinscalefactor -ucname -ucnamecode -ucnameoffset -ucnamespace -ucnamezero -ucnbnsname -ucnetmask -ucnew -ucnextheader -ucnumipaddresses -ucoctet -ucopcode -ucoptdata -ucoptionbytes -ucoptioncode -ucoptionlength -ucoptiontype -ucpeerwinscalefactor -ucpreference -ucprefix -ucprefixlength -ucprotocol -ucprotocoladdresslength -ucprotocolheadersize -ucrepcount -ucsenderprotocoladdress -ucserverhostname -ucserveridentifier -ucsocketoptions -ucspeed -ucstatus -uctcpflags -uctcpoffset -uctcpstate -uctimetolive -uctrafficclassflow -uctransactionid -uctransmitcount -uctype -uctypeofmessage -uctypeofservice -ucvalid -ucvalue -ucversionheaderlength -ucversiontrafficclass -ucversiontype -uczeros -udp -ue -uip -ulacknr -ulacknumber -ulactuallength -uladdresstolookup -ulalignbits -ulapplicationgetnextsequencenumber -ularpremovecacheentrybymac -ulborn -ulbroadcastaddress -ulbytecount -ulchecktime -ulclientipaddress -ulconnected -ulcount -ulcurmss -ulcurrentsequencenumber -ulcurrentspistatus -ulcurrenttimeseconds -uldata -uldefaultipaddress -uldelayms -uldestinationaddress -uldestinationipaddress -uldhcpcookie -uldhcpserveraddress -uldnshandlepacket -uldnsserver -uldnsserveraddress -uldnsserveraddresses -uldonemask -ulexpectipaddress -ulfifolength -ulfinsequencenumber -ulfirst -ulfirstsequencenumber -ulflag -ulflags -ulgateway -ulgatewayaddress -ulgenericlength -ulgetruntimecountervalue -ulhighestrxallowed -ulhighestsequencenumber -uliaid -ulin -ulindex -ulinitialsequencenumber -ulinternal -ulinterruptcause -ulinterruptmask -ulip -ulipaddress -ulipaddresses -ullalignmentword -ullast -ulleasetime -ullen -ullength -ullgethighresolutiontime -ullinkstatusmask -ullocaladdress -ullocalip -ullocations -ullocationsip -ullookupip -ulltcpalignment -ulmandatoryoptions -ulmask -ulmatching -ulmsec -ulmss -ulmtu -ulnbnshandlepacket -ulnetmask -ulnextfreetxdescriptor -ulnextsequencenumber -ulnexttxsequencenumber -ulnumbers -ulofferedipaddress -uloffset -ulong -ulonip -ulonmac -ulonnetmask -uloptionsdata -uloursequencenumber -ulparameter -ulphymask -ulpreferredipaddress -ulpreferredlifetime -ulprocessed -ulprotocol -ulpvalidlifetime -ulreadmdio -ulreceivelength -ulreloadtime -ulremainingtime -ulremoteip -ulrequestcount -ulreserved -ulreturn -ulrxwindowlength -ulseconds -ulsenderprotocoladdress -ulsendlength -ulsequencenumber -ulsize -ulskipcount -ulsourceaddress -ulsourceipaddress -ulspace -ulsrtt -ulstatus -ulsubnetmask -ulsum -ultargetprotocoladdress -ultcpwindowtxack -ultcpwindowtxget -ultcpwindowtxsack -ultimergetage -ultimestamp -ultimewhenaddedinseconds -ultransactionid -ulttl -ultxwindowlength -ultype -uluserdatalength -ulvalidlifetime -ulvalue -ulwhere -ulwindowsize -ulwords -un -una -uncached -undef -underrun -unhandled -unicast -unicastframesfilter -unicastpauseframedetect -uninitialised -unsetmacaddr -urg -url -usadditionalrrs -usadditionalrss -usaddress -usanswerrss -usanswers -usauthorityrrs -usauthrss -usbacklog -usboundport -uschecksum -uschecksumfound -uschildcount -usclass -uscurmss -usdatalength -usdestinationport -usdnstype -usduidtype -usec -uselapsedtime -userdaata -usexpected -usflags -usflowlabel -usfragmentoffset -usframetype -usgeneratechecksum -usgenerateprotocolchecksum -usgetextensionheaderlength -usgroupaddress -ushardwaretype -usheaderchecks -usheaderchecksum -usidentification -usidentifier -usinitmss -uslength -uslifetime -uslocalport -usmask -usmss -usmssinit -usnbflags -usnumarecordsstored -usoperation -usoption -usourportnumber -uspayloadlength -uspeerportnumber -usport -usportnr -usportnumber -usprotocolbytes -usprotocoltype -usquestions -usreachabletime -usremoteport -usrequestid -usretranstime -ussequencenumber -ussourceport -usstatus -ussum -ustaskstacksize -ustime -ustimeout -ustype -usudplength -usurgent -usvalue -uswindow -utf -util -uuid -uxaddresslength -uxarpclashcounter -uxblocktimeticks -uxborn -uxbufferlength -uxbuffersize -uxbytecount -uxbytesneeded -uxbytesread -uxclockticks -uxcontents -uxcount -uxcurrentseconds -uxdatalength -uxdatalengthbytes -uxdestlen -uxdnscount -uxenoughspace -uxentrycount -uxflags -uxfront -uxgetminimumipqueuespace -uxhead -uxheaderbytes -uxheaderlength -uxhexprintshort -uxhostlen -uxhosttype -uxicmpsize -uxidentifier -uxidsize -uxindex -uxipheaderlength -uxipheadersize -uxipheadersizepacket -uxipheadersizesocket -uxlast -uxlastminqueuespace -uxleft -uxlength -uxlittlespace -uxlocalport -uxlower -uxmax -uxmaxcount -uxmaxpackets -uxmessagetype -uxmid -uxnamelen -uxnewlength -uxnextpacketnumber -uxnumberofbytestosend -uxoffset -uxoptionlength -uxoptionslength -uxpacketlength -uxpayloaddatalength -uxpayloadlength -uxpayloadoffset -uxpayloadsize -uxprefixlength -uxprotocolheaderlength -uxptr -uxqueueminimumspace -uxqueuespacesavailable -uxreloadtime -uxremainingbytes -uxremainingsize -uxremainingtime -uxremaningtime -uxremoteport -uxrequestedsizebytes -uxresult -uxright -uxrxstreamsize -uxrxwinsize -uxschedulersuspended -uxsecs -uxsize -uxsocketsize -uxsourcebytesremaining -uxsourcelen -uxstart -uxstreambufferadd -uxstreambufferget -uxstreambuffermidspace -uxtail -uxtargetindex -uxtaskgetsystemstate -uxtaskpriority -uxtickstowait -uxtimeout -uxtimeoutstate -uxtotaldatalength -uxtotallength -uxtxstreamsize -uxtxwinsize -uxudpoffset -uxunrollcount -uxupper -uxwinsize -val -vapplicationipnetworkeventhook -vapplicationpingreplyhook -var -varpagecache -varpgeneraterequestpacket -varprefreshcacheentry -varprefreshcacheentryage -varprocesspacketrequest -varpsendgratuitous -varptimerreload -vcastconstpointerto -vcastconstptrto -vchecknetworktimers -vcleartxbuffers -vconfiguretimerforruntimestats -vdhcpprocess -vdhcpprocessendpoint -vdnscheckcallback -vdnsinitialise -vdnssetcallback -vdnstimerreload -ve -versionheaderlength -veventgroupdelete -vipnetworkupcalls -vipreloaddhcptimer -vipsetarpresolutiontimerenablestate -vipsetarptimerenablestate -vipsetdhcptimerenablestate -vipsetdnstimerenablestate -vipsettcptimerexpiredstate -viptimerstartarpresolution -vl -vlan -vlantagcomparison -vlantagidentifier -vlistinitialise -vlistinitialiseitem -vlistinsertend -vmyconnecthandler -vndagecache -vndrefreshcacheentry -vndsendneighboursolicitation -vndsendroutersolicitation -vnetworkinterfaceallocateramtobuffers -vnetworktimerreload -vperformaction -vportentercritical -vportexitcritical -vportfree -vprecheckconfigs -vprintresourcestats -vprocessgeneratedudppacket -vraprocess -vraprocessinit -vreceivena -vreceivera -vreleasenetworkbufferanddescriptor -vreturnethernetframe -vrxfaultinjection -vsetsocketendpoint -vsocketbind -vsocketclose -vsocketclosenexttime -vsocketgetsocketid -vsocketlistennexttime -vsocketselect -vsocketsetsocketid -vsocketwakeupuser -vstartntptask -vtaskdelay -vtasklist -vtasknotifygivefromisr -vtasksuspendall -vtcpnetstat -vtcpstatechange -vtcptimergetage -vtcptimerreload -vtcptimerset -vtcpwindowdestroy -vtcpwindowfree -vtcpwindowinit -wasn -wcast -wdwfcr -whereafter -wifi -wikipedia -winpcap -wnd -wol -woreg -wrdata -wrxsize -wsf -wsopt -wtxsize -www -xaddress -xaddresses -xaddressfamily -xaddressislocal -xaddresslength -xalldone -xallnetworksup -xapplicationdhcphook -xapplicationdhcpuserhook -xapplicationdnsqueryhook -xapplicationgetrandomnumber -xarpcache -xarpframe -xarphadipclash -xarpheader -xarppacket -xarpwaitresolution -xasynchronous -xattempt -xbacklog -xbest -xbitstoclear -xbitstoset -xblocktimeticks -xboundsocketlistitem -xboundtcpsocketslist -xboundudpsocketslist -xbroadcastmacaddress -xbuffer -xbufferlength -xbufferlistitem -xbytecount -xbytesleft -xcalculatesleeptime -xcallbacklist -xcheckloopback -xclearonexit -xclientid -xclientsocket -xcolon -xconnected -xcount -xcurlength -xcurrentorder -xcurstart -xdatalength -xdatalengthbytes -xdefaultaddressing -xdefaultpartudppacketheader -xdescriptorwaittime -xdestinationaddress -xdestinationaddresslength -xdhcpdata -xdhcpmessage -xdhcpsocket -xdhcpsocketusercount -xdhcptxperiod -xdhcptxtime -xdmarxdescriptors -xdnsbuf -xdnscache -xdnsmessage -xdnsservers -xdnssocket -xdoaccept -xdocheck -xdolog -xdomain -xdorandom -xdoremove -xdoreset -xdostore -xdumpingready -xechoserveraddress -xemacps -xemacpsif -xemactaskhandle -xenablestate -xend -xendpoint -xendpoints -xentries -xentryfound -xerrnum -xethernetheader -xeventbits -xeventgroup -xeventgroupsetbits -xeventgroupwaitbits -xexpected -xexpectedmessagetype -xexpiredstate -xextheadercount -xfamily -xfield -xflags -xforsend -xfound -xfreebufferslist -xgatewayaddress -xgetextensionorder -xgetphylinkstatus -xgivingup -xgmacswitchrequired -xhaddigit -xhadreception -xhand -xhandler -xhaserror -xhasspace -xhassynflag -xhigherprioritytaskwoken -xhighestindex -xhints -xhnd -xhow -xhtml -xicmpheader -xicmppacket -xidentifier -xilinx -xindex -xinternal -xipaddress -xipaddressfound -xipentry -xipheader -xipheadersize -xiptaskhandle -xiptaskinitialised -xiptracevalues -xiptype -xipversion -xisbound -xiscallingfromiptask -xisforrx -xisglobal -xisinputstream -xisipinarpcache -xiswaitingarpresolution -xitemvalue -xlastacttime -xlastalivetime -xlastgratuitousarptime -xlastround -xlastsource -xleasetime -xlength -xlinkstatustimer -xlistend -xlistitem -xlistitemalreadyinfreelist -xlocaladdress -xlocalbuffer -xlocalport -xlogging -xlookup -xloop -xlwipconfig -xmacaddress -xmacbroadcast -xmacentry -xmaxtime -xmessage -xmicreldevice -xmitcount -xml -xndcache -xnetworkaddressing -xnetworkbuffer -xnetworkbufferdescriptor -xnetworkbuffersemaphore -xnetworkbuffersinitialise -xnetworkdowneventpending -xnetworkendpoint -xnetworkeventqueue -xnetworkinterface -xnetworkinterfaceinitialise -xnetworkinterfaceoutput -xnetworkparams -xnetworktimer -xnetworkup -xnextorder -xntppacket -xntptaskhandle -xontcpconnect -xontcpreceive -xontcpsent -xonudpreceive -xonudpsent -xopcode -xotherislocal -xoutgoingpacket -xpacket -xpacketlist -xpar -xpeek -xphyfixedvalue -xphypreferences -xphystartautonegotiation -xport -xporthasudpsocket -xpqueue -xprefix -xprefixaddress -xpriorityqueue -xprivatestorage -xprocessedtcpmessage -xprocessreceivedtcppacket -xprocessreceivedudppacket -xprotocol -xprotocolcpy -xqueuecreateset -xqueuegenericcreatestatic -xqueuegenericsend -xqueuegenericsendfromisr -xqueueitem -xqueuereceive -xradata -xrandomok -xrandomtaskhandle -xrasolicitationrequest -xready -xreceiveblocktime -xregister -xreleaseaftersend -xremainingtime -xremoteip -xremoteport -xrequestedsizebytes -xreset -xresize -xresult -xretryindex -xreturn -xreturned -xround -xrxcallback -xrxsegments -xsegmentitem -xsegmentlist -xselectbits -xsemaphoregive -xsendblocktime -xsenddhcpevent -xsenderhardwareaddress -xsendeventstructtoiptask -xsendeventtoiptask -xsendlength -xsequencegreaterthan -xsequencelessthan -xserverid -xserversemaphore -xserversocket -xset -xshortcount -xsize -xsizewithoutdata -xsocket -xsocketbits -xsocketset -xsockettaskhandles -xsocketvalid -xsource -xsourceaddress -xstatus -xstream -xsum -xtargethardwareaddress -xtargetindex -xtaskcheckfortimeout -xtaskcreate -xtaskcreatestatic -xtaskgenericnotify -xtaskgetcurrenttaskhandle -xtaskgetmpusettings -xtaskgettickcount -xtaskhandle -xtasknotifygive -xtaskresumeall -xtcp -xtcpchecknewclient -xtcpheader -xtcppacket -xtcpsegments -xtcpsocketcheck -xtcptimer -xtcptimercheck -xtcpwindow -xtcpwindowgethead -xtcpwindownew -xtcpwindowpeekhead -xtcpwindowrxconfirm -xtcpwindowrxfind -xtcpwindowtxdone -xtcpwindowtxhasdata -xtcpwindowtxnew -xtemplist -xtickcount -xtickstojump -xtickstowait -xtime -xtimeout -xtotallength -xtransmittimer -xtxcallback -xtxdescriptorsemaphore -xtxqueue -xtxsegment -xtxsegments -xtype -xudp -xudpheader -xudppacket -xusebroadcast -xuseentry -xwaitallbits -xwaitingpacketslist -xwaitqueue -xwanteditemvalue -xwantedsize -xwillsleep -xwindow -xxx -xzerolength -xzerostart -xzynqdescriptor -xzynqgemgetphylinkstatus -xzynqgeminitialise -xzynqgemoutput -yyyy -zeroquantapause -zynq diff --git a/source/FreeRTOS_ARP.c b/source/FreeRTOS_ARP.c index 76e3b2e612..509e927ad7 100644 --- a/source/FreeRTOS_ARP.c +++ b/source/FreeRTOS_ARP.c @@ -242,16 +242,16 @@ static TickType_t xLastGratuitousARPTime = 0U; /* Process received ARP frame to see if there is a clash. */ #if ( ipconfigARP_USE_CLASH_DETECTION != 0 ) - { - NetworkEndPoint_t * pxSourceEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( ulSenderProtocolAddress, 2 ); + { + NetworkEndPoint_t * pxSourceEndPoint = FreeRTOS_FindEndPointOnIP_IPv4( ulSenderProtocolAddress, 2 ); - if( ( pxSourceEndPoint != NULL ) && ( pxSourceEndPoint->ipv4_settings.ulIPAddress == ulSenderProtocolAddress ) ) - { - xARPHadIPClash = pdTRUE; - /* Remember the MAC-address of the other device which has the same IP-address. */ - ( void ) memcpy( xARPClashMacAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, sizeof( xARPClashMacAddress.ucBytes ) ); - } + if( ( pxSourceEndPoint != NULL ) && ( pxSourceEndPoint->ipv4_settings.ulIPAddress == ulSenderProtocolAddress ) ) + { + xARPHadIPClash = pdTRUE; + /* Remember the MAC-address of the other device which has the same IP-address. */ + ( void ) memcpy( xARPClashMacAddress.ucBytes, pxARPHeader->xSenderHardwareAddress.ucBytes, sizeof( xARPClashMacAddress.ucBytes ) ); } + } #endif /* ipconfigARP_USE_CLASH_DETECTION */ } else @@ -845,21 +845,21 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, * is different. Continue looping to find a possible match with * ulIPAddress. */ #if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) - { - /* If ARP stores the MAC address of IP addresses outside the - * network, than the MAC address of the gateway should not be - * overwritten. */ - BaseType_t xOtherIsLocal = ( FreeRTOS_FindEndPointOnNetMask( xARPCache[ x ].ulIPAddress, 3 ) != NULL ) ? 1 : 0; /* ARP remote address. */ + { + /* If ARP stores the MAC address of IP addresses outside the + * network, than the MAC address of the gateway should not be + * overwritten. */ + BaseType_t xOtherIsLocal = ( FreeRTOS_FindEndPointOnNetMask( xARPCache[ x ].ulIPAddress, 3 ) != NULL ) ? 1 : 0; /* ARP remote address. */ - if( xAddressIsLocal == xOtherIsLocal ) - { - pxLocation->xMacEntry = x; - } - } - #else /* if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) */ + if( xAddressIsLocal == xOtherIsLocal ) { pxLocation->xMacEntry = x; } + } + #else /* if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) */ + { + pxLocation->xMacEntry = x; + } #endif /* if ( ipconfigARP_STORES_REMOTE_ADDRESSES != 0 ) */ } @@ -1026,7 +1026,7 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, eARPLookupResult_t eReturn = eARPCacheMiss; uint32_t ulAddressToLookup = *( pulIPAddress ); NetworkEndPoint_t * pxEndPoint; - uint32_t ulOrginal = *pulIPAddress; + uint32_t ulOriginal = *pulIPAddress; /* It is assumed that devices with the same netmask are on the same * LAN and don't need a gateway. */ @@ -1084,10 +1084,10 @@ static BaseType_t prvFindCacheEntry( const MACAddress_t * pxMACAddress, { eReturn = prvCacheLookup( ulAddressToLookup, pxMACAddress, ppxEndPoint ); - if( ( eReturn != eARPCacheHit ) || ( ulOrginal != ulAddressToLookup ) ) + if( ( eReturn != eARPCacheHit ) || ( ulOriginal != ulAddressToLookup ) ) { FreeRTOS_debug_printf( ( "ARP %xip %s using %xip\n", - ( unsigned ) FreeRTOS_ntohl( ulOrginal ), + ( unsigned ) FreeRTOS_ntohl( ulOriginal ), ( eReturn == eARPCacheHit ) ? "hit" : "miss", ( unsigned ) FreeRTOS_ntohl( ulAddressToLookup ) ) ); } @@ -1291,19 +1291,19 @@ void FreeRTOS_OutputARPRequest( uint32_t ulIPAddress ) vARPGenerateRequestPacket( pxNetworkBuffer ); #if ( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) + { + if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; + BaseType_t xIndex; - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; - } - - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; + for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) + { + pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; } + + pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; } + } #endif /* if( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) */ if( xIsCallingFromIPTask() != pdFALSE ) diff --git a/source/FreeRTOS_DHCP.c b/source/FreeRTOS_DHCP.c index 5ebeebcd71..e3e37e2ee5 100644 --- a/source/FreeRTOS_DHCP.c +++ b/source/FreeRTOS_DHCP.c @@ -422,21 +422,21 @@ FreeRTOS_debug_printf( ( "vDHCPProcess: giving up %lu > %lu ticks\n", EP_DHCPData.xDHCPTxPeriod, ipconfigMAXIMUM_DISCOVER_TX_PERIOD ) ); #if ( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 ) - { - /* Only use a fake Ack if the default IP address == 0x00 - * and the link local addressing is used. Start searching - * a free LinkLayer IP-address. Next state will be - * 'eGetLinkLayerAddress'. */ - prvPrepareLinkLayerIPLookUp( pxEndPoint ); - - /* Setting an IP address manually so set to not using - * leased address mode. */ - EP_DHCPData.eDHCPState = eGetLinkLayerAddress; - } + { + /* Only use a fake Ack if the default IP address == 0x00 + * and the link local addressing is used. Start searching + * a free LinkLayer IP-address. Next state will be + * 'eGetLinkLayerAddress'. */ + prvPrepareLinkLayerIPLookUp( pxEndPoint ); + + /* Setting an IP address manually so set to not using + * leased address mode. */ + EP_DHCPData.eDHCPState = eGetLinkLayerAddress; + } #else - { - xGivingUp = pdTRUE; - } + { + xGivingUp = pdTRUE; + } #endif /* ipconfigDHCP_FALL_BACK_AUTO_IP */ } } @@ -509,7 +509,7 @@ * It is enough to set 'EP_IPv4_SETTINGS.ulIPAddress'. */ *ipLOCAL_IP_ADDRESS_POINTER = EP_IPv4_SETTINGS.ulIPAddress; - iptraceDHCP_SUCCEDEED( EP_DHCPData.ulOfferedIPAddress ); + iptraceDHCP_SUCCEEDED( EP_DHCPData.ulOfferedIPAddress ); /* DHCP failed, the default configured IP-address will be used * Now call vIPNetworkUpCalls() to send the network-up event and @@ -751,7 +751,7 @@ if( xARPHadIPClash == pdFALSE ) { /* ARP OK. proceed. */ - iptraceDHCP_SUCCEDEED( EP_DHCPData.ulOfferedIPAddress ); + iptraceDHCP_SUCCEEDED( EP_DHCPData.ulOfferedIPAddress ); /* Auto-IP succeeded, the default configured IP-address will * be used. Now call vIPNetworkUpCalls() to send the @@ -928,7 +928,7 @@ static void prvInitialiseDHCP( NetworkEndPoint_t * pxEndPoint ) { /* Initialise the parameters that will be set by the DHCP process. Per - * https://www.ietf.org/rfc/rfc2131.txt, Transaction ID should be a random + * https://www.ietf.org/rfc/rfc2131.txt Transaction ID should be a random * value chosen by the client. */ /* Check for random number generator API failure. */ @@ -1432,31 +1432,31 @@ ( void ) memcpy( &( pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET ] ), pucOptionsArray, *pxOptionsArraySize ); #if ( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) - { - /* With this option, the hostname can be registered as well which makes - * it easier to lookup a device in a router's list of DHCP clients. */ - - /* Point to where the OPTION_END was stored to add data. */ - pucPtr = &( pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET + ( *pxOptionsArraySize - 1U ) ] ); - pucPtr[ 0U ] = dhcpIPv4_DNS_HOSTNAME_OPTIONS_CODE; - pucPtr[ 1U ] = ( uint8_t ) uxNameLength; - - /* - * Use helper variables for memcpy() to remain - * compliant with MISRA Rule 21.15. These should be - * optimized away. - */ - if( pucHostName != NULL ) - { - pvCopySource = pucHostName; - pvCopyDest = &pucPtr[ 2U ]; + { + /* With this option, the hostname can be registered as well which makes + * it easier to lookup a device in a router's list of DHCP clients. */ - ( void ) memcpy( pvCopyDest, pvCopySource, uxNameLength ); - } + /* Point to where the OPTION_END was stored to add data. */ + pucPtr = &( pucUDPPayloadBuffer[ dhcpFIRST_OPTION_BYTE_OFFSET + ( *pxOptionsArraySize - 1U ) ] ); + pucPtr[ 0U ] = dhcpIPv4_DNS_HOSTNAME_OPTIONS_CODE; + pucPtr[ 1U ] = ( uint8_t ) uxNameLength; - pucPtr[ 2U + uxNameLength ] = ( uint8_t ) dhcpOPTION_END_BYTE; - *pxOptionsArraySize += ( size_t ) ( 2U + uxNameLength ); + /* + * Use helper variables for memcpy() to remain + * compliant with MISRA Rule 21.15. These should be + * optimized away. + */ + if( pucHostName != NULL ) + { + pvCopySource = pucHostName; + pvCopyDest = &pucPtr[ 2U ]; + + ( void ) memcpy( pvCopyDest, pvCopySource, uxNameLength ); } + + pucPtr[ 2U + uxNameLength ] = ( uint8_t ) dhcpOPTION_END_BYTE; + *pxOptionsArraySize += ( size_t ) ( 2U + uxNameLength ); + } #endif /* if ( ipconfigDHCP_REGISTER_HOSTNAME == 1 ) */ /* Map in the client identifier. */ diff --git a/source/FreeRTOS_DHCPv6.c b/source/FreeRTOS_DHCPv6.c index 8aade90030..a416fedb14 100644 --- a/source/FreeRTOS_DHCPv6.c +++ b/source/FreeRTOS_DHCPv6.c @@ -493,7 +493,7 @@ static void vDHCPv6ProcessEndPoint_HandleReply( NetworkEndPoint_t * pxEndPoint, EP_DHCPData.eDHCPState = eLeasedAddress; - iptraceDHCP_SUCCEDEED( EP_DHCPData.ulOfferedIPAddress ); + iptraceDHCP_SUCCEEDED( EP_DHCPData.ulOfferedIPAddress ); /* Close socket to ensure packets don't queue on it. */ prvCloseDHCPv6Socket( pxEndPoint ); @@ -773,15 +773,15 @@ static void vDHCPv6ProcessEndPoint( BaseType_t xReset, else { #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - static eDHCPState_t lastState = eNotUsingLeasedAddress; + { + static eDHCPState_t lastState = eNotUsingLeasedAddress; - if( lastState != EP_DHCPData.eDHCPState ) - { - lastState = EP_DHCPData.eDHCPState; - FreeRTOS_debug_printf( ( "vDHCPv6ProcessEndPoint: enter %s (%d)\n", prvStateName( EP_DHCPData.eDHCPState ), EP_DHCPData.eDHCPState ) ); - } + if( lastState != EP_DHCPData.eDHCPState ) + { + lastState = EP_DHCPData.eDHCPState; + FreeRTOS_debug_printf( ( "vDHCPv6ProcessEndPoint: enter %s (%d)\n", prvStateName( EP_DHCPData.eDHCPState ), EP_DHCPData.eDHCPState ) ); } + } #endif /* ( ipconfigHAS_DEBUG_PRINTF == 1 ) */ xGivingUp = xDHCPv6ProcessEndPoint_HandleState( pxEndPoint, pxDHCPMessage ); @@ -910,7 +910,7 @@ static void prvCreateDHCPv6Socket( NetworkEndPoint_t * pxEndPoint ) static void prvInitialiseDHCPv6( NetworkEndPoint_t * pxEndPoint ) { /* Initialise the parameters that will be set by the DHCP process. Per - * https://www.ietf.org/rfc/rfc2131.txt, Transaction ID should be a random + * https://www.ietf.org/rfc/rfc2131.txt Transaction ID should be a random * value chosen by the client. */ /* Check for random number generator API failure. */ diff --git a/source/FreeRTOS_DNS.c b/source/FreeRTOS_DNS.c index e487398a6b..9fb62a1969 100644 --- a/source/FreeRTOS_DNS.c +++ b/source/FreeRTOS_DNS.c @@ -96,8 +96,8 @@ BaseType_t xFamily ); #if ( ipconfigUSE_LLMNR == 1 ) - /** @brief The MAC address used for LLMNR. */ - const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; + /** @brief The MAC address used for LLMNR. */ + const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; #endif /* ipconfigUSE_LLMNR == 1 */ /*-----------------------------------------------------------*/ @@ -123,7 +123,7 @@ /** * @brief The IPv6 link-scope multicast MAC address */ - const MACAddress_t xLLMNR_MacAdressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; + const MACAddress_t xLLMNR_MacAddressIPv6 = { { 0x33, 0x33, 0x00, 0x01, 0x00, 0x03 } }; #endif /* ipconfigUSE_LLMNR && ipconfigUSE_IPv6 */ #if ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) @@ -150,13 +150,13 @@ * The MAC-addresses are provided here in case a network * interface needs it. */ - const MACAddress_t xMDNS_MACAdressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; + const MACAddress_t xMDNS_MACAddressIPv6 = { { 0x33, 0x33, 0x00, 0x00, 0x00, 0xFB } }; #endif /* ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) */ #if ( ipconfigUSE_MDNS == 1 ) - /** @brief The MAC address used for MDNS. */ - const MACAddress_t xMDNS_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; + /** @brief The MAC address used for MDNS. */ + const MACAddress_t xMDNS_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb } }; #endif /* ipconfigUSE_MDNS == 1 */ /** @brief This global variable is being used to indicate to the driver which IP type @@ -417,13 +417,13 @@ #endif { #if ( ipconfigDNS_USE_CALLBACKS == 1 ) - { - ulResult = prvPrepareLookup( pcName, ppxResult, xFamily, pCallback, pvSearchID, uxTimeout ); - } + { + ulResult = prvPrepareLookup( pcName, ppxResult, xFamily, pCallback, pvSearchID, uxTimeout ); + } #else - { - ulResult = prvPrepareLookup( pcName, ppxResult, xFamily ); - } + { + ulResult = prvPrepareLookup( pcName, ppxResult, xFamily ); + } #endif /* ( ipconfigDNS_USE_CALLBACKS == 1 ) */ if( ulResult != 0U ) @@ -611,26 +611,26 @@ #endif #if ( ipconfigUSE_DNS_CACHE != 0 ) + { + if( pcHostName != NULL ) { - if( pcHostName != NULL ) - { - size_t uxLength = strlen( pcHostName ) + 1U; + size_t uxLength = strlen( pcHostName ) + 1U; - if( uxLength <= ipconfigDNS_CACHE_NAME_LENGTH ) - { - /* The name is not too long. */ - xLengthOk = pdTRUE; - } - else - { - FreeRTOS_printf( ( "prvPrepareLookup: name is too long ( %u > %u )\n", - ( unsigned ) uxLength, - ( unsigned ) ipconfigDNS_CACHE_NAME_LENGTH ) ); - } + if( uxLength <= ipconfigDNS_CACHE_NAME_LENGTH ) + { + /* The name is not too long. */ + xLengthOk = pdTRUE; + } + else + { + FreeRTOS_printf( ( "prvPrepareLookup: name is too long ( %u > %u )\n", + ( unsigned ) uxLength, + ( unsigned ) ipconfigDNS_CACHE_NAME_LENGTH ) ); } } + } - if( ( pcHostName != NULL ) && ( xLengthOk != pdFALSE ) ) + if( ( pcHostName != NULL ) && ( xLengthOk != pdFALSE ) ) #else /* if ( ipconfigUSE_DNS_CACHE != 0 ) */ if( pcHostName != NULL ) #endif /* ( ipconfigUSE_DNS_CACHE != 0 ) */ @@ -638,9 +638,9 @@ /* If the supplied hostname is an IP address, put it in ppxAddressInfo * and return. */ #if ( ipconfigINCLUDE_FULL_INET_ADDR == 1 ) - { - ulIPAddress = prvPrepare_ReadIPAddress( pcHostName, xFamily, ppxAddressInfo ); - } + { + ulIPAddress = prvPrepare_ReadIPAddress( pcHostName, xFamily, ppxAddressInfo ); + } #endif /* ipconfigINCLUDE_FULL_INET_ADDR == 1 */ /* If a DNS cache is used then check the cache before issuing another DNS @@ -679,30 +679,30 @@ } #if ( ipconfigDNS_USE_CALLBACKS == 1 ) + { + if( pCallbackFunction != NULL ) { - if( pCallbackFunction != NULL ) + if( ulIPAddress == 0U ) { - if( ulIPAddress == 0U ) - { - /* The user has provided a callback function, so do not block on recvfrom() */ - if( xHasRandom != pdFALSE ) - { - uxReadTimeOut_ticks = 0U; - vDNSSetCallBack( pcHostName, - pvSearchID, - pCallbackFunction, - uxTimeout, - ( TickType_t ) uxIdentifier, - ( xFamily == FREERTOS_AF_INET6 ) ? pdTRUE : pdFALSE ); - } - } - else /* When ipconfigDNS_USE_CALLBACKS enabled, ppxAddressInfo is always non null. */ + /* The user has provided a callback function, so do not block on recvfrom() */ + if( xHasRandom != pdFALSE ) { - /* The IP address is known, do the call-back now. */ - pCallbackFunction( pcHostName, pvSearchID, *( ppxAddressInfo ) ); + uxReadTimeOut_ticks = 0U; + vDNSSetCallBack( pcHostName, + pvSearchID, + pCallbackFunction, + uxTimeout, + ( TickType_t ) uxIdentifier, + ( xFamily == FREERTOS_AF_INET6 ) ? pdTRUE : pdFALSE ); } } + else /* When ipconfigDNS_USE_CALLBACKS enabled, ppxAddressInfo is always non null. */ + { + /* The IP address is known, do the call-back now. */ + pCallbackFunction( pcHostName, pvSearchID, *( ppxAddressInfo ) ); + } } + } #endif /* if ( ipconfigDNS_USE_CALLBACKS == 1 ) */ if( ( ulIPAddress == 0U ) && ( xHasRandom != pdFALSE ) ) @@ -883,79 +883,79 @@ /* Looking for e.g. "mydevice" or "mydevice.local", * while using either mDNS or LLMNR. */ #if ( ipconfigUSE_MDNS == 1 ) + { + if( bHasLocal ) { - if( bHasLocal ) - { - /* Looking up a name like "mydevice.local". - * Use mDNS addresses. */ + /* Looking up a name like "mydevice.local". + * Use mDNS addresses. */ - pxAddress->sin_port = ipMDNS_PORT; - pxAddress->sin_port = FreeRTOS_ntohs( pxAddress->sin_port ); - xNeed_Endpoint = pdTRUE; - - switch( xDNS_IP_Preference ) - { - #if ( ipconfigUSE_IPv4 != 0 ) - case xPreferenceIPv4: - pxAddress->sin_address.ulIP_IPv4 = ipMDNS_IP_ADDRESS; /* Is in network byte order. */ - /* sin_family is default set to FREERTOS_AF_INET */ - break; - #endif /* ( ipconfigUSE_IPv4 != 0 ) */ + pxAddress->sin_port = ipMDNS_PORT; + pxAddress->sin_port = FreeRTOS_ntohs( pxAddress->sin_port ); + xNeed_Endpoint = pdTRUE; - #if ( ipconfigUSE_IPv6 != 0 ) - case xPreferenceIPv6: - memcpy( pxAddress->sin_address.xIP_IPv6.ucBytes, - ipMDNS_IP_ADDR_IPv6.ucBytes, - ipSIZE_OF_IPv6_ADDRESS ); - pxAddress->sin_family = FREERTOS_AF_INET6; - break; - #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + switch( xDNS_IP_Preference ) + { + #if ( ipconfigUSE_IPv4 != 0 ) + case xPreferenceIPv4: + pxAddress->sin_address.ulIP_IPv4 = ipMDNS_IP_ADDRESS; /* Is in network byte order. */ + /* sin_family is default set to FREERTOS_AF_INET */ + break; + #endif /* ( ipconfigUSE_IPv4 != 0 ) */ - default: - /* MISRA 16.4 Compliance */ - xNeed_Endpoint = pdFALSE; - FreeRTOS_debug_printf( ( "prvFillSockAddress: Undefined xDNS_IP_Preference \n" ) ); + #if ( ipconfigUSE_IPv6 != 0 ) + case xPreferenceIPv6: + memcpy( pxAddress->sin_address.xIP_IPv6.ucBytes, + ipMDNS_IP_ADDR_IPv6.ucBytes, + ipSIZE_OF_IPv6_ADDRESS ); + pxAddress->sin_family = FREERTOS_AF_INET6; break; - } + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + + default: + /* MISRA 16.4 Compliance */ + xNeed_Endpoint = pdFALSE; + FreeRTOS_debug_printf( ( "prvFillSockAddress: Undefined xDNS_IP_Preference \n" ) ); + break; } } + } #endif /* if ( ipconfigUSE_MDNS == 1 ) */ #if ( ipconfigUSE_LLMNR == 1 ) + { + /* The hostname doesn't have a dot. */ + if( bHasDot == pdFALSE ) { - /* The hostname doesn't have a dot. */ - if( bHasDot == pdFALSE ) - { - /* Use LLMNR addressing. */ - pxAddress->sin_port = ipLLMNR_PORT; - pxAddress->sin_port = FreeRTOS_ntohs( pxAddress->sin_port ); - xNeed_Endpoint = pdTRUE; + /* Use LLMNR addressing. */ + pxAddress->sin_port = ipLLMNR_PORT; + pxAddress->sin_port = FreeRTOS_ntohs( pxAddress->sin_port ); + xNeed_Endpoint = pdTRUE; - switch( xDNS_IP_Preference ) - { - #if ( ipconfigUSE_IPv4 != 0 ) - case xPreferenceIPv4: - pxAddress->sin_address.ulIP_IPv4 = ipLLMNR_IP_ADDR; /* Is in network byte order. */ - pxAddress->sin_family = FREERTOS_AF_INET; - break; - #endif /* ( ipconfigUSE_IPv4 != 0 ) */ - - #if ( ipconfigUSE_IPv6 != 0 ) - case xPreferenceIPv6: - memcpy( pxAddress->sin_address.xIP_IPv6.ucBytes, - ipLLMNR_IP_ADDR_IPv6.ucBytes, - ipSIZE_OF_IPv6_ADDRESS ); - pxAddress->sin_family = FREERTOS_AF_INET6; - break; - #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + switch( xDNS_IP_Preference ) + { + #if ( ipconfigUSE_IPv4 != 0 ) + case xPreferenceIPv4: + pxAddress->sin_address.ulIP_IPv4 = ipLLMNR_IP_ADDR; /* Is in network byte order. */ + pxAddress->sin_family = FREERTOS_AF_INET; + break; + #endif /* ( ipconfigUSE_IPv4 != 0 ) */ - default: - /* MISRA 16.4 Compliance */ - xNeed_Endpoint = pdFALSE; - FreeRTOS_debug_printf( ( "prvFillSockAddress: Undefined xDNS_IP_Preference (LLMNR) \n" ) ); + #if ( ipconfigUSE_IPv6 != 0 ) + case xPreferenceIPv6: + memcpy( pxAddress->sin_address.xIP_IPv6.ucBytes, + ipLLMNR_IP_ADDR_IPv6.ucBytes, + ipSIZE_OF_IPv6_ADDRESS ); + pxAddress->sin_family = FREERTOS_AF_INET6; break; - } + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + + default: + /* MISRA 16.4 Compliance */ + xNeed_Endpoint = pdFALSE; + FreeRTOS_debug_printf( ( "prvFillSockAddress: Undefined xDNS_IP_Preference (LLMNR) \n" ) ); + break; } } + } #endif /* if ( ipconfigUSE_LLMNR == 1 ) */ #if ( ipconfigUSE_MDNS == 1 ) || ( ipconfigUSE_LLMNR == 1 ) @@ -1173,15 +1173,15 @@ if( xDNSBuf.pucPayloadBuffer != NULL ) { #if ( ipconfigUSE_LLMNR == 1 ) + { + if( FreeRTOS_ntohs( pxAddress->sin_port ) == ipLLMNR_PORT ) { - if( FreeRTOS_ntohs( pxAddress->sin_port ) == ipLLMNR_PORT ) - { - /* MISRA Ref 11.3.1 [Misaligned access] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - ( ( ( DNSMessage_t * ) xDNSBuf.pucPayloadBuffer ) )->usFlags = 0; - } + /* MISRA Ref 11.3.1 [Misaligned access] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ + /* coverity[misra_c_2012_rule_11_3_violation] */ + ( ( ( DNSMessage_t * ) xDNSBuf.pucPayloadBuffer ) )->usFlags = 0; } + } #endif /* A two-step conversion to conform to MISRA. */ diff --git a/source/FreeRTOS_DNS_Parser.c b/source/FreeRTOS_DNS_Parser.c index 696587046c..dbe426f50d 100644 --- a/source/FreeRTOS_DNS_Parser.c +++ b/source/FreeRTOS_DNS_Parser.c @@ -72,11 +72,11 @@ #endif /* ( ipconfigUSE_IPv6 != 0 ) */ #if ( ipconfigUSE_IPv4 != 0 ) - { - IPPacket_t * xIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + { + IPPacket_t * xIPPacket = ( ( IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); - pxEndPoint = FreeRTOS_FindEndPointOnNetMask( xIPPacket->xIPHeader.ulSourceIPAddress, 6 ); - } + pxEndPoint = FreeRTOS_FindEndPointOnNetMask( xIPPacket->xIPHeader.ulSourceIPAddress, 6 ); + } #endif /* ( ipconfigUSE_IPv4 != 0 ) */ if( pxEndPoint != NULL ) @@ -357,12 +357,12 @@ for( x = 0U; x < xSet.usQuestions; x++ ) { #if ( ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) ) + { + if( x == 0U ) { - if( x == 0U ) - { - xSet.pcRequestedName = ( char * ) xSet.pucByte; - } + xSet.pcRequestedName = ( char * ) xSet.pucByte; } + } #endif #if ( ipconfigUSE_DNS_CACHE == 1 ) || ( ipconfigDNS_USE_CALLBACKS == 1 ) @@ -394,11 +394,11 @@ if( xSet.uxSourceBytesRemaining >= sizeof( uint32_t ) ) { #if ( ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) ) - { - /* usChar2u16 returns value in host endianness. */ - xSet.usType = usChar2u16( xSet.pucByte ); - xSet.usClass = usChar2u16( &( xSet.pucByte[ 2 ] ) ); - } + { + /* usChar2u16 returns value in host endianness. */ + xSet.usType = usChar2u16( xSet.pucByte ); + xSet.usClass = usChar2u16( &( xSet.pucByte[ 2 ] ) ); + } #endif /* ipconfigUSE_LLMNR */ /* Skip the type and class fields. */ @@ -467,12 +467,12 @@ ( void ) memcpy( &( xEndPoint ), pxEndPoint, sizeof( xEndPoint ) ); #if ( ipconfigUSE_IPv6 != 0 ) - { - /*logging*/ - FreeRTOS_printf( ( "prvParseDNS_HandleLLMNRRequest[%s]: type %04X\n", xSet.pcName, xSet.usType ) ); + { + /*logging*/ + FreeRTOS_printf( ( "prvParseDNS_HandleLLMNRRequest[%s]: type %04X\n", xSet.pcName, xSet.usType ) ); - xEndPoint.usDNSType = ( uint8_t ) xSet.usType; - } + xEndPoint.usDNSType = ( uint8_t ) xSet.usType; + } #endif /* ( ipconfigUSE_IPv6 != 0 ) */ /* If this is not a reply to our DNS request, it might be an mDNS or an LLMNR @@ -506,13 +506,13 @@ else #endif /* ( ipconfigUSE_IPv6 != 0 ) */ #if ( ipconfigUSE_IPv4 != 0 ) - { - uxExtraLength = sizeof( LLMNRAnswer_t ); - } + { + uxExtraLength = sizeof( LLMNRAnswer_t ); + } #else /* ( ipconfigUSE_IPv4 != 0 ) */ - { - /* do nothing, coverity happy */ - } + { + /* do nothing, coverity happy */ + } #endif /* ( ipconfigUSE_IPv4 != 0 ) */ /* Set the size of the outgoing packet. */ @@ -550,10 +550,10 @@ { pxAnswer = ( ( LLMNRAnswer_t * ) xSet.pucByte ); /* We leave 'usIdentifier' and 'usQuestions' untouched */ - vSetField16( xSet.pxDNSMessageHeader, DNSMessage_t, usFlags, dnsLLMNR_FLAGS_IS_REPONSE ); /* Set the response flag */ - vSetField16( xSet.pxDNSMessageHeader, DNSMessage_t, usAnswers, 1 ); /* Provide a single answer */ - vSetField16( xSet.pxDNSMessageHeader, DNSMessage_t, usAuthorityRRs, 0 ); /* No authority */ - vSetField16( xSet.pxDNSMessageHeader, DNSMessage_t, usAdditionalRRs, 0 ); /* No additional info */ + vSetField16( xSet.pxDNSMessageHeader, DNSMessage_t, usFlags, dnsLLMNR_FLAGS_IS_RESPONSE ); /* Set the response flag */ + vSetField16( xSet.pxDNSMessageHeader, DNSMessage_t, usAnswers, 1 ); /* Provide a single answer */ + vSetField16( xSet.pxDNSMessageHeader, DNSMessage_t, usAuthorityRRs, 0 ); /* No authority */ + vSetField16( xSet.pxDNSMessageHeader, DNSMessage_t, usAdditionalRRs, 0 ); /* No additional info */ pxAnswer->ucNameCode = dnsNAME_IS_OFFSET; pxAnswer->ucNameOffset = ( uint8_t ) ( xSet.pcRequestedName - ( char * ) pucNewBuffer ); @@ -783,60 +783,60 @@ } #if ( ipconfigDNS_USE_CALLBACKS == 1 ) - { - BaseType_t xCallbackResult; + { + BaseType_t xCallbackResult; - xCallbackResult = xDNSDoCallback( pxSet, ( ppxAddressInfo != NULL ) ? *( ppxAddressInfo ) : NULL ); + xCallbackResult = xDNSDoCallback( pxSet, ( ppxAddressInfo != NULL ) ? *( ppxAddressInfo ) : NULL ); - /* See if any asynchronous call was made to FreeRTOS_gethostbyname_a() */ - if( xCallbackResult != pdFALSE ) - { - /* This device has requested this DNS look-up. - * The result may be stored in the DNS cache. */ - pxSet->xDoStore = pdTRUE; - } + /* See if any asynchronous call was made to FreeRTOS_gethostbyname_a() */ + if( xCallbackResult != pdFALSE ) + { + /* This device has requested this DNS look-up. + * The result may be stored in the DNS cache. */ + pxSet->xDoStore = pdTRUE; } + } #endif /* ipconfigDNS_USE_CALLBACKS == 1 */ #if ( ipconfigUSE_DNS_CACHE == 1 ) - { - char cBuffer[ 40 ]; + { + char cBuffer[ 40 ]; - /* The reply will only be stored in the DNS cache when the - * request was issued by this device. */ - if( pxSet->xDoStore != pdFALSE ) - { - ( void ) FreeRTOS_dns_update( - pxSet->pcName, - &xIP_Address, - pxDNSAnswerRecord->ulTTL, - pdFALSE, - NULL ); - pxSet->usNumARecordsStored++; /* Track # of A records stored */ - } + /* The reply will only be stored in the DNS cache when the + * request was issued by this device. */ + if( pxSet->xDoStore != pdFALSE ) + { + ( void ) FreeRTOS_dns_update( + pxSet->pcName, + &xIP_Address, + pxDNSAnswerRecord->ulTTL, + pdFALSE, + NULL ); + pxSet->usNumARecordsStored++; /* Track # of A records stored */ + } - if( pxSet->usType == ( uint16_t ) dnsTYPE_AAAA_HOST ) - { - ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) xIP_Address.xIPAddress.xIP_IPv6.ucBytes, cBuffer, sizeof( cBuffer ) ); - FreeRTOS_printf( ( "DNS[0x%04X]: The answer to '%s' (%s) will%s be stored\n", - ( unsigned ) pxSet->pxDNSMessageHeader->usIdentifier, - pxSet->pcName, - cBuffer, - ( pxSet->xDoStore != 0 ) ? "" : " NOT" ) ); - } - else - { - ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET, - ( const void * ) &( pxSet->ulIPAddress ), - cBuffer, - ( socklen_t ) sizeof( cBuffer ) ); - /* Show what has happened. */ - FreeRTOS_printf( ( "DNS[0x%04X]: The answer to '%s' (%s) will%s be stored\n", - pxSet->pxDNSMessageHeader->usIdentifier, - pxSet->pcName, - cBuffer, - ( pxSet->xDoStore != 0 ) ? "" : " NOT" ) ); - } + if( pxSet->usType == ( uint16_t ) dnsTYPE_AAAA_HOST ) + { + ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) xIP_Address.xIPAddress.xIP_IPv6.ucBytes, cBuffer, sizeof( cBuffer ) ); + FreeRTOS_printf( ( "DNS[0x%04X]: The answer to '%s' (%s) will%s be stored\n", + ( unsigned ) pxSet->pxDNSMessageHeader->usIdentifier, + pxSet->pcName, + cBuffer, + ( pxSet->xDoStore != 0 ) ? "" : " NOT" ) ); } + else + { + ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET, + ( const void * ) &( pxSet->ulIPAddress ), + cBuffer, + ( socklen_t ) sizeof( cBuffer ) ); + /* Show what has happened. */ + FreeRTOS_printf( ( "DNS[0x%04X]: The answer to '%s' (%s) will%s be stored\n", + pxSet->pxDNSMessageHeader->usIdentifier, + pxSet->pcName, + cBuffer, + ( pxSet->xDoStore != 0 ) ? "" : " NOT" ) ); + } + } #endif /* ipconfigUSE_DNS_CACHE */ if( ( ulReturnIPAddress == 0U ) && ( pxSet->ulIPAddress != 0U ) ) @@ -980,21 +980,21 @@ } #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) + { + #if ( ipconfigUSE_IPv6 != 0 ) + /* IPv6 IP-headers have no checksum field. */ + if( ( pxIPHeader->ucVersionHeaderLength & 0xf0U ) != 0x60U ) + #endif { - #if ( ipconfigUSE_IPv6 != 0 ) - /* IPv6 IP-headers have no checksum field. */ - if( ( pxIPHeader->ucVersionHeaderLength & 0xf0U ) != 0x60U ) - #endif - { - /* Calculate the IP header checksum. */ - pxIPHeader->usHeaderChecksum = 0U; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), uxIPHeaderLength ); - pxIPHeader->usHeaderChecksum = ( uint16_t ) ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - } - - /* calculate the UDP checksum for outgoing package */ - ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxUDPPacket, uxDataLength, pdTRUE ); + /* Calculate the IP header checksum. */ + pxIPHeader->usHeaderChecksum = 0U; + pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), uxIPHeaderLength ); + pxIPHeader->usHeaderChecksum = ( uint16_t ) ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); } + + /* calculate the UDP checksum for outgoing package */ + ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxUDPPacket, uxDataLength, pdTRUE ); + } #endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) */ /* Important: tell NIC driver how many bytes must be sent */ @@ -1103,28 +1103,28 @@ } #if ( ipconfigUSE_DNS_CACHE == 1 ) + { + if( ( usFlags & dnsNBNS_FLAGS_RESPONSE ) != 0U ) { - if( ( usFlags & dnsNBNS_FLAGS_RESPONSE ) != 0U ) - { - /* If this is a response from another device, - * add the name to the DNS cache */ - IPv46_Address_t xIPAddress; + /* If this is a response from another device, + * add the name to the DNS cache */ + IPv46_Address_t xIPAddress; - xIPAddress.xIPAddress.ulIP_IPv4 = ulIPAddress; - #if ( ipconfigUSE_IPv6 != 0 ) - { - xIPAddress.xIs_IPv6 = pdFALSE; - } - #endif - - ( void ) FreeRTOS_dns_update( ( char * ) ucNBNSName, &( xIPAddress ), 0, pdFALSE, NULL ); + xIPAddress.xIPAddress.ulIP_IPv4 = ulIPAddress; + #if ( ipconfigUSE_IPv6 != 0 ) + { + xIPAddress.xIs_IPv6 = pdFALSE; } + #endif + + ( void ) FreeRTOS_dns_update( ( char * ) ucNBNSName, &( xIPAddress ), 0, pdFALSE, NULL ); } + } #else /* if ( ipconfigUSE_DNS_CACHE == 1 ) */ - { - /* Avoid compiler warnings. */ - ( void ) ulIPAddress; - } + { + /* Avoid compiler warnings. */ + ( void ) ulIPAddress; + } #endif /* ipconfigUSE_DNS_CACHE */ if( ( usType != dnsNBNS_TYPE_NET_BIOS ) || @@ -1170,7 +1170,7 @@ if( xBufferAllocFixedSize == pdFALSE ) { - /* We're linked with BufferAlolocation_2.c + /* We're linked with BufferAllocation_2.c * pxResizeNetworkBufferWithDescriptor() will malloc a new bigger buffer, * and memcpy the data. The old buffer will be free'd. */ diff --git a/source/FreeRTOS_ICMP.c b/source/FreeRTOS_ICMP.c index 78cc9c6c5d..75e51bb79b 100644 --- a/source/FreeRTOS_ICMP.c +++ b/source/FreeRTOS_ICMP.c @@ -102,17 +102,17 @@ { case ipICMP_ECHO_REQUEST: #if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) - { - eReturn = prvProcessICMPEchoRequest( pxICMPPacket, pxNetworkBuffer ); - } + { + eReturn = prvProcessICMPEchoRequest( pxICMPPacket, pxNetworkBuffer ); + } #endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) */ break; case ipICMP_ECHO_REPLY: #if ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - { - prvProcessICMPEchoReply( pxICMPPacket ); - } + { + prvProcessICMPEchoReply( pxICMPPacket ); + } #endif /* ipconfigSUPPORT_OUTGOING_PINGS */ break; @@ -171,24 +171,24 @@ #endif #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the IP header checksum, in case the driver won't do that. */ - pxIPHeader->usHeaderChecksum = 0x00U; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), uxIPHeaderSizePacket( pxNetworkBuffer ) ); - pxIPHeader->usHeaderChecksum = ( uint16_t ) ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); + { + /* calculate the IP header checksum, in case the driver won't do that. */ + pxIPHeader->usHeaderChecksum = 0x00U; + pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), uxIPHeaderSizePacket( pxNetworkBuffer ) ); + pxIPHeader->usHeaderChecksum = ( uint16_t ) ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - /* calculate the ICMP checksum for an outgoing packet. */ - ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxICMPPacket, pxNetworkBuffer->xDataLength, pdTRUE ); - } + /* calculate the ICMP checksum for an outgoing packet. */ + ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxICMPPacket, pxNetworkBuffer->xDataLength, pdTRUE ); + } #else - { - /* Just to prevent compiler warnings about unused parameters. */ - ( void ) pxNetworkBuffer; + { + /* Just to prevent compiler warnings about unused parameters. */ + ( void ) pxNetworkBuffer; - /* Many EMAC peripherals will only calculate the ICMP checksum - * correctly if the field is nulled beforehand. */ - pxICMPHeader->usChecksum = 0U; - } + /* Many EMAC peripherals will only calculate the ICMP checksum + * correctly if the field is nulled beforehand. */ + pxICMPHeader->usChecksum = 0U; + } #endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) */ return eReturnEthernetFrame; diff --git a/source/FreeRTOS_IP.c b/source/FreeRTOS_IP.c index c6fd21cc1b..7366e8f895 100644 --- a/source/FreeRTOS_IP.c +++ b/source/FreeRTOS_IP.c @@ -277,19 +277,19 @@ static void prvProcessIPEventsAndTimers( void ) } #if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) + { + if( xReceivedEvent.eEventType != eNoEvent ) { - if( xReceivedEvent.eEventType != eNoEvent ) - { - UBaseType_t uxCount; + UBaseType_t uxCount; - uxCount = uxQueueSpacesAvailable( xNetworkEventQueue ); + uxCount = uxQueueSpacesAvailable( xNetworkEventQueue ); - if( uxQueueMinimumSpace > uxCount ) - { - uxQueueMinimumSpace = uxCount; - } + if( uxQueueMinimumSpace > uxCount ) + { + uxQueueMinimumSpace = uxCount; } } + } #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ iptraceNETWORK_EVENT_RECEIVED( xReceivedEvent.eEventType ); @@ -402,17 +402,17 @@ static void prvProcessIPEventsAndTimers( void ) * vSocketSelect() will check which sockets actually have an event * and update the socket field xSocketBits. */ #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - #if ( ipconfigSELECT_USES_NOTIFY != 0 ) - { - SocketSelectMessage_t * pxMessage = ( ( SocketSelectMessage_t * ) xReceivedEvent.pvData ); - vSocketSelect( pxMessage->pxSocketSet ); - ( void ) xTaskNotifyGive( pxMessage->xTaskhandle ); - } - #else - { - vSocketSelect( ( ( SocketSelect_t * ) xReceivedEvent.pvData ) ); - } - #endif /* ( ipconfigSELECT_USES_NOTIFY != 0 ) */ + #if ( ipconfigSELECT_USES_NOTIFY != 0 ) + { + SocketSelectMessage_t * pxMessage = ( ( SocketSelectMessage_t * ) xReceivedEvent.pvData ); + vSocketSelect( pxMessage->pxSocketSet ); + ( void ) xTaskNotifyGive( pxMessage->xTaskhandle ); + } + #else + { + vSocketSelect( ( ( SocketSelect_t * ) xReceivedEvent.pvData ) ); + } + #endif /* ( ipconfigSELECT_USES_NOTIFY != 0 ) */ #endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ break; @@ -461,13 +461,13 @@ static void prvProcessIPEventsAndTimers( void ) case eSocketSetDeleteEvent: #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) - { - SocketSelect_t * pxSocketSet = ( SocketSelect_t * ) ( xReceivedEvent.pvData ); + { + SocketSelect_t * pxSocketSet = ( SocketSelect_t * ) ( xReceivedEvent.pvData ); - iptraceMEM_STATS_DELETE( pxSocketSet ); - vEventGroupDelete( pxSocketSet->xSelectGroup ); - vPortFree( ( void * ) pxSocketSet ); - } + iptraceMEM_STATS_DELETE( pxSocketSet ); + vEventGroupDelete( pxSocketSet->xSelectGroup ); + vPortFree( ( void * ) pxSocketSet ); + } #endif /* ipconfigSUPPORT_SELECT_FUNCTION == 1 */ break; @@ -510,28 +510,28 @@ static void prvIPTask_Initialise( void ) } #if ( ipconfigUSE_TCP == 1 ) - { - /* Initialise the TCP timer. */ - vTCPTimerReload( pdMS_TO_TICKS( ipTCP_TIMER_PERIOD_MS ) ); - } + { + /* Initialise the TCP timer. */ + vTCPTimerReload( pdMS_TO_TICKS( ipTCP_TIMER_PERIOD_MS ) ); + } #endif /* Mark the timer as inactive since we are not waiting on any ARP resolution as of now. */ vIPSetARPResolutionTimerEnableState( pdFALSE ); #if ( ( ipconfigDNS_USE_CALLBACKS != 0 ) && ( ipconfigUSE_DNS != 0 ) ) - { - /* The following function is declared in FreeRTOS_DNS.c and 'private' to - * this library */ - vDNSInitialise(); - } + { + /* The following function is declared in FreeRTOS_DNS.c and 'private' to + * this library */ + vDNSInitialise(); + } #endif /* ( ipconfigDNS_USE_CALLBACKS != 0 ) && ( ipconfigUSE_DNS != 0 ) */ #if ( ( ipconfigUSE_DNS_CACHE != 0 ) && ( ipconfigUSE_DNS != 0 ) ) - { - /* Clear the DNS cache once only. */ - FreeRTOS_dnsclear(); - } + { + /* Clear the DNS cache once only. */ + FreeRTOS_dnsclear(); + } #endif /* ( ( ipconfigUSE_DNS_CACHE != 0 ) && ( ipconfigUSE_DNS != 0 ) ) */ /* Initialisation is complete and events can now be processed. */ @@ -587,31 +587,31 @@ static void prvCallDHCP_RA_Handler( NetworkEndPoint_t * pxEndPoint ) #endif /* The DHCP state machine needs processing. */ #if ( ipconfigUSE_DHCP == 1 ) + { + if( ( pxEndPoint->bits.bWantDHCP != pdFALSE_UNSIGNED ) && ( xIsIPv6 == pdFALSE ) ) { - if( ( pxEndPoint->bits.bWantDHCP != pdFALSE_UNSIGNED ) && ( xIsIPv6 == pdFALSE ) ) - { - /* Process DHCP messages for a given end-point. */ - vDHCPProcess( pdFALSE, pxEndPoint ); - } + /* Process DHCP messages for a given end-point. */ + vDHCPProcess( pdFALSE, pxEndPoint ); } + } #endif /* ipconfigUSE_DHCP */ #if ( ( ipconfigUSE_DHCPv6 == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) + { + if( ( xIsIPv6 == pdTRUE ) && ( pxEndPoint->bits.bWantDHCP != pdFALSE_UNSIGNED ) ) { - if( ( xIsIPv6 == pdTRUE ) && ( pxEndPoint->bits.bWantDHCP != pdFALSE_UNSIGNED ) ) - { - /* Process DHCPv6 messages for a given end-point. */ - vDHCPv6Process( pdFALSE, pxEndPoint ); - } + /* Process DHCPv6 messages for a given end-point. */ + vDHCPv6Process( pdFALSE, pxEndPoint ); } + } #endif /* ipconfigUSE_DHCPv6 */ #if ( ( ipconfigUSE_RA == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) + { + if( ( xIsIPv6 == pdTRUE ) && ( pxEndPoint->bits.bWantRA != pdFALSE_UNSIGNED ) ) { - if( ( xIsIPv6 == pdTRUE ) && ( pxEndPoint->bits.bWantRA != pdFALSE_UNSIGNED ) ) - { - /* Process RA messages for a given end-point. */ - vRAProcess( pdFALSE, pxEndPoint ); - } + /* Process RA messages for a given end-point. */ + vRAProcess( pdFALSE, pxEndPoint ); } + } #endif /* ( ( ipconfigUSE_RA == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) */ /* Mention pxEndPoint and xIsIPv6 in case they have not been used. */ @@ -642,24 +642,24 @@ void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint ) pxEndPoint->bits.bEndPointUp = pdTRUE_UNSIGNED; #if ( ipconfigUSE_NETWORK_EVENT_HOOK == 1 ) - #if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) - { - vApplicationIPNetworkEventHook( eNetworkUp ); - } - #else - { - vApplicationIPNetworkEventHook_Multi( eNetworkUp, pxEndPoint ); - } - #endif + #if ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) + { + vApplicationIPNetworkEventHook( eNetworkUp ); + } + #else + { + vApplicationIPNetworkEventHook_Multi( eNetworkUp, pxEndPoint ); + } + #endif #endif /* ipconfigUSE_NETWORK_EVENT_HOOK */ #if ( ipconfigDNS_USE_CALLBACKS != 0 ) - { - /* The following function is declared in FreeRTOS_DNS.c and 'private' to - * this library */ - extern void vDNSInitialise( void ); - vDNSInitialise(); - } + { + /* The following function is declared in FreeRTOS_DNS.c and 'private' to + * this library */ + extern void vDNSInitialise( void ); + vDNSInitialise(); + } #endif /* ipconfigDNS_USE_CALLBACKS != 0 */ /* Set remaining time to 0 so it will become active immediately. */ @@ -676,36 +676,36 @@ void vIPNetworkUpCalls( struct xNetworkEndPoint * pxEndPoint ) static void prvHandleEthernetPacket( NetworkBufferDescriptor_t * pxBuffer ) { #if ( ipconfigUSE_LINKED_RX_MESSAGES == 0 ) - { - /* When ipconfigUSE_LINKED_RX_MESSAGES is set to 0 then only one - * buffer will be sent at a time. This is the default way for +TCP to pass - * messages from the MAC to the TCP/IP stack. */ - prvProcessEthernetPacket( pxBuffer ); - } + { + /* When ipconfigUSE_LINKED_RX_MESSAGES is set to 0 then only one + * buffer will be sent at a time. This is the default way for +TCP to pass + * messages from the MAC to the TCP/IP stack. */ + prvProcessEthernetPacket( pxBuffer ); + } #else /* ipconfigUSE_LINKED_RX_MESSAGES */ - { - NetworkBufferDescriptor_t * pxNextBuffer; + { + NetworkBufferDescriptor_t * pxNextBuffer; - /* An optimisation that is useful when there is high network traffic. - * Instead of passing received packets into the IP task one at a time the - * network interface can chain received packets together and pass them into - * the IP task in one go. The packets are chained using the pxNextBuffer - * member. The loop below walks through the chain processing each packet - * in the chain in turn. */ + /* An optimisation that is useful when there is high network traffic. + * Instead of passing received packets into the IP task one at a time the + * network interface can chain received packets together and pass them into + * the IP task in one go. The packets are chained using the pxNextBuffer + * member. The loop below walks through the chain processing each packet + * in the chain in turn. */ - /* While there is another packet in the chain. */ - while( pxBuffer != NULL ) - { - /* Store a pointer to the buffer after pxBuffer for use later on. */ - pxNextBuffer = pxBuffer->pxNextBuffer; + /* While there is another packet in the chain. */ + while( pxBuffer != NULL ) + { + /* Store a pointer to the buffer after pxBuffer for use later on. */ + pxNextBuffer = pxBuffer->pxNextBuffer; - /* Make it NULL to avoid using it later on. */ - pxBuffer->pxNextBuffer = NULL; + /* Make it NULL to avoid using it later on. */ + pxBuffer->pxNextBuffer = NULL; - prvProcessEthernetPacket( pxBuffer ); - pxBuffer = pxNextBuffer; - } + prvProcessEthernetPacket( pxBuffer ); + pxBuffer = pxNextBuffer; } + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ } /*-----------------------------------------------------------*/ @@ -932,9 +932,9 @@ void * FreeRTOS_GetUDPPayloadBuffer_Multi( size_t uxRequestedSizeBytes, pxFillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) ); FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress ); #if ( ipconfigUSE_DHCP != 0 ) - { - xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE; - } + { + xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE; + } #endif /* ipconfigUSE_DHCP */ return FreeRTOS_IPInit_Multi(); } @@ -959,30 +959,30 @@ BaseType_t FreeRTOS_IPInit_Multi( void ) /* Attempt to create the queue used to communicate with the IP task. */ #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) - { - static StaticQueue_t xNetworkEventStaticQueue; - static uint8_t ucNetworkEventQueueStorageArea[ ipconfigEVENT_QUEUE_LENGTH * sizeof( IPStackEvent_t ) ]; - xNetworkEventQueue = xQueueCreateStatic( ipconfigEVENT_QUEUE_LENGTH, - sizeof( IPStackEvent_t ), - ucNetworkEventQueueStorageArea, - &xNetworkEventStaticQueue ); - } + { + static StaticQueue_t xNetworkEventStaticQueue; + static uint8_t ucNetworkEventQueueStorageArea[ ipconfigEVENT_QUEUE_LENGTH * sizeof( IPStackEvent_t ) ]; + xNetworkEventQueue = xQueueCreateStatic( ipconfigEVENT_QUEUE_LENGTH, + sizeof( IPStackEvent_t ), + ucNetworkEventQueueStorageArea, + &xNetworkEventStaticQueue ); + } #else - { - xNetworkEventQueue = xQueueCreate( ipconfigEVENT_QUEUE_LENGTH, sizeof( IPStackEvent_t ) ); - configASSERT( xNetworkEventQueue != NULL ); - } + { + xNetworkEventQueue = xQueueCreate( ipconfigEVENT_QUEUE_LENGTH, sizeof( IPStackEvent_t ) ); + configASSERT( xNetworkEventQueue != NULL ); + } #endif /* configSUPPORT_STATIC_ALLOCATION */ if( xNetworkEventQueue != NULL ) { #if ( configQUEUE_REGISTRY_SIZE > 0 ) - { - /* A queue registry is normally used to assist a kernel aware - * debugger. If one is in use then it will be helpful for the debugger - * to show information about the network event queue. */ - vQueueAddToRegistry( xNetworkEventQueue, "NetEvnt" ); - } + { + /* A queue registry is normally used to assist a kernel aware + * debugger. If one is in use then it will be helpful for the debugger + * to show information about the network event queue. */ + vQueueAddToRegistry( xNetworkEventQueue, "NetEvnt" ); + } #endif /* configQUEUE_REGISTRY_SIZE */ if( xNetworkBuffersInitialise() == pdPASS ) @@ -992,31 +992,31 @@ BaseType_t FreeRTOS_IPInit_Multi( void ) /* Create the task that processes Ethernet and stack events. */ #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + static StaticTask_t xIPTaskBuffer; + static StackType_t xIPTaskStack[ ipconfigIP_TASK_STACK_SIZE_WORDS ]; + xIPTaskHandle = xTaskCreateStatic( prvIPTask, + "IP-Task", + ipconfigIP_TASK_STACK_SIZE_WORDS, + NULL, + ipconfigIP_TASK_PRIORITY, + xIPTaskStack, + &xIPTaskBuffer ); + + if( xIPTaskHandle != NULL ) { - static StaticTask_t xIPTaskBuffer; - static StackType_t xIPTaskStack[ ipconfigIP_TASK_STACK_SIZE_WORDS ]; - xIPTaskHandle = xTaskCreateStatic( prvIPTask, - "IP-Task", - ipconfigIP_TASK_STACK_SIZE_WORDS, - NULL, - ipconfigIP_TASK_PRIORITY, - xIPTaskStack, - &xIPTaskBuffer ); - - if( xIPTaskHandle != NULL ) - { - xReturn = pdTRUE; - } + xReturn = pdTRUE; } + } #else /* if ( configSUPPORT_STATIC_ALLOCATION == 1 ) */ - { - xReturn = xTaskCreate( prvIPTask, - "IP-task", - ipconfigIP_TASK_STACK_SIZE_WORDS, - NULL, - ipconfigIP_TASK_PRIORITY, - &( xIPTaskHandle ) ); - } + { + xReturn = xTaskCreate( prvIPTask, + "IP-task", + ipconfigIP_TASK_STACK_SIZE_WORDS, + NULL, + ipconfigIP_TASK_PRIORITY, + &( xIPTaskHandle ) ); + } #endif /* configSUPPORT_STATIC_ALLOCATION */ } else @@ -1391,22 +1391,22 @@ BaseType_t xSendEventStructToIPTask( const IPStackEvent_t * pxEvent, xSendMessage = pdTRUE; #if ( ipconfigUSE_TCP == 1 ) + { + if( pxEvent->eEventType == eTCPTimerEvent ) { - if( pxEvent->eEventType == eTCPTimerEvent ) - { - /* TCP timer events are sent to wake the timer task when - * xTCPTimer has expired, but there is no point sending them if the - * IP task is already awake processing other message. */ - vIPSetTCPTimerExpiredState( pdTRUE ); + /* TCP timer events are sent to wake the timer task when + * xTCPTimer has expired, but there is no point sending them if the + * IP task is already awake processing other message. */ + vIPSetTCPTimerExpiredState( pdTRUE ); - if( uxQueueMessagesWaiting( xNetworkEventQueue ) != 0U ) - { - /* Not actually going to send the message but this is not a - * failure as the message didn't need to be sent. */ - xSendMessage = pdFALSE; - } + if( uxQueueMessagesWaiting( xNetworkEventQueue ) != 0U ) + { + /* Not actually going to send the message but this is not a + * failure as the message didn't need to be sent. */ + xSendMessage = pdFALSE; } } + } #endif /* ipconfigUSE_TCP */ if( xSendMessage != pdFALSE ) @@ -1481,7 +1481,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE } else #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_DNS != 0 ) ) - if( memcmp( xLLMNR_MacAdress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + if( memcmp( xLLMNR_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) { /* The packet is a request for LLMNR - process it. */ eReturn = eProcessBuffer; @@ -1489,7 +1489,7 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE else #endif /* ipconfigUSE_LLMNR */ #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_DNS != 0 ) ) - if( memcmp( xMDNS_MacAdress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) + if( memcmp( xMDNS_MacAddress.ucBytes, pxEthernetHeader->xDestinationAddress.ucBytes, sizeof( MACAddress_t ) ) == 0 ) { /* The packet is a request for MDNS - process it. */ eReturn = eProcessBuffer; @@ -1511,21 +1511,21 @@ eFrameProcessingResult_t eConsiderFrameForProcessing( const uint8_t * const pucE } #if ( ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES == 1 ) + { + uint16_t usFrameType; + + if( eReturn == eProcessBuffer ) { - uint16_t usFrameType; + usFrameType = pxEthernetHeader->usFrameType; + usFrameType = FreeRTOS_ntohs( usFrameType ); - if( eReturn == eProcessBuffer ) + if( usFrameType <= 0x600U ) { - usFrameType = pxEthernetHeader->usFrameType; - usFrameType = FreeRTOS_ntohs( usFrameType ); - - if( usFrameType <= 0x600U ) - { - /* Not an Ethernet II frame. */ - eReturn = eReleaseBuffer; - } + /* Not an Ethernet II frame. */ + eReturn = eReleaseBuffer; } } + } #endif /* ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES == 1 */ return eReturn; @@ -1975,9 +1975,9 @@ static eFrameProcessingResult_t prvProcessIPPacket( const IPPacket_t * pxIPPacke * went wrong because it will not be able to validate what it * receives. */ #if ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) - { - eReturn = ProcessICMPPacket( pxNetworkBuffer ); - } + { + eReturn = ProcessICMPPacket( pxNetworkBuffer ); + } #endif /* ( ipconfigREPLY_TO_INCOMING_PINGS == 1 ) || ( ipconfigSUPPORT_OUTGOING_PINGS == 1 ) */ break; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ @@ -2038,21 +2038,21 @@ void vReturnEthernetFrame( NetworkBufferDescriptor_t * pxNetworkBuffer, #endif #if ( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) + { + if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; - - FreeRTOS_printf( ( "vReturnEthernetFrame: length %u\n", ( unsigned ) pxNetworkBuffer->xDataLength ) ); + BaseType_t xIndex; - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; - } + FreeRTOS_printf( ( "vReturnEthernetFrame: length %u\n", ( unsigned ) pxNetworkBuffer->xDataLength ) ); - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; + for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) + { + pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; } + + pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; } + } #endif /* if( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) */ #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) diff --git a/source/FreeRTOS_IP_Timers.c b/source/FreeRTOS_IP_Timers.c index 286d8c7fd4..709c9e5b8b 100644 --- a/source/FreeRTOS_IP_Timers.c +++ b/source/FreeRTOS_IP_Timers.c @@ -146,46 +146,46 @@ TickType_t xCalculateSleepTime( void ) } #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) - { - const NetworkEndPoint_t * pxEndPoint = pxNetworkEndPoints; + { + const NetworkEndPoint_t * pxEndPoint = pxNetworkEndPoints; - while( pxEndPoint != NULL ) + while( pxEndPoint != NULL ) + { + if( pxEndPoint->xDHCP_RATimer.bActive != pdFALSE_UNSIGNED ) { - if( pxEndPoint->xDHCP_RATimer.bActive != pdFALSE_UNSIGNED ) + if( pxEndPoint->xDHCP_RATimer.ulRemainingTime < uxMaximumSleepTime ) { - if( pxEndPoint->xDHCP_RATimer.ulRemainingTime < uxMaximumSleepTime ) - { - uxMaximumSleepTime = pxEndPoint->xDHCP_RATimer.ulRemainingTime; - } + uxMaximumSleepTime = pxEndPoint->xDHCP_RATimer.ulRemainingTime; } - - pxEndPoint = pxEndPoint->pxNext; } + + pxEndPoint = pxEndPoint->pxNext; } + } #endif /* ipconfigUSE_DHCP */ #if ( ipconfigUSE_TCP == 1 ) + { + if( xTCPTimer.bActive != pdFALSE_UNSIGNED ) { - if( xTCPTimer.bActive != pdFALSE_UNSIGNED ) + if( xTCPTimer.ulRemainingTime < uxMaximumSleepTime ) { - if( xTCPTimer.ulRemainingTime < uxMaximumSleepTime ) - { - uxMaximumSleepTime = xTCPTimer.ulRemainingTime; - } + uxMaximumSleepTime = xTCPTimer.ulRemainingTime; } } + } #endif #if ( ipconfigDNS_USE_CALLBACKS != 0 ) + { + if( xDNSTimer.bActive != pdFALSE_UNSIGNED ) { - if( xDNSTimer.bActive != pdFALSE_UNSIGNED ) + if( xDNSTimer.ulRemainingTime < uxMaximumSleepTime ) { - if( xDNSTimer.ulRemainingTime < uxMaximumSleepTime ) - { - uxMaximumSleepTime = xDNSTimer.ulRemainingTime; - } + uxMaximumSleepTime = xDNSTimer.ulRemainingTime; } } + } #endif return uxMaximumSleepTime; @@ -230,86 +230,86 @@ void vCheckNetworkTimers( void ) } #if ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA == 1 ) - { - /* Is it time for DHCP processing? */ - NetworkEndPoint_t * pxEndPoint = pxNetworkEndPoints; + { + /* Is it time for DHCP processing? */ + NetworkEndPoint_t * pxEndPoint = pxNetworkEndPoints; - while( pxEndPoint != NULL ) + while( pxEndPoint != NULL ) + { + if( prvIPTimerCheck( &( pxEndPoint->xDHCP_RATimer ) ) != pdFALSE ) { - if( prvIPTimerCheck( &( pxEndPoint->xDHCP_RATimer ) ) != pdFALSE ) - { - #if ( ipconfigUSE_DHCP == 1 ) - if( END_POINT_USES_DHCP( pxEndPoint ) ) - { - ( void ) xSendDHCPEvent( pxEndPoint ); - } - #endif /* ( ipconfigUSE_DHCP == 1 ) */ - - #if ( ( ipconfigUSE_RA != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) - if( END_POINT_USES_RA( pxEndPoint ) ) - { - vRAProcess( pdFALSE, pxEndPoint ); - } - #endif /* ( ipconfigUSE_RA != 0 ) */ - } + #if ( ipconfigUSE_DHCP == 1 ) + if( END_POINT_USES_DHCP( pxEndPoint ) ) + { + ( void ) xSendDHCPEvent( pxEndPoint ); + } + #endif /* ( ipconfigUSE_DHCP == 1 ) */ - pxEndPoint = pxEndPoint->pxNext; + #if ( ( ipconfigUSE_RA != 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) + if( END_POINT_USES_RA( pxEndPoint ) ) + { + vRAProcess( pdFALSE, pxEndPoint ); + } + #endif /* ( ipconfigUSE_RA != 0 ) */ } + + pxEndPoint = pxEndPoint->pxNext; } + } #endif /* ( ipconfigUSE_DHCP == 1 ) || ( ipconfigUSE_RA != 0 ) */ #if ( ipconfigDNS_USE_CALLBACKS != 0 ) + { + /* Is it time for DNS processing? */ + if( prvIPTimerCheck( &xDNSTimer ) != pdFALSE ) { - /* Is it time for DNS processing? */ - if( prvIPTimerCheck( &xDNSTimer ) != pdFALSE ) - { - vDNSCheckCallBack( NULL ); - } + vDNSCheckCallBack( NULL ); } + } #endif /* ipconfigDNS_USE_CALLBACKS */ #if ( ipconfigUSE_TCP == 1 ) - { - BaseType_t xWillSleep; - TickType_t xNextTime; - BaseType_t xCheckTCPSockets; + { + BaseType_t xWillSleep; + TickType_t xNextTime; + BaseType_t xCheckTCPSockets; - /* If the IP task has messages waiting to be processed then - * it will not sleep in any case. */ - if( uxQueueMessagesWaiting( xNetworkEventQueue ) == 0U ) - { - xWillSleep = pdTRUE; - } - else - { - xWillSleep = pdFALSE; - } + /* If the IP task has messages waiting to be processed then + * it will not sleep in any case. */ + if( uxQueueMessagesWaiting( xNetworkEventQueue ) == 0U ) + { + xWillSleep = pdTRUE; + } + else + { + xWillSleep = pdFALSE; + } - /* Sockets need to be checked if the TCP timer has expired. */ - xCheckTCPSockets = prvIPTimerCheck( &xTCPTimer ); + /* Sockets need to be checked if the TCP timer has expired. */ + xCheckTCPSockets = prvIPTimerCheck( &xTCPTimer ); - /* Sockets will also be checked if there are TCP messages but the - * message queue is empty (indicated by xWillSleep being true). */ - if( xWillSleep != pdFALSE ) - { - xCheckTCPSockets = pdTRUE; - } + /* Sockets will also be checked if there are TCP messages but the + * message queue is empty (indicated by xWillSleep being true). */ + if( xWillSleep != pdFALSE ) + { + xCheckTCPSockets = pdTRUE; + } - if( xCheckTCPSockets != pdFALSE ) - { - /* Attend to the sockets, returning the period after which the - * check must be repeated. */ - xNextTime = xTCPTimerCheck( xWillSleep ); - prvIPTimerStart( &xTCPTimer, xNextTime ); - xProcessedTCPMessage = 0; - } + if( xCheckTCPSockets != pdFALSE ) + { + /* Attend to the sockets, returning the period after which the + * check must be repeated. */ + xNextTime = xTCPTimerCheck( xWillSleep ); + prvIPTimerStart( &xTCPTimer, xNextTime ); + xProcessedTCPMessage = 0; } + } - /* See if any socket was planned to be closed. */ - vSocketCloseNextTime( NULL ); + /* See if any socket was planned to be closed. */ + vSocketCloseNextTime( NULL ); - /* See if any reusable socket needs to go back to 'eTCP_LISTEN' state. */ - vSocketListenNextTime( NULL ); + /* See if any reusable socket needs to go back to 'eTCP_LISTEN' state. */ + vSocketListenNextTime( NULL ); #endif /* ipconfigUSE_TCP == 1 */ /* Is it time to trigger the repeated NetworkDown events? */ diff --git a/source/FreeRTOS_IP_Utils.c b/source/FreeRTOS_IP_Utils.c index f25b10bf74..7c115fe676 100644 --- a/source/FreeRTOS_IP_Utils.c +++ b/source/FreeRTOS_IP_Utils.c @@ -234,9 +234,9 @@ static uint16_t prvGetChecksumFromPacket( const struct xPacketSummary * pxSet ) /* coverity[misra_c_2012_rule_11_6_violation] */ xEventMessage.pvData = ( void * ) pxEndPoint; #if ( ipconfigUSE_DHCPv6 == 1 ) || ( ipconfigUSE_DHCP == 1 ) - { - pxEndPoint->xDHCPData.eExpectedState = uxOption; - } + { + pxEndPoint->xDHCPData.eExpectedState = uxOption; + } #endif return xSendEventStructToIPTask( &xEventMessage, uxDontBlock ); @@ -403,9 +403,9 @@ static BaseType_t prvChecksumProtocolChecks( size_t uxBufferLength, { pxSet->uxProtocolHeaderLength = sizeof( pxSet->pxProtocolHeaders->xUDPHeader ); #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - pxSet->pcType = "UDP"; - } + { + pxSet->pcType = "UDP"; + } #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ } } @@ -434,9 +434,9 @@ static BaseType_t prvChecksumProtocolChecks( size_t uxBufferLength, pxSet->uxProtocolHeaderLength = ipSIZE_OF_TCP_HEADER + uxOptionsLength; #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - pxSet->pcType = "TCP"; - } + { + pxSet->pcType = "TCP"; + } #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ } } @@ -456,16 +456,16 @@ static BaseType_t prvChecksumProtocolChecks( size_t uxBufferLength, pxSet->uxProtocolHeaderLength = sizeof( pxSet->pxProtocolHeaders->xICMPHeader ); #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) + { + if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) { - if( pxSet->ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) - { - pxSet->pcType = "ICMP"; - } - else - { - pxSet->pcType = "IGMP"; - } + pxSet->pcType = "ICMP"; } + else + { + pxSet->pcType = "IGMP"; + } + } #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ } } @@ -507,9 +507,9 @@ static BaseType_t prvChecksumProtocolMTUCheck( struct xPacketSummary * pxSet ) ( pxSet->usProtocolBytes > ulMaxLength ) ) { #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: len invalid: %u\n", pxSet->pcType, pxSet->usProtocolBytes ) ); - } + { + FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: len invalid: %u\n", pxSet->pcType, pxSet->usProtocolBytes ) ); + } #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ /* Again, in a 16-bit return value there is no space to indicate an @@ -836,28 +836,28 @@ void prvProcessNetworkDownEvent( struct xNetworkInterface * pxInterface ) /* The bit 'bEndPointUp' stays low until vIPNetworkUpCalls() is called. */ pxEndPoint->bits.bEndPointUp = pdFALSE_UNSIGNED; #if ( ipconfigUSE_NETWORK_EVENT_HOOK == 1 ) + { + if( pxEndPoint->bits.bCallDownHook != pdFALSE_UNSIGNED ) { - if( pxEndPoint->bits.bCallDownHook != pdFALSE_UNSIGNED ) + #if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) { - #if defined( ipconfigIPv4_BACKWARD_COMPATIBLE ) && ( ipconfigIPv4_BACKWARD_COMPATIBLE == 1 ) - { - vApplicationIPNetworkEventHook( eNetworkDown ); - } - #else - { - vApplicationIPNetworkEventHook_Multi( eNetworkDown, pxEndPoint ); - } - #endif + vApplicationIPNetworkEventHook( eNetworkDown ); } - else + #else { - /* The next time NetworkEventHook will be called for this end-point. */ - pxEndPoint->bits.bCallDownHook = pdTRUE_UNSIGNED; + vApplicationIPNetworkEventHook_Multi( eNetworkDown, pxEndPoint ); } + #endif } + else + { + /* The next time NetworkEventHook will be called for this end-point. */ + pxEndPoint->bits.bCallDownHook = pdTRUE_UNSIGNED; + } + } #endif /* ipconfigUSE_NETWORK_EVENT_HOOK */ - /* Per the ARP Cache Validation section of https://tools.ietf.org/html/rfc1122, + /* Per the ARP Cache Validation section of https://tools.ietf.org/html/rfc1122 * treat network down as a "delivery problem" and flush the ARP cache for this * interface. */ FreeRTOS_ClearARP( pxEndPoint ); @@ -954,55 +954,55 @@ void vPreCheckConfigs( void ) configASSERT( FreeRTOS_GetIPTaskHandle() == NULL ); #if ( configASSERT_DEFINED == 1 ) - { - volatile size_t uxSize = sizeof( uintptr_t ); + { + volatile size_t uxSize = sizeof( uintptr_t ); - if( uxSize == 8U ) - { - /* This is a 64-bit platform, make sure there is enough space in - * pucEthernetBuffer to store a pointer and also make sure that the value of - * ipconfigBUFFER_PADDING is such that (ipconfigBUFFER_PADDING + ipSIZE_OF_ETH_HEADER) is a - * 32 bit (4 byte) aligned value, so that when incrementing the ethernet buffer with - * (ipconfigBUFFER_PADDING + ipSIZE_OF_ETH_HEADER) bytes it lands in a 32 bit aligned address - * which lets us efficiently access 32 bit values later in the packet. */ - configASSERT( ( ipconfigBUFFER_PADDING >= 14 ) && ( ( ( ( ipconfigBUFFER_PADDING ) + ( ipSIZE_OF_ETH_HEADER ) ) % 4 ) == 0 ) ); - } + if( uxSize == 8U ) + { + /* This is a 64-bit platform, make sure there is enough space in + * pucEthernetBuffer to store a pointer and also make sure that the value of + * ipconfigBUFFER_PADDING is such that (ipconfigBUFFER_PADDING + ipSIZE_OF_ETH_HEADER) is a + * 32 bit (4 byte) aligned value, so that when incrementing the ethernet buffer with + * (ipconfigBUFFER_PADDING + ipSIZE_OF_ETH_HEADER) bytes it lands in a 32 bit aligned address + * which lets us efficiently access 32 bit values later in the packet. */ + configASSERT( ( ipconfigBUFFER_PADDING >= 14 ) && ( ( ( ( ipconfigBUFFER_PADDING ) + ( ipSIZE_OF_ETH_HEADER ) ) % 4 ) == 0 ) ); + } - /* LCOV_EXCL_BR_START */ - uxSize = ipconfigNETWORK_MTU; - /* Check if MTU is big enough. */ - configASSERT( uxSize >= ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + ipconfigTCP_MSS ) ); + /* LCOV_EXCL_BR_START */ + uxSize = ipconfigNETWORK_MTU; + /* Check if MTU is big enough. */ + configASSERT( uxSize >= ( ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER + ipconfigTCP_MSS ) ); - uxSize = sizeof( EthernetHeader_t ); - /* Check structure packing is correct. */ - configASSERT( uxSize == ipEXPECTED_EthernetHeader_t_SIZE ); + uxSize = sizeof( EthernetHeader_t ); + /* Check structure packing is correct. */ + configASSERT( uxSize == ipEXPECTED_EthernetHeader_t_SIZE ); - uxSize = sizeof( ARPHeader_t ); - configASSERT( uxSize == ipEXPECTED_ARPHeader_t_SIZE ); + uxSize = sizeof( ARPHeader_t ); + configASSERT( uxSize == ipEXPECTED_ARPHeader_t_SIZE ); - uxSize = sizeof( IPHeader_t ); - configASSERT( uxSize == ipEXPECTED_IPHeader_t_SIZE ); + uxSize = sizeof( IPHeader_t ); + configASSERT( uxSize == ipEXPECTED_IPHeader_t_SIZE ); - uxSize = sizeof( ICMPHeader_t ); - configASSERT( uxSize == ipEXPECTED_ICMPHeader_t_SIZE ); + uxSize = sizeof( ICMPHeader_t ); + configASSERT( uxSize == ipEXPECTED_ICMPHeader_t_SIZE ); - uxSize = sizeof( UDPHeader_t ); - configASSERT( uxSize == ipEXPECTED_UDPHeader_t_SIZE ); + uxSize = sizeof( UDPHeader_t ); + configASSERT( uxSize == ipEXPECTED_UDPHeader_t_SIZE ); - #if ipconfigUSE_TCP == 1 - { - uxSize = sizeof( TCPHeader_t ); - configASSERT( uxSize == ( ipEXPECTED_TCPHeader_t_SIZE + ipSIZE_TCP_OPTIONS ) ); - } - #endif - /* LCOV_EXCL_BR_STOP */ - - /* ipIP_TYPE_OFFSET is used like so: - * pxNetworkBuffer->pucEthernetBuffer[ 0 - ( BaseType_t ) ipIP_TYPE_OFFSET ] = IP-Version-Byte - * It's value MUST be > 0. Otherwise, storing the IPv4 version byte - * will overwrite the Ethernet header. */ - configASSERT( ipIP_TYPE_OFFSET > 0 ); + #if ipconfigUSE_TCP == 1 + { + uxSize = sizeof( TCPHeader_t ); + configASSERT( uxSize == ( ipEXPECTED_TCPHeader_t_SIZE + ipSIZE_TCP_OPTIONS ) ); } + #endif + /* LCOV_EXCL_BR_STOP */ + + /* ipIP_TYPE_OFFSET is used like so: + * pxNetworkBuffer->pucEthernetBuffer[ 0 - ( BaseType_t ) ipIP_TYPE_OFFSET ] = IP-Version-Byte + * It's value MUST be > 0. Otherwise, storing the IPv4 version byte + * will overwrite the Ethernet header. */ + configASSERT( ipIP_TYPE_OFFSET > 0 ); + } #endif /* if ( configASSERT_DEFINED == 1 ) */ } /*-----------------------------------------------------------*/ @@ -1036,9 +1036,9 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer, DEBUG_DECLARE_TRACE_VARIABLE( BaseType_t, xLocation, 0 ); #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - xSet.pcType = "???"; - } + { + xSet.pcType = "???"; + } #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ configASSERT( ( ( ( IPPacket_t * ) pucEthernetBuffer )->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) || @@ -1112,16 +1112,16 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer, else if( ( prvGetChecksumFromPacket( &( xSet ) ) == 0U ) && ( xSet.ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) ) { #if ( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 ) - { - /* Sender hasn't set the checksum, drop the packet because - * ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS is not set. */ - xSet.usChecksum = ipWRONG_CRC; - } + { + /* Sender hasn't set the checksum, drop the packet because + * ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS is not set. */ + xSet.usChecksum = ipWRONG_CRC; + } #else /* if ( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 ) */ - { - /* Sender hasn't set the checksum, no use to calculate it. */ - xSet.usChecksum = ipCORRECT_CRC; - } + { + /* Sender hasn't set the checksum, no use to calculate it. */ + xSet.usChecksum = ipCORRECT_CRC; + } #endif /* if ( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 ) */ DEBUG_SET_TRACE_VARIABLE( xLocation, 12 ); break; @@ -1441,19 +1441,19 @@ uint16_t usGenerateChecksum( uint16_t usSum, } #if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - UBaseType_t uxCurrentCount = 0u; + { + UBaseType_t uxCurrentCount = 0u; - uxCurrentCount = uxGetMinimumIPQueueSpace(); + uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - * while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } + if( uxLastMinQueueSpace != uxCurrentCount ) + { + /* The logging produced below may be helpful + * while tuning +TCP: see how many buffers are in use. */ + uxLastMinQueueSpace = uxCurrentCount; + FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); } + } #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ diff --git a/source/FreeRTOS_IPv4.c b/source/FreeRTOS_IPv4.c index 05958979da..a4cd45e6dd 100644 --- a/source/FreeRTOS_IPv4.c +++ b/source/FreeRTOS_IPv4.c @@ -235,175 +235,175 @@ enum eFrameProcessingResult prvAllowIPPacketIPv4( const struct xIP_PACKET * cons #endif #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 0 ) + { + /* In systems with a very small amount of RAM, it might be advantageous + * to have incoming messages checked earlier, by the network card driver. + * This method may decrease the usage of sparse network buffers. */ + uint32_t ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress; + uint32_t ulSourceIPAddress = pxIPHeader->ulSourceIPAddress; + + /* Ensure that the incoming packet is not fragmented because the stack + * doesn't not support IP fragmentation. All but the last fragment coming in will have their + * "more fragments" flag set and the last fragment will have a non-zero offset. + * We need to drop the packet in either of those cases. */ + if( ( ( pxIPHeader->usFragmentOffset & ipFRAGMENT_OFFSET_BIT_MASK ) != 0U ) || ( ( pxIPHeader->usFragmentOffset & ipFRAGMENT_FLAGS_MORE_FRAGMENTS ) != 0U ) ) { - /* In systems with a very small amount of RAM, it might be advantageous - * to have incoming messages checked earlier, by the network card driver. - * This method may decrease the usage of sparse network buffers. */ - uint32_t ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress; - uint32_t ulSourceIPAddress = pxIPHeader->ulSourceIPAddress; - - /* Ensure that the incoming packet is not fragmented because the stack - * doesn't not support IP fragmentation. All but the last fragment coming in will have their - * "more fragments" flag set and the last fragment will have a non-zero offset. - * We need to drop the packet in either of those cases. */ - if( ( ( pxIPHeader->usFragmentOffset & ipFRAGMENT_OFFSET_BIT_MASK ) != 0U ) || ( ( pxIPHeader->usFragmentOffset & ipFRAGMENT_FLAGS_MORE_FRAGMENTS ) != 0U ) ) - { - /* Can not handle, fragmented packet. */ - eReturn = eReleaseBuffer; - } + /* Can not handle, fragmented packet. */ + eReturn = eReleaseBuffer; + } - /* Test if the length of the IP-header is between 20 and 60 bytes, - * and if the IP-version is 4. */ - else if( ( pxIPHeader->ucVersionHeaderLength < ipIPV4_VERSION_HEADER_LENGTH_MIN ) || - ( pxIPHeader->ucVersionHeaderLength > ipIPV4_VERSION_HEADER_LENGTH_MAX ) ) - { - /* Can not handle, unknown or invalid header version. */ - eReturn = eReleaseBuffer; - } - else if( - ( FreeRTOS_FindEndPointOnIP_IPv4( ulDestinationIPAddress, 4 ) == NULL ) && - ( pxNetworkBuffer->pxEndPoint == NULL ) && - /* Is it an IPv4 broadcast address x.x.x.255 ? */ - ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xffU ) != 0xffU ) && - ( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) && - /* Or (during DHCP negotiation) we have no IP-address yet? */ - ( FreeRTOS_IsNetworkUp() != pdFALSE ) ) - { - /* Packet is not for this node, release it */ - eReturn = eReleaseBuffer; - } - /* Is the source address correct? */ - else if( ( FreeRTOS_ntohl( ulSourceIPAddress ) & 0xffU ) == 0xffU ) - { - /* The source address cannot be broadcast address. Replying to this - * packet may cause network storms. Drop the packet. */ - eReturn = eReleaseBuffer; - } - else if( ( memcmp( xBroadcastMACAddress.ucBytes, - pxIPPacket->xEthernetHeader.xDestinationAddress.ucBytes, - sizeof( MACAddress_t ) ) == 0 ) && - ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xffU ) != 0xffU ) ) - { - /* Ethernet address is a broadcast address, but the IP address is not a - * broadcast address. */ - eReturn = eReleaseBuffer; - } - else if( memcmp( xBroadcastMACAddress.ucBytes, - pxIPPacket->xEthernetHeader.xSourceAddress.ucBytes, - sizeof( MACAddress_t ) ) == 0 ) - { - /* Ethernet source is a broadcast address. Drop the packet. */ - eReturn = eReleaseBuffer; - } - else if( xIsIPv4Multicast( ulSourceIPAddress ) == pdTRUE ) - { - /* Source is a multicast IP address. Drop the packet in conformity with RFC 1112 section 7.2. */ - eReturn = eReleaseBuffer; - } - else - { - /* Packet is not fragmented, destination is this device, source IP and MAC - * addresses are correct. */ - } + /* Test if the length of the IP-header is between 20 and 60 bytes, + * and if the IP-version is 4. */ + else if( ( pxIPHeader->ucVersionHeaderLength < ipIPV4_VERSION_HEADER_LENGTH_MIN ) || + ( pxIPHeader->ucVersionHeaderLength > ipIPV4_VERSION_HEADER_LENGTH_MAX ) ) + { + /* Can not handle, unknown or invalid header version. */ + eReturn = eReleaseBuffer; + } + else if( + ( FreeRTOS_FindEndPointOnIP_IPv4( ulDestinationIPAddress, 4 ) == NULL ) && + ( pxNetworkBuffer->pxEndPoint == NULL ) && + /* Is it an IPv4 broadcast address x.x.x.255 ? */ + ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xffU ) != 0xffU ) && + ( xIsIPv4Multicast( ulDestinationIPAddress ) == pdFALSE ) && + /* Or (during DHCP negotiation) we have no IP-address yet? */ + ( FreeRTOS_IsNetworkUp() != pdFALSE ) ) + { + /* Packet is not for this node, release it */ + eReturn = eReleaseBuffer; + } + /* Is the source address correct? */ + else if( ( FreeRTOS_ntohl( ulSourceIPAddress ) & 0xffU ) == 0xffU ) + { + /* The source address cannot be broadcast address. Replying to this + * packet may cause network storms. Drop the packet. */ + eReturn = eReleaseBuffer; + } + else if( ( memcmp( xBroadcastMACAddress.ucBytes, + pxIPPacket->xEthernetHeader.xDestinationAddress.ucBytes, + sizeof( MACAddress_t ) ) == 0 ) && + ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xffU ) != 0xffU ) ) + { + /* Ethernet address is a broadcast address, but the IP address is not a + * broadcast address. */ + eReturn = eReleaseBuffer; + } + else if( memcmp( xBroadcastMACAddress.ucBytes, + pxIPPacket->xEthernetHeader.xSourceAddress.ucBytes, + sizeof( MACAddress_t ) ) == 0 ) + { + /* Ethernet source is a broadcast address. Drop the packet. */ + eReturn = eReleaseBuffer; + } + else if( xIsIPv4Multicast( ulSourceIPAddress ) == pdTRUE ) + { + /* Source is a multicast IP address. Drop the packet in conformity with RFC 1112 section 7.2. */ + eReturn = eReleaseBuffer; + } + else + { + /* Packet is not fragmented, destination is this device, source IP and MAC + * addresses are correct. */ } + } #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ #if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 ) + { + /* Some drivers of NIC's with checksum-offloading will enable the above + * define, so that the checksum won't be checked again here */ + if( eReturn == eProcessBuffer ) { - /* Some drivers of NIC's with checksum-offloading will enable the above - * define, so that the checksum won't be checked again here */ - if( eReturn == eProcessBuffer ) - { - const NetworkEndPoint_t * pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxIPPacket->xEthernetHeader.xSourceAddress ), NULL ); + const NetworkEndPoint_t * pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxIPPacket->xEthernetHeader.xSourceAddress ), NULL ); - /* Do not check the checksum of loop-back messages. */ - if( pxEndPoint == NULL ) + /* Do not check the checksum of loop-back messages. */ + if( pxEndPoint == NULL ) + { + /* Is the IP header checksum correct? + * + * NOTE: When the checksum of IP header is calculated while not omitting + * the checksum field, the resulting value of the checksum always is 0xffff + * which is denoted by ipCORRECT_CRC. See this wiki for more information: + * https://en.wikipedia.org/wiki/IPv4_header_checksum#Verifying_the_IPv4_header_checksum + * and this RFC: https://tools.ietf.org/html/rfc1624#page-4 + */ + if( usGenerateChecksum( 0U, ( const uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ( size_t ) uxHeaderLength ) != ipCORRECT_CRC ) { - /* Is the IP header checksum correct? - * - * NOTE: When the checksum of IP header is calculated while not omitting - * the checksum field, the resulting value of the checksum always is 0xffff - * which is denoted by ipCORRECT_CRC. See this wiki for more information: - * https://en.wikipedia.org/wiki/IPv4_header_checksum#Verifying_the_IPv4_header_checksum - * and this RFC: https://tools.ietf.org/html/rfc1624#page-4 - */ - if( usGenerateChecksum( 0U, ( const uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), ( size_t ) uxHeaderLength ) != ipCORRECT_CRC ) - { - /* Check sum in IP-header not correct. */ - eReturn = eReleaseBuffer; - } - /* Is the upper-layer checksum (TCP/UDP/ICMP) correct? */ - else if( usGenerateProtocolChecksum( ( uint8_t * ) ( pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer->xDataLength, pdFALSE ) != ipCORRECT_CRC ) - { - /* Protocol checksum not accepted. */ - eReturn = eReleaseBuffer; - } - else - { - /* The checksum of the received packet is OK. */ - } + /* Check sum in IP-header not correct. */ + eReturn = eReleaseBuffer; + } + /* Is the upper-layer checksum (TCP/UDP/ICMP) correct? */ + else if( usGenerateProtocolChecksum( ( uint8_t * ) ( pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer->xDataLength, pdFALSE ) != ipCORRECT_CRC ) + { + /* Protocol checksum not accepted. */ + eReturn = eReleaseBuffer; + } + else + { + /* The checksum of the received packet is OK. */ } } } + } #else /* if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 ) */ + { + if( eReturn == eProcessBuffer ) { - if( eReturn == eProcessBuffer ) + if( xCheckIPv4SizeFields( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ) != pdPASS ) { - if( xCheckIPv4SizeFields( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ) != pdPASS ) - { - /* Some of the length checks were not successful. */ - eReturn = eReleaseBuffer; - } + /* Some of the length checks were not successful. */ + eReturn = eReleaseBuffer; } + } - #if ( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 ) + #if ( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 ) + { + /* Check if this is a UDP packet without a checksum. */ + if( eReturn == eProcessBuffer ) + { + uint8_t ucProtocol; + const ProtocolHeaders_t * pxProtocolHeaders; + + /* ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS is defined as 0, + * and so UDP packets carrying a protocol checksum of 0, will + * be dropped. */ + ucProtocol = pxIPPacket->xIPHeader.ucProtocol; + /* MISRA Ref 11.3.1 [Misaligned access] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ + /* coverity[misra_c_2012_rule_11_3_violation] */ + pxProtocolHeaders = ( ( ProtocolHeaders_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ( size_t ) ipSIZE_OF_IPv4_HEADER ] ) ); + + /* Identify the next protocol. */ + if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) { - /* Check if this is a UDP packet without a checksum. */ - if( eReturn == eProcessBuffer ) + if( pxProtocolHeaders->xUDPHeader.usChecksum == ( uint16_t ) 0U ) { - uint8_t ucProtocol; - const ProtocolHeaders_t * pxProtocolHeaders; - - /* ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS is defined as 0, - * and so UDP packets carrying a protocol checksum of 0, will - * be dropped. */ - ucProtocol = pxIPPacket->xIPHeader.ucProtocol; - /* MISRA Ref 11.3.1 [Misaligned access] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - pxProtocolHeaders = ( ( ProtocolHeaders_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ( size_t ) ipSIZE_OF_IPv4_HEADER ] ) ); - - /* Identify the next protocol. */ - if( ucProtocol == ( uint8_t ) ipPROTOCOL_UDP ) + #if ( ipconfigHAS_PRINTF != 0 ) { - if( pxProtocolHeaders->xUDPHeader.usChecksum == ( uint16_t ) 0U ) + static BaseType_t xCount = 0; + + /* Exclude this from branch coverage as this is only used for debugging. */ + if( xCount < 5 ) /* LCOV_EXCL_BR_LINE */ { - #if ( ipconfigHAS_PRINTF != 0 ) - { - static BaseType_t xCount = 0; - - /* Exclude this from branch coverage as this is only used for debugging. */ - if( xCount < 5 ) /* LCOV_EXCL_BR_LINE */ - { - FreeRTOS_printf( ( "prvAllowIPPacket: UDP packet from %xip without CRC dropped\n", - FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ) ) ); - xCount++; - } - } - #endif /* ( ipconfigHAS_PRINTF != 0 ) */ - - /* Protocol checksum not accepted. */ - eReturn = eReleaseBuffer; + FreeRTOS_printf( ( "prvAllowIPPacket: UDP packet from %xip without CRC dropped\n", + FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ) ) ); + xCount++; } } + #endif /* ( ipconfigHAS_PRINTF != 0 ) */ + + /* Protocol checksum not accepted. */ + eReturn = eReleaseBuffer; } } - #endif /* ( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 ) */ - - /* to avoid warning unused parameters */ - ( void ) pxNetworkBuffer; - ( void ) uxHeaderLength; + } } + #endif /* ( ipconfigUDP_PASS_ZERO_CHECKSUM_PACKETS == 0 ) */ + + /* to avoid warning unused parameters */ + ( void ) pxNetworkBuffer; + ( void ) uxHeaderLength; + } #endif /* ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 */ return eReturn; @@ -427,45 +427,45 @@ enum eFrameProcessingResult prvCheckIP4HeaderOptions( struct xNETWORK_BUFFER * c * depending on a user define. */ #if ( ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS != 0 ) - { - /* MISRA Ref 11.3.1 [Misaligned access] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - IPHeader_t * pxIPHeader = ( ( IPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) ); - - /* All structs of headers expect a IP header size of 20 bytes - * IP header options were included, we'll ignore them and cut them out. */ - size_t uxLength = ( size_t ) pxIPHeader->ucVersionHeaderLength; - - /* Check if the IP headers are acceptable and if it has our destination. - * The lowest four bits of 'ucVersionHeaderLength' indicate the IP-header - * length in multiples of 4. */ - size_t uxHeaderLength = ( size_t ) ( ( uxLength & 0x0FU ) << 2 ); - - /* Number of bytes contained in IPv4 header options. */ - const size_t optlen = ( ( size_t ) uxHeaderLength ) - ipSIZE_OF_IPv4_HEADER; - /* From: the previous start of UDP/ICMP/TCP data. */ - const uint8_t * pucSource = ( const uint8_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ sizeof( EthernetHeader_t ) + uxHeaderLength ] ); - /* To: the usual start of UDP/ICMP/TCP data at offset 20 (decimal ) from IP header. */ - uint8_t * pucTarget = ( uint8_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ sizeof( EthernetHeader_t ) + ipSIZE_OF_IPv4_HEADER ] ); - /* How many: total length minus the options and the lower headers. */ - const size_t xMoveLen = pxNetworkBuffer->xDataLength - ( optlen + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_ETH_HEADER ); - - ( void ) memmove( pucTarget, pucSource, xMoveLen ); - pxNetworkBuffer->xDataLength -= optlen; - /* Update the total length of the IP packet after removing options. */ - pxIPHeader->usLength = FreeRTOS_htons( FreeRTOS_ntohs( pxIPHeader->usLength ) - optlen ); - - /* Rewrite the Version/IHL byte to indicate that this packet has no IP options. */ - pxIPHeader->ucVersionHeaderLength = ( uint8_t ) ( ( pxIPHeader->ucVersionHeaderLength & 0xF0U ) | /* High nibble is the version. */ - ( ( ipSIZE_OF_IPv4_HEADER >> 2 ) & 0x0FU ) ); - } + { + /* MISRA Ref 11.3.1 [Misaligned access] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ + /* coverity[misra_c_2012_rule_11_3_violation] */ + IPHeader_t * pxIPHeader = ( ( IPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ) ); + + /* All structs of headers expect a IP header size of 20 bytes + * IP header options were included, we'll ignore them and cut them out. */ + size_t uxLength = ( size_t ) pxIPHeader->ucVersionHeaderLength; + + /* Check if the IP headers are acceptable and if it has our destination. + * The lowest four bits of 'ucVersionHeaderLength' indicate the IP-header + * length in multiples of 4. */ + size_t uxHeaderLength = ( size_t ) ( ( uxLength & 0x0FU ) << 2 ); + + /* Number of bytes contained in IPv4 header options. */ + const size_t optlen = ( ( size_t ) uxHeaderLength ) - ipSIZE_OF_IPv4_HEADER; + /* From: the previous start of UDP/ICMP/TCP data. */ + const uint8_t * pucSource = ( const uint8_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ sizeof( EthernetHeader_t ) + uxHeaderLength ] ); + /* To: the usual start of UDP/ICMP/TCP data at offset 20 (decimal ) from IP header. */ + uint8_t * pucTarget = ( uint8_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ sizeof( EthernetHeader_t ) + ipSIZE_OF_IPv4_HEADER ] ); + /* How many: total length minus the options and the lower headers. */ + const size_t xMoveLen = pxNetworkBuffer->xDataLength - ( optlen + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_ETH_HEADER ); + + ( void ) memmove( pucTarget, pucSource, xMoveLen ); + pxNetworkBuffer->xDataLength -= optlen; + /* Update the total length of the IP packet after removing options. */ + pxIPHeader->usLength = FreeRTOS_htons( FreeRTOS_ntohs( pxIPHeader->usLength ) - optlen ); + + /* Rewrite the Version/IHL byte to indicate that this packet has no IP options. */ + pxIPHeader->ucVersionHeaderLength = ( uint8_t ) ( ( pxIPHeader->ucVersionHeaderLength & 0xF0U ) | /* High nibble is the version. */ + ( ( ipSIZE_OF_IPv4_HEADER >> 2 ) & 0x0FU ) ); + } #else /* if ( ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS != 0 ) */ - { - /* 'ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS' is not set, so packets carrying - * IP-options will be dropped. */ - eReturn = eReleaseBuffer; - } + { + /* 'ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS' is not set, so packets carrying + * IP-options will be dropped. */ + eReturn = eReleaseBuffer; + } #endif /* if ( ipconfigIP_PASS_PACKETS_WITH_IP_OPTIONS != 0 ) */ return eReturn; diff --git a/source/FreeRTOS_IPv6.c b/source/FreeRTOS_IPv6.c index 7224096803..6050e5ca12 100644 --- a/source/FreeRTOS_IPv6.c +++ b/source/FreeRTOS_IPv6.c @@ -452,94 +452,94 @@ eFrameProcessingResult_t prvAllowIPPacketIPv6( const IPHeader_IPv6_t * const pxI eFrameProcessingResult_t eReturn; #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 0 ) + { + /* In systems with a very small amount of RAM, it might be advantageous + * to have incoming messages checked earlier, by the network card driver. + * This method may decrease the usage of sparse network buffers. */ + const IPv6_Address_t * pxDestinationIPAddress = &( pxIPv6Header->xDestinationAddress ); + const IPv6_Address_t * pxSourceIPAddress = &( pxIPv6Header->xSourceAddress ); + BaseType_t xHasUnspecifiedAddress = pdFALSE; + + /* Drop if packet has unspecified IPv6 address (defined in RFC4291 - sec 2.5.2) + * either in source or destination address. */ + if( ( memcmp( pxDestinationIPAddress->ucBytes, xIPv6UnspecifiedAddress.ucBytes, sizeof( IPv6_Address_t ) ) == 0 ) || + ( memcmp( pxSourceIPAddress->ucBytes, xIPv6UnspecifiedAddress.ucBytes, sizeof( IPv6_Address_t ) ) == 0 ) ) { - /* In systems with a very small amount of RAM, it might be advantageous - * to have incoming messages checked earlier, by the network card driver. - * This method may decrease the usage of sparse network buffers. */ - const IPv6_Address_t * pxDestinationIPAddress = &( pxIPv6Header->xDestinationAddress ); - const IPv6_Address_t * pxSourceIPAddress = &( pxIPv6Header->xSourceAddress ); - BaseType_t xHasUnspecifiedAddress = pdFALSE; - - /* Drop if packet has unspecified IPv6 address (defined in RFC4291 - sec 2.5.2) - * either in source or destination address. */ - if( ( memcmp( pxDestinationIPAddress->ucBytes, xIPv6UnspecifiedAddress.ucBytes, sizeof( IPv6_Address_t ) ) == 0 ) || - ( memcmp( pxSourceIPAddress->ucBytes, xIPv6UnspecifiedAddress.ucBytes, sizeof( IPv6_Address_t ) ) == 0 ) ) - { - xHasUnspecifiedAddress = pdTRUE; - } + xHasUnspecifiedAddress = pdTRUE; + } - /* Is the packet for this IP address? */ - if( ( xHasUnspecifiedAddress == pdFALSE ) && - ( pxNetworkBuffer->pxEndPoint != NULL ) && - ( memcmp( pxDestinationIPAddress->ucBytes, pxNetworkBuffer->pxEndPoint->ipv6_settings.xIPAddress.ucBytes, sizeof( IPv6_Address_t ) ) == 0 ) ) - { - eReturn = eProcessBuffer; - } - /* Is it the legal multicast address? */ - else if( ( xHasUnspecifiedAddress == pdFALSE ) && - ( ( xIsIPv6AllowedMulticast( pxDestinationIPAddress ) != pdFALSE ) || - /* Is it loopback address sent from this node? */ - ( xIsIPv6Loopback( pxIPv6Header ) != pdFALSE ) || - /* Or (during DHCP negotiation) we have no IP-address yet? */ - ( FreeRTOS_IsNetworkUp() == 0 ) ) ) - { - eReturn = eProcessBuffer; - } - else - { - /* Packet is not for this node, or the network is still not up, - * release it */ - eReturn = eReleaseBuffer; - FreeRTOS_printf( ( "prvAllowIPPacketIPv6: drop %pip (from %pip)\n", pxDestinationIPAddress->ucBytes, pxIPv6Header->xSourceAddress.ucBytes ) ); - } + /* Is the packet for this IP address? */ + if( ( xHasUnspecifiedAddress == pdFALSE ) && + ( pxNetworkBuffer->pxEndPoint != NULL ) && + ( memcmp( pxDestinationIPAddress->ucBytes, pxNetworkBuffer->pxEndPoint->ipv6_settings.xIPAddress.ucBytes, sizeof( IPv6_Address_t ) ) == 0 ) ) + { + eReturn = eProcessBuffer; } - #else /* if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 0 ) */ + /* Is it the legal multicast address? */ + else if( ( xHasUnspecifiedAddress == pdFALSE ) && + ( ( xIsIPv6AllowedMulticast( pxDestinationIPAddress ) != pdFALSE ) || + /* Is it loopback address sent from this node? */ + ( xIsIPv6Loopback( pxIPv6Header ) != pdFALSE ) || + /* Or (during DHCP negotiation) we have no IP-address yet? */ + ( FreeRTOS_IsNetworkUp() == 0 ) ) ) { - ( void ) pxIPv6Header; - /* The packet has been checked by the network interface. */ eReturn = eProcessBuffer; } + else + { + /* Packet is not for this node, or the network is still not up, + * release it */ + eReturn = eReleaseBuffer; + FreeRTOS_printf( ( "prvAllowIPPacketIPv6: drop %pip (from %pip)\n", pxDestinationIPAddress->ucBytes, pxIPv6Header->xSourceAddress.ucBytes ) ); + } + } + #else /* if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 0 ) */ + { + ( void ) pxIPv6Header; + /* The packet has been checked by the network interface. */ + eReturn = eProcessBuffer; + } #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ #if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 ) + { + /* Some drivers of NIC's with checksum-offloading will enable the above + * define, so that the checksum won't be checked again here */ + if( eReturn == eProcessBuffer ) { - /* Some drivers of NIC's with checksum-offloading will enable the above - * define, so that the checksum won't be checked again here */ - if( eReturn == eProcessBuffer ) + /* MISRA Ref 11.3.1 [Misaligned access] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ + /* coverity[misra_c_2012_rule_11_3_violation] */ + const IPPacket_t * pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + const NetworkEndPoint_t * pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxIPPacket->xEthernetHeader.xSourceAddress ), NULL ); + + /* IPv6 does not have a separate checksum in the IP-header */ + /* Is the upper-layer checksum (TCP/UDP/ICMP) correct? */ + /* Do not check the checksum of loop-back messages. */ + if( pxEndPoint == NULL ) { - /* MISRA Ref 11.3.1 [Misaligned access] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - const IPPacket_t * pxIPPacket = ( ( const IPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); - const NetworkEndPoint_t * pxEndPoint = FreeRTOS_FindEndPointOnMAC( &( pxIPPacket->xEthernetHeader.xSourceAddress ), NULL ); - - /* IPv6 does not have a separate checksum in the IP-header */ - /* Is the upper-layer checksum (TCP/UDP/ICMP) correct? */ - /* Do not check the checksum of loop-back messages. */ - if( pxEndPoint == NULL ) + if( usGenerateProtocolChecksum( ( uint8_t * ) ( pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer->xDataLength, pdFALSE ) != ipCORRECT_CRC ) { - if( usGenerateProtocolChecksum( ( uint8_t * ) ( pxNetworkBuffer->pucEthernetBuffer ), pxNetworkBuffer->xDataLength, pdFALSE ) != ipCORRECT_CRC ) - { - /* Protocol checksum not accepted. */ - eReturn = eReleaseBuffer; - } + /* Protocol checksum not accepted. */ + eReturn = eReleaseBuffer; } } } + } #else /* if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 ) */ + { + if( eReturn == eProcessBuffer ) { - if( eReturn == eProcessBuffer ) + if( xCheckIPv6SizeFields( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ) != pdPASS ) { - if( xCheckIPv6SizeFields( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength ) != pdPASS ) - { - /* Some of the length checks were not successful. */ - eReturn = eReleaseBuffer; - } + /* Some of the length checks were not successful. */ + eReturn = eReleaseBuffer; } - - /* to avoid warning unused parameters */ - ( void ) pxNetworkBuffer; } + + /* to avoid warning unused parameters */ + ( void ) pxNetworkBuffer; + } #endif /* ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 0 */ ( void ) uxHeaderLength; diff --git a/source/FreeRTOS_IPv6_Utils.c b/source/FreeRTOS_IPv6_Utils.c index 7e0776fb24..848395a89f 100644 --- a/source/FreeRTOS_IPv6_Utils.c +++ b/source/FreeRTOS_IPv6_Utils.c @@ -162,9 +162,9 @@ BaseType_t prvChecksumICMPv6Checks( size_t uxBufferLength, { pxSet->uxProtocolHeaderLength = xICMPLength; #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - pxSet->pcType = "ICMP_IPv6"; - } + { + pxSet->pcType = "ICMP_IPv6"; + } #endif /* ipconfigHAS_DEBUG_PRINTF != 0 */ } diff --git a/source/FreeRTOS_ND.c b/source/FreeRTOS_ND.c index 1eafaad383..ea64f8cb49 100644 --- a/source/FreeRTOS_ND.c +++ b/source/FreeRTOS_ND.c @@ -533,16 +533,16 @@ pxNetworkBuffer->xDataLength = ( size_t ) ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + uxICMPSize ); #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the ICMPv6 checksum for outgoing package */ - ( void ) usGenerateProtocolChecksum( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE ); - } + { + /* calculate the ICMPv6 checksum for outgoing package */ + ( void ) usGenerateProtocolChecksum( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE ); + } #else - { - /* Many EMAC peripherals will only calculate the ICMP checksum - * correctly if the field is nulled beforehand. */ - pxICMPPacket->xICMPHeaderIPv6.usChecksum = 0; - } + { + /* Many EMAC peripherals will only calculate the ICMP checksum + * correctly if the field is nulled beforehand. */ + pxICMPPacket->xICMPHeaderIPv6.usChecksum = 0; + } #endif /* This function will fill in the Ethernet addresses and send the packet */ @@ -643,16 +643,16 @@ /* Checksums. */ #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the ICMPv6 checksum for outgoing package */ - ( void ) usGenerateProtocolChecksum( pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, pdTRUE ); - } + { + /* calculate the ICMPv6 checksum for outgoing package */ + ( void ) usGenerateProtocolChecksum( pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, pdTRUE ); + } #else - { - /* Many EMAC peripherals will only calculate the ICMP checksum - * correctly if the field is nulled beforehand. */ - pxICMPHeader_IPv6->usChecksum = 0U; - } + { + /* Many EMAC peripherals will only calculate the ICMP checksum + * correctly if the field is nulled beforehand. */ + pxICMPHeader_IPv6->usChecksum = 0U; + } #endif /* This function will fill in the eth addresses and send the packet */ @@ -842,8 +842,8 @@ pcReturn = "PACKET_TOO_BIG"; break; - case ipICMP_TIME_EXEEDED_IPv6: - pcReturn = "TIME_EXEEDED"; + case ipICMP_TIME_EXCEEDED_IPv6: + pcReturn = "TIME_EXCEEDED"; break; case ipICMP_PARAMETER_PROBLEM_IPv6: @@ -942,18 +942,18 @@ size_t uxNeededSize; #if ( ipconfigHAS_PRINTF == 1 ) + { + if( pxICMPHeader_IPv6->ucTypeOfMessage != ipICMP_PING_REQUEST_IPv6 ) { - if( pxICMPHeader_IPv6->ucTypeOfMessage != ipICMP_PING_REQUEST_IPv6 ) - { - char pcAddress[ 40 ]; - FreeRTOS_printf( ( "ICMPv6_recv %d (%s) from %pip to %pip end-point = %s\n", - pxICMPHeader_IPv6->ucTypeOfMessage, - pcMessageType( ( BaseType_t ) pxICMPHeader_IPv6->ucTypeOfMessage ), - ( void * ) pxICMPPacket->xIPHeader.xSourceAddress.ucBytes, - ( void * ) pxICMPPacket->xIPHeader.xDestinationAddress.ucBytes, - pcEndpointName( pxEndPoint, pcAddress, sizeof( pcAddress ) ) ) ); - } + char pcAddress[ 40 ]; + FreeRTOS_printf( ( "ICMPv6_recv %d (%s) from %pip to %pip end-point = %s\n", + pxICMPHeader_IPv6->ucTypeOfMessage, + pcMessageType( ( BaseType_t ) pxICMPHeader_IPv6->ucTypeOfMessage ), + ( void * ) pxICMPPacket->xIPHeader.xSourceAddress.ucBytes, + ( void * ) pxICMPPacket->xIPHeader.xDestinationAddress.ucBytes, + pcEndpointName( pxEndPoint, pcAddress, sizeof( pcAddress ) ) ) ); } + } #endif /* ( ipconfigHAS_PRINTF == 1 ) */ if( ( pxEndPoint != NULL ) && ( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) ) @@ -962,7 +962,7 @@ { case ipICMP_DEST_UNREACHABLE_IPv6: case ipICMP_PACKET_TOO_BIG_IPv6: - case ipICMP_TIME_EXEEDED_IPv6: + case ipICMP_TIME_EXCEEDED_IPv6: case ipICMP_PARAMETER_PROBLEM_IPv6: /* These message types are not implemented. They are logged here above. */ break; @@ -1193,16 +1193,16 @@ pxNetworkBuffer->xDataLength = ( size_t ) ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + uxICMPSize ); #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the ICMPv6 checksum for outgoing package */ - ( void ) usGenerateProtocolChecksum( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE ); - } + { + /* calculate the ICMPv6 checksum for outgoing package */ + ( void ) usGenerateProtocolChecksum( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, pdTRUE ); + } #else - { - /* Many EMAC peripherals will only calculate the ICMP checksum - * correctly if the field is nulled beforehand. */ - pxICMPHeader_IPv6->usChecksum = 0; - } + { + /* Many EMAC peripherals will only calculate the ICMP checksum + * correctly if the field is nulled beforehand. */ + pxICMPHeader_IPv6->usChecksum = 0; + } #endif /* Set the parameter 'bReleaseAfterSend'. */ diff --git a/source/FreeRTOS_RA.c b/source/FreeRTOS_RA.c index c549b87d85..0a5c10ee4a 100644 --- a/source/FreeRTOS_RA.c +++ b/source/FreeRTOS_RA.c @@ -206,16 +206,16 @@ /* Checksums. */ #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the ICMPv6 checksum for outgoing package */ - ( void ) usGenerateProtocolChecksum( pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, pdTRUE ); - } + { + /* calculate the ICMPv6 checksum for outgoing package */ + ( void ) usGenerateProtocolChecksum( pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, pdTRUE ); + } #else - { - /* Many EMAC peripherals will only calculate the ICMP checksum - * correctly if the field is nulled beforehand. */ - xRASolicitationRequest->usChecksum = 0U; - } + { + /* Many EMAC peripherals will only calculate the ICMP checksum + * correctly if the field is nulled beforehand. */ + xRASolicitationRequest->usChecksum = 0U; + } #endif /* This function will fill in the eth addresses and send the packet */ @@ -487,7 +487,7 @@ /* Obtained configuration from a router. */ uxNewReloadTime = pdMS_TO_TICKS( 1000U * pxEndPoint->xRAData.ulPreferredLifeTime ); pxEndPoint->xRAData.eRAState = eRAStatePreLease; - iptraceRA_SUCCEDEED( &( pxEndPoint->ipv6_settings.xIPAddress ) ); + iptraceRA_SUCCEEDED( &( pxEndPoint->ipv6_settings.xIPAddress ) ); FreeRTOS_printf( ( "RA: succeeded, using IP address %pip Reload after %u seconds\n", ( void * ) pxEndPoint->ipv6_settings.xIPAddress.ucBytes, ( unsigned ) pxEndPoint->xRAData.ulPreferredLifeTime ) ); @@ -658,15 +658,15 @@ uxReloadTime = xRAProcess_HandleOtherStates( pxEndPoint, uxReloadTime ); #if ( ipconfigHAS_PRINTF == 1 ) - { - FreeRTOS_printf( ( "vRAProcess( %ld, %pip) bRouterReplied=%d bIPAddressInUse=%d state %d -> %d\n", - xDoReset, - ( void * ) pxEndPoint->ipv6_defaults.xIPAddress.ucBytes, - pxEndPoint->xRAData.bits.bRouterReplied, - pxEndPoint->xRAData.bits.bIPAddressInUse, - eRAState, - pxEndPoint->xRAData.eRAState ) ); - } + { + FreeRTOS_printf( ( "vRAProcess( %ld, %pip) bRouterReplied=%d bIPAddressInUse=%d state %d -> %d\n", + xDoReset, + ( void * ) pxEndPoint->ipv6_defaults.xIPAddress.ucBytes, + pxEndPoint->xRAData.bits.bRouterReplied, + pxEndPoint->xRAData.bits.bIPAddressInUse, + eRAState, + pxEndPoint->xRAData.eRAState ) ); + } #endif /* ( ipconfigHAS_PRINTF == 1 ) */ if( uxReloadTime != 0U ) diff --git a/source/FreeRTOS_Routing.c b/source/FreeRTOS_Routing.c index e165d5a31c..f2babf08bd 100644 --- a/source/FreeRTOS_Routing.c +++ b/source/FreeRTOS_Routing.c @@ -479,9 +479,9 @@ struct xIPv6_Couple NetworkEndPoint_t * pxEndPoint = pxNetworkEndPoints; #if ( ipconfigHAS_ROUTING_STATISTICS == 1 ) - { - xRoutingStatistics.ulOnMAC++; - } + { + xRoutingStatistics.ulOnMAC++; + } #endif /* If input MAC address is NULL, return NULL. */ @@ -914,16 +914,16 @@ struct xIPv6_Couple /* Check if 'pucEthernetBuffer()' has the expected alignment, * which is 32-bits + 2. */ #ifndef _lint - { - /* MISRA Ref 11.4.3 [Casting pointer to int for verification] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */ - /* coverity[misra_c_2012_rule_11_4_violation] */ - uintptr_t uxAddress = ( uintptr_t ) pucEthernetBuffer; - uxAddress += 2U; - configASSERT( ( uxAddress % 4U ) == 0U ); - /* And in case configASSERT is not defined. */ - ( void ) uxAddress; - } + { + /* MISRA Ref 11.4.3 [Casting pointer to int for verification] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-114 */ + /* coverity[misra_c_2012_rule_11_4_violation] */ + uintptr_t uxAddress = ( uintptr_t ) pucEthernetBuffer; + uxAddress += 2U; + configASSERT( ( uxAddress % 4U ) == 0U ); + /* And in case configASSERT is not defined. */ + ( void ) uxAddress; + } #endif /* ifndef _lint */ /* An Ethernet packet has been received. Inspect the contents to see which @@ -931,10 +931,10 @@ struct xIPv6_Couple */ #if ( ipconfigHAS_ROUTING_STATISTICS == 1 ) - { - /* Some stats while developing. */ - xRoutingStatistics.ulMatching++; - } + { + /* Some stats while developing. */ + xRoutingStatistics.ulMatching++; + } #endif { uint16_t usFrameType = pxPacket->xUDPPacket.xEthernetHeader.usFrameType; @@ -963,30 +963,30 @@ struct xIPv6_Couple /* Handle ARP frame types if ipconfigUSE_IPv4 != 0 */ #if ( ipconfigUSE_IPv4 != 0 ) - { - /* MISRA Ref 11.3.1 [Misaligned access] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - const ARPPacket_t * pxARPFrame = ( const ARPPacket_t * ) pucEthernetBuffer; - - if( pxARPFrame->xARPHeader.usOperation == ( uint16_t ) ipARP_REQUEST ) - { - ( void ) memcpy( xIPAddressFrom.xIP_IPv6.ucBytes, pxPacket->xARPPacket.xARPHeader.ucSenderProtocolAddress, sizeof( uint32_t ) ); - xIPAddressTo.ulIP_IPv4 = pxPacket->xARPPacket.xARPHeader.ulTargetProtocolAddress; - } - else if( pxARPFrame->xARPHeader.usOperation == ( uint16_t ) ipARP_REPLY ) - { - ( void ) memcpy( xIPAddressTo.xIP_IPv6.ucBytes, pxPacket->xARPPacket.xARPHeader.ucSenderProtocolAddress, sizeof( uint32_t ) ); - xIPAddressFrom.ulIP_IPv4 = pxPacket->xARPPacket.xARPHeader.ulTargetProtocolAddress; - } - else - { - /* do nothing, coverity happy */ - } + { + /* MISRA Ref 11.3.1 [Misaligned access] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ + /* coverity[misra_c_2012_rule_11_3_violation] */ + const ARPPacket_t * pxARPFrame = ( const ARPPacket_t * ) pucEthernetBuffer; - FreeRTOS_debug_printf( ( "pxEasyFit: ARP %xip -> %xip\n", ( unsigned ) FreeRTOS_ntohl( xIPAddressFrom.ulIP_IPv4 ), ( unsigned ) FreeRTOS_ntohl( xIPAddressTo.ulIP_IPv4 ) ) ); + if( pxARPFrame->xARPHeader.usOperation == ( uint16_t ) ipARP_REQUEST ) + { + ( void ) memcpy( xIPAddressFrom.xIP_IPv6.ucBytes, pxPacket->xARPPacket.xARPHeader.ucSenderProtocolAddress, sizeof( uint32_t ) ); + xIPAddressTo.ulIP_IPv4 = pxPacket->xARPPacket.xARPHeader.ulTargetProtocolAddress; } - xDoProcessPacket = pdTRUE; + else if( pxARPFrame->xARPHeader.usOperation == ( uint16_t ) ipARP_REPLY ) + { + ( void ) memcpy( xIPAddressTo.xIP_IPv6.ucBytes, pxPacket->xARPPacket.xARPHeader.ucSenderProtocolAddress, sizeof( uint32_t ) ); + xIPAddressFrom.ulIP_IPv4 = pxPacket->xARPPacket.xARPHeader.ulTargetProtocolAddress; + } + else + { + /* do nothing, coverity happy */ + } + + FreeRTOS_debug_printf( ( "pxEasyFit: ARP %xip -> %xip\n", ( unsigned ) FreeRTOS_ntohl( xIPAddressFrom.ulIP_IPv4 ), ( unsigned ) FreeRTOS_ntohl( xIPAddressTo.ulIP_IPv4 ) ) ); + } + xDoProcessPacket = pdTRUE; #endif /* ( ipconfigUSE_IPv4 != 0 ) */ break; diff --git a/source/FreeRTOS_Sockets.c b/source/FreeRTOS_Sockets.c index 6f495e65d5..080ec35846 100644 --- a/source/FreeRTOS_Sockets.c +++ b/source/FreeRTOS_Sockets.c @@ -75,7 +75,7 @@ * Automatically generated port numbers will be between * socketAUTO_PORT_ALLOCATION_START_NUMBER and 0xffff. * - * @note Per https://tools.ietf.org/html/rfc6056, "the dynamic ports consist of + * @note Per https://tools.ietf.org/html/rfc6056 "the dynamic ports consist of * the range 49152-65535. However, ephemeral port selection algorithms should * use the whole range 1024-65535" excluding those already in use (inbound * or outbound). @@ -436,9 +436,9 @@ void vNetworkSocketsInit( void ) vListInitialise( &xBoundUDPSocketsList ); #if ( ipconfigUSE_TCP == 1 ) - { - vListInitialise( &xBoundTCPSocketsList ); - } + { + vListInitialise( &xBoundTCPSocketsList ); + } #endif /* ipconfigUSE_TCP == 1 */ } /*-----------------------------------------------------------*/ @@ -473,41 +473,41 @@ static BaseType_t prvDetermineSocketSize( BaseType_t xDomain, { /* Only Ethernet is currently supported. */ #if ( ( ipconfigUSE_IPv4 != 0 ) && ( ipconfigUSE_IPv6 == 0 ) ) + { + if( xDomain != FREERTOS_AF_INET ) { - if( xDomain != FREERTOS_AF_INET ) - { - xReturn = pdFAIL; - } - - configASSERT( xDomain == FREERTOS_AF_INET ); + xReturn = pdFAIL; } + + configASSERT( xDomain == FREERTOS_AF_INET ); + } #elif ( ( ipconfigUSE_IPv4 == 0 ) && ( ipconfigUSE_IPv6 != 0 ) ) + { + if( xDomain != FREERTOS_AF_INET6 ) { - if( xDomain != FREERTOS_AF_INET6 ) - { - xReturn = pdFAIL; - } - - configASSERT( xDomain == FREERTOS_AF_INET6 ); + xReturn = pdFAIL; } + + configASSERT( xDomain == FREERTOS_AF_INET6 ); + } #else /* if ( ( ipconfigUSE_IPv4 != 0 ) && ( ipconfigUSE_IPv6 == 0 ) ) */ + { + if( ( xDomain != FREERTOS_AF_INET ) && ( xDomain != FREERTOS_AF_INET6 ) ) { - if( ( xDomain != FREERTOS_AF_INET ) && ( xDomain != FREERTOS_AF_INET6 ) ) - { - xReturn = pdFAIL; - } - - configASSERT( ( xDomain == FREERTOS_AF_INET ) || ( xDomain == FREERTOS_AF_INET6 ) ); + xReturn = pdFAIL; } + + configASSERT( ( xDomain == FREERTOS_AF_INET ) || ( xDomain == FREERTOS_AF_INET6 ) ); + } #endif /* if ( ( ipconfigUSE_IPv4 != 0 ) && ( ipconfigUSE_IPv6 == 0 ) ) */ /* Check if the UDP socket-list has been initialised. */ configASSERT( listLIST_IS_INITIALISED( &xBoundUDPSocketsList ) ); #if ( ipconfigUSE_TCP == 1 ) - { - /* Check if the TCP socket-list has been initialised. */ - configASSERT( listLIST_IS_INITIALISED( &xBoundTCPSocketsList ) ); - } + { + /* Check if the TCP socket-list has been initialised. */ + configASSERT( listLIST_IS_INITIALISED( &xBoundTCPSocketsList ) ); + } #endif /* ipconfigUSE_TCP == 1 */ if( xProtocol == FREERTOS_IPPROTO_UDP ) @@ -583,15 +583,15 @@ static BaseType_t prvDetermineSocketSize( BaseType_t xDomain, pxSocket->u.xTCP.uxTxStreamSize = ( size_t ) FreeRTOS_round_up( ipconfigTCP_TX_BUFFER_LENGTH, ipconfigTCP_MSS ); /* Use half of the buffer size of the TCP windows */ #if ( ipconfigUSE_TCP_WIN == 1 ) - { - pxSocket->u.xTCP.uxRxWinSize = FreeRTOS_max_size_t( 1U, ( pxSocket->u.xTCP.uxRxStreamSize / 2U ) / ipconfigTCP_MSS ); - pxSocket->u.xTCP.uxTxWinSize = FreeRTOS_max_size_t( 1U, ( pxSocket->u.xTCP.uxTxStreamSize / 2U ) / ipconfigTCP_MSS ); - } + { + pxSocket->u.xTCP.uxRxWinSize = FreeRTOS_max_size_t( 1U, ( pxSocket->u.xTCP.uxRxStreamSize / 2U ) / ipconfigTCP_MSS ); + pxSocket->u.xTCP.uxTxWinSize = FreeRTOS_max_size_t( 1U, ( pxSocket->u.xTCP.uxTxStreamSize / 2U ) / ipconfigTCP_MSS ); + } #else - { - pxSocket->u.xTCP.uxRxWinSize = 1U; - pxSocket->u.xTCP.uxTxWinSize = 1U; - } + { + pxSocket->u.xTCP.uxRxWinSize = 1U; + pxSocket->u.xTCP.uxTxWinSize = 1U; + } #endif /* The above values are just defaults, and can be overridden by @@ -734,9 +734,9 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, vListInitialise( &( pxSocket->u.xUDP.xWaitingPacketsList ) ); #if ( ipconfigUDP_MAX_RX_PACKETS > 0U ) - { - pxSocket->u.xUDP.uxMaxPackets = ( UBaseType_t ) ipconfigUDP_MAX_RX_PACKETS; - } + { + pxSocket->u.xUDP.uxMaxPackets = ( UBaseType_t ) ipconfigUDP_MAX_RX_PACKETS; + } #endif /* ipconfigUDP_MAX_RX_PACKETS > 0 */ } @@ -987,14 +987,14 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, uxResult = xEventGroupWaitBits( pxSocketSet->xSelectGroup, ( ( EventBits_t ) eSELECT_ALL ), pdFALSE, pdFALSE, xRemainingTime ); #if ( ipconfigSUPPORT_SIGNALS != 0 ) + { + if( ( uxResult & ( ( EventBits_t ) eSELECT_INTR ) ) != 0U ) { - if( ( uxResult & ( ( EventBits_t ) eSELECT_INTR ) ) != 0U ) - { - ( void ) xEventGroupClearBits( pxSocketSet->xSelectGroup, ( EventBits_t ) eSELECT_INTR ); - FreeRTOS_debug_printf( ( "FreeRTOS_select: interrupted\n" ) ); - break; - } + ( void ) xEventGroupClearBits( pxSocketSet->xSelectGroup, ( EventBits_t ) eSELECT_INTR ); + FreeRTOS_debug_printf( ( "FreeRTOS_select: interrupted\n" ) ); + break; } + } #endif /* ipconfigSUPPORT_SIGNALS */ /* Have the IP-task find the socket which had an event */ @@ -1039,19 +1039,19 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, xSelectEvent.eEventType = eSocketSelectEvent; #if ( ipconfigSELECT_USES_NOTIFY != 0 ) - { - xSelectMessage.pxSocketSet = pxSocketSet; - xSelectMessage.xTaskhandle = xTaskGetCurrentTaskHandle(); - xSelectEvent.pvData = &( xSelectMessage ); - } + { + xSelectMessage.pxSocketSet = pxSocketSet; + xSelectMessage.xTaskhandle = xTaskGetCurrentTaskHandle(); + xSelectEvent.pvData = &( xSelectMessage ); + } #else - { - xSelectEvent.pvData = pxSocketSet; + { + xSelectEvent.pvData = pxSocketSet; - /* while the IP-task works on the request, the API will block on - * 'eSELECT_CALL_IP'. So clear it first. */ - ( void ) xEventGroupClearBits( pxSocketSet->xSelectGroup, ( BaseType_t ) eSELECT_CALL_IP ); - } + /* while the IP-task works on the request, the API will block on + * 'eSELECT_CALL_IP'. So clear it first. */ + ( void ) xEventGroupClearBits( pxSocketSet->xSelectGroup, ( BaseType_t ) eSELECT_CALL_IP ); + } #endif /* if ( ipconfigSELECT_USES_NOTIFY != 0 ) */ /* Now send the socket select event */ @@ -1065,13 +1065,13 @@ Socket_t FreeRTOS_socket( BaseType_t xDomain, /* As soon as the IP-task is ready, it will set 'eSELECT_CALL_IP' to * wakeup the calling API */ #if ( ipconfigSELECT_USES_NOTIFY != 0 ) - { - ( void ) ulTaskNotifyTake( pdFALSE, portMAX_DELAY ); - } + { + ( void ) ulTaskNotifyTake( pdFALSE, portMAX_DELAY ); + } #else - { - ( void ) xEventGroupWaitBits( pxSocketSet->xSelectGroup, ( BaseType_t ) eSELECT_CALL_IP, pdTRUE, pdFALSE, portMAX_DELAY ); - } + { + ( void ) xEventGroupWaitBits( pxSocketSet->xSelectGroup, ( BaseType_t ) eSELECT_CALL_IP, pdTRUE, pdFALSE, portMAX_DELAY ); + } #endif } } @@ -1110,11 +1110,11 @@ static NetworkBufferDescriptor_t * prvRecvFromWaitForPacket( FreeRTOS_Socket_t c if( xRemainingTime == ( TickType_t ) 0 ) { #if ( ipconfigSUPPORT_SIGNALS != 0 ) - { - /* Just check for the interrupt flag. */ - xEventBits = xEventGroupWaitBits( pxSocket->xEventGroup, ( EventBits_t ) eSOCKET_INTR, - pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, socketDONT_BLOCK ); - } + { + /* Just check for the interrupt flag. */ + xEventBits = xEventGroupWaitBits( pxSocket->xEventGroup, ( EventBits_t ) eSOCKET_INTR, + pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, socketDONT_BLOCK ); + } #endif /* ipconfigSUPPORT_SIGNALS */ break; } @@ -1138,22 +1138,22 @@ static NetworkBufferDescriptor_t * prvRecvFromWaitForPacket( FreeRTOS_Socket_t c pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, xRemainingTime ); #if ( ipconfigSUPPORT_SIGNALS != 0 ) + { + if( ( xEventBits & ( EventBits_t ) eSOCKET_INTR ) != 0U ) { - if( ( xEventBits & ( EventBits_t ) eSOCKET_INTR ) != 0U ) + if( ( xEventBits & ( EventBits_t ) eSOCKET_RECEIVE ) != 0U ) { - if( ( xEventBits & ( EventBits_t ) eSOCKET_RECEIVE ) != 0U ) - { - /* Shouldn't have cleared the eSOCKET_RECEIVE flag. */ - ( void ) xEventGroupSetBits( pxSocket->xEventGroup, ( EventBits_t ) eSOCKET_RECEIVE ); - } - - break; + /* Shouldn't have cleared the eSOCKET_RECEIVE flag. */ + ( void ) xEventGroupSetBits( pxSocket->xEventGroup, ( EventBits_t ) eSOCKET_RECEIVE ); } + + break; } + } #else /* if ( ipconfigSUPPORT_SIGNALS != 0 ) */ - { - ( void ) xEventBits; - } + { + ( void ) xEventBits; + } #endif /* ipconfigSUPPORT_SIGNALS */ lPacketCount = ( BaseType_t ) listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ); @@ -1445,12 +1445,12 @@ static int32_t prvSendUDPPacket( const FreeRTOS_Socket_t * pxSocket, /* The packet was successfully sent to the IP task. */ lReturn = ( int32_t ) uxTotalDataLength; #if ( ipconfigUSE_CALLBACKS == 1 ) + { + if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleSent ) ) { - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleSent ) ) - { - pxSocket->u.xUDP.pxHandleSent( ( FreeRTOS_Socket_t * ) pxSocket, uxTotalDataLength ); - } + pxSocket->u.xUDP.pxHandleSent( ( FreeRTOS_Socket_t * ) pxSocket, uxTotalDataLength ); } + } #endif /* ipconfigUSE_CALLBACKS */ } else @@ -1855,18 +1855,18 @@ static BaseType_t prvSocketBindAdd( FreeRTOS_Socket_t * pxSocket, * by calling xPortHasUDPSocket() then the IP-task must temporarily * suspend the scheduler to keep the list in a consistent state. */ #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - vTaskSuspendAll(); - } + { + vTaskSuspendAll(); + } #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ /* Add the socket to 'xBoundUDPSocketsList' or 'xBoundTCPSocketsList' */ vListInsertEnd( pxSocketList, &( pxSocket->xBoundSocketListItem ) ); #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - ( void ) xTaskResumeAll(); - } + { + ( void ) xTaskResumeAll(); + } #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ } } @@ -1919,19 +1919,19 @@ BaseType_t vSocketBind( FreeRTOS_Socket_t * pxSocket, ( void ) uxAddressLength; #if ( ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND == 1 ) + { + /* pxAddress will be NULL if sendto() was called on a socket without the + * socket being bound to an address. In this case, automatically allocate + * an address to the socket. There is a small chance that the allocated + * port will already be in use - if that is the case, then the check below + * [pxListFindListItemWithValue()] will result in an error being returned. */ + if( pxAddress == NULL ) { - /* pxAddress will be NULL if sendto() was called on a socket without the - * socket being bound to an address. In this case, automatically allocate - * an address to the socket. There is a small chance that the allocated - * port will already be in use - if that is the case, then the check below - * [pxListFindListItemWithValue()] will result in an error being returned. */ - if( pxAddress == NULL ) - { - pxAddress = &xAddress; - /* Put the port to zero to be assigned later. */ - pxAddress->sin_port = 0U; - } + pxAddress = &xAddress; + /* Put the port to zero to be assigned later. */ + pxAddress->sin_port = 0U; } + } #endif /* ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND == 1 */ /* Sockets must be bound before calling FreeRTOS_sendto() if @@ -2016,25 +2016,25 @@ BaseType_t FreeRTOS_closesocket( Socket_t xSocket ) else { #if ( ipconfigUSE_CALLBACKS == 1 ) - { - #if ( ipconfigUSE_TCP == 1 ) - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - /* Make sure that IP-task won't call the user callback's anymore */ - pxSocket->u.xTCP.pxHandleConnected = NULL; - pxSocket->u.xTCP.pxHandleReceive = NULL; - pxSocket->u.xTCP.pxHandleSent = NULL; - } - else - #endif /* ipconfigUSE_TCP == 1 */ - - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_UDP ) + { + #if ( ipconfigUSE_TCP == 1 ) + if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) { - /* Clear the two UDP handlers. */ - pxSocket->u.xUDP.pxHandleReceive = NULL; - pxSocket->u.xUDP.pxHandleSent = NULL; + /* Make sure that IP-task won't call the user callback's anymore */ + pxSocket->u.xTCP.pxHandleConnected = NULL; + pxSocket->u.xTCP.pxHandleReceive = NULL; + pxSocket->u.xTCP.pxHandleSent = NULL; } + else + #endif /* ipconfigUSE_TCP == 1 */ + + if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_UDP ) + { + /* Clear the two UDP handlers. */ + pxSocket->u.xUDP.pxHandleReceive = NULL; + pxSocket->u.xUDP.pxHandleSent = NULL; } + } #endif /* ipconfigUSE_CALLBACKS == 1 */ /* Let the IP task close the socket to keep it synchronised with the @@ -2074,40 +2074,40 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) NetworkBufferDescriptor_t * pxNetworkBuffer; #if ( ipconfigUSE_TCP == 1 ) + { + /* For TCP: clean up a little more. */ + if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) { - /* For TCP: clean up a little more. */ - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) + #if ( ipconfigUSE_TCP_WIN == 1 ) { - #if ( ipconfigUSE_TCP_WIN == 1 ) - { - if( pxSocket->u.xTCP.pxAckMessage != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); - } - - /* Free the resources which were claimed by the tcpWin member */ - vTCPWindowDestroy( &pxSocket->u.xTCP.xTCPWindow ); - } - #endif /* ipconfigUSE_TCP_WIN */ - - /* Free the input and output streams */ - if( pxSocket->u.xTCP.rxStream != NULL ) + if( pxSocket->u.xTCP.pxAckMessage != NULL ) { - iptraceMEM_STATS_DELETE( pxSocket->u.xTCP.rxStream ); - vPortFreeLarge( pxSocket->u.xTCP.rxStream ); + vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); } - if( pxSocket->u.xTCP.txStream != NULL ) - { - iptraceMEM_STATS_DELETE( pxSocket->u.xTCP.txStream ); - vPortFreeLarge( pxSocket->u.xTCP.txStream ); - } + /* Free the resources which were claimed by the tcpWin member */ + vTCPWindowDestroy( &pxSocket->u.xTCP.xTCPWindow ); + } + #endif /* ipconfigUSE_TCP_WIN */ - /* In case this is a child socket, make sure the child-count of the - * parent socket is decreased. */ - prvTCPSetSocketCount( pxSocket ); + /* Free the input and output streams */ + if( pxSocket->u.xTCP.rxStream != NULL ) + { + iptraceMEM_STATS_DELETE( pxSocket->u.xTCP.rxStream ); + vPortFreeLarge( pxSocket->u.xTCP.rxStream ); + } + + if( pxSocket->u.xTCP.txStream != NULL ) + { + iptraceMEM_STATS_DELETE( pxSocket->u.xTCP.txStream ); + vPortFreeLarge( pxSocket->u.xTCP.txStream ); } + + /* In case this is a child socket, make sure the child-count of the + * parent socket is decreased. */ + prvTCPSetSocketCount( pxSocket ); } + } #endif /* ipconfigUSE_TCP == 1 */ /* Socket must be unbound first, to ensure no more packets are queued on @@ -2118,17 +2118,17 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) * by calling xPortHasUDPSocket(), then the IP-task must temporarily * suspend the scheduler to keep the list in a consistent state. */ #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - vTaskSuspendAll(); - } + { + vTaskSuspendAll(); + } #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ ( void ) uxListRemove( &( pxSocket->xBoundSocketListItem ) ); #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) - { - ( void ) xTaskResumeAll(); - } + { + ( void ) xTaskResumeAll(); + } #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ } @@ -2150,15 +2150,15 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) } #if ( ipconfigUSE_TCP == 1 ) && ( ipconfigHAS_DEBUG_PRINTF != 0 ) + { + if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) { - if( pxSocket->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) - { - FreeRTOS_debug_printf( ( "FreeRTOS_closesocket[%s]: buffers %lu socks %lu\n", - prvSocketProps( pxSocket ), - uxGetNumberOfFreeNetworkBuffers(), - listCURRENT_LIST_LENGTH( &xBoundTCPSocketsList ) ) ); - } + FreeRTOS_debug_printf( ( "FreeRTOS_closesocket[%s]: buffers %lu socks %lu\n", + prvSocketProps( pxSocket ), + uxGetNumberOfFreeNetworkBuffers(), + listCURRENT_LIST_LENGTH( &xBoundTCPSocketsList ) ) ); } + } #endif /* ( ipconfigUSE_TCP == 1 ) && ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ /* And finally, after all resources have been freed, free the socket space */ @@ -2406,29 +2406,29 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) BaseType_t xReturn = 0; #if ( ipconfigUSE_TCP == 1 ) - { - UBaseType_t uxProtocol; - - if( ( lOptionName == FREERTOS_SO_UDP_RECV_HANDLER ) || - ( lOptionName == FREERTOS_SO_UDP_SENT_HANDLER ) ) - { - uxProtocol = ( UBaseType_t ) FREERTOS_IPPROTO_UDP; - } - else - { - uxProtocol = ( UBaseType_t ) FREERTOS_IPPROTO_TCP; - } + { + UBaseType_t uxProtocol; - if( pxSocket->ucProtocol != ( uint8_t ) uxProtocol ) - { - xReturn = -pdFREERTOS_ERRNO_EINVAL; - } + if( ( lOptionName == FREERTOS_SO_UDP_RECV_HANDLER ) || + ( lOptionName == FREERTOS_SO_UDP_SENT_HANDLER ) ) + { + uxProtocol = ( UBaseType_t ) FREERTOS_IPPROTO_UDP; } - #else /* if ( ipconfigUSE_TCP == 1 ) */ + else { - /* No need to check if the socket has the right - * protocol, because only UDP sockets can be created. */ + uxProtocol = ( UBaseType_t ) FREERTOS_IPPROTO_TCP; } + + if( pxSocket->ucProtocol != ( uint8_t ) uxProtocol ) + { + xReturn = -pdFREERTOS_ERRNO_EINVAL; + } + } + #else /* if ( ipconfigUSE_TCP == 1 ) */ + { + /* No need to check if the socket has the right + * protocol, because only UDP sockets can be created. */ + } #endif /* ipconfigUSE_TCP */ if( xReturn == 0 ) @@ -2511,15 +2511,15 @@ void * vSocketClose( FreeRTOS_Socket_t * pxSocket ) } #if ( ipconfigUSE_TCP_WIN == 1 ) - { - pxTCP->uxRxWinSize = ( uint32_t ) pxProps->lRxWinSize; /* Fixed value: size of the TCP reception window */ - pxTCP->uxTxWinSize = ( uint32_t ) pxProps->lTxWinSize; /* Fixed value: size of the TCP transmit window */ - } + { + pxTCP->uxRxWinSize = ( uint32_t ) pxProps->lRxWinSize; /* Fixed value: size of the TCP reception window */ + pxTCP->uxTxWinSize = ( uint32_t ) pxProps->lTxWinSize; /* Fixed value: size of the TCP transmit window */ + } #else - { - pxTCP->uxRxWinSize = 1U; - pxTCP->uxTxWinSize = 1U; - } + { + pxTCP->uxRxWinSize = 1U; + pxTCP->uxTxWinSize = 1U; + } #endif /* In case the socket has already initialised its tcpWin, @@ -3519,38 +3519,38 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) /* _HT_ must work this out, now vSocketWakeUpUser will be called for any important * event or transition */ #if ( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) + { + if( pxSocket->pxUserSemaphore != NULL ) { - if( pxSocket->pxUserSemaphore != NULL ) - { - ( void ) xSemaphoreGive( pxSocket->pxUserSemaphore ); - } + ( void ) xSemaphoreGive( pxSocket->pxUserSemaphore ); } + } #endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */ #if ( ipconfigSOCKET_HAS_USER_WAKE_CALLBACK == 1 ) + { + if( pxSocket->pxUserWakeCallback != NULL ) { - if( pxSocket->pxUserWakeCallback != NULL ) - { - pxSocket->pxUserWakeCallback( pxSocket ); - } + pxSocket->pxUserWakeCallback( pxSocket ); } + } #endif /* ipconfigSOCKET_HAS_USER_WAKE_CALLBACK */ #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) + { + if( pxSocket->pxSocketSet != NULL ) { - if( pxSocket->pxSocketSet != NULL ) - { - EventBits_t xSelectBits = ( pxSocket->xEventBits >> SOCKET_EVENT_BIT_COUNT ) & ( ( EventBits_t ) eSELECT_ALL ); + EventBits_t xSelectBits = ( pxSocket->xEventBits >> SOCKET_EVENT_BIT_COUNT ) & ( ( EventBits_t ) eSELECT_ALL ); - if( xSelectBits != 0U ) - { - pxSocket->xSocketBits |= xSelectBits; - ( void ) xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, xSelectBits ); - } + if( xSelectBits != 0U ) + { + pxSocket->xSocketBits |= xSelectBits; + ( void ) xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, xSelectBits ); } - - pxSocket->xEventBits &= ( EventBits_t ) eSOCKET_ALL; } + + pxSocket->xEventBits &= ( EventBits_t ) eSOCKET_ALL; + } #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ if( ( pxSocket->xEventGroup != NULL ) && ( pxSocket->xEventBits != 0U ) ) @@ -4168,11 +4168,11 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) if( xRemainingTime == ( TickType_t ) 0U ) { #if ( ipconfigSUPPORT_SIGNALS != 0 ) - { - /* Just check for the interrupt flag. */ - xEventBits = xEventGroupWaitBits( pxSocket->xEventGroup, ( EventBits_t ) eSOCKET_INTR, - pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, socketDONT_BLOCK ); - } + { + /* Just check for the interrupt flag. */ + xEventBits = xEventGroupWaitBits( pxSocket->xEventGroup, ( EventBits_t ) eSOCKET_INTR, + pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, socketDONT_BLOCK ); + } #endif /* ipconfigSUPPORT_SIGNALS */ break; } @@ -4200,16 +4200,16 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) ( EventBits_t ) eSOCKET_RECEIVE | ( EventBits_t ) eSOCKET_CLOSED | ( EventBits_t ) eSOCKET_INTR, pdTRUE /*xClearOnExit*/, pdFALSE /*xWaitAllBits*/, xRemainingTime ); #if ( ipconfigSUPPORT_SIGNALS != 0 ) + { + if( ( xEventBits & ( EventBits_t ) eSOCKET_INTR ) != 0U ) { - if( ( xEventBits & ( EventBits_t ) eSOCKET_INTR ) != 0U ) - { - break; - } + break; } + } #else - { - ( void ) xEventBits; - } + { + ( void ) xEventBits; + } #endif /* ipconfigSUPPORT_SIGNALS */ if( pxSocket->u.xTCP.rxStream != NULL ) @@ -5161,12 +5161,12 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) pxSocket->xEventBits |= ( EventBits_t ) eSOCKET_RECEIVE; #if ipconfigSUPPORT_SELECT_FUNCTION == 1 + { + if( ( pxSocket->xSelectBits & ( EventBits_t ) eSELECT_READ ) != 0U ) { - if( ( pxSocket->xSelectBits & ( EventBits_t ) eSELECT_READ ) != 0U ) - { - pxSocket->xEventBits |= ( ( ( EventBits_t ) eSELECT_READ ) << SOCKET_EVENT_BIT_COUNT ); - } + pxSocket->xEventBits |= ( ( ( EventBits_t ) eSELECT_READ ) << SOCKET_EVENT_BIT_COUNT ); } + } #endif } #endif /* ipconfigUSE_TCP */ @@ -5216,38 +5216,38 @@ void vSocketWakeUpUser( FreeRTOS_Socket_t * pxSocket ) if( xResult >= 0 ) { #if ( ipconfigUSE_CALLBACKS == 1 ) + { + if( ( bHasHandler != pdFALSE ) && ( uxStreamBufferGetSize( pxStream ) == 0U ) && ( uxOffset == 0U ) && ( pcData != NULL ) ) { - if( ( bHasHandler != pdFALSE ) && ( uxStreamBufferGetSize( pxStream ) == 0U ) && ( uxOffset == 0U ) && ( pcData != NULL ) ) - { - /* Data can be passed directly to the user because there is - * no data in the RX-stream, it the new data must be stored - * at offset zero, and a buffer 'pcData' is provided. - */ - pucBuffer = pcData; - - /* Zero-copy for call-back: no need to add the bytes to the - * stream, only the pointer will be advanced by uxStreamBufferAdd(). */ - pcData = NULL; - } + /* Data can be passed directly to the user because there is + * no data in the RX-stream, it the new data must be stored + * at offset zero, and a buffer 'pcData' is provided. + */ + pucBuffer = pcData; + + /* Zero-copy for call-back: no need to add the bytes to the + * stream, only the pointer will be advanced by uxStreamBufferAdd(). */ + pcData = NULL; } + } #endif /* ipconfigUSE_CALLBACKS */ xResult = ( int32_t ) uxStreamBufferAdd( pxStream, uxOffset, pcData, ( size_t ) ulByteCount ); #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) + { + if( xResult != ( int32_t ) ulByteCount ) { - if( xResult != ( int32_t ) ulByteCount ) - { - FreeRTOS_debug_printf( ( "lTCPAddRxdata: at %u: %d/%u bytes (tail %u head %u space %u front %u)\n", - ( unsigned int ) uxOffset, - ( int ) xResult, - ( unsigned int ) ulByteCount, - ( unsigned int ) pxStream->uxTail, - ( unsigned int ) pxStream->uxHead, - ( unsigned int ) uxStreamBufferFrontSpace( pxStream ), - ( unsigned int ) pxStream->uxFront ) ); - } + FreeRTOS_debug_printf( ( "lTCPAddRxdata: at %u: %d/%u bytes (tail %u head %u space %u front %u)\n", + ( unsigned int ) uxOffset, + ( int ) xResult, + ( unsigned int ) ulByteCount, + ( unsigned int ) pxStream->uxTail, + ( unsigned int ) pxStream->uxHead, + ( unsigned int ) uxStreamBufferFrontSpace( pxStream ), + ( unsigned int ) pxStream->uxFront ) ); } + } #endif /* ipconfigHAS_DEBUG_PRINTF */ if( uxOffset == 0U ) @@ -6079,12 +6079,12 @@ void * pvSocketGetSocketID( const ConstSocket_t xSocket ) xBitsToClear = ( xBitsToClear & ~xGroupBits ) & ( ( EventBits_t ) eSELECT_ALL ); #if ( ipconfigSUPPORT_SIGNALS != 0 ) - { - /* Maybe the socketset was signalled, but don't - * clear the 'eSELECT_INTR' bit here, as it will be used - * and cleared in FreeRTOS_select(). */ - xBitsToClear &= ~( ( EventBits_t ) eSELECT_INTR ); - } + { + /* Maybe the socketset was signalled, but don't + * clear the 'eSELECT_INTR' bit here, as it will be used + * and cleared in FreeRTOS_select(). */ + xBitsToClear &= ~( ( EventBits_t ) eSELECT_INTR ); + } #endif /* ipconfigSUPPORT_SIGNALS */ if( xBitsToClear != 0U ) diff --git a/source/FreeRTOS_TCP_IP.c b/source/FreeRTOS_TCP_IP.c index 8944065720..eed44bc144 100644 --- a/source/FreeRTOS_TCP_IP.c +++ b/source/FreeRTOS_TCP_IP.c @@ -162,59 +162,59 @@ } #if ( ipconfigUSE_TCP_WIN == 1 ) + { + if( pxSocket->u.xTCP.pxAckMessage != NULL ) { - if( pxSocket->u.xTCP.pxAckMessage != NULL ) + /* The first task of this regular socket check is to send-out delayed + * ACK's. */ + if( pxSocket->u.xTCP.bits.bUserShutdown == pdFALSE_UNSIGNED ) { - /* The first task of this regular socket check is to send-out delayed - * ACK's. */ - if( pxSocket->u.xTCP.bits.bUserShutdown == pdFALSE_UNSIGNED ) + /* Earlier data was received but not yet acknowledged. This + * function is called when the TCP timer for the socket expires, the + * ACK may be sent now. */ + if( pxSocket->u.xTCP.eTCPState != eCLOSED ) { - /* Earlier data was received but not yet acknowledged. This - * function is called when the TCP timer for the socket expires, the - * ACK may be sent now. */ - if( pxSocket->u.xTCP.eTCPState != eCLOSED ) + if( ( xTCPWindowLoggingLevel > 1 ) && ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) ) { - if( ( xTCPWindowLoggingLevel > 1 ) && ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) ) - { - FreeRTOS_debug_printf( ( "Send[%u->%u] del ACK %u SEQ %u (len %u)\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usRemotePort, - ( unsigned ) ( pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber - pxSocket->u.xTCP.xTCPWindow.rx.ulFirstSequenceNumber ), - ( unsigned ) ( pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber - pxSocket->u.xTCP.xTCPWindow.tx.ulFirstSequenceNumber ), - ( unsigned ) ( uxIPHeaderSizeSocket( pxSocket ) + ipSIZE_OF_TCP_HEADER ) ) ); - } - - prvTCPReturnPacket( pxSocket, pxSocket->u.xTCP.pxAckMessage, ( uint32_t ) ( uxIPHeaderSizeSocket( pxSocket ) + ipSIZE_OF_TCP_HEADER ), ipconfigZERO_COPY_TX_DRIVER ); - - #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* The ownership has been passed to the SEND routine, - * clear the pointer to it. */ - pxSocket->u.xTCP.pxAckMessage = NULL; - } - #endif /* ipconfigZERO_COPY_TX_DRIVER */ + FreeRTOS_debug_printf( ( "Send[%u->%u] del ACK %u SEQ %u (len %u)\n", + pxSocket->usLocalPort, + pxSocket->u.xTCP.usRemotePort, + ( unsigned ) ( pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber - pxSocket->u.xTCP.xTCPWindow.rx.ulFirstSequenceNumber ), + ( unsigned ) ( pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber - pxSocket->u.xTCP.xTCPWindow.tx.ulFirstSequenceNumber ), + ( unsigned ) ( uxIPHeaderSizeSocket( pxSocket ) + ipSIZE_OF_TCP_HEADER ) ) ); } - if( prvTCPNextTimeout( pxSocket ) > 1U ) + prvTCPReturnPacket( pxSocket, pxSocket->u.xTCP.pxAckMessage, ( uint32_t ) ( uxIPHeaderSizeSocket( pxSocket ) + ipSIZE_OF_TCP_HEADER ), ipconfigZERO_COPY_TX_DRIVER ); + + #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) { - /* Tell the code below that this function is ready. */ - xReady = pdTRUE; + /* The ownership has been passed to the SEND routine, + * clear the pointer to it. */ + pxSocket->u.xTCP.pxAckMessage = NULL; } - } - else - { - /* The user wants to perform an active shutdown(), skip sending - * the delayed ACK. The function prvTCPSendPacket() will send the - * FIN along with the ACK's. */ + #endif /* ipconfigZERO_COPY_TX_DRIVER */ } - if( pxSocket->u.xTCP.pxAckMessage != NULL ) + if( prvTCPNextTimeout( pxSocket ) > 1U ) { - vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); - pxSocket->u.xTCP.pxAckMessage = NULL; + /* Tell the code below that this function is ready. */ + xReady = pdTRUE; } } + else + { + /* The user wants to perform an active shutdown(), skip sending + * the delayed ACK. The function prvTCPSendPacket() will send the + * FIN along with the ACK's. */ + } + + if( pxSocket->u.xTCP.pxAckMessage != NULL ) + { + vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); + pxSocket->u.xTCP.pxAckMessage = NULL; + } } + } #endif /* ipconfigUSE_TCP_WIN */ if( xReady == pdFALSE ) @@ -230,11 +230,11 @@ ( void ) prvTCPNextTimeout( pxSocket ); #if ( ipconfigTCP_HANG_PROTECTION == 1 ) - { - /* In all (non-connected) states in which keep-alive messages can not be sent - * the anti-hang protocol will close sockets that are 'hanging'. */ - xResult = prvTCPStatusAgeCheck( pxSocket ); - } + { + /* In all (non-connected) states in which keep-alive messages can not be sent + * the anti-hang protocol will close sockets that are 'hanging'. */ + xResult = prvTCPStatusAgeCheck( pxSocket ); + } #endif } @@ -254,18 +254,18 @@ void prvTCPTouchSocket( struct xSOCKET * pxSocket ) { #if ( ipconfigTCP_HANG_PROTECTION == 1 ) - { - pxSocket->u.xTCP.xLastActTime = xTaskGetTickCount(); - } + { + pxSocket->u.xTCP.xLastActTime = xTaskGetTickCount(); + } #endif #if ( ipconfigTCP_KEEP_ALIVE == 1 ) - { - pxSocket->u.xTCP.bits.bWaitKeepAlive = pdFALSE_UNSIGNED; - pxSocket->u.xTCP.bits.bSendKeepAlive = pdFALSE_UNSIGNED; - pxSocket->u.xTCP.ucKeepRepCount = 0U; - pxSocket->u.xTCP.xLastAliveTime = xTaskGetTickCount(); - } + { + pxSocket->u.xTCP.bits.bWaitKeepAlive = pdFALSE_UNSIGNED; + pxSocket->u.xTCP.bits.bSendKeepAlive = pdFALSE_UNSIGNED; + pxSocket->u.xTCP.ucKeepRepCount = 0U; + pxSocket->u.xTCP.xLastAliveTime = xTaskGetTickCount(); + } #endif ( void ) pxSocket; @@ -346,27 +346,27 @@ xParent->xEventBits |= ( EventBits_t ) eSOCKET_ACCEPT; #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) + { + /* Library support FreeRTOS_select(). Receiving a new + * connection is being translated as a READ event. */ + if( ( xParent->xSelectBits & ( ( EventBits_t ) eSELECT_READ ) ) != 0U ) { - /* Library support FreeRTOS_select(). Receiving a new - * connection is being translated as a READ event. */ - if( ( xParent->xSelectBits & ( ( EventBits_t ) eSELECT_READ ) ) != 0U ) - { - xParent->xEventBits |= ( ( EventBits_t ) eSELECT_READ ) << SOCKET_EVENT_BIT_COUNT; - } + xParent->xEventBits |= ( ( EventBits_t ) eSELECT_READ ) << SOCKET_EVENT_BIT_COUNT; } + } #endif #if ( ipconfigUSE_CALLBACKS == 1 ) + { + if( ( ipconfigIS_VALID_PROG_ADDRESS( xParent->u.xTCP.pxHandleConnected ) ) && + ( xParent->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) ) { - if( ( ipconfigIS_VALID_PROG_ADDRESS( xParent->u.xTCP.pxHandleConnected ) ) && - ( xParent->u.xTCP.bits.bReuseSocket == pdFALSE_UNSIGNED ) ) - { - /* The listening socket does not become connected itself, in stead - * a child socket is created. - * Postpone a call the OnConnect event until the end of this function. */ - xConnected = xParent; - } + /* The listening socket does not become connected itself, in stead + * a child socket is created. + * Postpone a call the OnConnect event until the end of this function. */ + xConnected = xParent; } + } #endif } @@ -386,12 +386,12 @@ pxSocket->xEventBits |= ( EventBits_t ) eSOCKET_CONNECT; #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) + { + if( ( pxSocket->xSelectBits & ( ( EventBits_t ) eSELECT_WRITE ) ) != 0U ) { - if( ( pxSocket->xSelectBits & ( ( EventBits_t ) eSELECT_WRITE ) ) != 0U ) - { - pxSocket->xEventBits |= ( ( EventBits_t ) eSELECT_WRITE ) << SOCKET_EVENT_BIT_COUNT; - } + pxSocket->xEventBits |= ( ( EventBits_t ) eSELECT_WRITE ) << SOCKET_EVENT_BIT_COUNT; } + } #endif } } @@ -401,23 +401,23 @@ xParent->xEventBits |= ( EventBits_t ) eSOCKET_CLOSED; #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) + { + if( ( xParent->xSelectBits & ( EventBits_t ) eSELECT_EXCEPT ) != 0U ) { - if( ( xParent->xSelectBits & ( EventBits_t ) eSELECT_EXCEPT ) != 0U ) - { - xParent->xEventBits |= ( ( EventBits_t ) eSELECT_EXCEPT ) << SOCKET_EVENT_BIT_COUNT; - } + xParent->xEventBits |= ( ( EventBits_t ) eSELECT_EXCEPT ) << SOCKET_EVENT_BIT_COUNT; } + } #endif } #if ( ipconfigUSE_CALLBACKS == 1 ) + { + if( ( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleConnected ) ) && ( xConnected == NULL ) ) { - if( ( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleConnected ) ) && ( xConnected == NULL ) ) - { - /* The 'connected' state has changed, call the user handler. */ - xConnected = pxSocket; - } + /* The 'connected' state has changed, call the user handler. */ + xConnected = pxSocket; } + } #endif /* ipconfigUSE_CALLBACKS */ if( prvTCPSocketIsActive( pxSocket->u.xTCP.eTCPState ) == 0 ) @@ -493,57 +493,57 @@ prvTCPTouchSocket( pxSocket ); #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) + { + if( ( xTCPWindowLoggingLevel >= 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) ) ) { - if( ( xTCPWindowLoggingLevel >= 0 ) && ( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) ) ) - { - char pcBuffer[ 40 ]; - - switch( pxSocket->bits.bIsIPv6 ) /* LCOV_EXCL_BR_LINE */ - { - #if ( ipconfigUSE_IPv4 != 0 ) - case pdFALSE_UNSIGNED: - { - uint32_t ulIPAddress = FreeRTOS_ntohl( pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 ); - FreeRTOS_inet_ntop( FREERTOS_AF_INET4, - ( const uint8_t * ) &ulIPAddress, - pcBuffer, - sizeof( pcBuffer ) ); - } - break; - #endif /* ( ipconfigUSE_IPv4 != 0 ) */ - - #if ( ipconfigUSE_IPv6 != 0 ) - case pdTRUE_UNSIGNED: - FreeRTOS_inet_ntop( FREERTOS_AF_INET6, - pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, - pcBuffer, - sizeof( pcBuffer ) ); - break; - #endif /* ( ipconfigUSE_IPv6 != 0 ) */ - - default: /* LCOV_EXCL_LINE */ - /* MISRA 16.4 Compliance */ - break; /* LCOV_EXCL_LINE */ - } + char pcBuffer[ 40 ]; - FreeRTOS_debug_printf( ( "Socket %u -> [%s]:%u State %s->%s\n", - pxSocket->usLocalPort, - pcBuffer, - pxSocket->u.xTCP.usRemotePort, - FreeRTOS_GetTCPStateName( ( UBaseType_t ) xPreviousState ), - FreeRTOS_GetTCPStateName( ( UBaseType_t ) eTCPState ) ) ); + switch( pxSocket->bits.bIsIPv6 ) /* LCOV_EXCL_BR_LINE */ + { + #if ( ipconfigUSE_IPv4 != 0 ) + case pdFALSE_UNSIGNED: + { + uint32_t ulIPAddress = FreeRTOS_ntohl( pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 ); + FreeRTOS_inet_ntop( FREERTOS_AF_INET4, + ( const uint8_t * ) &ulIPAddress, + pcBuffer, + sizeof( pcBuffer ) ); + } + break; + #endif /* ( ipconfigUSE_IPv4 != 0 ) */ + + #if ( ipconfigUSE_IPv6 != 0 ) + case pdTRUE_UNSIGNED: + FreeRTOS_inet_ntop( FREERTOS_AF_INET6, + pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, + pcBuffer, + sizeof( pcBuffer ) ); + break; + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + + default: /* LCOV_EXCL_LINE */ + /* MISRA 16.4 Compliance */ + break; /* LCOV_EXCL_LINE */ } + + FreeRTOS_debug_printf( ( "Socket %u -> [%s]:%u State %s->%s\n", + pxSocket->usLocalPort, + pcBuffer, + pxSocket->u.xTCP.usRemotePort, + FreeRTOS_GetTCPStateName( ( UBaseType_t ) xPreviousState ), + FreeRTOS_GetTCPStateName( ( UBaseType_t ) eTCPState ) ) ); } + } #endif /* ipconfigHAS_DEBUG_PRINTF */ #if ( ipconfigUSE_CALLBACKS == 1 ) + { + if( xConnected != NULL ) { - if( xConnected != NULL ) - { - /* The 'connected' state has changed, call the OnConnect handler of the parent. */ - xConnected->u.xTCP.pxHandleConnected( ( Socket_t ) xConnected, bAfter ); - } + /* The 'connected' state has changed, call the OnConnect handler of the parent. */ + xConnected->u.xTCP.pxHandleConnected( ( Socket_t ) xConnected, bAfter ); } + } #endif if( xParent != NULL ) diff --git a/source/FreeRTOS_TCP_IP_IPv4.c b/source/FreeRTOS_TCP_IP_IPv4.c index ad39ecf687..ced279dcb7 100644 --- a/source/FreeRTOS_TCP_IP_IPv4.c +++ b/source/FreeRTOS_TCP_IP_IPv4.c @@ -184,10 +184,10 @@ BaseType_t xProcessReceivedTCPPacket_IPV4( NetworkBufferDescriptor_t * pxDescrip * connection had gone. Send a RST in order to get a new connect * request. */ #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - FreeRTOS_debug_printf( ( "TCP: Server can't handle flags: %s from %xip:%u to port %u\n", - prvTCPFlagMeaning( ( UBaseType_t ) ucTCPFlags ), ( unsigned ) xRemoteIP.xIPAddress.ulIP_IPv4, usRemotePort, usLocalPort ) ); - } + { + FreeRTOS_debug_printf( ( "TCP: Server can't handle flags: %s from %xip:%u to port %u\n", + prvTCPFlagMeaning( ( UBaseType_t ) ucTCPFlags ), ( unsigned ) xRemoteIP.xIPAddress.ulIP_IPv4, usRemotePort, usLocalPort ) ); + } #endif /* ipconfigHAS_DEBUG_PRINTF */ if( ( ucTCPFlags & tcpTCP_FLAG_RST ) == 0U ) @@ -304,15 +304,15 @@ BaseType_t xProcessReceivedTCPPacket_IPV4( NetworkBufferDescriptor_t * pxDescrip usWindow = FreeRTOS_ntohs( pxProtocolHeaders->xTCPHeader.usWindow ); pxSocket->u.xTCP.ulWindowSize = ( uint32_t ) usWindow; #if ( ipconfigUSE_TCP_WIN == 1 ) + { + /* rfc1323 : The Window field in a SYN (i.e., a or ) + * segment itself is never scaled. */ + if( ( ucTCPFlags & ( uint8_t ) tcpTCP_FLAG_SYN ) == 0U ) { - /* rfc1323 : The Window field in a SYN (i.e., a or ) - * segment itself is never scaled. */ - if( ( ucTCPFlags & ( uint8_t ) tcpTCP_FLAG_SYN ) == 0U ) - { - pxSocket->u.xTCP.ulWindowSize = - ( pxSocket->u.xTCP.ulWindowSize << pxSocket->u.xTCP.ucPeerWinScaleFactor ); - } + pxSocket->u.xTCP.ulWindowSize = + ( pxSocket->u.xTCP.ulWindowSize << pxSocket->u.xTCP.ucPeerWinScaleFactor ); } + } #endif /* ipconfigUSE_TCP_WIN */ /* In prvTCPHandleState() the incoming messages will be handled @@ -322,9 +322,9 @@ BaseType_t xProcessReceivedTCPPacket_IPV4( NetworkBufferDescriptor_t * pxDescrip /* prvTCPHandleState() has sent a message, see if there are more to * be transmitted. */ #if ( ipconfigUSE_TCP_WIN == 1 ) - { - ( void ) prvTCPSendRepeated( pxSocket, &pxNetworkBuffer ); - } + { + ( void ) prvTCPSendRepeated( pxSocket, &pxNetworkBuffer ); + } #endif /* ipconfigUSE_TCP_WIN */ } diff --git a/source/FreeRTOS_TCP_IP_IPv6.c b/source/FreeRTOS_TCP_IP_IPv6.c index 1e0662fe14..ce1ac13049 100644 --- a/source/FreeRTOS_TCP_IP_IPv6.c +++ b/source/FreeRTOS_TCP_IP_IPv6.c @@ -177,10 +177,10 @@ BaseType_t xProcessReceivedTCPPacket_IPV6( NetworkBufferDescriptor_t * pxDescrip * connection had gone. Send a RST in order to get a new connect * request. */ #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - FreeRTOS_debug_printf( ( "TCP: Server can't handle flags: %s from %xip:%u to port %u\n", - prvTCPFlagMeaning( ( UBaseType_t ) ucTCPFlags ), ( unsigned ) xRemoteIP.xIPAddress.ulIP_IPv4, usRemotePort, usLocalPort ) ); - } + { + FreeRTOS_debug_printf( ( "TCP: Server can't handle flags: %s from %xip:%u to port %u\n", + prvTCPFlagMeaning( ( UBaseType_t ) ucTCPFlags ), ( unsigned ) xRemoteIP.xIPAddress.ulIP_IPv4, usRemotePort, usLocalPort ) ); + } #endif /* ipconfigHAS_DEBUG_PRINTF */ if( ( ucTCPFlags & tcpTCP_FLAG_RST ) == 0U ) @@ -297,15 +297,15 @@ BaseType_t xProcessReceivedTCPPacket_IPV6( NetworkBufferDescriptor_t * pxDescrip usWindow = FreeRTOS_ntohs( pxProtocolHeaders->xTCPHeader.usWindow ); pxSocket->u.xTCP.ulWindowSize = ( uint32_t ) usWindow; #if ( ipconfigUSE_TCP_WIN == 1 ) + { + /* rfc1323 : The Window field in a SYN (i.e., a or ) + * segment itself is never scaled. */ + if( ( ucTCPFlags & ( uint8_t ) tcpTCP_FLAG_SYN ) == 0U ) { - /* rfc1323 : The Window field in a SYN (i.e., a or ) - * segment itself is never scaled. */ - if( ( ucTCPFlags & ( uint8_t ) tcpTCP_FLAG_SYN ) == 0U ) - { - pxSocket->u.xTCP.ulWindowSize = - ( pxSocket->u.xTCP.ulWindowSize << pxSocket->u.xTCP.ucPeerWinScaleFactor ); - } + pxSocket->u.xTCP.ulWindowSize = + ( pxSocket->u.xTCP.ulWindowSize << pxSocket->u.xTCP.ucPeerWinScaleFactor ); } + } #endif /* ipconfigUSE_TCP_WIN */ /* In prvTCPHandleState() the incoming messages will be handled @@ -315,9 +315,9 @@ BaseType_t xProcessReceivedTCPPacket_IPV6( NetworkBufferDescriptor_t * pxDescrip /* prvTCPHandleState() has sent a message, see if there are more to * be transmitted. */ #if ( ipconfigUSE_TCP_WIN == 1 ) - { - ( void ) prvTCPSendRepeated( pxSocket, &pxNetworkBuffer ); - } + { + ( void ) prvTCPSendRepeated( pxSocket, &pxNetworkBuffer ); + } #endif /* ipconfigUSE_TCP_WIN */ } diff --git a/source/FreeRTOS_TCP_Reception.c b/source/FreeRTOS_TCP_Reception.c index 1401cf2f9a..3b06cd32a8 100644 --- a/source/FreeRTOS_TCP_Reception.c +++ b/source/FreeRTOS_TCP_Reception.c @@ -324,26 +324,26 @@ else { #if ( ipconfigUSE_TCP_WIN == 1 ) + { + /* Selective ACK: the peer has received a packet but it is missing + * earlier packets. At least this packet does not need retransmission + * anymore. ulTCPWindowTxSack( ) takes care of this administration. + */ + if( pucPtr[ 0U ] == tcpTCP_OPT_SACK_A ) { - /* Selective ACK: the peer has received a packet but it is missing - * earlier packets. At least this packet does not need retransmission - * anymore. ulTCPWindowTxSack( ) takes care of this administration. - */ - if( pucPtr[ 0U ] == tcpTCP_OPT_SACK_A ) - { - ucLen = ( uint8_t ) ( ucLen - 2U ); - lIndex += 2; + ucLen = ( uint8_t ) ( ucLen - 2U ); + lIndex += 2; - while( ucLen >= ( uint8_t ) 8U ) - { - prvReadSackOption( pucPtr, ( size_t ) lIndex, pxSocket ); - lIndex += 8; - ucLen = ( uint8_t ) ( ucLen - 8U ); - } - - /* ucLen should be 0 by now. */ + while( ucLen >= ( uint8_t ) 8U ) + { + prvReadSackOption( pucPtr, ( size_t ) lIndex, pxSocket ); + lIndex += 8; + ucLen = ( uint8_t ) ( ucLen - 8U ); } + + /* ucLen should be 0 by now. */ } + } #endif /* ipconfigUSE_TCP_WIN == 1 */ lIndex += ( int32_t ) ucLen; @@ -387,26 +387,26 @@ pxSocket->xEventBits |= ( EventBits_t ) eSOCKET_SEND; #if ipconfigSUPPORT_SELECT_FUNCTION == 1 + { + if( ( pxSocket->xSelectBits & ( EventBits_t ) eSELECT_WRITE ) != 0U ) { - if( ( pxSocket->xSelectBits & ( EventBits_t ) eSELECT_WRITE ) != 0U ) - { - /* The field 'xEventBits' is used to store regular socket events - * (at most 8), as well as 'select events', which will be left-shifted. - */ - pxSocket->xEventBits |= ( ( EventBits_t ) eSELECT_WRITE ) << SOCKET_EVENT_BIT_COUNT; - } + /* The field 'xEventBits' is used to store regular socket events + * (at most 8), as well as 'select events', which will be left-shifted. + */ + pxSocket->xEventBits |= ( ( EventBits_t ) eSELECT_WRITE ) << SOCKET_EVENT_BIT_COUNT; } + } #endif /* In case the socket owner has installed an OnSent handler, * call it now. */ #if ( ipconfigUSE_CALLBACKS == 1 ) + { + if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleSent ) ) { - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleSent ) ) - { - pxSocket->u.xTCP.pxHandleSent( pxSocket, ulCount ); - } + pxSocket->u.xTCP.pxHandleSent( pxSocket, ulCount ); } + } #endif /* ipconfigUSE_CALLBACKS == 1 */ } } @@ -627,16 +627,16 @@ /* After a missing packet has come in, higher packets may be passed to * the user. */ #if ( ipconfigUSE_TCP_WIN == 1 ) + { + /* Now lTCPAddRxdata() will move the rxHead pointer forward + * so data becomes available to the user immediately + * In case the low-water mark is reached, bLowWater will be set. */ + if( ( xResult == 0 ) && ( pxTCPWindow->ulUserDataLength > 0U ) ) { - /* Now lTCPAddRxdata() will move the rxHead pointer forward - * so data becomes available to the user immediately - * In case the low-water mark is reached, bLowWater will be set. */ - if( ( xResult == 0 ) && ( pxTCPWindow->ulUserDataLength > 0U ) ) - { - ( void ) lTCPAddRxdata( pxSocket, 0U, NULL, pxTCPWindow->ulUserDataLength ); - pxTCPWindow->ulUserDataLength = 0; - } + ( void ) lTCPAddRxdata( pxSocket, 0U, NULL, pxTCPWindow->ulUserDataLength ); + pxTCPWindow->ulUserDataLength = 0; } + } #endif /* ipconfigUSE_TCP_WIN */ } else diff --git a/source/FreeRTOS_TCP_State_Handling.c b/source/FreeRTOS_TCP_State_Handling.c index 22bd54cd13..a897eae011 100644 --- a/source/FreeRTOS_TCP_State_Handling.c +++ b/source/FreeRTOS_TCP_State_Handling.c @@ -186,13 +186,13 @@ if( xAge > ( ( TickType_t ) ipconfigTCP_HANG_PROTECTION_TIME * ( TickType_t ) configTICK_RATE_HZ ) ) { #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - FreeRTOS_debug_printf( ( "Inactive socket closed: port %u rem %xip:%u status %s\n", - pxSocket->usLocalPort, - ( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4, - pxSocket->u.xTCP.usRemotePort, - FreeRTOS_GetTCPStateName( ( UBaseType_t ) pxSocket->u.xTCP.eTCPState ) ) ); - } + { + FreeRTOS_debug_printf( ( "Inactive socket closed: port %u rem %xip:%u status %s\n", + pxSocket->usLocalPort, + ( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4, + pxSocket->u.xTCP.usRemotePort, + FreeRTOS_GetTCPStateName( ( UBaseType_t ) pxSocket->u.xTCP.eTCPState ) ) ); + } #endif /* ipconfigHAS_DEBUG_PRINTF */ /* Move to eCLOSE_WAIT, user may close the socket. */ @@ -436,19 +436,19 @@ pxTCPWindow->ulOurSequenceNumber = pxTCPWindow->tx.ulFirstSequenceNumber + 1U; #if ( ipconfigUSE_TCP_WIN == 1 ) - { - char pcBuffer[ 40 ]; /* Space to print an IP-address. */ - ( void ) FreeRTOS_inet_ntop( ( pxSocket->bits.bIsIPv6 != 0U ) ? FREERTOS_AF_INET6 : FREERTOS_AF_INET, - ( void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, - pcBuffer, - sizeof( pcBuffer ) ); - FreeRTOS_debug_printf( ( "TCP: %s %u => %s port %u set ESTAB (scaling %u)\n", - ( pxSocket->u.xTCP.eTCPState == ( uint8_t ) eCONNECT_SYN ) ? "active" : "passive", - pxSocket->usLocalPort, + { + char pcBuffer[ 40 ]; /* Space to print an IP-address. */ + ( void ) FreeRTOS_inet_ntop( ( pxSocket->bits.bIsIPv6 != 0U ) ? FREERTOS_AF_INET6 : FREERTOS_AF_INET, + ( void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, pcBuffer, - pxSocket->u.xTCP.usRemotePort, - ( unsigned ) pxSocket->u.xTCP.bits.bWinScaling ) ); - } + sizeof( pcBuffer ) ); + FreeRTOS_debug_printf( ( "TCP: %s %u => %s port %u set ESTAB (scaling %u)\n", + ( pxSocket->u.xTCP.eTCPState == ( uint8_t ) eCONNECT_SYN ) ? "active" : "passive", + pxSocket->usLocalPort, + pcBuffer, + pxSocket->u.xTCP.usRemotePort, + ( unsigned ) pxSocket->u.xTCP.bits.bWinScaling ) ); + } #endif /* ipconfigUSE_TCP_WIN */ if( ( pxSocket->u.xTCP.eTCPState == eCONNECT_SYN ) || ( ulReceiveLength != 0U ) ) @@ -461,15 +461,15 @@ } #if ( ipconfigUSE_TCP_WIN != 0 ) + { + if( pxSocket->u.xTCP.bits.bWinScaling == pdFALSE_UNSIGNED ) { - if( pxSocket->u.xTCP.bits.bWinScaling == pdFALSE_UNSIGNED ) - { - /* The other party did not send a scaling factor. - * A shifting factor in this side must be canceled. */ - pxSocket->u.xTCP.ucMyWinScaleFactor = 0; - pxSocket->u.xTCP.ucPeerWinScaleFactor = 0; - } + /* The other party did not send a scaling factor. + * A shifting factor in this side must be canceled. */ + pxSocket->u.xTCP.ucMyWinScaleFactor = 0; + pxSocket->u.xTCP.ucPeerWinScaleFactor = 0; } + } #endif /* ipconfigUSE_TCP_WIN */ /* This was the third step of connecting: SYN, SYN+ACK, ACK so now the @@ -520,10 +520,10 @@ usWindow = FreeRTOS_ntohs( pxTCPHeader->usWindow ); pxSocket->u.xTCP.ulWindowSize = ( uint32_t ) usWindow; #if ( ipconfigUSE_TCP_WIN != 0 ) - { - pxSocket->u.xTCP.ulWindowSize = - ( pxSocket->u.xTCP.ulWindowSize << pxSocket->u.xTCP.ucPeerWinScaleFactor ); - } + { + pxSocket->u.xTCP.ulWindowSize = + ( pxSocket->u.xTCP.ulWindowSize << pxSocket->u.xTCP.ucPeerWinScaleFactor ); + } #endif /* ipconfigUSE_TCP_WIN */ if( ( ucTCPFlags & ( uint8_t ) tcpTCP_FLAG_ACK ) == 0U ) @@ -550,23 +550,23 @@ pxSocket->xEventBits |= ( EventBits_t ) eSOCKET_SEND; #if ipconfigSUPPORT_SELECT_FUNCTION == 1 + { + if( ( pxSocket->xSelectBits & ( ( EventBits_t ) eSELECT_WRITE ) ) != 0U ) { - if( ( pxSocket->xSelectBits & ( ( EventBits_t ) eSELECT_WRITE ) ) != 0U ) - { - pxSocket->xEventBits |= ( ( EventBits_t ) eSELECT_WRITE ) << SOCKET_EVENT_BIT_COUNT; - } + pxSocket->xEventBits |= ( ( EventBits_t ) eSELECT_WRITE ) << SOCKET_EVENT_BIT_COUNT; } + } #endif /* In case the socket owner has installed an OnSent handler, * call it now. */ #if ( ipconfigUSE_CALLBACKS == 1 ) + { + if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleSent ) ) { - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xTCP.pxHandleSent ) ) - { - pxSocket->u.xTCP.pxHandleSent( ( Socket_t ) pxSocket, ulCount ); - } + pxSocket->u.xTCP.pxHandleSent( ( Socket_t ) pxSocket, ulCount ); } + } #endif /* ipconfigUSE_CALLBACKS == 1 */ } } @@ -963,30 +963,30 @@ pxNewSocket->u.xTCP.uxTxWinSize = pxSocket->u.xTCP.uxTxWinSize; #if ( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) - { - pxNewSocket->pxUserSemaphore = pxSocket->pxUserSemaphore; - } + { + pxNewSocket->pxUserSemaphore = pxSocket->pxUserSemaphore; + } #endif /* ipconfigSOCKET_HAS_USER_SEMAPHORE */ #if ( ipconfigUSE_CALLBACKS == 1 ) - { - /* In case call-backs are used, copy them from parent to child. */ - pxNewSocket->u.xTCP.pxHandleConnected = pxSocket->u.xTCP.pxHandleConnected; - pxNewSocket->u.xTCP.pxHandleReceive = pxSocket->u.xTCP.pxHandleReceive; - pxNewSocket->u.xTCP.pxHandleSent = pxSocket->u.xTCP.pxHandleSent; - } + { + /* In case call-backs are used, copy them from parent to child. */ + pxNewSocket->u.xTCP.pxHandleConnected = pxSocket->u.xTCP.pxHandleConnected; + pxNewSocket->u.xTCP.pxHandleReceive = pxSocket->u.xTCP.pxHandleReceive; + pxNewSocket->u.xTCP.pxHandleSent = pxSocket->u.xTCP.pxHandleSent; + } #endif /* ipconfigUSE_CALLBACKS */ #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) + { + /* Child socket of listening sockets will inherit the Socket Set + * Otherwise the owner has no chance of including it into the set. */ + if( pxSocket->pxSocketSet != NULL ) { - /* Child socket of listening sockets will inherit the Socket Set - * Otherwise the owner has no chance of including it into the set. */ - if( pxSocket->pxSocketSet != NULL ) - { - pxNewSocket->pxSocketSet = pxSocket->pxSocketSet; - pxNewSocket->xSelectBits = pxSocket->xSelectBits | ( ( EventBits_t ) eSELECT_READ ) | ( ( EventBits_t ) eSELECT_EXCEPT ); - } + pxNewSocket->pxSocketSet = pxSocket->pxSocketSet; + pxNewSocket->xSelectBits = pxSocket->xSelectBits | ( ( EventBits_t ) eSELECT_READ ) | ( ( EventBits_t ) eSELECT_EXCEPT ); } + } #endif /* ipconfigSUPPORT_SELECT_FUNCTION */ /* And bind it to the same local port as its parent. */ @@ -994,30 +994,30 @@ xAddress.sin_port = FreeRTOS_htons( pxSocket->usLocalPort ); #if ( ipconfigTCP_HANG_PROTECTION == 1 ) - { - /* Only when there is anti-hanging protection, a socket may become an - * orphan temporarily. Once this socket is really connected, the owner of - * the server socket will be notified. */ - - /* When bPassQueued is true, the socket is an orphan until it gets - * connected. */ - pxNewSocket->u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED; - pxNewSocket->u.xTCP.pxPeerSocket = pxSocket; - } + { + /* Only when there is anti-hanging protection, a socket may become an + * orphan temporarily. Once this socket is really connected, the owner of + * the server socket will be notified. */ + + /* When bPassQueued is true, the socket is an orphan until it gets + * connected. */ + pxNewSocket->u.xTCP.bits.bPassQueued = pdTRUE_UNSIGNED; + pxNewSocket->u.xTCP.pxPeerSocket = pxSocket; + } #else - { - /* A reference to the new socket may be stored and the socket is marked - * as 'passable'. */ + { + /* A reference to the new socket may be stored and the socket is marked + * as 'passable'. */ - /* When bPassAccept is true, this socket may be returned in a call to - * accept(). */ - pxNewSocket->u.xTCP.bits.bPassAccept = pdTRUE_UNSIGNED; + /* When bPassAccept is true, this socket may be returned in a call to + * accept(). */ + pxNewSocket->u.xTCP.bits.bPassAccept = pdTRUE_UNSIGNED; - if( pxSocket->u.xTCP.pxPeerSocket == NULL ) - { - pxSocket->u.xTCP.pxPeerSocket = pxNewSocket; - } + if( pxSocket->u.xTCP.pxPeerSocket == NULL ) + { + pxSocket->u.xTCP.pxPeerSocket = pxNewSocket; } + } #endif /* if ( ipconfigTCP_HANG_PROTECTION == 1 ) */ pxSocket->u.xTCP.usChildCount++; diff --git a/source/FreeRTOS_TCP_Transmission.c b/source/FreeRTOS_TCP_Transmission.c index 63d76fecd8..99864f24c2 100644 --- a/source/FreeRTOS_TCP_Transmission.c +++ b/source/FreeRTOS_TCP_Transmission.c @@ -218,9 +218,9 @@ prvTCPReturnPacket( pxSocket, *ppxNetworkBuffer, ( uint32_t ) xSendLength, ipconfigZERO_COPY_TX_DRIVER ); #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - *ppxNetworkBuffer = NULL; - } + { + *ppxNetworkBuffer = NULL; + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ lResult += xSendLength; @@ -349,13 +349,13 @@ /* Avoid overflow of the 16-bit win field. */ #if ( ipconfigUSE_TCP_WIN != 0 ) - { - ulWinSize = ( ulSpace >> pxSocket->u.xTCP.ucMyWinScaleFactor ); - } + { + ulWinSize = ( ulSpace >> pxSocket->u.xTCP.ucMyWinScaleFactor ); + } #else - { - ulWinSize = ulSpace; - } + { + ulWinSize = ulSpace; + } #endif if( ulWinSize > 0xfffcU ) @@ -578,29 +578,29 @@ pxTCPHeader->ucOptdata[ 3 ] = ( uint8_t ) ( usMSS & 0xffU ); #if ( ipconfigUSE_TCP_WIN != 0 ) - { - pxSocket->u.xTCP.ucMyWinScaleFactor = prvWinScaleFactor( pxSocket ); + { + pxSocket->u.xTCP.ucMyWinScaleFactor = prvWinScaleFactor( pxSocket ); - pxTCPHeader->ucOptdata[ 4 ] = tcpTCP_OPT_NOOP; - pxTCPHeader->ucOptdata[ 5 ] = ( uint8_t ) ( tcpTCP_OPT_WSOPT ); - pxTCPHeader->ucOptdata[ 6 ] = ( uint8_t ) ( tcpTCP_OPT_WSOPT_LEN ); - pxTCPHeader->ucOptdata[ 7 ] = ( uint8_t ) pxSocket->u.xTCP.ucMyWinScaleFactor; - uxOptionsLength = 8U; - } + pxTCPHeader->ucOptdata[ 4 ] = tcpTCP_OPT_NOOP; + pxTCPHeader->ucOptdata[ 5 ] = ( uint8_t ) ( tcpTCP_OPT_WSOPT ); + pxTCPHeader->ucOptdata[ 6 ] = ( uint8_t ) ( tcpTCP_OPT_WSOPT_LEN ); + pxTCPHeader->ucOptdata[ 7 ] = ( uint8_t ) pxSocket->u.xTCP.ucMyWinScaleFactor; + uxOptionsLength = 8U; + } #else - { - uxOptionsLength = 4U; - } + { + uxOptionsLength = 4U; + } #endif /* if ( ipconfigUSE_TCP_WIN != 0 ) */ #if ( ipconfigUSE_TCP_WIN != 0 ) - { - pxTCPHeader->ucOptdata[ uxOptionsLength ] = tcpTCP_OPT_NOOP; - pxTCPHeader->ucOptdata[ uxOptionsLength + 1U ] = tcpTCP_OPT_NOOP; - pxTCPHeader->ucOptdata[ uxOptionsLength + 2U ] = tcpTCP_OPT_SACK_P; /* 4: Sack-Permitted Option. */ - pxTCPHeader->ucOptdata[ uxOptionsLength + 3U ] = 2U; /* 2: length of this option. */ - uxOptionsLength += 4U; - } + { + pxTCPHeader->ucOptdata[ uxOptionsLength ] = tcpTCP_OPT_NOOP; + pxTCPHeader->ucOptdata[ uxOptionsLength + 1U ] = tcpTCP_OPT_NOOP; + pxTCPHeader->ucOptdata[ uxOptionsLength + 2U ] = tcpTCP_OPT_SACK_P; /* 4: Sack-Permitted Option. */ + pxTCPHeader->ucOptdata[ uxOptionsLength + 3U ] = 2U; /* 2: length of this option. */ + uxOptionsLength += 4U; + } #endif /* ipconfigUSE_TCP_WIN == 0 */ return uxOptionsLength; /* bytes, not words. */ } @@ -881,13 +881,13 @@ ulDataGot = ( uint32_t ) uxStreamBufferGet( pxSocket->u.xTCP.txStream, uxOffset, pucSendData, ( size_t ) lDataLen, pdTRUE ); #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) + { + if( ulDataGot != ( uint32_t ) lDataLen ) { - if( ulDataGot != ( uint32_t ) lDataLen ) - { - FreeRTOS_debug_printf( ( "uxStreamBufferGet: pos %d offs %u only %u != %d\n", - ( int ) lStreamPos, ( unsigned ) uxOffset, ( unsigned ) ulDataGot, ( int ) lDataLen ) ); - } + FreeRTOS_debug_printf( ( "uxStreamBufferGet: pos %d offs %u only %u != %d\n", + ( int ) lStreamPos, ( unsigned ) uxOffset, ( unsigned ) ulDataGot, ( int ) lDataLen ) ); } + } #endif /* If the owner of the socket requests a closure, add the FIN @@ -899,17 +899,17 @@ if( ulDistance == ulDataGot ) { #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - /* the order of volatile accesses is undefined - * so such workaround */ - size_t uxHead = pxSocket->u.xTCP.txStream->uxHead; - size_t uxMid = pxSocket->u.xTCP.txStream->uxMid; - size_t uxTail = pxSocket->u.xTCP.txStream->uxTail; - - FreeRTOS_debug_printf( ( "CheckClose %u <= %u (%u <= %u <= %u)\n", - ( unsigned ) ulDataGot, ( unsigned ) ulDistance, - ( unsigned ) uxTail, ( unsigned ) uxMid, ( unsigned ) uxHead ) ); - } + { + /* the order of volatile accesses is undefined + * so such workaround */ + size_t uxHead = pxSocket->u.xTCP.txStream->uxHead; + size_t uxMid = pxSocket->u.xTCP.txStream->uxMid; + size_t uxTail = pxSocket->u.xTCP.txStream->uxTail; + + FreeRTOS_debug_printf( ( "CheckClose %u <= %u (%u <= %u <= %u)\n", + ( unsigned ) ulDataGot, ( unsigned ) ulDistance, + ( unsigned ) uxTail, ( unsigned ) uxMid, ( unsigned ) uxHead ) ); + } #endif /* if ( ipconfigHAS_DEBUG_PRINTF == 1 ) */ /* Although the socket sends a FIN, it will stay in @@ -943,47 +943,47 @@ } #if ( ipconfigTCP_KEEP_ALIVE != 0 ) + { + if( pxSocket->u.xTCP.ucKeepRepCount > 3U ) /*_RB_ Magic number. */ { - if( pxSocket->u.xTCP.ucKeepRepCount > 3U ) /*_RB_ Magic number. */ + FreeRTOS_debug_printf( ( "keep-alive: giving up %xip:%u\n", + ( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4, /* IP address of remote machine. */ + pxSocket->u.xTCP.usRemotePort ) ); /* Port on remote machine. */ + vTCPStateChange( pxSocket, eCLOSE_WAIT ); + lDataLen = -1; + } + + if( ( lDataLen == 0 ) && ( pxSocket->u.xTCP.bits.bWinChange == pdFALSE_UNSIGNED ) ) + { + /* If there is no data to be sent, and no window-update message, + * we might want to send a keep-alive message. */ + TickType_t xAge = xTaskGetTickCount() - pxSocket->u.xTCP.xLastAliveTime; + TickType_t xMax; + xMax = ( ( TickType_t ) ipconfigTCP_KEEP_ALIVE_INTERVAL * ( TickType_t ) configTICK_RATE_HZ ); + + if( pxSocket->u.xTCP.ucKeepRepCount != 0U ) { - FreeRTOS_debug_printf( ( "keep-alive: giving up %xip:%u\n", - ( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4, /* IP address of remote machine. */ - pxSocket->u.xTCP.usRemotePort ) ); /* Port on remote machine. */ - vTCPStateChange( pxSocket, eCLOSE_WAIT ); - lDataLen = -1; + xMax = 3U * configTICK_RATE_HZ; } - if( ( lDataLen == 0 ) && ( pxSocket->u.xTCP.bits.bWinChange == pdFALSE_UNSIGNED ) ) + if( xAge > xMax ) { - /* If there is no data to be sent, and no window-update message, - * we might want to send a keep-alive message. */ - TickType_t xAge = xTaskGetTickCount() - pxSocket->u.xTCP.xLastAliveTime; - TickType_t xMax; - xMax = ( ( TickType_t ) ipconfigTCP_KEEP_ALIVE_INTERVAL * ( TickType_t ) configTICK_RATE_HZ ); + pxSocket->u.xTCP.xLastAliveTime = xTaskGetTickCount(); - if( pxSocket->u.xTCP.ucKeepRepCount != 0U ) + if( xTCPWindowLoggingLevel != 0 ) { - xMax = 3U * configTICK_RATE_HZ; + FreeRTOS_debug_printf( ( "keep-alive: %xip:%u count %u\n", + ( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4, + pxSocket->u.xTCP.usRemotePort, + pxSocket->u.xTCP.ucKeepRepCount ) ); } - if( xAge > xMax ) - { - pxSocket->u.xTCP.xLastAliveTime = xTaskGetTickCount(); - - if( xTCPWindowLoggingLevel != 0 ) - { - FreeRTOS_debug_printf( ( "keep-alive: %xip:%u count %u\n", - ( unsigned ) pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4, - pxSocket->u.xTCP.usRemotePort, - pxSocket->u.xTCP.ucKeepRepCount ) ); - } - - pxSocket->u.xTCP.bits.bSendKeepAlive = pdTRUE_UNSIGNED; - pxSocket->u.xTCP.usTimeout = ( ( uint16_t ) pdMS_TO_TICKS( 2500U ) ); - pxSocket->u.xTCP.ucKeepRepCount++; - } + pxSocket->u.xTCP.bits.bSendKeepAlive = pdTRUE_UNSIGNED; + pxSocket->u.xTCP.usTimeout = ( ( uint16_t ) pdMS_TO_TICKS( 2500U ) ); + pxSocket->u.xTCP.ucKeepRepCount++; } } + } #endif /* ipconfigTCP_KEEP_ALIVE */ } @@ -1185,88 +1185,88 @@ lRxSpace = ( int32_t ) ulRxBufferSpace; #if ipconfigUSE_TCP_WIN == 1 + { + /* An ACK may be delayed if the peer has space for at least 2 x MSS. */ + lMinLength = ( ( int32_t ) 2 ) * ( ( int32_t ) pxSocket->u.xTCP.usMSS ); + + /* In case we're receiving data continuously, we might postpone sending + * an ACK to gain performance. */ + /* lint e9007 is OK because 'uxIPHeaderSizeSocket()' has no side-effects. */ + if( ( ulReceiveLength > 0U ) && /* Data was sent to this socket. */ + ( lRxSpace >= lMinLength ) && /* There is Rx space for more data. */ + ( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED ) && /* Not in a closure phase. */ + ( xSendLength == xSizeWithoutData ) && /* No Tx data or options to be sent. */ + ( pxSocket->u.xTCP.eTCPState == eESTABLISHED ) && /* Connection established. */ + ( pxTCPHeader->ucTCPFlags == tcpTCP_FLAG_ACK ) ) /* There are no other flags than an ACK. */ { - /* An ACK may be delayed if the peer has space for at least 2 x MSS. */ - lMinLength = ( ( int32_t ) 2 ) * ( ( int32_t ) pxSocket->u.xTCP.usMSS ); - - /* In case we're receiving data continuously, we might postpone sending - * an ACK to gain performance. */ - /* lint e9007 is OK because 'uxIPHeaderSizeSocket()' has no side-effects. */ - if( ( ulReceiveLength > 0U ) && /* Data was sent to this socket. */ - ( lRxSpace >= lMinLength ) && /* There is Rx space for more data. */ - ( pxSocket->u.xTCP.bits.bFinSent == pdFALSE_UNSIGNED ) && /* Not in a closure phase. */ - ( xSendLength == xSizeWithoutData ) && /* No Tx data or options to be sent. */ - ( pxSocket->u.xTCP.eTCPState == eESTABLISHED ) && /* Connection established. */ - ( pxTCPHeader->ucTCPFlags == tcpTCP_FLAG_ACK ) ) /* There are no other flags than an ACK. */ - { - uint32_t ulCurMSS = ( uint32_t ) pxSocket->u.xTCP.usMSS; - - if( pxSocket->u.xTCP.pxAckMessage != *ppxNetworkBuffer ) - { - /* There was still a delayed in queue, delete it. */ - if( pxSocket->u.xTCP.pxAckMessage != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); - } + uint32_t ulCurMSS = ( uint32_t ) pxSocket->u.xTCP.usMSS; - pxSocket->u.xTCP.pxAckMessage = *ppxNetworkBuffer; - } - - if( ulReceiveLength < ulCurMSS ) /* Received a small message. */ - { - pxSocket->u.xTCP.usTimeout = ( uint16_t ) tcpDELAYED_ACK_SHORT_DELAY_MS; - } - else + if( pxSocket->u.xTCP.pxAckMessage != *ppxNetworkBuffer ) + { + /* There was still a delayed in queue, delete it. */ + if( pxSocket->u.xTCP.pxAckMessage != NULL ) { - /* Normally a delayed ACK should wait 200 ms for a next incoming - * packet. Only wait 20 ms here to gain performance. A slow ACK - * for full-size message. */ - pxSocket->u.xTCP.usTimeout = ( uint16_t ) pdMS_TO_TICKS( tcpDELAYED_ACK_LONGER_DELAY_MS ); - - if( pxSocket->u.xTCP.usTimeout < 1U ) /* LCOV_EXCL_BR_LINE, the second branch will never be hit */ - { - pxSocket->u.xTCP.usTimeout = 1U; /* LCOV_EXCL_LINE, this line will not be reached */ - } + vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); } - if( ( xTCPWindowLoggingLevel > 1 ) && ( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) ) ) - { - FreeRTOS_debug_printf( ( "Send[%u->%u] del ACK %u SEQ %u (len %u) tmout %u d %d\n", - pxSocket->usLocalPort, - pxSocket->u.xTCP.usRemotePort, - ( unsigned ) ( pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ), - ( unsigned ) ( pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ), - ( unsigned ) xSendLength, - pxSocket->u.xTCP.usTimeout, - ( int ) lRxSpace ) ); - } + pxSocket->u.xTCP.pxAckMessage = *ppxNetworkBuffer; + } - *ppxNetworkBuffer = NULL; - xSendLength = 0; + if( ulReceiveLength < ulCurMSS ) /* Received a small message. */ + { + pxSocket->u.xTCP.usTimeout = ( uint16_t ) tcpDELAYED_ACK_SHORT_DELAY_MS; } - else if( pxSocket->u.xTCP.pxAckMessage != NULL ) + else { - /* As an ACK is not being delayed, remove any earlier delayed ACK - * message. */ - if( pxSocket->u.xTCP.pxAckMessage != *ppxNetworkBuffer ) + /* Normally a delayed ACK should wait 200 ms for a next incoming + * packet. Only wait 20 ms here to gain performance. A slow ACK + * for full-size message. */ + pxSocket->u.xTCP.usTimeout = ( uint16_t ) pdMS_TO_TICKS( tcpDELAYED_ACK_LONGER_DELAY_MS ); + + if( pxSocket->u.xTCP.usTimeout < 1U ) /* LCOV_EXCL_BR_LINE, the second branch will never be hit */ { - vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); + pxSocket->u.xTCP.usTimeout = 1U; /* LCOV_EXCL_LINE, this line will not be reached */ } + } - pxSocket->u.xTCP.pxAckMessage = NULL; + if( ( xTCPWindowLoggingLevel > 1 ) && ( ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) ) ) + { + FreeRTOS_debug_printf( ( "Send[%u->%u] del ACK %u SEQ %u (len %u) tmout %u d %d\n", + pxSocket->usLocalPort, + pxSocket->u.xTCP.usRemotePort, + ( unsigned ) ( pxTCPWindow->rx.ulCurrentSequenceNumber - pxTCPWindow->rx.ulFirstSequenceNumber ), + ( unsigned ) ( pxSocket->u.xTCP.xTCPWindow.ulOurSequenceNumber - pxTCPWindow->tx.ulFirstSequenceNumber ), + ( unsigned ) xSendLength, + pxSocket->u.xTCP.usTimeout, + ( int ) lRxSpace ) ); } - else + + *ppxNetworkBuffer = NULL; + xSendLength = 0; + } + else if( pxSocket->u.xTCP.pxAckMessage != NULL ) + { + /* As an ACK is not being delayed, remove any earlier delayed ACK + * message. */ + if( pxSocket->u.xTCP.pxAckMessage != *ppxNetworkBuffer ) { - /* The ack will not be postponed, and there was no stored ack ( in 'pxAckMessage' ). */ + vReleaseNetworkBufferAndDescriptor( pxSocket->u.xTCP.pxAckMessage ); } + + pxSocket->u.xTCP.pxAckMessage = NULL; } - #else /* if ipconfigUSE_TCP_WIN == 1 */ + else { - /* Remove compiler warnings. */ - ( void ) ulReceiveLength; - ( void ) pxTCPHeader; - ( void ) lRxSpace; + /* The ack will not be postponed, and there was no stored ack ( in 'pxAckMessage' ). */ } + } + #else /* if ipconfigUSE_TCP_WIN == 1 */ + { + /* Remove compiler warnings. */ + ( void ) ulReceiveLength; + ( void ) pxTCPHeader; + ( void ) lRxSpace; + } #endif /* ipconfigUSE_TCP_WIN */ if( xSendLength != 0 ) @@ -1285,10 +1285,10 @@ * ipconfigZERO_COPY_TX_DRIVER. */ prvTCPReturnPacket( pxSocket, *ppxNetworkBuffer, ( uint32_t ) xSendLength, ipconfigZERO_COPY_TX_DRIVER ); #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* The driver has taken ownership of the Network Buffer. */ - *ppxNetworkBuffer = NULL; - } + { + /* The driver has taken ownership of the Network Buffer. */ + *ppxNetworkBuffer = NULL; + } #endif } @@ -1315,26 +1315,26 @@ ( void ) pxNetworkBuffer; ( void ) ucTCPFlags; #else + { + switch( uxIPHeaderSizePacket( pxNetworkBuffer ) ) { - switch( uxIPHeaderSizePacket( pxNetworkBuffer ) ) - { - #if ( ipconfigUSE_IPv4 != 0 ) - case ipSIZE_OF_IPv4_HEADER: - xReturn = prvTCPSendSpecialPktHelper_IPV4( pxNetworkBuffer, ucTCPFlags ); - break; - #endif /* ( ipconfigUSE_IPv4 != 0 ) */ - - #if ( ipconfigUSE_IPv6 != 0 ) - case ipSIZE_OF_IPv6_HEADER: - xReturn = prvTCPSendSpecialPktHelper_IPV6( pxNetworkBuffer, ucTCPFlags ); - break; - #endif /* ( ipconfigUSE_IPv6 != 0 ) */ - - default: - xReturn = pdFAIL; + #if ( ipconfigUSE_IPv4 != 0 ) + case ipSIZE_OF_IPv4_HEADER: + xReturn = prvTCPSendSpecialPktHelper_IPV4( pxNetworkBuffer, ucTCPFlags ); break; - } + #endif /* ( ipconfigUSE_IPv4 != 0 ) */ + + #if ( ipconfigUSE_IPv6 != 0 ) + case ipSIZE_OF_IPv6_HEADER: + xReturn = prvTCPSendSpecialPktHelper_IPV6( pxNetworkBuffer, ucTCPFlags ); + break; + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + + default: + xReturn = pdFAIL; + break; } + } #endif /* !ipconfigIGNORE_UNKNOWN_PACKETS */ /* The packet was not consumed. */ diff --git a/source/FreeRTOS_TCP_Transmission_IPv4.c b/source/FreeRTOS_TCP_Transmission_IPv4.c index 4a3877fbdd..850fe7b231 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv4.c +++ b/source/FreeRTOS_TCP_Transmission_IPv4.c @@ -110,9 +110,9 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, ( void ) memset( &xTempBuffer, 0, sizeof( xTempBuffer ) ); #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - pxNetworkBuffer->pxNextBuffer = NULL; - } + { + pxNetworkBuffer->pxNextBuffer = NULL; + } #endif pxNetworkBuffer->pucEthernetBuffer = pxSocket->u.xTCP.xPacket.u.ucLastPacket; pxNetworkBuffer->xDataLength = sizeof( pxSocket->u.xTCP.xPacket.u.ucLastPacket ); @@ -120,23 +120,23 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, } #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) + { + if( xDoRelease == pdFALSE ) { - if( xDoRelease == pdFALSE ) - { - /* A zero-copy network driver wants to pass the packet buffer - * to DMA, so a new buffer must be created. */ - pxNetworkBuffer = pxDuplicateNetworkBufferWithDescriptor( pxNetworkBuffer, ( size_t ) pxNetworkBuffer->xDataLength ); + /* A zero-copy network driver wants to pass the packet buffer + * to DMA, so a new buffer must be created. */ + pxNetworkBuffer = pxDuplicateNetworkBufferWithDescriptor( pxNetworkBuffer, ( size_t ) pxNetworkBuffer->xDataLength ); - if( pxNetworkBuffer != NULL ) - { - xDoRelease = pdTRUE; - } - else - { - FreeRTOS_debug_printf( ( "prvTCPReturnPacket: duplicate failed\n" ) ); - } + if( pxNetworkBuffer != NULL ) + { + xDoRelease = pdTRUE; + } + else + { + FreeRTOS_debug_printf( ( "prvTCPReturnPacket: duplicate failed\n" ) ); } } + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ /* MISRA Ref 11.3.1 [Misaligned access] */ @@ -209,15 +209,15 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, #endif #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the IP header checksum, in case the driver won't do that. */ - pxIPHeader->usHeaderChecksum = 0x00U; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), uxIPHeaderSize ); - pxIPHeader->usHeaderChecksum = ( uint16_t ) ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); + { + /* calculate the IP header checksum, in case the driver won't do that. */ + pxIPHeader->usHeaderChecksum = 0x00U; + pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), uxIPHeaderSize ); + pxIPHeader->usHeaderChecksum = ( uint16_t ) ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - /* calculate the TCP checksum for an outgoing packet. */ - ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxTCPPacket, pxNetworkBuffer->xDataLength, pdTRUE ); - } + /* calculate the TCP checksum for an outgoing packet. */ + ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxTCPPacket, pxNetworkBuffer->xDataLength, pdTRUE ); + } #endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) */ vFlip_16( pxProtocolHeaders->xTCPHeader.usSourcePort, pxProtocolHeaders->xTCPHeader.usDestinationPort ); @@ -227,9 +227,9 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, pxNetworkBuffer->xDataLength += ipSIZE_OF_ETH_HEADER; #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - pxNetworkBuffer->pxNextBuffer = NULL; - } + { + pxNetworkBuffer->pxNextBuffer = NULL; + } #endif pvCopySource = &pxEthernetHeader->xSourceAddress; @@ -262,19 +262,19 @@ void prvTCPReturnPacket_IPV4( FreeRTOS_Socket_t * pxSocket, ( void ) memcpy( pvCopyDest, pvCopySource, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); #if ( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) + { + if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; - - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; - } + BaseType_t xIndex; - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; + for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) + { + pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; } + + pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; } + } #endif /* if( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) */ /* Send! */ @@ -331,10 +331,10 @@ BaseType_t prvTCPPrepareConnect_IPV4( FreeRTOS_Socket_t * pxSocket ) uint32_t ulInitialSequenceNumber = 0; #if ( ipconfigHAS_PRINTF != 0 ) - { - /* Only necessary for nicer logging. */ - ( void ) memset( xEthAddress.ucBytes, 0, sizeof( xEthAddress.ucBytes ) ); - } + { + /* Only necessary for nicer logging. */ + ( void ) memset( xEthAddress.ucBytes, 0, sizeof( xEthAddress.ucBytes ) ); + } #endif /* ipconfigHAS_PRINTF != 0 */ ulRemoteIP = FreeRTOS_htonl( pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4 ); @@ -474,32 +474,32 @@ BaseType_t prvTCPSendSpecialPktHelper_IPV4( NetworkBufferDescriptor_t * pxNetwor ( void ) pxNetworkBuffer; ( void ) ucTCPFlags; #else - { - /* Map the ethernet buffer onto the TCPPacket_t struct for easy access to the fields. */ + { + /* Map the ethernet buffer onto the TCPPacket_t struct for easy access to the fields. */ - /* MISRA Ref 11.3.1 [Misaligned access] */ + /* MISRA Ref 11.3.1 [Misaligned access] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - TCPPacket_t * pxTCPPacket = ( ( TCPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); - const uint32_t ulSendLength = - ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER; /* Plus 0 options. */ + /* coverity[misra_c_2012_rule_11_3_violation] */ + TCPPacket_t * pxTCPPacket = ( ( TCPPacket_t * ) pxNetworkBuffer->pucEthernetBuffer ); + const uint32_t ulSendLength = + ipSIZE_OF_IPv4_HEADER + ipSIZE_OF_TCP_HEADER; /* Plus 0 options. */ - uint8_t ucFlagsReceived = pxTCPPacket->xTCPHeader.ucTCPFlags; - pxTCPPacket->xTCPHeader.ucTCPFlags = ucTCPFlags; - pxTCPPacket->xTCPHeader.ucTCPOffset = ( ipSIZE_OF_TCP_HEADER ) << 2; + uint8_t ucFlagsReceived = pxTCPPacket->xTCPHeader.ucTCPFlags; + pxTCPPacket->xTCPHeader.ucTCPFlags = ucTCPFlags; + pxTCPPacket->xTCPHeader.ucTCPOffset = ( ipSIZE_OF_TCP_HEADER ) << 2; - if( ( ucFlagsReceived & tcpTCP_FLAG_SYN ) != 0U ) - { - /* A synchronize packet is received. It counts as 1 pseudo byte of data, - * so increase the variable with 1. Before sending a reply, the values of - * 'ulSequenceNumber' and 'ulAckNr' will be swapped. */ - uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulSequenceNumber ); - ulSequenceNumber++; - pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( ulSequenceNumber ); - } - - prvTCPReturnPacket( NULL, pxNetworkBuffer, ulSendLength, pdFALSE ); + if( ( ucFlagsReceived & tcpTCP_FLAG_SYN ) != 0U ) + { + /* A synchronize packet is received. It counts as 1 pseudo byte of data, + * so increase the variable with 1. Before sending a reply, the values of + * 'ulSequenceNumber' and 'ulAckNr' will be swapped. */ + uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulSequenceNumber ); + ulSequenceNumber++; + pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( ulSequenceNumber ); } + + prvTCPReturnPacket( NULL, pxNetworkBuffer, ulSendLength, pdFALSE ); + } #endif /* !ipconfigIGNORE_UNKNOWN_PACKETS */ /* The packet was not consumed. */ diff --git a/source/FreeRTOS_TCP_Transmission_IPv6.c b/source/FreeRTOS_TCP_Transmission_IPv6.c index 1f091a0151..e2afb837e4 100644 --- a/source/FreeRTOS_TCP_Transmission_IPv6.c +++ b/source/FreeRTOS_TCP_Transmission_IPv6.c @@ -118,9 +118,9 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, ( void ) memset( &xTempBuffer, 0, sizeof( xTempBuffer ) ); #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - pxNetworkBuffer->pxNextBuffer = NULL; - } + { + pxNetworkBuffer->pxNextBuffer = NULL; + } #endif pxNetworkBuffer->pucEthernetBuffer = pxSocket->u.xTCP.xPacket.u.ucLastPacket; pxNetworkBuffer->xDataLength = sizeof( pxSocket->u.xTCP.xPacket.u.ucLastPacket ); @@ -128,23 +128,23 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, } #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) + { + if( xDoRelease == pdFALSE ) { - if( xDoRelease == pdFALSE ) - { - /* A zero-copy network driver wants to pass the packet buffer - * to DMA, so a new buffer must be created. */ - pxNetworkBuffer = pxDuplicateNetworkBufferWithDescriptor( pxNetworkBuffer, ( size_t ) pxNetworkBuffer->xDataLength ); + /* A zero-copy network driver wants to pass the packet buffer + * to DMA, so a new buffer must be created. */ + pxNetworkBuffer = pxDuplicateNetworkBufferWithDescriptor( pxNetworkBuffer, ( size_t ) pxNetworkBuffer->xDataLength ); - if( pxNetworkBuffer != NULL ) - { - xDoRelease = pdTRUE; - } - else - { - FreeRTOS_debug_printf( ( "prvTCPReturnPacket: duplicate failed\n" ) ); - } + if( pxNetworkBuffer != NULL ) + { + xDoRelease = pdTRUE; + } + else + { + FreeRTOS_debug_printf( ( "prvTCPReturnPacket: duplicate failed\n" ) ); } } + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ configASSERT( pxNetworkBuffer->pucEthernetBuffer != NULL ); @@ -210,11 +210,11 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, pxIPHeader->usPayloadLength = FreeRTOS_htons( ulLen - sizeof( IPHeader_IPv6_t ) ); #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - /* calculate the TCP checksum for an outgoing packet. */ - uint32_t ulTotalLength = ulLen + ipSIZE_OF_ETH_HEADER; - ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxNetworkBuffer->pucEthernetBuffer, ulTotalLength, pdTRUE ); - } + { + /* calculate the TCP checksum for an outgoing packet. */ + uint32_t ulTotalLength = ulLen + ipSIZE_OF_ETH_HEADER; + ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxNetworkBuffer->pucEthernetBuffer, ulTotalLength, pdTRUE ); + } #endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 */ vFlip_16( pxProtocolHeaders->xTCPHeader.usSourcePort, pxProtocolHeaders->xTCPHeader.usDestinationPort ); @@ -224,9 +224,9 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, pxNetworkBuffer->xDataLength += ipSIZE_OF_ETH_HEADER; #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - pxNetworkBuffer->pxNextBuffer = NULL; - } + { + pxNetworkBuffer->pxNextBuffer = NULL; + } #endif ( void ) memcpy( xDestinationIPAddress.ucBytes, pxIPHeader->xDestinationAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); @@ -258,19 +258,19 @@ void prvTCPReturnPacket_IPV6( FreeRTOS_Socket_t * pxSocket, ( void ) memcpy( pvCopyDest, pvCopySource, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); #if ( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) + { + if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; - - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; - } + BaseType_t xIndex; - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; + for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) + { + pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; } + + pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; } + } #endif /* if( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) */ /* Send! */ @@ -327,10 +327,10 @@ BaseType_t prvTCPPrepareConnect_IPV6( FreeRTOS_Socket_t * pxSocket ) NetworkEndPoint_t * pxEndPoint = NULL; #if ( ipconfigHAS_PRINTF != 0 ) - { - /* Only necessary for nicer logging. */ - ( void ) memset( xEthAddress.ucBytes, 0, sizeof( xEthAddress.ucBytes ) ); - } + { + /* Only necessary for nicer logging. */ + ( void ) memset( xEthAddress.ucBytes, 0, sizeof( xEthAddress.ucBytes ) ); + } #endif /* ipconfigHAS_PRINTF != 0 */ ( void ) memset( xRemoteIP.xIP_IPv6.ucBytes, 0, ipSIZE_OF_IPv6_ADDRESS ); @@ -497,32 +497,32 @@ BaseType_t prvTCPSendSpecialPktHelper_IPV6( NetworkBufferDescriptor_t * pxNetwor ( void ) pxNetworkBuffer; ( void ) ucTCPFlags; #else - { - /* Map the ethernet buffer onto the TCPPacket_t struct for easy access to the fields. */ - - /* MISRA Ref 11.3.1 [Misaligned access] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ - /* coverity[misra_c_2012_rule_11_3_violation] */ - TCPPacket_IPv6_t * pxTCPPacket = ( ( TCPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); - const uint32_t ulSendLength = - ipSIZE_OF_IPv6_HEADER + ipSIZE_OF_TCP_HEADER; /* Plus 0 options. */ + { + /* Map the ethernet buffer onto the TCPPacket_t struct for easy access to the fields. */ - uint8_t ucFlagsReceived = pxTCPPacket->xTCPHeader.ucTCPFlags; - pxTCPPacket->xTCPHeader.ucTCPFlags = ucTCPFlags; - pxTCPPacket->xTCPHeader.ucTCPOffset = ( ipSIZE_OF_TCP_HEADER ) << 2; + /* MISRA Ref 11.3.1 [Misaligned access] */ + /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-113 */ + /* coverity[misra_c_2012_rule_11_3_violation] */ + TCPPacket_IPv6_t * pxTCPPacket = ( ( TCPPacket_IPv6_t * ) pxNetworkBuffer->pucEthernetBuffer ); + const uint32_t ulSendLength = + ipSIZE_OF_IPv6_HEADER + ipSIZE_OF_TCP_HEADER; /* Plus 0 options. */ - if( ( ucFlagsReceived & tcpTCP_FLAG_SYN ) != 0U ) - { - /* A synchronize packet is received. It counts as 1 pseudo byte of data, - * so increase the variable with 1. Before sending a reply, the values of - * 'ulSequenceNumber' and 'ulAckNr' will be swapped. */ - uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulSequenceNumber ); - ulSequenceNumber++; - pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( ulSequenceNumber ); - } + uint8_t ucFlagsReceived = pxTCPPacket->xTCPHeader.ucTCPFlags; + pxTCPPacket->xTCPHeader.ucTCPFlags = ucTCPFlags; + pxTCPPacket->xTCPHeader.ucTCPOffset = ( ipSIZE_OF_TCP_HEADER ) << 2; - prvTCPReturnPacket( NULL, pxNetworkBuffer, ulSendLength, pdFALSE ); + if( ( ucFlagsReceived & tcpTCP_FLAG_SYN ) != 0U ) + { + /* A synchronize packet is received. It counts as 1 pseudo byte of data, + * so increase the variable with 1. Before sending a reply, the values of + * 'ulSequenceNumber' and 'ulAckNr' will be swapped. */ + uint32_t ulSequenceNumber = FreeRTOS_ntohl( pxTCPPacket->xTCPHeader.ulSequenceNumber ); + ulSequenceNumber++; + pxTCPPacket->xTCPHeader.ulSequenceNumber = FreeRTOS_htonl( ulSequenceNumber ); } + + prvTCPReturnPacket( NULL, pxNetworkBuffer, ulSendLength, pdFALSE ); + } #endif /* !ipconfigIGNORE_UNKNOWN_PACKETS */ /* The packet was not consumed. */ diff --git a/source/FreeRTOS_TCP_Utils_IPv4.c b/source/FreeRTOS_TCP_Utils_IPv4.c index b80c0a3660..40760fd4ed 100644 --- a/source/FreeRTOS_TCP_Utils_IPv4.c +++ b/source/FreeRTOS_TCP_Utils_IPv4.c @@ -64,13 +64,13 @@ void prvSocketSetMSS_IPV4( FreeRTOS_Socket_t * pxSocket ) { /* Do not allow MSS smaller than tcpMINIMUM_SEGMENT_LENGTH. */ #if ( ipconfigTCP_MSS >= tcpMINIMUM_SEGMENT_LENGTH ) - { - ulMSS = ipconfigTCP_MSS; - } + { + ulMSS = ipconfigTCP_MSS; + } #else - { - ulMSS = tcpMINIMUM_SEGMENT_LENGTH; - } + { + ulMSS = tcpMINIMUM_SEGMENT_LENGTH; + } #endif /* Check if the remote IP-address belongs to the same netmask. */ diff --git a/source/FreeRTOS_TCP_Utils_IPv6.c b/source/FreeRTOS_TCP_Utils_IPv6.c index 2c78b50561..7e3b528940 100644 --- a/source/FreeRTOS_TCP_Utils_IPv6.c +++ b/source/FreeRTOS_TCP_Utils_IPv6.c @@ -84,13 +84,13 @@ void prvSocketSetMSS_IPV6( FreeRTOS_Socket_t * pxSocket ) size_t uxDifference = ipSIZE_OF_IPv6_HEADER - ipSIZE_OF_IPv4_HEADER; /* Do not allow MSS smaller than tcpMINIMUM_SEGMENT_LENGTH. */ #if ( ipconfigTCP_MSS >= tcpMINIMUM_SEGMENT_LENGTH ) - { - ulMSS = ipconfigTCP_MSS; - } + { + ulMSS = ipconfigTCP_MSS; + } #else - { - ulMSS = tcpMINIMUM_SEGMENT_LENGTH; - } + { + ulMSS = tcpMINIMUM_SEGMENT_LENGTH; + } #endif ulMSS = ( uint32_t ) ( ulMSS - uxDifference ); @@ -105,10 +105,10 @@ void prvSocketSetMSS_IPV6( FreeRTOS_Socket_t * pxSocket ) } #if ( ipconfigHAS_DEBUG_PRINTF == 1 ) - { - ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cIPv6Address, sizeof( cIPv6Address ) ); - FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cIPv6Address, pxSocket->u.xTCP.usRemotePort ) ); - } + { + ( void ) FreeRTOS_inet_ntop( FREERTOS_AF_INET6, ( const void * ) pxSocket->u.xTCP.xRemoteIP.xIP_IPv6.ucBytes, cIPv6Address, sizeof( cIPv6Address ) ); + FreeRTOS_debug_printf( ( "prvSocketSetMSS: %u bytes for %s ip port %u\n", ( unsigned ) ulMSS, cIPv6Address, pxSocket->u.xTCP.usRemotePort ) ); + } #endif pxSocket->u.xTCP.usMSS = ( uint16_t ) ulMSS; diff --git a/source/FreeRTOS_TCP_WIN.c b/source/FreeRTOS_TCP_WIN.c index 8296657984..c570fe611a 100644 --- a/source/FreeRTOS_TCP_WIN.c +++ b/source/FreeRTOS_TCP_WIN.c @@ -446,10 +446,10 @@ * nulled already. Set the owner to a segment descriptor. */ #if ( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 1 ) - { - vListInitialiseItem( &( xTCPSegments[ xIndex ].xSegmentItem ) ); - vListInitialiseItem( &( xTCPSegments[ xIndex ].xQueueItem ) ); - } + { + vListInitialiseItem( &( xTCPSegments[ xIndex ].xSegmentItem ) ); + vListInitialiseItem( &( xTCPSegments[ xIndex ].xQueueItem ) ); + } #endif listSET_LIST_ITEM_OWNER( &( xTCPSegments[ xIndex ].xSegmentItem ), ( void * ) &( xTCPSegments[ xIndex ] ) ); @@ -571,15 +571,15 @@ pxSegment->lDataLength = lCount; pxSegment->ulSequenceNumber = ulSequenceNumber; #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - static UBaseType_t xLowestLength = ipconfigTCP_WIN_SEG_COUNT; - UBaseType_t xLength = listCURRENT_LIST_LENGTH( &xSegmentList ); + { + static UBaseType_t xLowestLength = ipconfigTCP_WIN_SEG_COUNT; + UBaseType_t xLength = listCURRENT_LIST_LENGTH( &xSegmentList ); - if( xLowestLength > xLength ) - { - xLowestLength = xLength; - } + if( xLowestLength > xLength ) + { + xLowestLength = xLength; } + } #endif /* ipconfigHAS_DEBUG_PRINTF */ } @@ -787,19 +787,19 @@ /* Create and initialize a window. */ #if ( ipconfigUSE_TCP_WIN == 1 ) + { + if( xTCPSegments == NULL ) { - if( xTCPSegments == NULL ) - { - ( void ) prvCreateSectors(); - } + ( void ) prvCreateSectors(); + } - vListInitialise( &( pxWindow->xTxSegments ) ); - vListInitialise( &( pxWindow->xRxSegments ) ); + vListInitialise( &( pxWindow->xTxSegments ) ); + vListInitialise( &( pxWindow->xRxSegments ) ); - vListInitialise( &( pxWindow->xPriorityQueue ) ); /* Priority queue: segments which must be sent immediately */ - vListInitialise( &( pxWindow->xTxQueue ) ); /* Transmit queue: segments queued for transmission */ - vListInitialise( &( pxWindow->xWaitQueue ) ); /* Waiting queue: outstanding segments */ - } + vListInitialise( &( pxWindow->xPriorityQueue ) ); /* Priority queue: segments which must be sent immediately */ + vListInitialise( &( pxWindow->xTxQueue ) ); /* Transmit queue: segments queued for transmission */ + vListInitialise( &( pxWindow->xWaitQueue ) ); /* Waiting queue: outstanding segments */ + } #endif /* ipconfigUSE_TCP_WIN == 1 */ if( xTCPWindowLoggingLevel != 0 ) @@ -848,9 +848,9 @@ } #if ( ipconfigUSE_TCP_WIN == 0 ) - { - pxWindow->xTxSegment.lMaxLength = ( int32_t ) pxWindow->usMSS; - } + { + pxWindow->xTxSegment.lMaxLength = ( int32_t ) pxWindow->usMSS; + } #endif /* ipconfigUSE_TCP_WIN == 1 */ /*Start with a timeout of 2 * 500 ms (1 sec). */ @@ -896,7 +896,7 @@ xTCPSegments = NULL; } } - #endif /* ipconfgiUSE_TCP_WIN == 1 */ + #endif /* ipconfigUSE_TCP_WIN == 1 */ /*-----------------------------------------------------------*/ /*============================================================================= @@ -983,7 +983,7 @@ return pxBest; } - #endif /* ipconfgiUSE_TCP_WIN == 1 */ + #endif /* ipconfigUSE_TCP_WIN == 1 */ /*-----------------------------------------------------------*/ #if ( ipconfigUSE_TCP_WIN == 1 ) @@ -1059,7 +1059,7 @@ pxWindow->rx.ulCurrentSequenceNumber = ulCurrentSequenceNumber; } - #endif /* ipconfgiUSE_TCP_WIN == 1 */ + #endif /* ipconfigUSE_TCP_WIN == 1 */ /*-----------------------------------------------------------*/ #if ( ipconfigUSE_TCP_WIN == 1 ) @@ -1170,7 +1170,7 @@ return lReturn; } - #endif /* ipconfgiUSE_TCP_WIN == 1 */ + #endif /* ipconfigUSE_TCP_WIN == 1 */ /*-----------------------------------------------------------*/ #if ( ipconfigUSE_TCP_WIN == 1 ) @@ -1300,7 +1300,7 @@ return lReturn; } - #endif /* ipconfgiUSE_TCP_WIN == 1 */ + #endif /* ipconfigUSE_TCP_WIN == 1 */ /*-----------------------------------------------------------*/ /*============================================================================= @@ -2010,16 +2010,16 @@ * AAAAAAA BBBBBBB << acked * aaaaaaa aaaa << sent */ #if ( ipconfigHAS_DEBUG_PRINTF != 0 ) - { - uint32_t ulFirstSeq = pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber; - FreeRTOS_debug_printf( ( "prvTCPWindowTxCheckAck[%u.%u]: %u - %u Partial sequence number %u - %u\n", - pxWindow->usPeerPortNumber, - pxWindow->usOurPortNumber, - ( unsigned ) ( ulFirstSeq - pxWindow->tx.ulFirstSequenceNumber ), - ( unsigned ) ( ulLast - pxWindow->tx.ulFirstSequenceNumber ), - ( unsigned ) ulFirstSeq, - ( unsigned ) ( ulFirstSeq + ulDataLength ) ) ); - } + { + uint32_t ulFirstSeq = pxSegment->ulSequenceNumber - pxWindow->tx.ulFirstSequenceNumber; + FreeRTOS_debug_printf( ( "prvTCPWindowTxCheckAck[%u.%u]: %u - %u Partial sequence number %u - %u\n", + pxWindow->usPeerPortNumber, + pxWindow->usOurPortNumber, + ( unsigned ) ( ulFirstSeq - pxWindow->tx.ulFirstSequenceNumber ), + ( unsigned ) ( ulLast - pxWindow->tx.ulFirstSequenceNumber ), + ( unsigned ) ulFirstSeq, + ( unsigned ) ( ulFirstSeq + ulDataLength ) ) ); + } #endif /* ( ipconfigHAS_DEBUG_PRINTF != 0 ) */ break; diff --git a/source/FreeRTOS_UDP_IPv4.c b/source/FreeRTOS_UDP_IPv4.c index 8b545616c0..9562ea90d8 100644 --- a/source/FreeRTOS_UDP_IPv4.c +++ b/source/FreeRTOS_UDP_IPv4.c @@ -160,9 +160,9 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor /* Save options now, as they will be overwritten by memcpy */ #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - ucSocketOptions = pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ]; - } + { + ucSocketOptions = pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ]; + } #endif /* @@ -210,40 +210,40 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor #endif #if ( ipconfigUSE_LLMNR == 1 ) + { + /* LLMNR messages are typically used on a LAN and they're + * not supposed to cross routers */ + if( pxNetworkBuffer->xIPAddress.ulIP_IPv4 == ipLLMNR_IP_ADDR ) { - /* LLMNR messages are typically used on a LAN and they're - * not supposed to cross routers */ - if( pxNetworkBuffer->xIPAddress.ulIP_IPv4 == ipLLMNR_IP_ADDR ) - { - pxIPHeader->ucTimeToLive = 0x01; - } + pxIPHeader->ucTimeToLive = 0x01; } + } #endif #if ( ipconfigUSE_MDNS == 1 ) + { + /* mDNS messages have a hop-count of 255, see RFC 6762, section 11. */ + if( pxNetworkBuffer->xIPAddress.ulIP_IPv4 == ipMDNS_IP_ADDRESS ) { - /* mDNS messages have a hop-count of 255, see RFC 6762, section 11. */ - if( pxNetworkBuffer->xIPAddress.ulIP_IPv4 == ipMDNS_IP_ADDRESS ) - { - pxIPHeader->ucTimeToLive = 0xffU; - } + pxIPHeader->ucTimeToLive = 0xffU; } + } #endif #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - pxIPHeader->usHeaderChecksum = 0U; - pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), uxIPHeaderSizePacket( pxNetworkBuffer ) ); - pxIPHeader->usHeaderChecksum = ( uint16_t ) ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); + { + pxIPHeader->usHeaderChecksum = 0U; + pxIPHeader->usHeaderChecksum = usGenerateChecksum( 0U, ( uint8_t * ) &( pxIPHeader->ucVersionHeaderLength ), uxIPHeaderSizePacket( pxNetworkBuffer ) ); + pxIPHeader->usHeaderChecksum = ( uint16_t ) ~FreeRTOS_htons( pxIPHeader->usHeaderChecksum ); - if( ( ucSocketOptions & ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT ) != 0U ) - { - ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxUDPPacket, pxNetworkBuffer->xDataLength, pdTRUE ); - } - else - { - pxUDPPacket->xUDPHeader.usChecksum = 0U; - } + if( ( ucSocketOptions & ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT ) != 0U ) + { + ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxUDPPacket, pxNetworkBuffer->xDataLength, pdTRUE ); } + else + { + pxUDPPacket->xUDPHeader.usChecksum = 0U; + } + } #endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) */ } else if( eReturned == eARPCacheMiss ) @@ -294,19 +294,19 @@ void vProcessGeneratedUDPPacket_IPv4( NetworkBufferDescriptor_t * const pxNetwor ( void ) memcpy( pxEthernetHeader->xSourceAddress.ucBytes, pxNetworkBuffer->pxEndPoint->xMACAddress.ucBytes, ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); #if ( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) + { + if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; + BaseType_t xIndex; - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; - } - - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; + for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) + { + pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; } + + pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; } + } #endif /* if( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) */ iptraceNETWORK_INTERFACE_OUTPUT( pxNetworkBuffer->xDataLength, pxNetworkBuffer->pucEthernetBuffer ); @@ -392,49 +392,49 @@ BaseType_t xProcessReceivedUDPPacket_IPv4( NetworkBufferDescriptor_t * pxNetwork } #if ( ipconfigUSE_CALLBACKS == 1 ) + { + /* Did the owner of this socket register a reception handler ? */ + if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleReceive ) ) { - /* Did the owner of this socket register a reception handler ? */ - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleReceive ) ) + struct freertos_sockaddr xSourceAddress, destinationAddress; + void * pcData = &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ); + FOnUDPReceive_t xHandler = ( FOnUDPReceive_t ) pxSocket->u.xUDP.pxHandleReceive; + + xSourceAddress.sin_port = pxNetworkBuffer->usPort; + xSourceAddress.sin_address.ulIP_IPv4 = pxNetworkBuffer->xIPAddress.ulIP_IPv4; + xSourceAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET4; + xSourceAddress.sin_len = ( uint8_t ) sizeof( xSourceAddress ); + destinationAddress.sin_port = usPort; + destinationAddress.sin_address.ulIP_IPv4 = pxUDPPacket->xIPHeader.ulDestinationIPAddress; + destinationAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET4; + destinationAddress.sin_len = ( uint8_t ) sizeof( destinationAddress ); + + /* The value of 'xDataLength' was proven to be at least the size of a UDP packet in prvProcessIPPacket(). */ + if( xHandler( ( Socket_t ) pxSocket, + ( void * ) pcData, + ( size_t ) ( pxNetworkBuffer->xDataLength - ipUDP_PAYLOAD_OFFSET_IPv4 ), + &( xSourceAddress ), + &( destinationAddress ) ) != 0 ) { - struct freertos_sockaddr xSourceAddress, destinationAddress; - void * pcData = &( pxNetworkBuffer->pucEthernetBuffer[ ipUDP_PAYLOAD_OFFSET_IPv4 ] ); - FOnUDPReceive_t xHandler = ( FOnUDPReceive_t ) pxSocket->u.xUDP.pxHandleReceive; - - xSourceAddress.sin_port = pxNetworkBuffer->usPort; - xSourceAddress.sin_address.ulIP_IPv4 = pxNetworkBuffer->xIPAddress.ulIP_IPv4; - xSourceAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET4; - xSourceAddress.sin_len = ( uint8_t ) sizeof( xSourceAddress ); - destinationAddress.sin_port = usPort; - destinationAddress.sin_address.ulIP_IPv4 = pxUDPPacket->xIPHeader.ulDestinationIPAddress; - destinationAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET4; - destinationAddress.sin_len = ( uint8_t ) sizeof( destinationAddress ); - - /* The value of 'xDataLength' was proven to be at least the size of a UDP packet in prvProcessIPPacket(). */ - if( xHandler( ( Socket_t ) pxSocket, - ( void * ) pcData, - ( size_t ) ( pxNetworkBuffer->xDataLength - ipUDP_PAYLOAD_OFFSET_IPv4 ), - &( xSourceAddress ), - &( destinationAddress ) ) != 0 ) - { - xReturn = pdFAIL; /* xHandler has consumed the data, do not add it to .xWaitingPacketsList'. */ - } + xReturn = pdFAIL; /* xHandler has consumed the data, do not add it to .xWaitingPacketsList'. */ } } + } #endif /* ipconfigUSE_CALLBACKS */ #if ( ipconfigUDP_MAX_RX_PACKETS > 0U ) + { + if( xReturn == pdPASS ) { - if( xReturn == pdPASS ) + if( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) >= pxSocket->u.xUDP.uxMaxPackets ) { - if( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) >= pxSocket->u.xUDP.uxMaxPackets ) - { - FreeRTOS_debug_printf( ( "xProcessReceivedUDPPacket: buffer full %ld >= %ld port %u\n", - listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ), - pxSocket->u.xUDP.uxMaxPackets, pxSocket->usLocalPort ) ); - xReturn = pdFAIL; /* we did not consume or release the buffer */ - } + FreeRTOS_debug_printf( ( "xProcessReceivedUDPPacket: buffer full %ld >= %ld port %u\n", + listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ), + pxSocket->u.xUDP.uxMaxPackets, pxSocket->usLocalPort ) ); + xReturn = pdFAIL; /* we did not consume or release the buffer */ } } + } #endif /* if ( ipconfigUDP_MAX_RX_PACKETS > 0U ) */ #if ( ipconfigUSE_CALLBACKS == 1 ) || ( ipconfigUDP_MAX_RX_PACKETS > 0U ) @@ -462,30 +462,30 @@ BaseType_t xProcessReceivedUDPPacket_IPv4( NetworkBufferDescriptor_t * pxNetwork } #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) + { + if( ( pxSocket->pxSocketSet != NULL ) && ( ( pxSocket->xSelectBits & ( ( EventBits_t ) eSELECT_READ ) ) != 0U ) ) { - if( ( pxSocket->pxSocketSet != NULL ) && ( ( pxSocket->xSelectBits & ( ( EventBits_t ) eSELECT_READ ) ) != 0U ) ) - { - ( void ) xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, ( EventBits_t ) eSELECT_READ ); - } + ( void ) xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, ( EventBits_t ) eSELECT_READ ); } + } #endif #if ( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) + { + if( pxSocket->pxUserSemaphore != NULL ) { - if( pxSocket->pxUserSemaphore != NULL ) - { - ( void ) xSemaphoreGive( pxSocket->pxUserSemaphore ); - } + ( void ) xSemaphoreGive( pxSocket->pxUserSemaphore ); } + } #endif #if ( ipconfigUSE_DHCP == 1 ) + { + if( xIsDHCPSocket( pxSocket ) != 0 ) { - if( xIsDHCPSocket( pxSocket ) != 0 ) - { - ( void ) xSendDHCPEvent( pxNetworkBuffer->pxEndPoint ); - } + ( void ) xSendDHCPEvent( pxNetworkBuffer->pxEndPoint ); } + } #endif } } diff --git a/source/FreeRTOS_UDP_IPv6.c b/source/FreeRTOS_UDP_IPv6.c index 15f7934340..7644780da4 100644 --- a/source/FreeRTOS_UDP_IPv6.c +++ b/source/FreeRTOS_UDP_IPv6.c @@ -312,9 +312,9 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor /* Save options now, as they will be overwritten by memcpy */ #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) - { - ucSocketOptions = pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ]; - } + { + ucSocketOptions = pxNetworkBuffer->pucEthernetBuffer[ ipSOCKET_OPTIONS_OFFSET ]; + } #endif #if ipconfigSUPPORT_OUTGOING_PINGS == 1 @@ -330,16 +330,16 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor } #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) + { + if( ( ucSocketOptions & ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT ) != 0U ) { - if( ( ucSocketOptions & ( uint8_t ) FREERTOS_SO_UDPCKSUM_OUT ) != 0U ) - { - ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxUDPPacket_IPv6, pxNetworkBuffer->xDataLength, pdTRUE ); - } - else - { - pxUDPPacket_IPv6->xUDPHeader.usChecksum = 0U; - } + ( void ) usGenerateProtocolChecksum( ( uint8_t * ) pxUDPPacket_IPv6, pxNetworkBuffer->xDataLength, pdTRUE ); + } + else + { + pxUDPPacket_IPv6->xUDPHeader.usChecksum = 0U; } + } #endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 0 ) */ } else if( eReturned == eARPCacheMiss ) @@ -380,19 +380,19 @@ void vProcessGeneratedUDPPacket_IPv6( NetworkBufferDescriptor_t * const pxNetwor ( size_t ) ipMAC_ADDRESS_LENGTH_BYTES ); #if ( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) + { + if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) { - if( pxNetworkBuffer->xDataLength < ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES ) - { - BaseType_t xIndex; - - for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) - { - pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; - } + BaseType_t xIndex; - pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; + for( xIndex = ( BaseType_t ) pxNetworkBuffer->xDataLength; xIndex < ( BaseType_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; xIndex++ ) + { + pxNetworkBuffer->pucEthernetBuffer[ xIndex ] = 0U; } + + pxNetworkBuffer->xDataLength = ( size_t ) ipconfigETHERNET_MINIMUM_PACKET_BYTES; } + } #endif /* if( ipconfigETHERNET_MINIMUM_PACKET_BYTES > 0 ) */ iptraceNETWORK_INTERFACE_OUTPUT( pxNetworkBuffer->xDataLength, pxNetworkBuffer->pucEthernetBuffer ); ( void ) pxInterface->pfOutput( pxInterface, pxNetworkBuffer, pdTRUE ); @@ -477,55 +477,55 @@ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetwork pxNetworkBuffer->pxEndPoint ); #if ( ipconfigUSE_CALLBACKS == 1 ) - { - size_t uxIPLength = uxIPHeaderSizePacket( pxNetworkBuffer ); - size_t uxPayloadSize; + { + size_t uxIPLength = uxIPHeaderSizePacket( pxNetworkBuffer ); + size_t uxPayloadSize; - /* Did the owner of this socket register a reception handler ? */ - if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleReceive ) ) + /* Did the owner of this socket register a reception handler ? */ + if( ipconfigIS_VALID_PROG_ADDRESS( pxSocket->u.xUDP.pxHandleReceive ) ) + { + struct freertos_sockaddr xSourceAddress, destinationAddress; + /* The application hook needs to know the from- and to-addresses. */ + + void * pcData = &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + uxIPLength + ipSIZE_OF_UDP_HEADER ] ); + FOnUDPReceive_t xHandler = ( FOnUDPReceive_t ) pxSocket->u.xUDP.pxHandleReceive; + + xSourceAddress.sin_port = pxNetworkBuffer->usPort; + destinationAddress.sin_port = usPort; + ( void ) memcpy( xSourceAddress.sin_address.xIP_IPv6.ucBytes, pxUDPPacket_IPv6->xIPHeader.xSourceAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + ( void ) memcpy( destinationAddress.sin_address.xIP_IPv6.ucBytes, pxUDPPacket_IPv6->xIPHeader.xDestinationAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); + xSourceAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET6; + destinationAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET6; + xSourceAddress.sin_len = ( uint8_t ) sizeof( xSourceAddress ); + destinationAddress.sin_len = ( uint8_t ) sizeof( destinationAddress ); + uxPayloadSize = pxNetworkBuffer->xDataLength - ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER + ( size_t ) ipSIZE_OF_IPv6_HEADER ); + + /* The value of 'xDataLength' was proven to be at least the size of a UDP packet in prvProcessIPPacket(). */ + if( xHandler( ( Socket_t ) pxSocket, + ( void * ) pcData, + uxPayloadSize, + &( xSourceAddress ), + &( destinationAddress ) ) != 0 ) { - struct freertos_sockaddr xSourceAddress, destinationAddress; - /* The application hook needs to know the from- and to-addresses. */ - - void * pcData = &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + uxIPLength + ipSIZE_OF_UDP_HEADER ] ); - FOnUDPReceive_t xHandler = ( FOnUDPReceive_t ) pxSocket->u.xUDP.pxHandleReceive; - - xSourceAddress.sin_port = pxNetworkBuffer->usPort; - destinationAddress.sin_port = usPort; - ( void ) memcpy( xSourceAddress.sin_address.xIP_IPv6.ucBytes, pxUDPPacket_IPv6->xIPHeader.xSourceAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); - ( void ) memcpy( destinationAddress.sin_address.xIP_IPv6.ucBytes, pxUDPPacket_IPv6->xIPHeader.xDestinationAddress.ucBytes, ipSIZE_OF_IPv6_ADDRESS ); - xSourceAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET6; - destinationAddress.sin_family = ( uint8_t ) FREERTOS_AF_INET6; - xSourceAddress.sin_len = ( uint8_t ) sizeof( xSourceAddress ); - destinationAddress.sin_len = ( uint8_t ) sizeof( destinationAddress ); - uxPayloadSize = pxNetworkBuffer->xDataLength - ( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_UDP_HEADER + ( size_t ) ipSIZE_OF_IPv6_HEADER ); - - /* The value of 'xDataLength' was proven to be at least the size of a UDP packet in prvProcessIPPacket(). */ - if( xHandler( ( Socket_t ) pxSocket, - ( void * ) pcData, - uxPayloadSize, - &( xSourceAddress ), - &( destinationAddress ) ) != 0 ) - { - xReturn = pdFAIL; /* xHandler has consumed the data, do not add it to .xWaitingPacketsList'. */ - } + xReturn = pdFAIL; /* xHandler has consumed the data, do not add it to .xWaitingPacketsList'. */ } } + } #endif /* ipconfigUSE_CALLBACKS */ #if ( ipconfigUDP_MAX_RX_PACKETS > 0U ) + { + if( xReturn == pdPASS ) { - if( xReturn == pdPASS ) + if( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) >= pxSocket->u.xUDP.uxMaxPackets ) { - if( listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ) >= pxSocket->u.xUDP.uxMaxPackets ) - { - FreeRTOS_debug_printf( ( "xProcessReceivedUDPPacket: buffer full %ld >= %ld port %u\n", - listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ), - pxSocket->u.xUDP.uxMaxPackets, pxSocket->usLocalPort ) ); - xReturn = pdFAIL; /* we did not consume or release the buffer */ - } + FreeRTOS_debug_printf( ( "xProcessReceivedUDPPacket: buffer full %ld >= %ld port %u\n", + listCURRENT_LIST_LENGTH( &( pxSocket->u.xUDP.xWaitingPacketsList ) ), + pxSocket->u.xUDP.uxMaxPackets, pxSocket->usLocalPort ) ); + xReturn = pdFAIL; /* we did not consume or release the buffer */ } } + } #endif /* if ( ipconfigUDP_MAX_RX_PACKETS > 0U ) */ #if ( ipconfigUSE_CALLBACKS == 1 ) || ( ipconfigUDP_MAX_RX_PACKETS > 0U ) @@ -553,30 +553,30 @@ BaseType_t xProcessReceivedUDPPacket_IPv6( NetworkBufferDescriptor_t * pxNetwork } #if ( ipconfigSUPPORT_SELECT_FUNCTION == 1 ) + { + if( ( pxSocket->pxSocketSet != NULL ) && ( ( pxSocket->xSelectBits & ( ( EventBits_t ) eSELECT_READ ) ) != 0U ) ) { - if( ( pxSocket->pxSocketSet != NULL ) && ( ( pxSocket->xSelectBits & ( ( EventBits_t ) eSELECT_READ ) ) != 0U ) ) - { - ( void ) xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, ( EventBits_t ) eSELECT_READ ); - } + ( void ) xEventGroupSetBits( pxSocket->pxSocketSet->xSelectGroup, ( EventBits_t ) eSELECT_READ ); } + } #endif #if ( ipconfigSOCKET_HAS_USER_SEMAPHORE == 1 ) + { + if( pxSocket->pxUserSemaphore != NULL ) { - if( pxSocket->pxUserSemaphore != NULL ) - { - ( void ) xSemaphoreGive( pxSocket->pxUserSemaphore ); - } + ( void ) xSemaphoreGive( pxSocket->pxUserSemaphore ); } + } #endif #if ( ipconfigUSE_DHCP == 1 ) + { + if( xIsDHCPSocket( pxSocket ) != 0 ) { - if( xIsDHCPSocket( pxSocket ) != 0 ) - { - ( void ) xSendDHCPEvent( pxNetworkBuffer->pxEndPoint ); - } + ( void ) xSendDHCPEvent( pxNetworkBuffer->pxEndPoint ); } + } #endif } } diff --git a/source/include/FreeRTOSIPConfigDefaults.h b/source/include/FreeRTOSIPConfigDefaults.h index db11848fe4..93a384f646 100644 --- a/source/include/FreeRTOSIPConfigDefaults.h +++ b/source/include/FreeRTOSIPConfigDefaults.h @@ -308,9 +308,9 @@ #ifndef FreeRTOS_debug_printf #define FreeRTOS_debug_printf( MSG ) do {} while( ipFALSE_BOOL ) - /* MISRA Ref 20.5.1 [Use of undef] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */ - /* coverity[misra_c_2012_rule_20_5_violation] */ +/* MISRA Ref 20.5.1 [Use of undef] */ +/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */ +/* coverity[misra_c_2012_rule_20_5_violation] */ #undef ipconfigHAS_DEBUG_PRINTF #define ipconfigHAS_DEBUG_PRINTF 0 #endif @@ -334,9 +334,9 @@ #ifndef FreeRTOS_printf #define FreeRTOS_printf( MSG ) do {} while( ipFALSE_BOOL ) - /* MISRA Ref 20.5.1 [Use of undef] */ - /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */ - /* coverity[misra_c_2012_rule_20_5_violation] */ +/* MISRA Ref 20.5.1 [Use of undef] */ +/* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2051 */ +/* coverity[misra_c_2012_rule_20_5_violation] */ #undef ipconfigHAS_PRINTF #define ipconfigHAS_PRINTF 0 #endif @@ -762,7 +762,7 @@ #if ( ipconfigUSE_DNS_CACHE != 0 ) -/* Per https://tools.ietf.org/html/rfc1035, 253 is the maximum string length +/* Per https://tools.ietf.org/html/rfc1035 253 is the maximum string length * of a DNS name. The following default accounts for a null terminator. */ #ifndef ipconfigDNS_CACHE_NAME_LENGTH #define ipconfigDNS_CACHE_NAME_LENGTH 254U diff --git a/source/include/FreeRTOS_BitConfig.h b/source/include/FreeRTOS_BitConfig.h index 03ee2b5574..5c27fc3189 100644 --- a/source/include/FreeRTOS_BitConfig.h +++ b/source/include/FreeRTOS_BitConfig.h @@ -36,7 +36,7 @@ #define FREERTOS_BITCONFIG_H #ifdef __cplusplus - extern "C" { + extern "C" { #endif /**< @brief The struct BitConfig_t holds a character array, its length and an index. */ diff --git a/source/include/FreeRTOS_DHCPv6.h b/source/include/FreeRTOS_DHCPv6.h index bd620c5df4..b3537d9703 100644 --- a/source/include/FreeRTOS_DHCPv6.h +++ b/source/include/FreeRTOS_DHCPv6.h @@ -32,7 +32,7 @@ #include "IPTraceMacroDefaults.h" #ifdef __cplusplus - extern "C" { + extern "C" { #endif /* IPv6 option numbers. */ diff --git a/source/include/FreeRTOS_DNS.h b/source/include/FreeRTOS_DNS.h index ee52841bb1..67dc7f6d5b 100644 --- a/source/include/FreeRTOS_DNS.h +++ b/source/include/FreeRTOS_DNS.h @@ -48,7 +48,7 @@ uint32_t ulDNSHandlePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer ); #if ( ipconfigUSE_LLMNR == 1 ) /* The LLMNR MAC address is 01:00:5e:00:00:fc */ - extern const MACAddress_t xLLMNR_MacAdress; + extern const MACAddress_t xLLMNR_MacAddress; #endif /* ipconfigUSE_LLMNR */ #if ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) @@ -57,12 +57,12 @@ uint32_t ulDNSHandlePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer ); extern const IPv6_Address_t ipLLMNR_IP_ADDR_IPv6; /* The LLMNR IPv6 MAC address is 33:33:00:01:00:03 */ - extern const MACAddress_t xLLMNR_MacAdressIPv6; + extern const MACAddress_t xLLMNR_MacAddressIPv6; #endif /* ipconfigUSE_LLMNR */ #if ( ipconfigUSE_MDNS == 1 ) /* The MDNS MAC address is 01:00:5e:00:00:fc */ - extern const MACAddress_t xMDNS_MacAdress; + extern const MACAddress_t xMDNS_MacAddress; #endif /* ipconfigUSE_MDNS */ #if ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) @@ -71,7 +71,7 @@ uint32_t ulDNSHandlePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer ); extern const IPv6_Address_t ipMDNS_IP_ADDR_IPv6; /* The MDNS IPv6 MAC address is 33:33:00:01:00:03 */ - extern const MACAddress_t xMDNS_MACAdressIPv6; + extern const MACAddress_t xMDNS_MACAddressIPv6; #endif /* ipconfigUSE_MDNS */ /** @brief While doing integration tests, it is necessary to influence the choice diff --git a/source/include/FreeRTOS_DNS_Globals.h b/source/include/FreeRTOS_DNS_Globals.h index e01091b6f8..649e8033cc 100644 --- a/source/include/FreeRTOS_DNS_Globals.h +++ b/source/include/FreeRTOS_DNS_Globals.h @@ -84,8 +84,8 @@ #ifndef _lint /* LLMNR constants. */ - #define dnsLLMNR_TTL_VALUE 300U /**< LLMNR time to live value of 5 minutes. */ - #define dnsLLMNR_FLAGS_IS_REPONSE 0x8000U /**< LLMNR flag value for response. */ + #define dnsLLMNR_TTL_VALUE 300U /**< LLMNR time to live value of 5 minutes. */ + #define dnsLLMNR_FLAGS_IS_RESPONSE 0x8000U /**< LLMNR flag value for response. */ #endif /* _lint */ /* NBNS constants. */ diff --git a/source/include/FreeRTOS_IPv4_Sockets.h b/source/include/FreeRTOS_IPv4_Sockets.h index 8cb2859c51..60b28f3173 100644 --- a/source/include/FreeRTOS_IPv4_Sockets.h +++ b/source/include/FreeRTOS_IPv4_Sockets.h @@ -35,7 +35,7 @@ #include "FreeRTOS.h" #ifdef __cplusplus - extern "C" { + extern "C" { #endif diff --git a/source/include/FreeRTOS_IPv6.h b/source/include/FreeRTOS_IPv6.h index 1111f22b61..66755b2d1a 100644 --- a/source/include/FreeRTOS_IPv6.h +++ b/source/include/FreeRTOS_IPv6.h @@ -50,7 +50,7 @@ /* Some IPv6 ICMP requests. */ #define ipICMP_DEST_UNREACHABLE_IPv6 ( ( uint8_t ) 1U ) #define ipICMP_PACKET_TOO_BIG_IPv6 ( ( uint8_t ) 2U ) -#define ipICMP_TIME_EXEEDED_IPv6 ( ( uint8_t ) 3U ) +#define ipICMP_TIME_EXCEEDED_IPv6 ( ( uint8_t ) 3U ) #define ipICMP_PARAMETER_PROBLEM_IPv6 ( ( uint8_t ) 4U ) #define ipICMP_PING_REQUEST_IPv6 ( ( uint8_t ) 128U ) #define ipICMP_PING_REPLY_IPv6 ( ( uint8_t ) 129U ) diff --git a/source/include/FreeRTOS_IPv6_Sockets.h b/source/include/FreeRTOS_IPv6_Sockets.h index 903e0617f8..53ed716773 100644 --- a/source/include/FreeRTOS_IPv6_Sockets.h +++ b/source/include/FreeRTOS_IPv6_Sockets.h @@ -36,7 +36,7 @@ #include "FreeRTOS_IP_Common.h" #ifdef __cplusplus - extern "C" { + extern "C" { #endif /** @brief When ucASCIIToHex() can not convert a character, diff --git a/source/include/FreeRTOS_Routing.h b/source/include/FreeRTOS_Routing.h index 9612491f2e..7d143b9b7a 100644 --- a/source/include/FreeRTOS_Routing.h +++ b/source/include/FreeRTOS_Routing.h @@ -38,7 +38,7 @@ #endif #ifdef __cplusplus - extern "C" { + extern "C" { #endif /* Every NetworkInterface needs a set of access functions: */ diff --git a/source/include/FreeRTOS_Sockets.h b/source/include/FreeRTOS_Sockets.h index a4b108c57c..5ce49529fd 100644 --- a/source/include/FreeRTOS_Sockets.h +++ b/source/include/FreeRTOS_Sockets.h @@ -49,7 +49,7 @@ #include "event_groups.h" #ifdef __cplusplus - extern "C" { + extern "C" { #endif #ifndef INC_FREERTOS_H diff --git a/source/include/IPTraceMacroDefaults.h b/source/include/IPTraceMacroDefaults.h index 6cfc785576..08282e1965 100644 --- a/source/include/IPTraceMacroDefaults.h +++ b/source/include/IPTraceMacroDefaults.h @@ -194,16 +194,16 @@ #define iptraceSENDING_DHCP_REQUEST() #endif -#ifndef iptraceDHCP_SUCCEDEED - #define iptraceDHCP_SUCCEDEED( address ) +#ifndef iptraceDHCP_SUCCEEDED + #define iptraceDHCP_SUCCEEDED( address ) #endif #ifndef iptraceRA_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS #define iptraceRA_REQUESTS_FAILED_USING_DEFAULT_IP_ADDRESS( ipv6_address ) #endif -#ifndef iptraceRA_SUCCEDEED - #define iptraceRA_SUCCEDEED( ipv6_address ) +#ifndef iptraceRA_SUCCEEDED + #define iptraceRA_SUCCEEDED( ipv6_address ) #endif #ifndef iptraceNETWORK_INTERFACE_TRANSMIT diff --git a/source/portable/BufferManagement/BufferAllocation_1.c b/source/portable/BufferManagement/BufferAllocation_1.c index 20cb5e4f6d..2d564d0085 100644 --- a/source/portable/BufferManagement/BufferAllocation_1.c +++ b/source/portable/BufferManagement/BufferAllocation_1.c @@ -179,17 +179,17 @@ BaseType_t xNetworkBuffersInitialise( void ) ipconfigBUFFER_ALLOC_INIT(); #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) - { - static StaticSemaphore_t xNetworkBufferSemaphoreBuffer; - xNetworkBufferSemaphore = xSemaphoreCreateCountingStatic( - ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, - ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, - &xNetworkBufferSemaphoreBuffer ); - } + { + static StaticSemaphore_t xNetworkBufferSemaphoreBuffer; + xNetworkBufferSemaphore = xSemaphoreCreateCountingStatic( + ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, + ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, + &xNetworkBufferSemaphoreBuffer ); + } #else - { - xNetworkBufferSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); - } + { + xNetworkBufferSemaphore = xSemaphoreCreateCounting( ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ( UBaseType_t ) ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); + } #endif /* configSUPPORT_STATIC_ALLOCATION */ configASSERT( xNetworkBufferSemaphore != NULL ); @@ -294,16 +294,16 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS pxReturn->pxEndPoint = NULL; #if ( ipconfigTCP_IP_SANITY != 0 ) - { - prvShowWarnings(); - } + { + prvShowWarnings(); + } #endif /* ipconfigTCP_IP_SANITY */ #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - /* make sure the buffer is not linked */ - pxReturn->pxNextBuffer = NULL; - } + { + /* make sure the buffer is not linked */ + pxReturn->pxNextBuffer = NULL; + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ } diff --git a/source/portable/BufferManagement/BufferAllocation_2.c b/source/portable/BufferManagement/BufferAllocation_2.c index 075cdf0a7b..4a7e2476e0 100644 --- a/source/portable/BufferManagement/BufferAllocation_2.c +++ b/source/portable/BufferManagement/BufferAllocation_2.c @@ -65,7 +65,7 @@ /* Compile time assertion with zero runtime effects * it will assert on 'e' not being zero, as it tries to divide by it, - * will also print the line where the error occured in case of failure */ + * will also print the line where the error occurred in case of failure */ /* MISRA Ref 20.10.1 [Lack of sizeof operator and compile time error checking] */ /* More details at: https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-2010 */ /* coverity[misra_c_2012_rule_20_10_violation] */ @@ -108,17 +108,17 @@ BaseType_t xNetworkBuffersInitialise( void ) if( xNetworkBufferSemaphore == NULL ) { #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) - { - static StaticSemaphore_t xNetworkBufferSemaphoreBuffer; - xNetworkBufferSemaphore = xSemaphoreCreateCountingStatic( - ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, - ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, - &xNetworkBufferSemaphoreBuffer ); - } + { + static StaticSemaphore_t xNetworkBufferSemaphoreBuffer; + xNetworkBufferSemaphore = xSemaphoreCreateCountingStatic( + ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, + ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, + &xNetworkBufferSemaphoreBuffer ); + } #else - { - xNetworkBufferSemaphore = xSemaphoreCreateCounting( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); - } + { + xNetworkBufferSemaphore = xSemaphoreCreateCounting( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ); + } #endif /* configSUPPORT_STATIC_ALLOCATION */ configASSERT( xNetworkBufferSemaphore != NULL ); @@ -126,19 +126,19 @@ BaseType_t xNetworkBuffersInitialise( void ) if( xNetworkBufferSemaphore != NULL ) { #if ( configQUEUE_REGISTRY_SIZE > 0 ) - { - vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" ); - } + { + vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" ); + } #endif /* configQUEUE_REGISTRY_SIZE */ /* If the trace recorder code is included name the semaphore for viewing * in FreeRTOS+Trace. */ #if ( ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 ) - { - extern QueueHandle_t xNetworkEventQueue; - vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" ); - vTraceSetQueueName( xNetworkBufferSemaphore, "NetworkBufferCount" ); - } + { + extern QueueHandle_t xNetworkEventQueue; + vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" ); + vTraceSetQueueName( xNetworkBufferSemaphore, "NetworkBufferCount" ); + } #endif /* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 */ vListInitialise( &xFreeBuffersList ); @@ -308,10 +308,10 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS pxReturn->pxEndPoint = NULL; #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - /* make sure the buffer is not linked */ - pxReturn->pxNextBuffer = NULL; - } + { + /* make sure the buffer is not linked */ + pxReturn->pxNextBuffer = NULL; + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ } } diff --git a/source/portable/Compiler/CompilerName/ReadMe.txt b/source/portable/Compiler/CompilerName/ReadMe.txt index 04a632a95a..9545651372 100644 --- a/source/portable/Compiler/CompilerName/ReadMe.txt +++ b/source/portable/Compiler/CompilerName/ReadMe.txt @@ -1,3 +1,3 @@ -Update pack_struct_start.h and pack_struct_end.h for your architecure. +Update pack_struct_start.h and pack_struct_end.h for your architecture. These files define the specifiers needed by your compiler to properly pack struct data need by FreeRTOS+TCP. diff --git a/source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c b/source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c index 474ff6fed5..8ae4d25421 100644 --- a/source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c +++ b/source/portable/NetworkInterface/ATSAM4E/NetworkInterface.c @@ -292,19 +292,19 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript } #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Confirm that the pxDescriptor may be kept by the driver. */ - configASSERT( bReleaseAfterSend != pdFALSE ); - } + { + /* Confirm that the pxDescriptor may be kept by the driver. */ + configASSERT( bReleaseAfterSend != pdFALSE ); + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ gmac_dev_write( &gs_gmac_dev, ( void * ) pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, prvTxCallback ); #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Confirm that the pxDescriptor may be kept by the driver. */ - bReleaseAfterSend = pdFALSE; - } + { + /* Confirm that the pxDescriptor may be kept by the driver. */ + bReleaseAfterSend = pdFALSE; + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ /* Not interested in a call-back after TX. */ iptraceNETWORK_INTERFACE_TRANSMIT(); @@ -553,17 +553,17 @@ static void prvEMACHandlerTask( void * pvParameters ) } #if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - uxCurrentCount = uxGetMinimumIPQueueSpace(); + { + uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - * while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } + if( uxLastMinQueueSpace != uxCurrentCount ) + { + /* The logging produced below may be helpful + * while tuning +TCP: see how many buffers are in use. */ + uxLastMinQueueSpace = uxCurrentCount; + FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); } + } #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ if( ( ulISREvents & EMAC_IF_ALL_EVENT ) == 0 ) @@ -589,23 +589,23 @@ static void prvEMACHandlerTask( void * pvParameters ) while( xQueueReceive( xTxBufferQueue, &pucBuffer, 0 ) != pdFALSE ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) + { + pxBuffer = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); + + if( pxBuffer != NULL ) { - pxBuffer = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); - - if( pxBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxBuffer ); - tx_release_count[ 0 ]++; - } - else - { - tx_release_count[ 1 ]++; - } + vReleaseNetworkBufferAndDescriptor( pxBuffer ); + tx_release_count[ 0 ]++; } - #else /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ + else { - tx_release_count[ 0 ]++; + tx_release_count[ 1 ]++; } + } + #else /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ + { + tx_release_count[ 0 ]++; + } #endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ uxCount = uxQueueMessagesWaiting( ( QueueHandle_t ) xTXDescriptorSemaphore ); diff --git a/source/portable/NetworkInterface/ATSAM4E/component/gmac.h b/source/portable/NetworkInterface/ATSAM4E/component/gmac.h index 099dbba609..5fd581e61e 100644 --- a/source/portable/NetworkInterface/ATSAM4E/component/gmac.h +++ b/source/portable/NetworkInterface/ATSAM4E/component/gmac.h @@ -245,10 +245,10 @@ #define GMAC_DCFGR_ESPA ( 0x1u << 7 ) /**< \brief (GMAC_DCFGR) Endian Swap Mode Enable for Packet Data Accesses */ #define GMAC_DCFGR_RXBMS_Pos 8 #define GMAC_DCFGR_RXBMS_Msk ( 0x3u << GMAC_DCFGR_RXBMS_Pos ) /**< \brief (GMAC_DCFGR) Receiver Packet Buffer Memory Size Select */ -#define GMAC_DCFGR_RXBMS_EIGHTH ( 0x0u << 8 ) /**< \brief (GMAC_DCFGR) 1 Kbyte Memory Size */ -#define GMAC_DCFGR_RXBMS_QUARTER ( 0x1u << 8 ) /**< \brief (GMAC_DCFGR) 2 Kbytes Memory Size */ -#define GMAC_DCFGR_RXBMS_HALF ( 0x2u << 8 ) /**< \brief (GMAC_DCFGR) 4 Kbytes Memory Size */ -#define GMAC_DCFGR_RXBMS_FULL ( 0x3u << 8 ) /**< \brief (GMAC_DCFGR) 8 Kbytes Memory Size */ +#define GMAC_DCFGR_RXBMS_EIGHTH ( 0x0u << 8 ) /**< \brief (GMAC_DCFGR) 1 KByte Memory Size */ +#define GMAC_DCFGR_RXBMS_QUARTER ( 0x1u << 8 ) /**< \brief (GMAC_DCFGR) 2 KBytes Memory Size */ +#define GMAC_DCFGR_RXBMS_HALF ( 0x2u << 8 ) /**< \brief (GMAC_DCFGR) 4 KBytes Memory Size */ +#define GMAC_DCFGR_RXBMS_FULL ( 0x3u << 8 ) /**< \brief (GMAC_DCFGR) 8 KBytes Memory Size */ #define GMAC_DCFGR_TXPBMS ( 0x1u << 10 ) /**< \brief (GMAC_DCFGR) Transmitter Packet Buffer Memory Size Select */ #define GMAC_DCFGR_TXCOEN ( 0x1u << 11 ) /**< \brief (GMAC_DCFGR) Transmitter Checksum Generation Offload Enable */ #define GMAC_DCFGR_DRBS_Pos 16 diff --git a/source/portable/NetworkInterface/ATSAM4E/ethernet_phy.c b/source/portable/NetworkInterface/ATSAM4E/ethernet_phy.c index 6a1f6f91b8..92e7b6ec68 100644 --- a/source/portable/NetworkInterface/ATSAM4E/ethernet_phy.c +++ b/source/portable/NetworkInterface/ATSAM4E/ethernet_phy.c @@ -56,7 +56,7 @@ /*/ @cond 0 */ /**INDENT-OFF**/ #ifdef __cplusplus - extern "C" { +extern "C" { #endif /**INDENT-ON**/ /*/ @endcond */ diff --git a/source/portable/NetworkInterface/ATSAM4E/ethernet_phy.h b/source/portable/NetworkInterface/ATSAM4E/ethernet_phy.h index cd435dd917..bcc4b77d44 100644 --- a/source/portable/NetworkInterface/ATSAM4E/ethernet_phy.h +++ b/source/portable/NetworkInterface/ATSAM4E/ethernet_phy.h @@ -47,7 +47,7 @@ #include "compiler.h" #ifdef __cplusplus - extern "C" { + extern "C" { #endif /* IEEE defined Registers */ diff --git a/source/portable/NetworkInterface/ATSAM4E/gmac.c b/source/portable/NetworkInterface/ATSAM4E/gmac.c index a20ffbd933..68bb254ca0 100644 --- a/source/portable/NetworkInterface/ATSAM4E/gmac.c +++ b/source/portable/NetworkInterface/ATSAM4E/gmac.c @@ -60,7 +60,7 @@ /*/ @cond 0 */ /**INDENT-OFF**/ #ifdef __cplusplus - extern "C" { +extern "C" { #endif /**INDENT-ON**/ /*/ @endcond */ @@ -219,13 +219,13 @@ static void gmac_reset_tx_mem( gmac_device_t * p_dev ) for( ul_index = 0; ul_index < p_dev->ul_tx_list_size; ul_index++ ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - ul_address = ( uint32_t ) 0u; - } + { + ul_address = ( uint32_t ) 0u; + } #else - { - ul_address = ( uint32_t ) ( &( p_tx_buff[ ul_index * GMAC_TX_UNITSIZE ] ) ); - } + { + ul_address = ( uint32_t ) ( &( p_tx_buff[ ul_index * GMAC_TX_UNITSIZE ] ) ); + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ p_td[ ul_index ].addr = ul_address; p_td[ ul_index ].status.val = GMAC_TXD_USED; @@ -476,13 +476,13 @@ void gmac_dev_init( Gmac * p_gmac, gmac_dev_mm.us_rx_size = GMAC_RX_BUFFERS; #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - gmac_dev_mm.p_tx_buffer = NULL; - } + { + gmac_dev_mm.p_tx_buffer = NULL; + } #else - { - gmac_dev_mm.p_tx_buffer = gs_uc_tx_buffer; - } + { + gmac_dev_mm.p_tx_buffer = gs_uc_tx_buffer; + } #endif gmac_dev_mm.p_tx_dscr = gs_tx_desc; gmac_dev_mm.us_tx_size = GMAC_TX_BUFFERS; @@ -518,9 +518,9 @@ static uint32_t gmac_dev_poll( gmac_device_t * p_gmac_dev ) pxHead = &p_gmac_dev->p_rx_dscr[ ulIndex ]; p_gmac_dev->ul_rx_idx = ulIndex; #if ( GMAC_STATS != 0 ) - { - gmacStats.incompCount++; - } + { + gmacStats.incompCount++; + } #endif } @@ -555,9 +555,9 @@ static uint32_t gmac_dev_poll( gmac_device_t * p_gmac_dev ) circ_inc32( &ulPrev, p_gmac_dev->ul_rx_list_size ); pxHead = &p_gmac_dev->p_rx_dscr[ ulPrev ]; #if ( GMAC_STATS != 0 ) - { - gmacStats.truncCount++; - } + { + gmacStats.truncCount++; + } #endif } while( ulPrev != ulIndex ); @@ -707,15 +707,15 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev, /* Calculating the checksum here is faster than calculating it from the GMAC buffer * because within p_buffer, it is well aligned */ #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Zero-copy... */ - p_tx_td->addr = ( uint32_t ) p_buffer; - } + { + /* Zero-copy... */ + p_tx_td->addr = ( uint32_t ) p_buffer; + } #else - { - /* Or Memcopy... */ - memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size ); - } + { + /* Or Memcopy... */ + memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size ); + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ vGMACGenerateChecksum( ( uint8_t * ) p_tx_td->addr ); } @@ -917,15 +917,15 @@ void gmac_handler( gmac_device_t * p_gmac_dev ) /* Why clear bits that are ignored anyway ? */ /* ul_isr &= ~(gmac_get_interrupt_mask(p_hw) | 0xF8030300); */ #if ( GMAC_STATS != 0 ) + { + for( index = 0; index < ARRAY_SIZE( intPairs ); index++ ) { - for( index = 0; index < ARRAY_SIZE( intPairs ); index++ ) + if( ul_isr & intPairs[ index ].mask ) { - if( ul_isr & intPairs[ index ].mask ) - { - gmacStats.intStatus[ intPairs[ index ].index ]++; - } + gmacStats.intStatus[ intPairs[ index ].index ]++; } } + } #endif /* GMAC_STATS != 0 */ /* RX packet */ @@ -990,9 +990,9 @@ void gmac_handler( gmac_device_t * p_gmac_dev ) { ( *p_tx_cb )( ul_tx_status_flag, ( void * ) p_tx_td->addr ); #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - p_tx_td->addr = 0ul; - } + { + p_tx_td->addr = 0ul; + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ } diff --git a/source/portable/NetworkInterface/ATSAM4E/gmac.h b/source/portable/NetworkInterface/ATSAM4E/gmac.h index c1c0594875..967ed868dd 100644 --- a/source/portable/NetworkInterface/ATSAM4E/gmac.h +++ b/source/portable/NetworkInterface/ATSAM4E/gmac.h @@ -49,7 +49,7 @@ /*/ @cond 0 */ /**INDENT-OFF**/ #ifdef __cplusplus - extern "C" { + extern "C" { #endif /**INDENT-ON**/ /*/ @endcond */ diff --git a/source/portable/NetworkInterface/ATSAM4E/instance/gmac.h b/source/portable/NetworkInterface/ATSAM4E/instance/gmac.h index 144daee543..814bea15fa 100644 --- a/source/portable/NetworkInterface/ATSAM4E/instance/gmac.h +++ b/source/portable/NetworkInterface/ATSAM4E/instance/gmac.h @@ -50,7 +50,7 @@ /*/ @cond 0 */ /**INDENT-OFF**/ #ifdef __cplusplus - extern "C" { + extern "C" { #endif /**INDENT-ON**/ /*/ @endcond */ diff --git a/source/portable/NetworkInterface/ATSAME5x/NetworkInterface.c b/source/portable/NetworkInterface/ATSAME5x/NetworkInterface.c index 2260dd7c02..809a5febe1 100644 --- a/source/portable/NetworkInterface/ATSAME5x/NetworkInterface.c +++ b/source/portable/NetworkInterface/ATSAME5x/NetworkInterface.c @@ -87,7 +87,7 @@ /* Setup LLMNR specific multicast address. */ #if ( defined( ipconfigUSE_LLMNR ) && ( ipconfigUSE_LLMNR == 1 ) ) - static uint8_t ucLLMNR_MAC_address[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; +static uint8_t ucLLMNR_MAC_address[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; #endif /* Receive task refresh time */ @@ -333,20 +333,20 @@ static void prvEMACDeferredInterruptHandlerTask( void * pvParameters ) else { #if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 1 ) + { + /* the Atmel SAM GMAC peripheral does not support hardware CRC offloading for ICMP packets. + * It must therefore be implemented in software. */ + pxIPPacket = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( IPPacket_t, pxBufferDescriptor->pucEthernetBuffer ); + + if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) { - /* the Atmel SAM GMAC peripheral does not support hardware CRC offloading for ICMP packets. - * It must therefore be implemented in software. */ - pxIPPacket = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( IPPacket_t, pxBufferDescriptor->pucEthernetBuffer ); - - if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) - { - xICMPChecksumResult = usGenerateProtocolChecksum( pxBufferDescriptor->pucEthernetBuffer, pxBufferDescriptor->xDataLength, pdFALSE ); - } - else - { - xICMPChecksumResult = ipCORRECT_CRC; /* Reset the result value in case this is not an ICMP packet. */ - } + xICMPChecksumResult = usGenerateProtocolChecksum( pxBufferDescriptor->pucEthernetBuffer, pxBufferDescriptor->xDataLength, pdFALSE ); } + else + { + xICMPChecksumResult = ipCORRECT_CRC; /* Reset the result value in case this is not an ICMP packet. */ + } + } #endif /* if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM == 1 ) */ /* See if the data contained in the received Ethernet frame needs @@ -437,16 +437,16 @@ BaseType_t xATSAM5x_NetworkInterfaceOutput( NetworkInterface_t * pxInterface, if( xATSAM5x_PHYGetLinkStatus( NULL ) ) { #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) - { - /* the Atmel SAM GMAC peripheral does not support hardware CRC offloading for ICMP packets. - * It must therefore be implemented in software. */ - const IPPacket_t * pxIPPacket = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( IPPacket_t, pxDescriptor->pucEthernetBuffer ); + { + /* the Atmel SAM GMAC peripheral does not support hardware CRC offloading for ICMP packets. + * It must therefore be implemented in software. */ + const IPPacket_t * pxIPPacket = ipCAST_CONST_PTR_TO_CONST_TYPE_PTR( IPPacket_t, pxDescriptor->pucEthernetBuffer ); - if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) - { - ( void ) usGenerateProtocolChecksum( pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, pdTRUE ); - } + if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) + { + ( void ) usGenerateProtocolChecksum( pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength, pdTRUE ); } + } #endif /* if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM == 1 ) */ mac_async_write( Ð_MAC, pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength ); @@ -519,27 +519,27 @@ static void prvGMACInit() /* Enable traffic for LLMNR, if defined. */ #if ( defined( ipconfigUSE_LLMNR ) && ( ipconfigUSE_LLMNR == 1 ) ) - { - mac_async_set_filter_ex( Ð_MAC, ucLLMNR_MAC_address ); - } + { + mac_async_set_filter_ex( Ð_MAC, ucLLMNR_MAC_address ); + } #endif #if ( ipconfigUSE_IPv6 != 0 ) - { - /* Allow all nodes IPv6 multicast MAC */ - uint8_t ucMACAddressAllNodes[ ipMAC_ADDRESS_LENGTH_BYTES ] = { 0x33, 0x33, 0, 0, 0, 1 }; - mac_async_set_filter_ex( Ð_MAC, ucMACAddressAllNodes ); + { + /* Allow all nodes IPv6 multicast MAC */ + uint8_t ucMACAddressAllNodes[ ipMAC_ADDRESS_LENGTH_BYTES ] = { 0x33, 0x33, 0, 0, 0, 1 }; + mac_async_set_filter_ex( Ð_MAC, ucMACAddressAllNodes ); - #if ( ipconfigUSE_LLMNR == 1 ) - { - uint8_t ucMACAddressLLMNRIPv6[ ipMAC_ADDRESS_LENGTH_BYTES ]; - /* Avoid warning */ - memcpy( ucMACAddressLLMNRIPv6, xLLMNR_MacAdressIPv6.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ); - mac_async_set_filter_ex( Ð_MAC, ucMACAddressLLMNRIPv6 ); - } - #endif /* ipconfigUSE_LLMNR */ + #if ( ipconfigUSE_LLMNR == 1 ) + { + uint8_t ucMACAddressLLMNRIPv6[ ipMAC_ADDRESS_LENGTH_BYTES ]; + /* Avoid warning */ + memcpy( ucMACAddressLLMNRIPv6, xLLMNR_MacAddressIPv6.ucBytes, ipMAC_ADDRESS_LENGTH_BYTES ); + mac_async_set_filter_ex( Ð_MAC, ucMACAddressLLMNRIPv6 ); } + #endif /* ipconfigUSE_LLMNR */ + } #endif /* ipconfigUSE_IPv6 */ for( pxEndPointIter = FreeRTOS_FirstEndPoint( pxMyInterface ); @@ -547,19 +547,19 @@ static void prvGMACInit() pxEndPointIter = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPointIter ) ) { #if ( ipconfigUSE_IPv6 != 0 ) + { + if( pxEndPointIter->bits.bIPv6 != pdFALSE_UNSIGNED ) { - if( pxEndPointIter->bits.bIPv6 != pdFALSE_UNSIGNED ) - { - /* Allow traffic from IPv6 solicited-node multicast MAC address for - * each endpoint */ - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; - - ucMACAddress[ 3 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 13 ]; - ucMACAddress[ 4 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 14 ]; - ucMACAddress[ 5 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - mac_async_set_filter_ex( Ð_MAC, ucMACAddress ); - } + /* Allow traffic from IPv6 solicited-node multicast MAC address for + * each endpoint */ + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + + ucMACAddress[ 3 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPointIter->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + mac_async_set_filter_ex( Ð_MAC, ucMACAddress ); } + } #endif /* ipconfigUSE_IPv6 */ /* Allow endpoint MAC */ diff --git a/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c b/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c index 3540a324a5..a2b19d7343 100644 --- a/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c +++ b/source/portable/NetworkInterface/DriverSAM/NetworkInterface.c @@ -631,18 +631,18 @@ static BaseType_t prvSAM_NetworkInterfaceOutput( NetworkInterface_t * pxInterfac TX_STAT_INCREMENT( tx_enqueue_ok ); #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Confirm that the pxDescriptor may be kept by the driver. */ - configASSERT( bReleaseAfterSend != pdFALSE ); - } + { + /* Confirm that the pxDescriptor may be kept by the driver. */ + configASSERT( bReleaseAfterSend != pdFALSE ); + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ #if ( NETWORK_BUFFERS_CACHED != 0 ) - { - uint32_t xlength = CACHE_LINE_SIZE * ( ( ulTransmitSize + NETWORK_BUFFER_HEADER_SIZE + CACHE_LINE_SIZE - 1 ) / CACHE_LINE_SIZE ); - uint32_t xAddress = ( uint32_t ) ( pxDescriptor->pucEthernetBuffer - NETWORK_BUFFER_HEADER_SIZE ); - cache_clean_invalidate_by_addr( xAddress, xlength ); - } + { + uint32_t xlength = CACHE_LINE_SIZE * ( ( ulTransmitSize + NETWORK_BUFFER_HEADER_SIZE + CACHE_LINE_SIZE - 1 ) / CACHE_LINE_SIZE ); + uint32_t xAddress = ( uint32_t ) ( pxDescriptor->pucEthernetBuffer - NETWORK_BUFFER_HEADER_SIZE ); + cache_clean_invalidate_by_addr( xAddress, xlength ); + } #endif ulResult = gmac_dev_write( &gs_gmac_dev, ( void * ) pxDescriptor->pucEthernetBuffer, ulTransmitSize ); @@ -653,10 +653,10 @@ static BaseType_t prvSAM_NetworkInterfaceOutput( NetworkInterface_t * pxInterfac } #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Confirm that the pxDescriptor may be kept by the driver. */ - bReleaseAfterSend = pdFALSE; - } + { + /* Confirm that the pxDescriptor may be kept by the driver. */ + bReleaseAfterSend = pdFALSE; + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ /* Not interested in a call-back after TX. */ iptraceNETWORK_INTERFACE_TRANSMIT(); @@ -710,35 +710,35 @@ static BaseType_t prvGMACInit( NetworkInterface_t * pxInterface ) GMAC->GMAC_NCFGR |= GMAC_NCFGR_MTIHEN; #if ( ipconfigUSE_LLMNR == 1 ) - { - prvAddMulticastMACAddress( xLLMNR_MacAdress.ucBytes ); - } + { + prvAddMulticastMACAddress( xLLMNR_MacAddress.ucBytes ); + } #endif /* ipconfigUSE_LLMNR */ #if ( ipconfigUSE_IPv6 != 0 ) + { + NetworkEndPoint_t * pxEndPoint; + #if ( ipconfigUSE_LLMNR == 1 ) { - NetworkEndPoint_t * pxEndPoint; - #if ( ipconfigUSE_LLMNR == 1 ) - { - prvAddMulticastMACAddress( xLLMNR_MacAdressIPv6.ucBytes ); - } - #endif /* ipconfigUSE_LLMNR */ + prvAddMulticastMACAddress( xLLMNR_MacAddressIPv6.ucBytes ); + } + #endif /* ipconfigUSE_LLMNR */ - for( pxEndPoint = FreeRTOS_FirstEndPoint( pxMyInterface ); - pxEndPoint != NULL; - pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) + for( pxEndPoint = FreeRTOS_FirstEndPoint( pxMyInterface ); + pxEndPoint != NULL; + pxEndPoint = FreeRTOS_NextEndPoint( pxMyInterface, pxEndPoint ) ) + { + if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) { - if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) - { - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; - ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; - ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; - ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - prvAddMulticastMACAddress( ucMACAddress ); - } + ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + prvAddMulticastMACAddress( ucMACAddress ); } } + } #endif /* ipconfigUSE_IPv6 */ { @@ -754,14 +754,14 @@ static BaseType_t prvGMACInit( NetworkInterface_t * pxInterface ) /* Select Media Independent Interface type */ #if ( SAME70 != 0 ) - { - /* Selecting RMII mode. */ - GMAC->GMAC_UR &= ~GMAC_UR_RMII; - } + { + /* Selecting RMII mode. */ + GMAC->GMAC_UR &= ~GMAC_UR_RMII; + } #else - { - gmac_select_mii_mode( GMAC, ETH_PHY_MODE ); - } + { + gmac_select_mii_mode( GMAC, ETH_PHY_MODE ); + } #endif gmac_enable_transmit( GMAC, true ); @@ -832,77 +832,77 @@ static void prvEthernetUpdateConfig( BaseType_t xForce ) if( ( xForce != pdFALSE ) || ( xPhyObject.ulLinkStatusMask != 0 ) ) { #if ( ipconfigETHERNET_AN_ENABLE != 0 ) - { - UBaseType_t uxWasEnabled; + { + UBaseType_t uxWasEnabled; - /* Restart the auto-negotiation. */ - uxWasEnabled = ( GMAC->GMAC_NCR & GMAC_NCR_MPE ) != 0u; + /* Restart the auto-negotiation. */ + uxWasEnabled = ( GMAC->GMAC_NCR & GMAC_NCR_MPE ) != 0u; - if( uxWasEnabled == 0u ) - { - /* Enable further GMAC maintenance. */ - GMAC->GMAC_NCR |= GMAC_NCR_MPE; - } + if( uxWasEnabled == 0u ) + { + /* Enable further GMAC maintenance. */ + GMAC->GMAC_NCR |= GMAC_NCR_MPE; + } - xPhyStartAutoNegotiation( &xPhyObject, xPhyGetMask( &xPhyObject ) ); + xPhyStartAutoNegotiation( &xPhyObject, xPhyGetMask( &xPhyObject ) ); - /* Configure the MAC with the Duplex Mode fixed by the - * auto-negotiation process. */ - if( xPhyObject.xPhyProperties.ucDuplex == PHY_DUPLEX_FULL ) - { - gmac_enable_full_duplex( GMAC, pdTRUE ); - } - else - { - gmac_enable_full_duplex( GMAC, pdFALSE ); - } + /* Configure the MAC with the Duplex Mode fixed by the + * auto-negotiation process. */ + if( xPhyObject.xPhyProperties.ucDuplex == PHY_DUPLEX_FULL ) + { + gmac_enable_full_duplex( GMAC, pdTRUE ); + } + else + { + gmac_enable_full_duplex( GMAC, pdFALSE ); + } - /* Configure the MAC with the speed fixed by the - * auto-negotiation process. */ - if( xPhyObject.xPhyProperties.ucSpeed == PHY_SPEED_10 ) - { - gmac_set_speed( GMAC, pdFALSE ); - } - else - { - gmac_set_speed( GMAC, pdTRUE ); - } + /* Configure the MAC with the speed fixed by the + * auto-negotiation process. */ + if( xPhyObject.xPhyProperties.ucSpeed == PHY_SPEED_10 ) + { + gmac_set_speed( GMAC, pdFALSE ); + } + else + { + gmac_set_speed( GMAC, pdTRUE ); + } - if( uxWasEnabled == 0u ) - { - /* Enable further GMAC maintenance. */ - GMAC->GMAC_NCR &= ~GMAC_NCR_MPE; - } + if( uxWasEnabled == 0u ) + { + /* Enable further GMAC maintenance. */ + GMAC->GMAC_NCR &= ~GMAC_NCR_MPE; } + } #else /* if ( ipconfigETHERNET_AN_ENABLE != 0 ) */ + { + if( xPHYProperties.ucDuplex == PHY_DUPLEX_FULL ) { - if( xPHYProperties.ucDuplex == PHY_DUPLEX_FULL ) - { - xPhyObject.xPhyPreferences.ucDuplex = PHY_DUPLEX_FULL; - gmac_enable_full_duplex( GMAC, pdTRUE ); - } - else - { - xPhyObject.xPhyPreferences.ucDuplex = PHY_DUPLEX_HALF; - gmac_enable_full_duplex( GMAC, pdFALSE ); - } + xPhyObject.xPhyPreferences.ucDuplex = PHY_DUPLEX_FULL; + gmac_enable_full_duplex( GMAC, pdTRUE ); + } + else + { + xPhyObject.xPhyPreferences.ucDuplex = PHY_DUPLEX_HALF; + gmac_enable_full_duplex( GMAC, pdFALSE ); + } - if( xPHYProperties.ucSpeed == PHY_SPEED_100 ) - { - xPhyObject.xPhyPreferences.ucSpeed = PHY_SPEED_100; - gmac_set_speed( GMAC, pdTRUE ); - } - else - { - xPhyObject.xPhyPreferences.ucSpeed = PHY_SPEED_10; - gmac_set_speed( GMAC, pdFALSE ); - } + if( xPHYProperties.ucSpeed == PHY_SPEED_100 ) + { + xPhyObject.xPhyPreferences.ucSpeed = PHY_SPEED_100; + gmac_set_speed( GMAC, pdTRUE ); + } + else + { + xPhyObject.xPhyPreferences.ucSpeed = PHY_SPEED_10; + gmac_set_speed( GMAC, pdFALSE ); + } - xPhyObject.xPhyPreferences.ucMDI_X = PHY_MDIX_AUTO; + xPhyObject.xPhyPreferences.ucMDI_X = PHY_MDIX_AUTO; - /* Use predefined (fixed) configuration. */ - xPhyFixedValue( &xPhyObject, xPhyGetMask( &xPhyObject ) ); - } + /* Use predefined (fixed) configuration. */ + xPhyFixedValue( &xPhyObject, xPhyGetMask( &xPhyObject ) ); + } #endif /* if ( ipconfigETHERNET_AN_ENABLE != 0 ) */ } } @@ -1007,15 +1007,15 @@ static uint32_t prvEMACRxPoll( void ) iptraceNETWORK_INTERFACE_RECEIVE(); #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - pxNextNetworkBufferDescriptor = pxPacketBuffer_to_NetworkBuffer( pucDMABuffer ); + { + pxNextNetworkBufferDescriptor = pxPacketBuffer_to_NetworkBuffer( pucDMABuffer ); - if( pxNextNetworkBufferDescriptor == NULL ) - { - /* Strange: can not translate from a DMA buffer to a Network Buffer. */ - break; - } + if( pxNextNetworkBufferDescriptor == NULL ) + { + /* Strange: can not translate from a DMA buffer to a Network Buffer. */ + break; } + } #endif /* ipconfigZERO_COPY_RX_DRIVER */ pxNextNetworkBufferDescriptor->xDataLength = ( size_t ) ulReceiveCount; @@ -1070,17 +1070,17 @@ void vCheckBuffersAndQueue( void ) static UBaseType_t uxCurrentCount; #if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - uxCurrentCount = uxGetMinimumIPQueueSpace(); + { + uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - * while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } + if( uxLastMinQueueSpace != uxCurrentCount ) + { + /* The logging produced below may be helpful + * while tuning +TCP: see how many buffers are in use. */ + uxLastMinQueueSpace = uxCurrentCount; + FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); } + } #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ uxCurrentCount = uxGetMinimumFreeNetworkBuffers(); @@ -1165,23 +1165,23 @@ static void prvEMACHandlerTask( void * pvParameters ) while( xQueueReceive( xTxBufferQueue, &pucBuffer, 0 ) != pdFALSE ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) + { + pxBuffer = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); + + if( pxBuffer != NULL ) { - pxBuffer = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); - - if( pxBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxBuffer ); - TX_STAT_INCREMENT( tx_release_ok ); - } - else - { - TX_STAT_INCREMENT( tx_release_bad ); - } + vReleaseNetworkBufferAndDescriptor( pxBuffer ); + TX_STAT_INCREMENT( tx_release_ok ); } - #else /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ + else { - TX_STAT_INCREMENT( tx_release_ok ); + TX_STAT_INCREMENT( tx_release_bad ); } + } + #else /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ + { + TX_STAT_INCREMENT( tx_release_ok ); + } #endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ uxCount = uxQueueMessagesWaiting( ( QueueHandle_t ) xTXDescriptorSemaphore ); diff --git a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c index f98afdb737..6fe1fb6f75 100644 --- a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c +++ b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.c @@ -42,7 +42,7 @@ */ /* - * Support and FAQ: visit Atmel Support + * Support and FAQ: visit Atmel Support */ @@ -79,7 +79,7 @@ /*/ @cond 0 */ /**INDENT-OFF**/ #ifdef __cplusplus - extern "C" { +extern "C" { #endif /**INDENT-ON**/ /*/ @endcond */ @@ -276,13 +276,13 @@ void gmac_reset_tx_mem( gmac_device_t * p_dev ) for( ul_index = 0; ul_index < GMAC_TX_BUFFERS; ul_index++ ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - ul_address = ( uint32_t ) 0u; - } + { + ul_address = ( uint32_t ) 0u; + } #else - { - ul_address = ( uint32_t ) ( &( gs_uc_tx_buffer[ ul_index * GMAC_TX_UNITSIZE ] ) ); - } + { + ul_address = ( uint32_t ) ( &( gs_uc_tx_buffer[ ul_index * GMAC_TX_UNITSIZE ] ) ); + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ gs_tx_desc[ ul_index ].addr = ul_address; gs_tx_desc[ ul_index ].status.val = GMAC_TXD_USED; @@ -294,14 +294,14 @@ void gmac_reset_tx_mem( gmac_device_t * p_dev ) /* Set transmit buffer queue */ gmac_set_tx_queue( p_hw, ( uint32_t ) gs_tx_desc ); #if ( SAME70 != 0 ) - { - gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_1 ); - gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_2 ); - /* Note that SAME70 REV B had 6 priority queues. */ - gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_3 ); - gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_4 ); - gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_5 ); - } + { + gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_1 ); + gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_2 ); + /* Note that SAME70 REV B had 6 priority queues. */ + gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_3 ); + gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_4 ); + gmac_set_tx_priority_queue( p_hw, ( uint32_t ) &gs_tx_desc_null, GMAC_QUE_5 ); + } #endif } @@ -326,17 +326,17 @@ static void gmac_reset_rx_mem( gmac_device_t * p_dev ) for( ul_index = 0; ul_index < GMAC_RX_BUFFERS; ul_index++ ) { #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - NetworkBufferDescriptor_t * pxNextNetworkBufferDescriptor; + { + NetworkBufferDescriptor_t * pxNextNetworkBufferDescriptor; - pxNextNetworkBufferDescriptor = pxGetNetworkBufferWithDescriptor( GMAC_RX_UNITSIZE, 0ul ); - configASSERT( pxNextNetworkBufferDescriptor != NULL ); - ul_address = ( uint32_t ) ( pxNextNetworkBufferDescriptor->pucEthernetBuffer ); - } + pxNextNetworkBufferDescriptor = pxGetNetworkBufferWithDescriptor( GMAC_RX_UNITSIZE, 0ul ); + configASSERT( pxNextNetworkBufferDescriptor != NULL ); + ul_address = ( uint32_t ) ( pxNextNetworkBufferDescriptor->pucEthernetBuffer ); + } #else - { - ul_address = ( uint32_t ) ( &( gs_uc_rx_buffer[ ul_index * GMAC_RX_UNITSIZE ] ) ); - } + { + ul_address = ( uint32_t ) ( &( gs_uc_rx_buffer[ ul_index * GMAC_RX_UNITSIZE ] ) ); + } #endif /* ipconfigZERO_COPY_RX_DRIVER */ gs_rx_desc[ ul_index ].addr.val = ul_address & GMAC_RXD_ADDR_MASK; gs_rx_desc[ ul_index ].status.val = 0; @@ -459,7 +459,6 @@ void gmac_dev_init( Gmac * p_gmac, * Note: SAM4E/SAME70 do have RX checksum offloading * but TX checksum offloading has NOT been implemented, * at least on a SAM4E. - * http://community.atmel.com/forum/sam4e-gmac-transmit-checksum-offload-enablesolved */ { @@ -468,11 +467,11 @@ void gmac_dev_init( Gmac * p_gmac, /* Let the GMAC set TX checksum's. */ ulValue |= GMAC_DCFGR_TXCOEN; #if ( SAME70 != 0 ) - { - /* Transmitter Packet Buffer Memory Size Select: - * Use full configured addressable space (4 Kbytes). */ - ulValue |= GMAC_DCFGR_TXPBMS; - } + { + /* Transmitter Packet Buffer Memory Size Select: + * Use full configured addressable space (4 KBytes). */ + ulValue |= GMAC_DCFGR_TXPBMS; + } #endif /* Clear the DMA Receive Buffer Size (DRBS) field: */ @@ -511,84 +510,84 @@ static uint32_t gmac_dev_poll( gmac_device_t * p_gmac_dev ) gmac_rx_descriptor_t * pxHead = &gs_rx_desc[ ulIndex ]; #if ( ipconfigZERO_COPY_RX_DRIVER == 0 ) + { + /* Discard any incomplete frames */ + while( ( pxHead->addr.val & GMAC_RXD_OWNERSHIP ) && + ( pxHead->status.val & GMAC_RXD_SOF ) == 0 ) { - /* Discard any incomplete frames */ - while( ( pxHead->addr.val & GMAC_RXD_OWNERSHIP ) && - ( pxHead->status.val & GMAC_RXD_SOF ) == 0 ) + pxHead->addr.val &= ~( GMAC_RXD_OWNERSHIP ); + circ_inc32( &ulIndex, GMAC_RX_BUFFERS ); + pxHead = &gs_rx_desc[ ulIndex ]; + p_gmac_dev->ul_rx_idx = ulIndex; + #if ( GMAC_STATS != 0 ) { - pxHead->addr.val &= ~( GMAC_RXD_OWNERSHIP ); - circ_inc32( &ulIndex, GMAC_RX_BUFFERS ); - pxHead = &gs_rx_desc[ ulIndex ]; - p_gmac_dev->ul_rx_idx = ulIndex; - #if ( GMAC_STATS != 0 ) - { - gmacStats.incompCount++; - } - #endif + gmacStats.incompCount++; } + #endif } + } #endif /* ipconfigZERO_COPY_RX_DRIVER == 0 */ while( ( pxHead->addr.val & GMAC_RXD_OWNERSHIP ) != 0 ) { #if ( ipconfigZERO_COPY_RX_DRIVER == 0 ) + { + if( ( pxHead->status.val & GMAC_RXD_EOF ) != 0 ) { - if( ( pxHead->status.val & GMAC_RXD_EOF ) != 0 ) - { - /* Here a complete frame has been seen with SOF and EOF */ - ulReturn = pxHead->status.bm.b_len; - break; - } + /* Here a complete frame has been seen with SOF and EOF */ + ulReturn = pxHead->status.bm.b_len; + break; + } - circ_inc32( &ulIndex, GMAC_RX_BUFFERS ); - pxHead = &gs_rx_desc[ ulIndex ]; + circ_inc32( &ulIndex, GMAC_RX_BUFFERS ); + pxHead = &gs_rx_desc[ ulIndex ]; - if( ( pxHead->addr.val & GMAC_RXD_OWNERSHIP ) == 0 ) - { - /* CPU is not the owner (yet) */ - break; - } + if( ( pxHead->addr.val & GMAC_RXD_OWNERSHIP ) == 0 ) + { + /* CPU is not the owner (yet) */ + break; + } + + if( ( pxHead->status.val & GMAC_RXD_SOF ) != 0 ) + { + /* Strange, we found a new Start Of Frame + * discard previous segments */ + int32_t ulPrev = p_gmac_dev->ul_rx_idx; + pxHead = &gs_rx_desc[ ulPrev ]; - if( ( pxHead->status.val & GMAC_RXD_SOF ) != 0 ) + do { - /* Strange, we found a new Start Of Frame - * discard previous segments */ - int32_t ulPrev = p_gmac_dev->ul_rx_idx; + pxHead->addr.val &= ~( GMAC_RXD_OWNERSHIP ); + circ_inc32( &ulPrev, GMAC_RX_BUFFERS ); pxHead = &gs_rx_desc[ ulPrev ]; - - do + #if ( GMAC_STATS != 0 ) { - pxHead->addr.val &= ~( GMAC_RXD_OWNERSHIP ); - circ_inc32( &ulPrev, GMAC_RX_BUFFERS ); - pxHead = &gs_rx_desc[ ulPrev ]; - #if ( GMAC_STATS != 0 ) - { - gmacStats.truncCount++; - } - #endif - } while( ulPrev != ulIndex ); - - p_gmac_dev->ul_rx_idx = ulIndex; - } + gmacStats.truncCount++; + } + #endif + } while( ulPrev != ulIndex ); + + p_gmac_dev->ul_rx_idx = ulIndex; } + } #else /* ipconfigZERO_COPY_RX_DRIVER */ + { + if( ( pxHead->status.val & ( GMAC_RXD_SOF | GMAC_RXD_EOF ) ) == ( GMAC_RXD_SOF | GMAC_RXD_EOF ) ) { - if( ( pxHead->status.val & ( GMAC_RXD_SOF | GMAC_RXD_EOF ) ) == ( GMAC_RXD_SOF | GMAC_RXD_EOF ) ) - { - /* Here a complete frame in a single segment. */ - ulReturn = pxHead->status.bm.b_len; - break; - } + /* Here a complete frame in a single segment. */ + ulReturn = pxHead->status.bm.b_len; + break; + } - /* Return the buffer to DMA. */ - pxHead->addr.bm.b_ownership = 0; + /* Return the buffer to DMA. */ + pxHead->addr.bm.b_ownership = 0; - /* Let ulIndex/pxHead point to the next buffer. */ - circ_inc32( &ulIndex, GMAC_RX_BUFFERS ); - pxHead = &gs_rx_desc[ ulIndex ]; - /* And remember this index. */ - p_gmac_dev->ul_rx_idx = ulIndex; - } + /* Let ulIndex/pxHead point to the next buffer. */ + circ_inc32( &ulIndex, GMAC_RX_BUFFERS ); + pxHead = &gs_rx_desc[ ulIndex ]; + /* And remember this index. */ + p_gmac_dev->ul_rx_idx = ulIndex; + } #endif /* ipconfigZERO_COPY_RX_DRIVER */ } @@ -637,55 +636,55 @@ uint32_t gmac_dev_read( gmac_device_t * p_gmac_dev, #endif #if ( ipconfigZERO_COPY_RX_DRIVER == 0 ) + { + /* The frame will be copied in 1 or 2 memcpy's */ + if( p_frame != NULL ) { - /* The frame will be copied in 1 or 2 memcpy's */ - if( p_frame != NULL ) - { - const uint8_t * source; - int32_t left; - int32_t toCopy; + const uint8_t * source; + int32_t left; + int32_t toCopy; - source = gs_uc_rx_buffer + nextIdx * GMAC_RX_UNITSIZE; + source = gs_uc_rx_buffer + nextIdx * GMAC_RX_UNITSIZE; - /* The driver receives frames up to 1514 bytes long. - * The actual value of ul_frame_size is 1536, so the - * following test is not really necessary: - */ + /* The driver receives frames up to 1514 bytes long. + * The actual value of ul_frame_size is 1536, so the + * following test is not really necessary: + */ - /* Read +2 bytes because buffers are aligned at -2 bytes */ - left = min( bytesLeft + 2, ( int32_t ) ul_frame_size ); - toCopy = ( GMAC_RX_BUFFERS - nextIdx ) * GMAC_RX_UNITSIZE; + /* Read +2 bytes because buffers are aligned at -2 bytes */ + left = min( bytesLeft + 2, ( int32_t ) ul_frame_size ); + toCopy = ( GMAC_RX_BUFFERS - nextIdx ) * GMAC_RX_UNITSIZE; - if( toCopy > left ) - { - toCopy = left; - } + if( toCopy > left ) + { + toCopy = left; + } - memcpy( p_frame, source, toCopy ); - left -= toCopy; + memcpy( p_frame, source, toCopy ); + left -= toCopy; - if( left != 0ul ) - { - memcpy( p_frame + toCopy, ( void * ) gs_uc_rx_buffer, left ); - } + if( left != 0ul ) + { + memcpy( p_frame + toCopy, ( void * ) gs_uc_rx_buffer, left ); } } + } #else /* ipconfigZERO_COPY_RX_DRIVER */ + { + if( p_frame != NULL ) { - if( p_frame != NULL ) - { - /* Return a pointer to the earlier DMA buffer. */ - *( pp_recv_frame ) = ( uint8_t * ) - ( ( ( gs_rx_desc[ nextIdx ].addr.val ) & ~( 0x03ul ) ) + 2 ); - /* Set the new DMA-buffer. */ - gs_rx_desc[ nextIdx ].addr.bm.addr_dw = ( ( uint32_t ) p_frame ) / 4; - } - else - { - /* The driver could not allocate a buffer to receive a packet. - * Leave the current DMA buffer in place. */ - } + /* Return a pointer to the earlier DMA buffer. */ + *( pp_recv_frame ) = ( uint8_t * ) + ( ( ( gs_rx_desc[ nextIdx ].addr.val ) & ~( 0x03ul ) ) + 2 ); + /* Set the new DMA-buffer. */ + gs_rx_desc[ nextIdx ].addr.bm.addr_dw = ( ( uint32_t ) p_frame ) / 4; + } + else + { + /* The driver could not allocate a buffer to receive a packet. + * Leave the current DMA buffer in place. */ } + } #endif /* ipconfigZERO_COPY_RX_DRIVER */ do @@ -752,15 +751,15 @@ uint32_t gmac_dev_write( gmac_device_t * p_gmac_dev, /* Calculating the checksum here is faster than calculating it from the GMAC buffer * because within p_buffer, it is well aligned */ #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Zero-copy... */ - p_tx_td->addr = ( uint32_t ) p_buffer; - } + { + /* Zero-copy... */ + p_tx_td->addr = ( uint32_t ) p_buffer; + } #else - { - /* Or memcopy... */ - memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size ); - } + { + /* Or memcopy... */ + memcpy( ( void * ) p_tx_td->addr, p_buffer, ul_size ); + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ { /* Needs to be called for SAM4E series only. */ @@ -921,15 +920,15 @@ void gmac_handler( gmac_device_t * p_gmac_dev ) uint32_t ul_tsr = gmac_get_tx_status( p_hw ); #if ( GMAC_STATS != 0 ) + { + for( index = 0; index < ARRAY_SIZE( intPairs ); index++ ) { - for( index = 0; index < ARRAY_SIZE( intPairs ); index++ ) + if( ul_isr & intPairs[ index ].mask ) { - if( ul_isr & intPairs[ index ].mask ) - { - gmacStats.intStatus[ intPairs[ index ].index ]++; - } + gmacStats.intStatus[ intPairs[ index ].index ]++; } } + } #endif /* GMAC_STATS != 0 */ /* RX packet */ @@ -982,9 +981,9 @@ void gmac_handler( gmac_device_t * p_gmac_dev ) /* Notify upper layer that a packet has been sent */ xTxCallback( ul_tx_status_flag, ( void * ) p_tx_td->addr ); /* Function call prvTxCallback */ #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - p_tx_td->addr = 0ul; - } + { + p_tx_td->addr = 0ul; + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ circ_inc32( &p_gmac_dev->l_tx_tail, GMAC_TX_BUFFERS ); diff --git a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h index 846285cd9c..3b6512f9eb 100644 --- a/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h +++ b/source/portable/NetworkInterface/DriverSAM/gmac_SAM.h @@ -53,7 +53,7 @@ /*/ @cond 0 */ /**INDENT-OFF**/ #ifdef __cplusplus - extern "C" { + extern "C" { #endif /**INDENT-ON**/ /*/ @endcond */ @@ -1469,7 +1469,7 @@ } /** - * \brief Set screening type 2 eherType register. + * \brief Set screening type 2 etherType register. * * \param p_gmac Pointer to the GMAC instance. * \param ethertype Ethertype compare value diff --git a/source/portable/NetworkInterface/LPC17xx/README.md b/source/portable/NetworkInterface/LPC17xx/README.md index d370df7964..f2b956b8db 100644 --- a/source/portable/NetworkInterface/LPC17xx/README.md +++ b/source/portable/NetworkInterface/LPC17xx/README.md @@ -1,9 +1,9 @@ -## Disclaimer : +## Disclaimer : Please note that LPC17xx port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting LPC17xx port to use it. diff --git a/source/portable/NetworkInterface/LPC18xx/NetworkInterface.c b/source/portable/NetworkInterface/LPC18xx/NetworkInterface.c index dbd4d2050d..f2a536c578 100644 --- a/source/portable/NetworkInterface/LPC18xx/NetworkInterface.c +++ b/source/portable/NetworkInterface/LPC18xx/NetworkInterface.c @@ -223,7 +223,7 @@ static uint32_t ulNextRxDescriptorToProcess; static TaskHandle_t xRxHanderTask = NULL; #if ( ipconfigUSE_LLMNR == 1 ) - static const uint8_t xLLMNR_MACAddress[] = { '\x01', '\x00', '\x5E', '\x00', '\x00', '\xFC' }; +static const uint8_t xLLMNR_MACAddress[] = { '\x01', '\x00', '\x5E', '\x00', '\x00', '\xFC' }; #endif /* ipconfigUSE_LLMNR == 1 */ /* xTXDescriptorSemaphore is a counting semaphore with @@ -258,9 +258,9 @@ BaseType_t xNetworkInterfaceInitialise( void ) LPC_ETHERNET->MAC_HASHTABLE_LOW = 0; #if ( ipconfigUSE_LLMNR == 1 ) - { - prvAddMACAddress( xLLMNR_MACAddress ); - } + { + prvAddMACAddress( xLLMNR_MACAddress ); + } #endif /* ipconfigUSE_LLMNR == 1 */ /* Promiscuous flag (PR) and Receive All flag (RA) set to zero. The @@ -269,25 +269,25 @@ BaseType_t xNetworkInterfaceInitialise( void ) LPC_ETHERNET->MAC_FRAME_FILTER = MAC_FF_HMC; #if ( configUSE_RMII == 1 ) + { + if( lpc_phy_init( pdTRUE, prvDelay ) != SUCCESS ) { - if( lpc_phy_init( pdTRUE, prvDelay ) != SUCCESS ) - { - xReturn = pdFAIL; - } + xReturn = pdFAIL; } + } #else + { + #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) { - #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) - { - #warning This path has not been tested. - } - #endif + #warning This path has not been tested. + } + #endif - if( lpc_phy_init( pdFALSE, prvDelay ) != SUCCESS ) - { - xReturn = pdFAIL; - } + if( lpc_phy_init( pdFALSE, prvDelay ) != SUCCESS ) + { + xReturn = pdFAIL; } + } #endif /* if ( configUSE_RMII == 1 ) */ if( xReturn == pdPASS ) @@ -386,20 +386,20 @@ static void vClearTXBuffers() } #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - ucPayLoad = ( uint8_t * ) xDMATxDescriptors[ ulTxDescriptorToClear ].B1ADD; + { + ucPayLoad = ( uint8_t * ) xDMATxDescriptors[ ulTxDescriptorToClear ].B1ADD; - if( ucPayLoad != NULL ) - { - /* B1ADD points to a pucEthernetBuffer of a Network Buffer descriptor. */ - pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); + if( ucPayLoad != NULL ) + { + /* B1ADD points to a pucEthernetBuffer of a Network Buffer descriptor. */ + pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); - configASSERT( pxNetworkBuffer != NULL ); + configASSERT( pxNetworkBuffer != NULL ); - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - xDMATxDescriptors[ ulTxDescriptorToClear ].B1ADD = ( uint32_t ) 0u; - } + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); + xDMATxDescriptors[ ulTxDescriptorToClear ].B1ADD = ( uint32_t ) 0u; } + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ /* Move onto the next descriptor, wrapping if necessary. */ @@ -449,25 +449,25 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxDescript else { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* bReleaseAfterSend should always be set when using the zero - * copy driver. */ - configASSERT( bReleaseAfterSend != pdFALSE ); + { + /* bReleaseAfterSend should always be set when using the zero + * copy driver. */ + configASSERT( bReleaseAfterSend != pdFALSE ); - /* The DMA's descriptor to point directly to the data in the - * network buffer descriptor. The data is not copied. */ - xDMATxDescriptors[ ulNextFreeTxDescriptor ].B1ADD = ( uint32_t ) pxDescriptor->pucEthernetBuffer; + /* The DMA's descriptor to point directly to the data in the + * network buffer descriptor. The data is not copied. */ + xDMATxDescriptors[ ulNextFreeTxDescriptor ].B1ADD = ( uint32_t ) pxDescriptor->pucEthernetBuffer; - /* The DMA descriptor will 'own' this Network Buffer, - * until it has been sent. So don't release it now. */ - bReleaseAfterSend = false; - } + /* The DMA descriptor will 'own' this Network Buffer, + * until it has been sent. So don't release it now. */ + bReleaseAfterSend = false; + } #else /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ - { - /* The data is copied from the network buffer descriptor into - * the DMA's descriptor. */ - memcpy( ( void * ) xDMATxDescriptors[ ulNextFreeTxDescriptor ].B1ADD, ( void * ) pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength ); - } + { + /* The data is copied from the network buffer descriptor into + * the DMA's descriptor. */ + memcpy( ( void * ) xDMATxDescriptors[ ulNextFreeTxDescriptor ].B1ADD, ( void * ) pxDescriptor->pucEthernetBuffer, pxDescriptor->xDataLength ); + } #endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ xDMATxDescriptors[ ulNextFreeTxDescriptor ].BSIZE = ( uint32_t ) TDES_ENH_BS1( pxDescriptor->xDataLength ); @@ -529,22 +529,22 @@ static void prvSetupTxDescriptors( void ) for( x = 0; x < configNUM_TX_DESCRIPTORS; x++ ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Nothing to do, B1ADD will be set when data is ready to transmit. - * Currently the memset above will have set it to NULL. */ - } + { + /* Nothing to do, B1ADD will be set when data is ready to transmit. + * Currently the memset above will have set it to NULL. */ + } #else - { - /* Allocate a buffer to the Tx descriptor. This is the most basic - * way of creating a driver as the data is then copied into the - * buffer. */ - xDMATxDescriptors[ x ].B1ADD = ( uint32_t ) pvPortMalloc( ipTOTAL_ETHERNET_FRAME_SIZE ); - - /* Use an assert to check the allocation as +TCP applications will - * often not use a malloc() failed hook as the TCP stack will recover - * from allocation failures. */ - configASSERT( xDMATxDescriptors[ x ].B1ADD != 0U ); - } + { + /* Allocate a buffer to the Tx descriptor. This is the most basic + * way of creating a driver as the data is then copied into the + * buffer. */ + xDMATxDescriptors[ x ].B1ADD = ( uint32_t ) pvPortMalloc( ipTOTAL_ETHERNET_FRAME_SIZE ); + + /* Use an assert to check the allocation as +TCP applications will + * often not use a malloc() failed hook as the TCP stack will recover + * from allocation failures. */ + configASSERT( xDMATxDescriptors[ x ].B1ADD != 0U ); + } #endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ /* Buffers hold an entire frame so all buffers are both the start and @@ -586,25 +586,25 @@ static void prvSetupRxDescriptors( void ) * known what size received frames will be. */ #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, 0 ); + { + pxNetworkBuffer = pxGetNetworkBufferWithDescriptor( ipTOTAL_ETHERNET_FRAME_SIZE, 0 ); - /* During start-up there should be enough Network Buffers available, - * so it is safe to use configASSERT(). - * In case this assert fails, please check: configNUM_RX_DESCRIPTORS, - * ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, and in case BufferAllocation_2.c - * is included, check the amount of available heap. */ - configASSERT( pxNetworkBuffer != NULL ); + /* During start-up there should be enough Network Buffers available, + * so it is safe to use configASSERT(). + * In case this assert fails, please check: configNUM_RX_DESCRIPTORS, + * ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS, and in case BufferAllocation_2.c + * is included, check the amount of available heap. */ + configASSERT( pxNetworkBuffer != NULL ); - /* Pass the actual buffer to DMA. */ - xDMARxDescriptors[ x ].B1ADD = ( uint32_t ) pxNetworkBuffer->pucEthernetBuffer; - } + /* Pass the actual buffer to DMA. */ + xDMARxDescriptors[ x ].B1ADD = ( uint32_t ) pxNetworkBuffer->pucEthernetBuffer; + } #else - { - /* All DMA descriptors are populated with permanent memory blocks. - * Their contents will be copy to Network Buffers. */ - xDMARxDescriptors[ x ].B1ADD = ( uint32_t ) pvPortMalloc( ipTOTAL_ETHERNET_FRAME_SIZE ); - } + { + /* All DMA descriptors are populated with permanent memory blocks. + * Their contents will be copy to Network Buffers. */ + xDMARxDescriptors[ x ].B1ADD = ( uint32_t ) pvPortMalloc( ipTOTAL_ETHERNET_FRAME_SIZE ); + } #endif /* ipconfigZERO_COPY_RX_DRIVER */ /* Use an assert to check the allocation as +TCP applications will often @@ -685,7 +685,7 @@ static BaseType_t prvNetworkInterfaceInput() NetworkBufferDescriptor_t * pxNewDescriptor; #endif /* ipconfigZERO_COPY_RX_DRIVER */ #if ( ipconfigUSE_LINKED_RX_MESSAGES == 0 ) - IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; + IPStackEvent_t xRxEvent = { eNetworkRxEvent, NULL }; #endif /* Process each descriptor that is not still in use by the DMA. */ @@ -739,36 +739,36 @@ static BaseType_t prvNetworkInterfaceInput() usLength = RDES_FLMSK( ulStatus ); #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Replace the character buffer 'B1ADD'. */ - pucBuffer = ( const uint8_t * const ) ( xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD ); - xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD = ( uint32_t ) pxNewDescriptor->pucEthernetBuffer; - - /* 'B1ADD' contained the address of a 'pucEthernetBuffer' that - * belongs to a Network Buffer. Find the original Network Buffer. */ - pxDescriptor = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); - - /* This zero-copy driver makes sure that every 'xDMARxDescriptors' contains - * a reference to a Network Buffer at any time. - * In case it runs out of Network Buffers, a DMA buffer won't be replaced, - * and the received messages is dropped. */ - configASSERT( pxDescriptor != NULL ); - } + { + /* Replace the character buffer 'B1ADD'. */ + pucBuffer = ( const uint8_t * const ) ( xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD ); + xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD = ( uint32_t ) pxNewDescriptor->pucEthernetBuffer; + + /* 'B1ADD' contained the address of a 'pucEthernetBuffer' that + * belongs to a Network Buffer. Find the original Network Buffer. */ + pxDescriptor = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); + + /* This zero-copy driver makes sure that every 'xDMARxDescriptors' contains + * a reference to a Network Buffer at any time. + * In case it runs out of Network Buffers, a DMA buffer won't be replaced, + * and the received messages is dropped. */ + configASSERT( pxDescriptor != NULL ); + } #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ - { - /* Create a buffer of exactly the required length. */ - pxDescriptor = pxGetNetworkBufferWithDescriptor( usLength, xDescriptorWaitTime ); - } + { + /* Create a buffer of exactly the required length. */ + pxDescriptor = pxGetNetworkBufferWithDescriptor( usLength, xDescriptorWaitTime ); + } #endif /* ipconfigZERO_COPY_RX_DRIVER */ if( pxDescriptor != NULL ) { pxDescriptor->xDataLength = ( size_t ) usLength; #if ( ipconfigZERO_COPY_RX_DRIVER == 0 ) - { - /* Copy the data into the allocated buffer. */ - memcpy( ( void * ) pxDescriptor->pucEthernetBuffer, ( void * ) xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD, usLength ); - } + { + /* Copy the data into the allocated buffer. */ + memcpy( ( void * ) pxDescriptor->pucEthernetBuffer, ( void * ) xDMARxDescriptors[ ulNextRxDescriptorToProcess ].B1ADD, usLength ); + } #endif /* ipconfigZERO_COPY_RX_DRIVER */ /* It is possible that more data was copied than @@ -1027,19 +1027,19 @@ static void prvEMACHandlerTask( void * pvParameters ) } #if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - static UBaseType_t uxLastMinQueueSpace = 0; + { + static UBaseType_t uxLastMinQueueSpace = 0; - uxCurrentCount = uxGetMinimumIPQueueSpace(); + uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - * while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } + if( uxLastMinQueueSpace != uxCurrentCount ) + { + /* The logging produced below may be helpful + * while tuning +TCP: see how many buffers are in use. */ + uxLastMinQueueSpace = uxCurrentCount; + FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); } + } #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ ulTaskNotifyTake( pdTRUE, xBlockTime ); diff --git a/source/portable/NetworkInterface/LPC18xx/README.md b/source/portable/NetworkInterface/LPC18xx/README.md index d79167c5ff..66225a7817 100644 --- a/source/portable/NetworkInterface/LPC18xx/README.md +++ b/source/portable/NetworkInterface/LPC18xx/README.md @@ -1,9 +1,9 @@ -## Disclaimer : +## Disclaimer : Please note that LPC18xx port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting LPC18xx port to use it. diff --git a/source/portable/NetworkInterface/LPC54018/README.md b/source/portable/NetworkInterface/LPC54018/README.md index 3563d205b2..93ffac83a8 100644 --- a/source/portable/NetworkInterface/LPC54018/README.md +++ b/source/portable/NetworkInterface/LPC54018/README.md @@ -1,9 +1,9 @@ -## Disclaimer : +## Disclaimer : Please note that LPC54018 port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting LPC54018 port to use it. diff --git a/source/portable/NetworkInterface/M487/README.md b/source/portable/NetworkInterface/M487/README.md index 10b22c28ed..ea8e8dbbc2 100644 --- a/source/portable/NetworkInterface/M487/README.md +++ b/source/portable/NetworkInterface/M487/README.md @@ -1,9 +1,9 @@ -## Disclaimer : +## Disclaimer : Please note that M487 port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting M487 port to use it. diff --git a/source/portable/NetworkInterface/M487/m480_eth.h b/source/portable/NetworkInterface/M487/m480_eth.h index 04311550fc..7561aca1f0 100644 --- a/source/portable/NetworkInterface/M487/m480_eth.h +++ b/source/portable/NetworkInterface/M487/m480_eth.h @@ -136,15 +136,15 @@ #define ETH_TS_ENABLE() do { EMAC->TSCTL = EMAC_TSCTL_TSEN_Msk; } while( 0 ) #define ETH_TS_START() do { EMAC->TSCTL |= ( EMAC_TSCTL_TSMODE_Msk | EMAC_TSCTL_TSIEN_Msk ); } while( 0 ) - s32_t ETH_settime( u32_t sec, - u32_t nsec ); - s32_t ETH_gettime( u32_t * sec, - u32_t * nsec ); - s32_t ETH_updatetime( u32_t neg, - u32_t sec, - u32_t nsec ); - s32_t ETH_adjtimex( int ppm ); - void ETH_setinc( void ); + s32_t ETH_settime( u32_t sec, + u32_t nsec ); + s32_t ETH_gettime( u32_t * sec, + u32_t * nsec ); + s32_t ETH_updatetime( u32_t neg, + u32_t sec, + u32_t nsec ); + s32_t ETH_adjtimex( int ppm ); + void ETH_setinc( void ); #endif /* ifdef TIME_STAMPING */ @@ -154,18 +154,18 @@ #define NU_DEBUGF( x ) #endif - void numaker_set_mac_addr( uint8_t * addr ); - int numaker_eth_init( uint8_t * mac_addr ); - uint8_t * numaker_eth_get_tx_buf( void ); - void numaker_eth_trigger_tx( uint16_t length, - void * p ); - int numaker_eth_get_rx_buf( uint16_t * len, - uint8_t ** buf ); - void numaker_eth_rx_next( void ); - void numaker_eth_trigger_rx( void ); - int numaker_eth_link_ok( void ); - void numaker_mac_address( uint8_t * mac ); - void numaker_eth_enable_interrupts( void ); - void numaker_eth_disable_interrupts( void ); +void numaker_set_mac_addr( uint8_t * addr ); +int numaker_eth_init( uint8_t * mac_addr ); +uint8_t * numaker_eth_get_tx_buf( void ); +void numaker_eth_trigger_tx( uint16_t length, + void * p ); +int numaker_eth_get_rx_buf( uint16_t * len, + uint8_t ** buf ); +void numaker_eth_rx_next( void ); +void numaker_eth_trigger_rx( void ); +int numaker_eth_link_ok( void ); +void numaker_mac_address( uint8_t * mac ); +void numaker_eth_enable_interrupts( void ); +void numaker_eth_disable_interrupts( void ); #endif /* _M480_ETH_ */ diff --git a/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c b/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c index a15b69c3f3..3edd910ad7 100644 --- a/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c +++ b/source/portable/NetworkInterface/MPS2_AN385/NetworkInterface.c @@ -346,7 +346,7 @@ static BaseType_t xMPS2_NetworkInterfaceOutput( NetworkInterface_t * pxInterface else { xReturn = pdFAIL; - FreeRTOS_debug_printf( ( "Error send by chuncks: %d\n", + FreeRTOS_debug_printf( ( "Error send by chunks: %d\n", error ) ); } } diff --git a/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/SMM_MPS2.h b/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/SMM_MPS2.h index 54f8846d96..fc2f90fa82 100644 --- a/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/SMM_MPS2.h +++ b/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/SMM_MPS2.h @@ -281,7 +281,7 @@ typedef struct /* Document DDI0194G_ssp_pl022_r1p3_trm.pdf */ /* SSPRIS Raw interrupt status register */ #define SSP_RIS_RORRIS_Pos 0 /* Raw Overrun interrupt flag */ #define SSP_RIS_RORRIS_Msk ( 1UL << SSP_RIS_RORRIS_Pos ) -#define SSP_RIS_RTRIS_Pos 1 /* Raw Timemout interrupt flag */ +#define SSP_RIS_RTRIS_Pos 1 /* Raw Timeout interrupt flag */ #define SSP_RIS_RTRIS_Msk ( 1UL << SSP_RIS_RTRIS_Pos ) #define SSP_RIS_RXRIS_Pos 2 /* Raw Receive interrupt flag */ #define SSP_RIS_RXRIS_Msk ( 1UL << SSP_RIS_RXRIS_Pos ) @@ -291,7 +291,7 @@ typedef struct /* Document DDI0194G_ssp_pl022_r1p3_trm.pdf */ /* SSPMIS Masked interrupt status register */ #define SSP_MIS_RORMIS_Pos 0 /* Masked Overrun interrupt flag */ #define SSP_MIS_RORMIS_Msk ( 1UL << SSP_MIS_RORMIS_Pos ) -#define SSP_MIS_RTMIS_Pos 1 /* Masked Timemout interrupt flag */ +#define SSP_MIS_RTMIS_Pos 1 /* Masked Timeout interrupt flag */ #define SSP_MIS_RTMIS_Msk ( 1UL << SSP_MIS_RTMIS_Pos ) #define SSP_MIS_RXMIS_Pos 2 /* Masked Receive interrupt flag */ #define SSP_MIS_RXMIS_Msk ( 1UL << SSP_MIS_RXMIS_Pos ) @@ -301,7 +301,7 @@ typedef struct /* Document DDI0194G_ssp_pl022_r1p3_trm.pdf */ /* SSPICR Interrupt clear register */ #define SSP_ICR_RORIC_Pos 0 /* Clears Overrun interrupt flag */ #define SSP_ICR_RORIC_Msk ( 1UL << SSP_ICR_RORIC_Pos ) -#define SSP_ICR_RTIC_Pos 1 /* Clears Timemout interrupt flag */ +#define SSP_ICR_RTIC_Pos 1 /* Clears Timeout interrupt flag */ #define SSP_ICR_RTIC_Msk ( 1UL << SSP_ICR_RTIC_Pos ) /* SSPDMACR DMA control register */ diff --git a/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.c b/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.c index 17e6d00ecb..48d4b6b566 100644 --- a/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.c +++ b/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.c @@ -723,7 +723,7 @@ void smsc9220_init_irqs( const struct smsc9220_eth_dev_t * dev ) smsc9220_disable_all_interrupts( dev ); smsc9220_clear_all_interrupts( dev ); - /* Set IRQ deassertion interval */ + /* Set IRQ de-assertion interval */ SET_BIT_FIELD( register_map->irq_cfg, IRQ_CFG_INT_DEAS_MASK, IRQ_CFG_INT_DEAS_POS, IRQ_CFG_INT_DEAS_10US ); diff --git a/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.h b/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.h index cabe6d2888..ee587b3c6a 100644 --- a/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.h +++ b/source/portable/NetworkInterface/MPS2_AN385/ether_lan9118/smsc9220_eth_drv.h @@ -27,7 +27,7 @@ #include #ifdef __cplusplus - extern "C" { + extern "C" { #endif /** SMSC9220 device configuration structure */ @@ -279,7 +279,7 @@ /** * \brief Sets the Maximum Transmission Unit by Tx fifo size. * Note: The MTU will be smaller by 512 bytes, - * whis is used by the status. + * which is used by the status. * * \param[in] dev Ethernet device structure \ref smsc9220_eth_dev_t * \param[in] val Size of the fifo in kbytes @@ -470,7 +470,7 @@ int smsc9220_check_id( const struct smsc9220_eth_dev_t * dev ); /** - * \brief Gets the data size of the Tx buffer, aka Maximum Trasmission Unit + * \brief Gets the data size of the Tx buffer, aka Maximum Transmission Unit * * \param[in] dev Ethernet device structure \ref smsc9220_eth_dev_t * diff --git a/source/portable/NetworkInterface/NXP1060/NetworkInterface.c b/source/portable/NetworkInterface/NXP1060/NetworkInterface.c index e2b8ea0a8a..ed1eb2ef6b 100644 --- a/source/portable/NetworkInterface/NXP1060/NetworkInterface.c +++ b/source/portable/NetworkInterface/NXP1060/NetworkInterface.c @@ -909,12 +909,12 @@ static status_t xEMACInit( phy_speed_t speed, sysClock ); #if ( ipconfigUSE_LLMNR == 1 ) - ENET_AddMulticastGroup( ethernetifLocal->base, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); + ENET_AddMulticastGroup( ethernetifLocal->base, ( uint8_t * ) xLLMNR_MacAddress.ucBytes ); #endif /* ipconfigUSE_LLMNR */ #if ( ipconfigUSE_IPv6 != 0 ) #if ( ipconfigUSE_LLMNR == 1 ) - ENET_AddMulticastGroup( ethernetifLocal->base, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); + ENET_AddMulticastGroup( ethernetifLocal->base, ( uint8_t * ) xLLMNR_MacAddressIPv6.ucBytes ); #endif /* ipconfigUSE_LLMNR */ for( pxEndPoint = FreeRTOS_FirstEndPoint( pxMyInterface ); diff --git a/source/portable/NetworkInterface/RX/NetworkInterface.c b/source/portable/NetworkInterface/RX/NetworkInterface.c index 74c08f7de0..e67046b87d 100644 --- a/source/portable/NetworkInterface/RX/NetworkInterface.c +++ b/source/portable/NetworkInterface/RX/NetworkInterface.c @@ -284,12 +284,12 @@ static void prvEMACDeferredInterruptHandlerTask( void * pvParameters ) for( ; ; ) { #if ( ipconfigHAS_PRINTF != 0 ) - { - /* Call a function that monitors resources: the amount of free network - * buffers and the amount of free space on the heap. See FreeRTOS_IP.c - * for more detailed comments. */ - vPrintResourceStats(); - } + { + /* Call a function that monitors resources: the amount of free network + * buffers and the amount of free space on the heap. See FreeRTOS_IP.c + * for more detailed comments. */ + vPrintResourceStats(); + } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ /* Wait for the Ethernet MAC interrupt to indicate that another packet @@ -479,7 +479,7 @@ static int InitializeNetwork( void ) BaseType_t return_code = pdFALSE; ether_param_t param; - /* Read the mac address after it has been initilized by the FreeRTOS IP Stack, rather than from defines + /* Read the mac address after it has been initialized by the FreeRTOS IP Stack, rather than from defines * as the mac address is usually read from the EEPROM, and it might be different to the mac address in * the defines, especially in production environments */ diff --git a/source/portable/NetworkInterface/SH2A/README.md b/source/portable/NetworkInterface/SH2A/README.md index 3994b826f5..934fbc107a 100644 --- a/source/portable/NetworkInterface/SH2A/README.md +++ b/source/portable/NetworkInterface/SH2A/README.md @@ -1,9 +1,9 @@ -## Disclaimer : +## Disclaimer : Please note that SH2A port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting SH2A port to use it. diff --git a/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c index 4ef7ca4174..f0541decbd 100644 --- a/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Fxx/NetworkInterface.c @@ -106,7 +106,7 @@ /* * Most users will want a PHY that negotiates about - * the connection properties: speed, dmix and duplex. + * the connection properties: speed, MDIX and duplex. * On some rare cases, you want to select what is being * advertised, properties like MDIX and duplex. */ @@ -239,11 +239,11 @@ static void vClearTXBuffers( void ); /*-----------------------------------------------------------*/ #if ( ipconfigUSE_LLMNR == 1 ) - static const uint8_t xLLMNR_MACAddress[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; +static const uint8_t xLLMNR_MACAddress[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; #endif #if ( ipconfigUSE_MDNS == 1 ) - static const uint8_t xMDNS_MACAddressIPv4[] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb }; +static const uint8_t xMDNS_MACAddressIPv4[] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb }; #endif static EthernetPhy_t xPhyObject; @@ -424,21 +424,21 @@ static void vClearTXBuffers() } #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) + { + ucPayLoad = ( uint8_t * ) DMATxDescToClear->Buffer1Addr; + + if( ucPayLoad != NULL ) { - ucPayLoad = ( uint8_t * ) DMATxDescToClear->Buffer1Addr; + pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); - if( ucPayLoad != NULL ) + if( pxNetworkBuffer != NULL ) { - pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); - - if( pxNetworkBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } - - DMATxDescToClear->Buffer1Addr = ( uint32_t ) 0u; + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); } + + DMATxDescToClear->Buffer1Addr = ( uint32_t ) 0u; } + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ DMATxDescToClear = ( ETH_DMADescTypeDef * ) ( DMATxDescToClear->Buffer2NextDescAddr ); @@ -484,26 +484,26 @@ BaseType_t xSTM32F_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface xETH.Init.RxMode = ETH_RXINTERRUPT_MODE; #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - /* using the ETH_CHECKSUM_BY_HARDWARE option: - * both the IP and the protocol checksums will be calculated - * by the peripheral. */ - xETH.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE; - } + { + /* using the ETH_CHECKSUM_BY_HARDWARE option: + * both the IP and the protocol checksums will be calculated + * by the peripheral. */ + xETH.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE; + } #else - { - xETH.Init.ChecksumMode = ETH_CHECKSUM_BY_SOFTWARE; - } + { + xETH.Init.ChecksumMode = ETH_CHECKSUM_BY_SOFTWARE; + } #endif #if ( ipconfigUSE_RMII != 0 ) - { - xETH.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII; - } + { + xETH.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII; + } #else - { - xETH.Init.MediaInterface = ETH_MEDIA_INTERFACE_MII; - } + { + xETH.Init.MediaInterface = ETH_MEDIA_INTERFACE_MII; + } #endif /* ipconfigUSE_RMII */ hal_eth_init_status = HAL_ETH_Init( &xETH ); @@ -529,30 +529,30 @@ BaseType_t xSTM32F_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface prvDMARxDescListInit(); #if ( ipconfigUSE_MDNS == 1 ) - { - /* Program the MDNS address. */ - prvMACAddressConfig( &xETH, xMACEntry, ( uint8_t * ) xMDNS_MACAddressIPv4 ); - xMACEntry += 8; - } + { + /* Program the MDNS address. */ + prvMACAddressConfig( &xETH, xMACEntry, ( uint8_t * ) xMDNS_MACAddressIPv4 ); + xMACEntry += 8; + } #endif #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) - { - prvMACAddressConfig( &xETH, xMACEntry, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); - xMACEntry += 8; - } + { + prvMACAddressConfig( &xETH, xMACEntry, ( uint8_t * ) xMDNS_MACAddressIPv6.ucBytes ); + xMACEntry += 8; + } #endif #if ( ipconfigUSE_LLMNR == 1 ) - { - /* Program the LLMNR address. */ - prvMACAddressConfig( &xETH, xMACEntry, ( uint8_t * ) xLLMNR_MACAddress ); - xMACEntry += 8; - } + { + /* Program the LLMNR address. */ + prvMACAddressConfig( &xETH, xMACEntry, ( uint8_t * ) xLLMNR_MACAddress ); + xMACEntry += 8; + } #endif #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) - { - prvMACAddressConfig( &xETH, xMACEntry, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); - xMACEntry += 8; - } + { + prvMACAddressConfig( &xETH, xMACEntry, ( uint8_t * ) xLLMNR_MacAddressIPv6.ucBytes ); + xMACEntry += 8; + } #endif { @@ -574,13 +574,13 @@ BaseType_t xSTM32F_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface } else #else /* if ( ipconfigUSE_IPv6 != 0 ) */ + { + if( xETH.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) { - if( xETH.Init.MACAddr != ( uint8_t * ) pxEndPoint->xMACAddress.ucBytes ) - { - prvMACAddressConfig( &xETH, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); - xMACEntry += 8; - } + prvMACAddressConfig( &xETH, xMACEntry, pxEndPoint->xMACAddress.ucBytes ); + xMACEntry += 8; } + } #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ if( xMACEntry > ( BaseType_t ) ETH_MAC_ADDRESS3 ) { @@ -590,16 +590,16 @@ BaseType_t xSTM32F_NetworkInterfaceInitialise( NetworkInterface_t * pxInterface } } #if ( ipconfigUSE_IPv6 != 0 ) + { + if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) { - if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) - { - /* 33:33:00:00:00:01 */ - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; + /* 33:33:00:00:00:01 */ + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; - prvMACAddressConfig( &xETH, xMACEntry, ucMACAddress ); - xMACEntry += 8; - } + prvMACAddressConfig( &xETH, xMACEntry, ucMACAddress ); + xMACEntry += 8; } + } #endif /* ( ipconfigUSE_IPv6 != 0 ) */ /* Force a negotiation with the Switch or Router and wait for LS. */ @@ -663,10 +663,10 @@ static void prvDMATxDescListInit() pxDMADescriptor->Status = ETH_DMATXDESC_TCH; #if ( ipconfigZERO_COPY_TX_DRIVER == 0 ) - { - /* Set Buffer1 address pointer */ - pxDMADescriptor->Buffer1Addr = ( uint32_t ) ( Tx_Buff[ xIndex ] ); - } + { + /* Set Buffer1 address pointer */ + pxDMADescriptor->Buffer1Addr = ( uint32_t ) ( Tx_Buff[ xIndex ] ); + } #endif if( xETH.Init.ChecksumMode == ETH_CHECKSUM_BY_HARDWARE ) @@ -716,29 +716,29 @@ static void prvDMARxDescListInit() pxDMADescriptor->ControlBufferSize = ETH_DMARXDESC_RCH | EMAC_DMA_BUFFER_SIZE; #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Set Buffer1 address pointer */ - NetworkBufferDescriptor_t * pxBuffer; + { + /* Set Buffer1 address pointer */ + NetworkBufferDescriptor_t * pxBuffer; - pxBuffer = pxGetNetworkBufferWithDescriptor( EMAC_DMA_BUFFER_SIZE, 100ul ); + pxBuffer = pxGetNetworkBufferWithDescriptor( EMAC_DMA_BUFFER_SIZE, 100ul ); - /* If the assert below fails, make sure that there are at least 'ETH_RXBUFNB' - * Network Buffers available during start-up ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ) */ - configASSERT( pxBuffer != NULL ); + /* If the assert below fails, make sure that there are at least 'ETH_RXBUFNB' + * Network Buffers available during start-up ( ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ) */ + configASSERT( pxBuffer != NULL ); - if( pxBuffer != NULL ) - { - pxDMADescriptor->Buffer1Addr = ( uint32_t ) pxBuffer->pucEthernetBuffer; - pxDMADescriptor->Status = ETH_DMARXDESC_OWN; - } - } - #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ + if( pxBuffer != NULL ) { - /* Set Buffer1 address pointer */ - pxDMADescriptor->Buffer1Addr = ( uint32_t ) ( Rx_Buff[ xIndex ] ); - /* Set Own bit of the Rx descriptor Status */ + pxDMADescriptor->Buffer1Addr = ( uint32_t ) pxBuffer->pucEthernetBuffer; pxDMADescriptor->Status = ETH_DMARXDESC_OWN; } + } + #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ + { + /* Set Buffer1 address pointer */ + pxDMADescriptor->Buffer1Addr = ( uint32_t ) ( Rx_Buff[ xIndex ] ); + /* Set Own bit of the Rx descriptor Status */ + pxDMADescriptor->Status = ETH_DMARXDESC_OWN; + } #endif /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ /* Initialize the next descriptor with the Next Descriptor Polling Enable */ @@ -809,39 +809,39 @@ static BaseType_t xSTM32F_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa } #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - const IPPacket_t * pxIPPacket; + { + const IPPacket_t * pxIPPacket; - pxIPPacket = ( const IPPacket_t * ) pxDescriptor->pucEthernetBuffer; - #if ( ipconfigUSE_IPv6 != 0 ) - if( pxIPPacket->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE ) - { - const IPHeader_IPv6_t * pxIPPacket_IPv6; + pxIPPacket = ( const IPPacket_t * ) pxDescriptor->pucEthernetBuffer; + #if ( ipconfigUSE_IPv6 != 0 ) + if( pxIPPacket->xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE ) + { + const IPHeader_IPv6_t * pxIPPacket_IPv6; - pxIPPacket_IPv6 = ( const IPHeader_IPv6_t * ) &( pxDescriptor->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ); + pxIPPacket_IPv6 = ( const IPHeader_IPv6_t * ) &( pxDescriptor->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER ] ); - if( pxIPPacket_IPv6->ucNextHeader == ( uint8_t ) ipPROTOCOL_ICMP_IPv6 ) - { - ICMPHeader_IPv6_t * pxICMPHeader_IPv6; + if( pxIPPacket_IPv6->ucNextHeader == ( uint8_t ) ipPROTOCOL_ICMP_IPv6 ) + { + ICMPHeader_IPv6_t * pxICMPHeader_IPv6; - pxICMPHeader_IPv6 = ( ICMPHeader_IPv6_t * ) &( pxDescriptor->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER ] ); - pxICMPHeader_IPv6->usChecksum = 0U; - } + pxICMPHeader_IPv6 = ( ICMPHeader_IPv6_t * ) &( pxDescriptor->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER ] ); + pxICMPHeader_IPv6->usChecksum = 0U; } - else - #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ + } + else + #endif /* if ( ipconfigUSE_IPv6 != 0 ) */ - if( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) + if( pxIPPacket->xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) + { + if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) { - if( pxIPPacket->xIPHeader.ucProtocol == ( uint8_t ) ipPROTOCOL_ICMP ) - { - ICMPHeader_t * pxICMPHeader; + ICMPHeader_t * pxICMPHeader; - pxICMPHeader = ( ICMPHeader_t * ) &( pxDescriptor->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER ] ); - pxICMPHeader->usChecksum = ( uint16_t ) 0U; - } + pxICMPHeader = ( ICMPHeader_t * ) &( pxDescriptor->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv4_HEADER ] ); + pxICMPHeader->usChecksum = ( uint16_t ) 0U; } } + } #endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM */ if( xPhyObject.ulLinkStatusMask != 0 ) @@ -870,32 +870,32 @@ static BaseType_t xSTM32F_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa } #if ( ipconfigZERO_COPY_TX_DRIVER == 0 ) - { - /* Copy the bytes. */ - memcpy( ( void * ) pxDmaTxDesc->Buffer1Addr, pxDescriptor->pucEthernetBuffer, ulTransmitSize ); - } + { + /* Copy the bytes. */ + memcpy( ( void * ) pxDmaTxDesc->Buffer1Addr, pxDescriptor->pucEthernetBuffer, ulTransmitSize ); + } #else - { - configASSERT( bReleaseAfterSend != 0 ); + { + configASSERT( bReleaseAfterSend != 0 ); - /* Move the buffer. */ - pxDmaTxDesc->Buffer1Addr = ( uint32_t ) pxDescriptor->pucEthernetBuffer; - /* The Network Buffer has been passed to DMA, no need to release it. */ - bReleaseAfterSend = pdFALSE_UNSIGNED; - } + /* Move the buffer. */ + pxDmaTxDesc->Buffer1Addr = ( uint32_t ) pxDescriptor->pucEthernetBuffer; + /* The Network Buffer has been passed to DMA, no need to release it. */ + bReleaseAfterSend = pdFALSE_UNSIGNED; + } #endif /* ipconfigZERO_COPY_TX_DRIVER */ /* Ask to set the IPv4 checksum. * Also need an Interrupt on Completion so that 'vClearTXBuffers()' will be called.. */ #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - pxDmaTxDesc->Status |= ETH_DMATXDESC_CIC_TCPUDPICMP_FULL | ETH_DMATXDESC_IC; - } + { + pxDmaTxDesc->Status |= ETH_DMATXDESC_CIC_TCPUDPICMP_FULL | ETH_DMATXDESC_IC; + } #else - { - pxDmaTxDesc->Status &= ~( ( uint32_t ) ETH_DMATXDESC_CIC ); - pxDmaTxDesc->Status |= ETH_DMATXDESC_IC; - } + { + pxDmaTxDesc->Status &= ~( ( uint32_t ) ETH_DMATXDESC_CIC ); + pxDmaTxDesc->Status |= ETH_DMATXDESC_IC; + } #endif @@ -907,11 +907,11 @@ static BaseType_t xSTM32F_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa pxDmaTxDesc->ControlBufferSize = ( ulTransmitSize & ETH_DMATXDESC_TBS1 ); #if ( NETWORK_BUFFERS_CACHED != 0 ) - { - BaseType_t xlength = CACHE_LINE_SIZE * ( ( ulTransmitSize + NETWORK_BUFFER_HEADER_SIZE + CACHE_LINE_SIZE - 1 ) / CACHE_LINE_SIZE ); - uint32_t * pulBuffer = ( uint32_t ) ( pxDescriptor->pucEthernetBuffer - NETWORK_BUFFER_HEADER_SIZE ); - cache_clean_invalidate_by_addr( pulBuffer, xlength ); - } + { + BaseType_t xlength = CACHE_LINE_SIZE * ( ( ulTransmitSize + NETWORK_BUFFER_HEADER_SIZE + CACHE_LINE_SIZE - 1 ) / CACHE_LINE_SIZE ); + uint32_t * pulBuffer = ( uint32_t ) ( pxDescriptor->pucEthernetBuffer - NETWORK_BUFFER_HEADER_SIZE ); + cache_clean_invalidate_by_addr( pulBuffer, xlength ); + } #endif /* Set Own bit of the Tx descriptor Status: gives the buffer back to ETHERNET DMA */ @@ -968,73 +968,73 @@ static BaseType_t xMayAcceptPacket( uint8_t * pucEthernetBuffer ) } #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) + { + const IPHeader_t * pxIPHeader = &( pxProtPacket->xTCPPacket.xIPHeader ); + uint32_t ulDestinationIPAddress; + + /* Ensure that the incoming packet is not fragmented (only outgoing packets + * can be fragmented) as these are the only handled IP frames currently. */ + if( ( pxIPHeader->usFragmentOffset & ipFRAGMENT_OFFSET_BIT_MASK ) != 0U ) { - const IPHeader_t * pxIPHeader = &( pxProtPacket->xTCPPacket.xIPHeader ); - uint32_t ulDestinationIPAddress; + return pdFALSE; + } - /* Ensure that the incoming packet is not fragmented (only outgoing packets - * can be fragmented) as these are the only handled IP frames currently. */ - if( ( pxIPHeader->usFragmentOffset & ipFRAGMENT_OFFSET_BIT_MASK ) != 0U ) - { - return pdFALSE; - } + /* HT: Might want to make the following configurable because + * most IP messages have a standard length of 20 bytes */ - /* HT: Might want to make the following configurable because - * most IP messages have a standard length of 20 bytes */ + /* 0x45 means: IPv4 with an IP header of 5 x 4 = 20 bytes + * 0x47 means: IPv4 with an IP header of 7 x 4 = 28 bytes */ + if( ( pxIPHeader->ucVersionHeaderLength < 0x45 ) || ( pxIPHeader->ucVersionHeaderLength > 0x4F ) ) + { + return pdFALSE; + } - /* 0x45 means: IPv4 with an IP header of 5 x 4 = 20 bytes - * 0x47 means: IPv4 with an IP header of 7 x 4 = 28 bytes */ - if( ( pxIPHeader->ucVersionHeaderLength < 0x45 ) || ( pxIPHeader->ucVersionHeaderLength > 0x4F ) ) - { - return pdFALSE; - } + ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress; - ulDestinationIPAddress = pxIPHeader->ulDestinationIPAddress; + /* Is the packet for this node? */ + if( ( ulDestinationIPAddress != *ipLOCAL_IP_ADDRESS_POINTER ) && + /* Is it a broadcast address x.x.x.255 ? */ + ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xff ) != 0xff ) && + #if ( ipconfigUSE_LLMNR == 1 ) + ( ulDestinationIPAddress != ipLLMNR_IP_ADDR ) && + #endif + ( *ipLOCAL_IP_ADDRESS_POINTER != 0 ) ) + { + FreeRTOS_debug_printf( ( "Drop IP %lxip\n", FreeRTOS_ntohl( ulDestinationIPAddress ) ) ); + return pdFALSE; + } - /* Is the packet for this node? */ - if( ( ulDestinationIPAddress != *ipLOCAL_IP_ADDRESS_POINTER ) && - /* Is it a broadcast address x.x.x.255 ? */ - ( ( FreeRTOS_ntohl( ulDestinationIPAddress ) & 0xff ) != 0xff ) && - #if ( ipconfigUSE_LLMNR == 1 ) - ( ulDestinationIPAddress != ipLLMNR_IP_ADDR ) && + if( pxIPHeader->ucProtocol == ipPROTOCOL_UDP ) + { + #if ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) || ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_DNS == 1 ) + uint16_t usSourcePort = FreeRTOS_ntohs( pxProtPacket->xUDPPacket.xUDPHeader.usSourcePort ); + uint16_t usDestinationPort = FreeRTOS_ntohs( pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort ); + #endif + + if( ( xPortHasUDPSocket( pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort ) == pdFALSE ) + #if ipconfigUSE_LLMNR == 1 + && ( usDestinationPort != ipLLMNR_PORT ) && + ( usSourcePort != ipLLMNR_PORT ) + #endif + #if ipconfigUSE_MDNS == 1 + && ( usDestinationPort != ipMDNS_PORT ) && + ( usSourcePort != ipMDNS_PORT ) + #endif + #if ipconfigUSE_NBNS == 1 + && ( usDestinationPort != ipNBNS_PORT ) && + ( usSourcePort != ipNBNS_PORT ) + #endif + #if ipconfigUSE_DNS == 1 + && ( usSourcePort != ipDNS_PORT ) #endif - ( *ipLOCAL_IP_ADDRESS_POINTER != 0 ) ) + ) { - FreeRTOS_debug_printf( ( "Drop IP %lxip\n", FreeRTOS_ntohl( ulDestinationIPAddress ) ) ); + /* Drop this packet, not for this device. */ + /* FreeRTOS_printf( ( "Drop: UDP port %d -> %d\n", usSourcePort, usDestinationPort ) ); */ return pdFALSE; } - - if( pxIPHeader->ucProtocol == ipPROTOCOL_UDP ) - { - #if ( ipconfigUSE_LLMNR == 1 ) || ( ipconfigUSE_MDNS == 1 ) || ( ipconfigUSE_NBNS == 1 ) || ( ipconfigUSE_DNS == 1 ) - uint16_t usSourcePort = FreeRTOS_ntohs( pxProtPacket->xUDPPacket.xUDPHeader.usSourcePort ); - uint16_t usDestinationPort = FreeRTOS_ntohs( pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort ); - #endif - - if( ( xPortHasUDPSocket( pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort ) == pdFALSE ) - #if ipconfigUSE_LLMNR == 1 - && ( usDestinationPort != ipLLMNR_PORT ) && - ( usSourcePort != ipLLMNR_PORT ) - #endif - #if ipconfigUSE_MDNS == 1 - && ( usDestinationPort != ipMDNS_PORT ) && - ( usSourcePort != ipMDNS_PORT ) - #endif - #if ipconfigUSE_NBNS == 1 - && ( usDestinationPort != ipNBNS_PORT ) && - ( usSourcePort != ipNBNS_PORT ) - #endif - #if ipconfigUSE_DNS == 1 - && ( usSourcePort != ipDNS_PORT ) - #endif - ) - { - /* Drop this packet, not for this device. */ - /* FreeRTOS_printf( ( "Drop: UDP port %d -> %d\n", usSourcePort, usDestinationPort ) ); */ - return pdFALSE; - } - } } + } #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ return pdTRUE; } @@ -1053,18 +1053,18 @@ static void prvPassEthMessages( NetworkBufferDescriptor_t * pxDescriptor ) * This is a deferred handler task, not a real interrupt, so it is ok to * use the task level function here. */ #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) + { + do { - do - { - NetworkBufferDescriptor_t * pxNext = pxDescriptor->pxNextBuffer; - vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - pxDescriptor = pxNext; - } while( pxDescriptor != NULL ); - } - #else - { + NetworkBufferDescriptor_t * pxNext = pxDescriptor->pxNextBuffer; vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - } + pxDescriptor = pxNext; + } while( pxDescriptor != NULL ); + } + #else + { + vReleaseNetworkBufferAndDescriptor( pxDescriptor ); + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ iptraceETHERNET_RX_EVENT_LOST(); FreeRTOS_printf( ( "prvPassEthMessages: Can not queue return packet!\n" ) ); @@ -1135,24 +1135,24 @@ static BaseType_t prvNetworkInterfaceInput( void ) } #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Find out which Network Buffer was originally passed to the descriptor. */ - pxCurDescriptor = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); - configASSERT( pxCurDescriptor != NULL ); - configASSERT( pxCurDescriptor->pucEthernetBuffer != NULL ); - } + { + /* Find out which Network Buffer was originally passed to the descriptor. */ + pxCurDescriptor = pxPacketBuffer_to_NetworkBuffer( pucBuffer ); + configASSERT( pxCurDescriptor != NULL ); + configASSERT( pxCurDescriptor->pucEthernetBuffer != NULL ); + } #else - { - /* In this mode, the two descriptors are the same. */ - pxCurDescriptor = pxNewDescriptor; + { + /* In this mode, the two descriptors are the same. */ + pxCurDescriptor = pxNewDescriptor; - if( pxNewDescriptor != NULL ) - { - /* The packet is accepted and a new Network Buffer was created, - * copy data to the Network Buffer. */ - memcpy( pxNewDescriptor->pucEthernetBuffer, pucBuffer, xReceivedLength ); - } + if( pxNewDescriptor != NULL ) + { + /* The packet is accepted and a new Network Buffer was created, + * copy data to the Network Buffer. */ + memcpy( pxNewDescriptor->pucEthernetBuffer, pucBuffer, xReceivedLength ); } + } #endif /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ if( xAccepted != pdFALSE ) @@ -1162,43 +1162,43 @@ static BaseType_t prvNetworkInterfaceInput( void ) pxCurDescriptor->pxEndPoint = FreeRTOS_MatchingEndpoint( pxMyInterface, pxCurDescriptor->pucEthernetBuffer ); #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - pxCurDescriptor->pxNextBuffer = NULL; - - if( pxFirstDescriptor == NULL ) - { - /* Becomes the first message */ - pxFirstDescriptor = pxCurDescriptor; - } - else if( pxLastDescriptor != NULL ) - { - /* Add to the tail */ - pxLastDescriptor->pxNextBuffer = pxCurDescriptor; - } + { + pxCurDescriptor->pxNextBuffer = NULL; - pxLastDescriptor = pxCurDescriptor; + if( pxFirstDescriptor == NULL ) + { + /* Becomes the first message */ + pxFirstDescriptor = pxCurDescriptor; } - #else /* if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) */ + else if( pxLastDescriptor != NULL ) { - prvPassEthMessages( pxCurDescriptor ); + /* Add to the tail */ + pxLastDescriptor->pxNextBuffer = pxCurDescriptor; } + + pxLastDescriptor = pxCurDescriptor; + } + #else /* if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) */ + { + prvPassEthMessages( pxCurDescriptor ); + } #endif /* if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) */ } /* Release descriptors to DMA */ #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) + { + /* Set Buffer1 address pointer */ + if( pxNewDescriptor != NULL ) { - /* Set Buffer1 address pointer */ - if( pxNewDescriptor != NULL ) - { - pxDMARxDescriptor->Buffer1Addr = ( uint32_t ) pxNewDescriptor->pucEthernetBuffer; - } - else - { - /* The packet was dropped and the same Network - * Buffer will be used to receive a new packet. */ - } + pxDMARxDescriptor->Buffer1Addr = ( uint32_t ) pxNewDescriptor->pucEthernetBuffer; + } + else + { + /* The packet was dropped and the same Network + * Buffer will be used to receive a new packet. */ } + } #endif /* ipconfigZERO_COPY_RX_DRIVER */ /* Set Buffer1 size and Second Address Chained bit */ @@ -1223,12 +1223,12 @@ static BaseType_t prvNetworkInterfaceInput( void ) } #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) + { + if( pxFirstDescriptor != NULL ) { - if( pxFirstDescriptor != NULL ) - { - prvPassEthMessages( pxFirstDescriptor ); - } + prvPassEthMessages( pxFirstDescriptor ); } + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ return( xReceivedLength > 0 ); @@ -1362,7 +1362,7 @@ static void prvEthernetUpdateConfig( BaseType_t xForce ) /* ETHERNET MAC Re-Configuration */ HAL_ETH_ConfigMAC( &xETH, ( ETH_MACInitTypeDef * ) NULL ); - /* Optionally, pass all mutlicast */ + /* Optionally, pass all multicast */ #if 0 xETH.Instance->MACFFR |= ETH_MACFFR_PAM; #endif @@ -1458,12 +1458,12 @@ static void prvEMACHandlerTask( void * pvParameters ) xResult = 0; #if ( ipconfigHAS_PRINTF != 0 ) - { - /* Call a function that monitors resources: the amount of free network - * buffers and the amount of free space on the heap. See FreeRTOS_IP.c - * for more detailed comments. */ - vPrintResourceStats(); - } + { + /* Call a function that monitors resources: the amount of free network + * buffers and the amount of free space on the heap. See FreeRTOS_IP.c + * for more detailed comments. */ + vPrintResourceStats(); + } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ if( xTXDescriptorSemaphore != NULL ) @@ -1508,12 +1508,12 @@ static void prvEMACHandlerTask( void * pvParameters ) prvEthernetUpdateConfig( pdFALSE ); #if ( ipconfigSUPPORT_NETWORK_DOWN_EVENT != 0 ) + { + if( xGetPhyLinkStatus( pxMyInterface ) == pdFALSE ) { - if( xGetPhyLinkStatus( pxMyInterface ) == pdFALSE ) - { - FreeRTOS_NetworkDown( pxMyInterface ); - } + FreeRTOS_NetworkDown( pxMyInterface ); } + } #endif /* ( ipconfigSUPPORT_NETWORK_DOWN_EVENT != 0 ) */ } } diff --git a/source/portable/NetworkInterface/STM32Fxx/readme.md b/source/portable/NetworkInterface/STM32Fxx/readme.md index e644a18706..c419195de5 100644 --- a/source/portable/NetworkInterface/STM32Fxx/readme.md +++ b/source/portable/NetworkInterface/STM32Fxx/readme.md @@ -1,4 +1,4 @@ -This is a FreeeRTOS+TCP driver that works for STM32Fxx parts. +This is a FreeRTOS+TCP driver that works for STM32Fxx parts. CONFIGURATION AND RUNNING diff --git a/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c b/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c index 303b327c1a..5f99e705c1 100644 --- a/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c +++ b/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.c @@ -270,29 +270,29 @@ else { #if ( stm_is_F1 != 0 ) + { + /* The STM32F1xx has a frequency up to 72 MHz. */ + /* CSR Clock Range between 60-72 MHz */ + tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div42; + } + #else + { + if( ( hclk >= 60000000uL ) && ( hclk < 100000000uL ) ) { - /* The STM32F1xx has a frequency up to 72 MHz. */ - /* CSR Clock Range between 60-72 MHz */ + /* CSR Clock Range between 60-100 MHz */ tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div42; } - #else + else if( ( hclk >= 100000000uL ) && ( hclk < 150000000uL ) ) + { + /* CSR Clock Range between 100-150 MHz */ + tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div62; + } + else /* ( ( hclk >= 150000000uL ) && ( hclk <= 183000000uL ) ) */ { - if( ( hclk >= 60000000uL ) && ( hclk < 100000000uL ) ) - { - /* CSR Clock Range between 60-100 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div42; - } - else if( ( hclk >= 100000000uL ) && ( hclk < 150000000uL ) ) - { - /* CSR Clock Range between 100-150 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div62; - } - else /* ( ( hclk >= 150000000uL ) && ( hclk <= 183000000uL ) ) */ - { - /* CSR Clock Range between 150-183 MHz */ - tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div102; - } + /* CSR Clock Range between 150-183 MHz */ + tmpreg |= ( uint32_t ) ETH_MACMIIAR_CR_Div102; } + } #endif /* if ( stm_is_F1 != 0 ) */ } #else /* if !defined( STM32F2xx ) */ @@ -1343,7 +1343,7 @@ /* Set the RPBL and 4*PBL bits according to ETH RxDMABurstLength value */ /* Set the PBL and 4*PBL bits according to ETH TxDMABurstLength value */ /* Set the Enhanced DMA descriptors bit according to ETH EnhancedDescriptorFormat value*/ - /* Set the DSL bit according to ETH DesciptorSkipLength value */ + /* Set the DSL bit according to ETH DescriptorSkipLength value */ /* Set the PR and DA bits according to ETH DMAArbitration value */ heth->Instance->DMABMR = ( uint32_t ) ( dmainit.AddressAlignedBeats | dmainit.FixedBurst | diff --git a/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.h b/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.h index 33be72f222..6f0f684ed8 100644 --- a/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.h +++ b/source/portable/NetworkInterface/STM32Fxx/stm32fxx_hal_eth.h @@ -53,7 +53,7 @@ #endif #ifdef __cplusplus - extern "C" { + extern "C" { #endif /** @addtogroup STM32Fxx_HAL_Driver @@ -994,9 +994,9 @@ #define ETH_DMAPTPRXDESC_PTPMT_FOLLOWUP ( ( uint32_t ) 0x00000200U ) /* FollowUp message (all clock types) */ #define ETH_DMAPTPRXDESC_PTPMT_DELAYREQ ( ( uint32_t ) 0x00000300U ) /* DelayReq message (all clock types) */ #define ETH_DMAPTPRXDESC_PTPMT_DELAYRESP ( ( uint32_t ) 0x00000400U ) /* DelayResp message (all clock types) */ - #define ETH_DMAPTPRXDESC_PTPMT_PDELAYREQ_ANNOUNCE ( ( uint32_t ) 0x00000500U ) /* PdelayReq message (peer-to-peer transparent clock) or Announce message (Ordinary or Boundary clock) */ - #define ETH_DMAPTPRXDESC_PTPMT_PDELAYRESP_MANAG ( ( uint32_t ) 0x00000600U ) /* PdelayResp message (peer-to-peer transparent clock) or Management message (Ordinary or Boundary clock) */ - #define ETH_DMAPTPRXDESC_PTPMT_PDELAYRESPFOLLOWUP_SIGNAL ( ( uint32_t ) 0x00000700U ) /* PdelayRespFollowUp message (peer-to-peer transparent clock) or Signaling message (Ordinary or Boundary clock) */ + #define ETH_DMAPTPRXDESC_PTPMT_PDELAYREQ_ANNOUNCE ( ( uint32_t ) 0x00000500U ) /* PDelayReq message (peer-to-peer transparent clock) or Announce message (Ordinary or Boundary clock) */ + #define ETH_DMAPTPRXDESC_PTPMT_PDELAYRESP_MANAG ( ( uint32_t ) 0x00000600U ) /* PDelayResp message (peer-to-peer transparent clock) or Management message (Ordinary or Boundary clock) */ + #define ETH_DMAPTPRXDESC_PTPMT_PDELAYRESPFOLLOWUP_SIGNAL ( ( uint32_t ) 0x00000700U ) /* PDelayRespFollowUp message (peer-to-peer transparent clock) or Signaling message (Ordinary or Boundary clock) */ #define ETH_DMAPTPRXDESC_IPV6PR ( ( uint32_t ) 0x00000080U ) /* IPv6 Packet Received */ #define ETH_DMAPTPRXDESC_IPV4PR ( ( uint32_t ) 0x00000040U ) /* IPv4 Packet Received */ #define ETH_DMAPTPRXDESC_IPCB ( ( uint32_t ) 0x00000020U ) /* IP Checksum Bypassed */ diff --git a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c index c79f09d058..50c6fc0f73 100644 --- a/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c +++ b/source/portable/NetworkInterface/STM32Hxx/NetworkInterface.c @@ -299,15 +299,15 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt xTxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CRCPAD; #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - /*xTxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC; */ - xTxConfig.Attributes |= ETH_TX_PACKETS_FEATURES_CSUM; - xTxConfig.ChecksumCtrl = ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT_PHDR_CALC; - } + { + /*xTxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC; */ + xTxConfig.Attributes |= ETH_TX_PACKETS_FEATURES_CSUM; + xTxConfig.ChecksumCtrl = ETH_DMATXNDESCRF_CIC_IPHDR_PAYLOAD_INSERT_PHDR_CALC; + } #else - { - xTxConfig.ChecksumCtrl = ETH_CHECKSUM_DISABLE; - } + { + xTxConfig.ChecksumCtrl = ETH_CHECKSUM_DISABLE; + } #endif xTxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT; @@ -324,44 +324,44 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt uint8_t * pucBuffer; #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - pucBuffer = pucGetRXBuffer( ETH_RX_BUF_SIZE ); - configASSERT( pucBuffer != NULL ); - } + { + pucBuffer = pucGetRXBuffer( ETH_RX_BUF_SIZE ); + configASSERT( pucBuffer != NULL ); + } #else - { - pucBuffer = Rx_Buff[ uxIndex ]; - } + { + pucBuffer = Rx_Buff[ uxIndex ]; + } #endif HAL_ETH_DescAssignMemory( &( xEthHandle ), uxIndex, pucBuffer, NULL ); } #if ( ipconfigUSE_MDNS == 1 ) - { - /* Program the MDNS address. */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MacAdress.ucBytes ); - xMACEntry += 8; - } + { + /* Program the MDNS address. */ + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MacAddress.ucBytes ); + xMACEntry += 8; + } #endif #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) - { - prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MACAdressIPv6.ucBytes ); - xMACEntry += 8; - } + { + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xMDNS_MACAddressIPv6.ucBytes ); + xMACEntry += 8; + } #endif #if ( ipconfigUSE_LLMNR == 1 ) - { - /* Program the LLMNR address. */ - prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAdress.ucBytes ); - xMACEntry += 8; - } + { + /* Program the LLMNR address. */ + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAddress.ucBytes ); + xMACEntry += 8; + } #endif #if ( ( ipconfigUSE_LLMNR == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) - { - prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAdressIPv6.ucBytes ); - xMACEntry += 8; - } + { + prvMACAddressConfig( &xEthHandle, xMACEntry, ( uint8_t * ) xLLMNR_MacAddressIPv6.ucBytes ); + xMACEntry += 8; + } #endif { @@ -414,16 +414,16 @@ static BaseType_t xSTM32H_NetworkInterfaceInitialise( NetworkInterface_t * pxInt } #if ( ipconfigUSE_IPv6 != 0 ) + { + if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) { - if( xMACEntry <= ( BaseType_t ) ETH_MAC_ADDRESS3 ) - { - /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ - uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; + /* Allow traffic destined to IPv6 all nodes multicast MAC 33:33:00:00:00:01 */ + uint8_t ucMACAddress[ 6 ] = { 0x33, 0x33, 0, 0, 0, 0x01 }; - prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); - xMACEntry += 8; - } + prvMACAddressConfig( &xEthHandle, xMACEntry, ucMACAddress ); + xMACEntry += 8; } + } #endif /* ( ipconfigUSE_IPv6 != 0 ) */ /* Initialize the MACB and set all PHY properties */ @@ -571,23 +571,23 @@ static BaseType_t xSTM32H_NetworkInterfaceOutput( NetworkInterface_t * pxInterfa /* Memory barrier: Make sure that the data written to the packet buffer got written. */ __DSB(); - /* Get exclusive accces to the TX process. + /* Get exclusive access to the TX process. * Both the IP-task and the EMAC task will work on the TX process. */ if( xSemaphoreTake( xTransmissionMutex, xBlockTimeTicks ) != pdFAIL ) { #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - /* Do not release the buffer. */ - xReleaseAfterSend = pdFALSE; - } + { + /* Do not release the buffer. */ + xReleaseAfterSend = pdFALSE; + } #else - { - memcpy( pucTXBuffer, pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength ); + { + memcpy( pucTXBuffer, pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength ); - /* A memory barrier to make sure that the outgoing packets has been written - * to the physical memory. */ - __DSB(); - } + /* A memory barrier to make sure that the outgoing packets has been written + * to the physical memory. */ + __DSB(); + } #endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ if( HAL_ETH_Transmit_IT( &( xEthHandle ), &( xTxConfig ) ) == HAL_OK ) @@ -678,13 +678,13 @@ static void prvEthernetUpdateConfig( BaseType_t xForce ) MACConf.Speed = speed; HAL_ETH_SetMACConfig( &( xEthHandle ), &( MACConf ) ); #if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 ) - { - MACConf.ChecksumOffload = ENABLE; - } + { + MACConf.ChecksumOffload = ENABLE; + } #else - { - MACConf.ChecksumOffload = DISABLE; - } + { + MACConf.ChecksumOffload = DISABLE; + } #endif /* ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 ) */ /* Restart MAC interface */ @@ -722,30 +722,30 @@ static BaseType_t prvNetworkInterfaceInput( void ) xReturn++; #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) - { - /* Reserve the maximum length for the next reception. */ - uxLength = ETH_RX_BUF_SIZE; - - if( data_buffer.buffer != NULL ) - { - pxReceivedBuffer = pxPacketBuffer_to_NetworkBuffer( data_buffer.buffer ); - #if ( ipconfigTCP_IP_SANITY != 0 ) - { - configASSERT( bIsValidNetworkDescriptor( pxReceivedBuffer ) != 0 ); - } - #endif - } + { + /* Reserve the maximum length for the next reception. */ + uxLength = ETH_RX_BUF_SIZE; - if( pxReceivedBuffer == NULL ) + if( data_buffer.buffer != NULL ) + { + pxReceivedBuffer = pxPacketBuffer_to_NetworkBuffer( data_buffer.buffer ); + #if ( ipconfigTCP_IP_SANITY != 0 ) { - FreeRTOS_printf( ( "Strange: no descriptor received\n" ) ); + configASSERT( bIsValidNetworkDescriptor( pxReceivedBuffer ) != 0 ); } + #endif } - #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ + + if( pxReceivedBuffer == NULL ) { - /* Reserve the length of the packet that was just received. */ - uxLength = uxDataLength; + FreeRTOS_printf( ( "Strange: no descriptor received\n" ) ); } + } + #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ + { + /* Reserve the length of the packet that was just received. */ + uxLength = uxDataLength; + } #endif /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ pxBufferDescriptor = pxGetNetworkBufferWithDescriptor( uxLength, 0u ); @@ -758,33 +758,33 @@ static BaseType_t prvNetworkInterfaceInput( void ) } #if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) + { + if( pxBufferDescriptor == NULL ) { - if( pxBufferDescriptor == NULL ) - { - /* Can not receive this packet. Buffer will be re-used. */ - pxReceivedBuffer = NULL; - } - else if( pxReceivedBuffer != NULL ) - { - pxReceivedBuffer->xDataLength = uxDataLength; - } - else - { - /* Allocating a new buffer failed. */ - } + /* Can not receive this packet. Buffer will be re-used. */ + pxReceivedBuffer = NULL; + } + else if( pxReceivedBuffer != NULL ) + { + pxReceivedBuffer->xDataLength = uxDataLength; + } + else + { + /* Allocating a new buffer failed. */ } + } #else /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ + { + if( pxBufferDescriptor != NULL ) { - if( pxBufferDescriptor != NULL ) - { - pxReceivedBuffer = pxBufferDescriptor; - /* The copy method. */ - memcpy( pxReceivedBuffer->pucEthernetBuffer, data_buffer.buffer, uxDataLength ); - pxReceivedBuffer->xDataLength = uxDataLength; - /* Make sure that the descriptor isn't used any more. */ - pxBufferDescriptor = NULL; - } + pxReceivedBuffer = pxBufferDescriptor; + /* The copy method. */ + memcpy( pxReceivedBuffer->pucEthernetBuffer, data_buffer.buffer, uxDataLength ); + pxReceivedBuffer->xDataLength = uxDataLength; + /* Make sure that the descriptor isn't used any more. */ + pxBufferDescriptor = NULL; } + } #endif /* if ( ipconfigZERO_COPY_RX_DRIVER != 0 ) */ { @@ -1044,36 +1044,36 @@ static void prvEMACHandlerTask( void * pvParameters ) BaseType_t xResult = 0; #if ( ipconfigHAS_PRINTF != 0 ) - { - size_t uxUsed; - size_t uxOwnCount; + { + size_t uxUsed; + size_t uxOwnCount; - /* Call a function that monitors resources: the amount of free network - * buffers and the amount of free space on the heap. See FreeRTOS_IP.c - * for more detailed comments. */ - vPrintResourceStats(); + /* Call a function that monitors resources: the amount of free network + * buffers and the amount of free space on the heap. See FreeRTOS_IP.c + * for more detailed comments. */ + vPrintResourceStats(); - /* Some more statistics: number of free descriptors. */ - uxUsed = ETH_TX_DESC_CNT - uxSemaphoreGetCount( xTXDescriptorSemaphore ); + /* Some more statistics: number of free descriptors. */ + uxUsed = ETH_TX_DESC_CNT - uxSemaphoreGetCount( xTXDescriptorSemaphore ); - if( uxTXDescriptorsUsed < uxUsed ) - { - uxTXDescriptorsUsed = uxUsed; - FreeRTOS_printf( ( "TX descriptors %u/%u\n", - uxTXDescriptorsUsed, - ETH_TX_DESC_CNT ) ); - } + if( uxTXDescriptorsUsed < uxUsed ) + { + uxTXDescriptorsUsed = uxUsed; + FreeRTOS_printf( ( "TX descriptors %u/%u\n", + uxTXDescriptorsUsed, + ETH_TX_DESC_CNT ) ); + } - uxOwnCount = uxGetOwnCount( &( xEthHandle ) ); + uxOwnCount = uxGetOwnCount( &( xEthHandle ) ); - if( uxRXDescriptorsUsed > uxOwnCount ) - { - uxRXDescriptorsUsed = uxOwnCount; - FreeRTOS_printf( ( "RX descriptors %u/%u\n", - uxRXDescriptorsUsed, - ETH_RX_DESC_CNT ) ); - } + if( uxRXDescriptorsUsed > uxOwnCount ) + { + uxRXDescriptorsUsed = uxOwnCount; + FreeRTOS_printf( ( "RX descriptors %u/%u\n", + uxRXDescriptorsUsed, + ETH_RX_DESC_CNT ) ); } + } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ ulTaskNotifyTake( pdFALSE, ulMaxBlockTime ); diff --git a/source/portable/NetworkInterface/STM32Hxx/readme.md b/source/portable/NetworkInterface/STM32Hxx/readme.md index 4df2b56f27..e43fc59167 100644 --- a/source/portable/NetworkInterface/STM32Hxx/readme.md +++ b/source/portable/NetworkInterface/STM32Hxx/readme.md @@ -8,7 +8,7 @@ Number of DMA descriptors, for transmission and for reception. The descriptors for transmission are protected with a counting semaphore. By the time that a packet has been sent, the other TX descriptor becomes available already. -The number of descriptors has an incluence on the performance. But that also depends on the size +The number of descriptors has an influence on the performance. But that also depends on the size of the TCP buffers and TCP window sizes. When ETH_RX_DESC_CNT is too low, the adapter may miss incoming packets, they will be dropped. diff --git a/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c b/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c index 0a44278bb2..7e7e09d355 100644 --- a/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c +++ b/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.c @@ -638,7 +638,7 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; /** * @brief Unregister an ETH Callback - * ETH callabck is redirected to the weak predefined callback + * ETH callback is redirected to the weak predefined callback * @param heth eth handle * @param CallbackID ID of the callback to be unregistered * This parameter can be one of the following values: @@ -977,7 +977,7 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; /* Set the ETH peripheral state to BUSY */ heth->gState = HAL_ETH_STATE_BUSY; - /* Disable intrrupts: + /* Disable interrupts: * - Tx complete interrupt * - Rx complete interrupt * - Fatal bus interrupt @@ -1065,7 +1065,7 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; tickstart = HAL_GetTick(); - /* Wait for data to be transmitted or timeout occured */ + /* Wait for data to be transmitted or timeout occurred */ while( ( dmatxdesc->DESC3 & ETH_DMATXNDESCWBF_OWN ) != ( uint32_t ) RESET ) { if( ( heth->Instance->DMACSR & ETH_DMACSR_FBE ) != ( uint32_t ) RESET ) @@ -1558,15 +1558,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; if( __HAL_ETH_DMA_GET_IT_SOURCE( heth, ETH_DMACIER_RIE ) ) { #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /*Call registered Receive complete callback*/ - heth->RxCpltCallback( heth ); - } + { + /*Call registered Receive complete callback*/ + heth->RxCpltCallback( heth ); + } #else - { - /* Receive complete callback */ - HAL_ETH_RxCpltCallback( heth ); - } + { + /* Receive complete callback */ + HAL_ETH_RxCpltCallback( heth ); + } #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */ /* Clear the Eth DMA Rx IT pending bits */ @@ -1580,15 +1580,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; if( __HAL_ETH_DMA_GET_IT_SOURCE( heth, ETH_DMACIER_TIE ) ) { #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /*Call registered Transmit complete callback*/ - heth->TxCpltCallback( heth ); - } + { + /*Call registered Transmit complete callback*/ + heth->TxCpltCallback( heth ); + } #else - { - /* Transfer complete callback */ - HAL_ETH_TxCpltCallback( heth ); - } + { + /* Transfer complete callback */ + HAL_ETH_TxCpltCallback( heth ); + } #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */ /* Clear the Eth DMA Tx IT pending bits */ @@ -1603,7 +1603,7 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; { heth->ErrorCode |= HAL_ETH_ERROR_DMA; - /* if fatal bus error occured */ + /* if fatal bus error occurred */ if( __HAL_ETH_DMA_GET_IT( heth, ETH_DMACSR_FBE ) ) { /* Get DMA error code */ @@ -1627,15 +1627,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; } #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /* Call registered DMA Error callback*/ - heth->DMAErrorCallback( heth ); - } + { + /* Call registered DMA Error callback*/ + heth->DMAErrorCallback( heth ); + } #else - { - /* Ethernet DMA Error callback */ - HAL_ETH_DMAErrorCallback( heth ); - } + { + /* Ethernet DMA Error callback */ + HAL_ETH_DMAErrorCallback( heth ); + } #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */ } } @@ -1649,15 +1649,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; set_error_state( heth, HAL_ETH_STATE_ERROR ); #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /* Call registered MAC Error callback*/ - heth->DMAErrorCallback( heth ); - } + { + /* Call registered MAC Error callback*/ + heth->DMAErrorCallback( heth ); + } #else - { - /* Ethernet MAC Error callback */ - HAL_ETH_MACErrorCallback( heth ); - } + { + /* Ethernet MAC Error callback */ + HAL_ETH_MACErrorCallback( heth ); + } #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */ heth->MACErrorCode = ( uint32_t ) ( 0x0U ); @@ -1670,15 +1670,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; heth->MACWakeUpEvent = READ_BIT( heth->Instance->MACPCSR, ( ETH_MACPCSR_RWKPRCVD | ETH_MACPCSR_MGKPRCVD ) ); #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /* Call registered PMT callback*/ - heth->PMTCallback( heth ); - } + { + /* Call registered PMT callback*/ + heth->PMTCallback( heth ); + } #else - { - /* Ethernet PMT callback */ - HAL_ETH_PMTCallback( heth ); - } + { + /* Ethernet PMT callback */ + HAL_ETH_PMTCallback( heth ); + } #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */ heth->MACWakeUpEvent = ( uint32_t ) ( 0x0U ); @@ -1691,15 +1691,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; heth->MACLPIEvent = READ_BIT( heth->Instance->MACPCSR, 0x0000000FU ); #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /* Call registered EEE callback*/ - heth->EEECallback( heth ); - } + { + /* Call registered EEE callback*/ + heth->EEECallback( heth ); + } #else - { - /* Ethernet EEE callback */ - HAL_ETH_EEECallback( heth ); - } + { + /* Ethernet EEE callback */ + HAL_ETH_EEECallback( heth ); + } #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */ heth->MACLPIEvent = ( uint32_t ) ( 0x0U ); @@ -1714,15 +1714,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; /* Clear ETH WAKEUP Exti pending bit */ __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG( ETH_WAKEUP_EXTI_LINE ); #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /* Call registered WakeUp callback*/ - heth->WakeUpCallback( heth ); - } + { + /* Call registered WakeUp callback*/ + heth->WakeUpCallback( heth ); + } #else - { - /* ETH WAKEUP callback */ - HAL_ETH_WakeUpCallback( heth ); - } + { + /* ETH WAKEUP callback */ + HAL_ETH_WakeUpCallback( heth ); + } #endif } } @@ -1734,15 +1734,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; /* Clear ETH WAKEUP Exti pending bit */ __HAL_ETH_WAKEUP_EXTID2_CLEAR_FLAG( ETH_WAKEUP_EXTI_LINE ); #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /* Call registered WakeUp callback*/ - heth->WakeUpCallback( heth ); - } + { + /* Call registered WakeUp callback*/ + heth->WakeUpCallback( heth ); + } #else - { - /* ETH WAKEUP callback */ - HAL_ETH_WakeUpCallback( heth ); - } + { + /* ETH WAKEUP callback */ + HAL_ETH_WakeUpCallback( heth ); + } #endif } } @@ -1753,15 +1753,15 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; /* Clear ETH WAKEUP Exti pending bit */ __HAL_ETH_WAKEUP_EXTI_CLEAR_FLAG( ETH_WAKEUP_EXTI_LINE ); #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - { - /* Call registered WakeUp callback*/ - heth->WakeUpCallback( heth ); - } + { + /* Call registered WakeUp callback*/ + heth->WakeUpCallback( heth ); + } #else - { - /* ETH WAKEUP callback */ - HAL_ETH_WakeUpCallback( heth ); - } + { + /* ETH WAKEUP callback */ + HAL_ETH_WakeUpCallback( heth ); + } #endif } #endif /* #if defined(DUAL_CORE) */ @@ -2794,7 +2794,7 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; WRITE_REG( dmarxdesc->BackupAddr0, 0x0 ); WRITE_REG( dmarxdesc->BackupAddr1, 0x0 ); - /* Set Rx descritors adresses */ + /* Set Rx descritors addresses */ WRITE_REG( heth->RxDescList.RxDesc[ i ], ( uint32_t ) dmarxdesc ); } @@ -2830,25 +2830,25 @@ extern SemaphoreHandle_t xTXDescriptorSemaphore; } #if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) - { - NetworkBufferDescriptor_t * pxNetworkBuffer; - uint8_t * ucPayLoad; + { + NetworkBufferDescriptor_t * pxNetworkBuffer; + uint8_t * ucPayLoad; - ucPayLoad = ( uint8_t * ) xDMATxDescriptor->DESC0; + ucPayLoad = ( uint8_t * ) xDMATxDescriptor->DESC0; - if( ucPayLoad == NULL ) - { - /* No buffer is assigned or DMA still OWNs this descriptor. */ - break; - } + if( ucPayLoad == NULL ) + { + /* No buffer is assigned or DMA still OWNs this descriptor. */ + break; + } - pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); + pxNetworkBuffer = pxPacketBuffer_to_NetworkBuffer( ucPayLoad ); - if( pxNetworkBuffer != NULL ) - { - vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); - } + if( pxNetworkBuffer != NULL ) + { + vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer ); } + } #endif /* if ( ipconfigZERO_COPY_TX_DRIVER != 0 ) */ xDMATxDescriptor->DESC0 = ( uint32_t ) 0u; diff --git a/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.h b/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.h index b762885f84..a8a6cc3b49 100644 --- a/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.h +++ b/source/portable/NetworkInterface/STM32Hxx/stm32hxx_hal_eth.h @@ -27,7 +27,7 @@ #include "stm32h7xx_hal_def.h" #ifdef __cplusplus - extern "C" { + extern "C" { #endif #if defined( ETH ) @@ -59,7 +59,7 @@ uint16_t ERR_IHE : 1, /* IP Header Error */ ERR_DB : 1, /* Deferred Bit */ - ERR_Umderflow : 1, /* Underflow Error */ + ERR_Underflow : 1, /* Underflow Error */ ERR_ExcDefer : 1, /* Excessive Deferral */ ERR_CC : 4, /* Collision count. */ ERR_EC : 1, /* Excessive Collision */ @@ -373,7 +373,7 @@ uint32_t GiantPacketSizeLimit; /*!< Specifies the packet size that the MAC will declare it as Giant, If it's size is * greater than the value programmed in this field in units of bytes - * This parameter must be a number between Min_Data = 0x618 (1518 byte) and Max_Data = 0x3FFF (32 Kbyte)*/ + * This parameter must be a number between Min_Data = 0x618 (1518 byte) and Max_Data = 0x3FFF (32 KByte)*/ FunctionalState ExtendedInterPacketGap; /*!< Enable or disables the extended inter packet gap. */ @@ -653,7 +653,7 @@ */ /* - * DMA Tx Normal Desciptor Read Format + * DMA Tx Normal Descriptor Read Format * ----------------------------------------------------------------------------------------------- * TDES0 | Buffer1 or Header Address [31:0] | * ----------------------------------------------------------------------------------------------- @@ -766,7 +766,7 @@ /* - * DMA Tx Context Desciptor + * DMA Tx Context Descriptor * ----------------------------------------------------------------------------------------------- * TDES0 | Timestamp Low | * ----------------------------------------------------------------------------------------------- @@ -883,9 +883,9 @@ #define ETH_DMARXNDESCWBF_PMT_FUP ( ( uint32_t ) 0x00000200U ) /*!< PTP Message Type: Follow_Up (all clock types) */ #define ETH_DMARXNDESCWBF_PMT_DREQ ( ( uint32_t ) 0x00000300U ) /*!< PTP Message Type: Delay_Req (all clock types) */ #define ETH_DMARXNDESCWBF_PMT_DRESP ( ( uint32_t ) 0x00000400U ) /*!< PTP Message Type: Delay_Resp (all clock types) */ - #define ETH_DMARXNDESCWBF_PMT_PDREQ ( ( uint32_t ) 0x00000500U ) /*!< PTP Message Type: Pdelay_Req (in peer-to-peer transparent clock) */ - #define ETH_DMARXNDESCWBF_PMT_PDRESP ( ( uint32_t ) 0x00000600U ) /*!< PTP Message Type: Pdelay_Resp (in peer-to-peer transparent clock) */ - #define ETH_DMARXNDESCWBF_PMT_PDRESPFUP ( ( uint32_t ) 0x00000700U ) /*!< PTP Message Type: Pdelay_Resp_Follow_Up (in peer-to-peer transparent clock) */ + #define ETH_DMARXNDESCWBF_PMT_PDREQ ( ( uint32_t ) 0x00000500U ) /*!< PTP Message Type: PDelay_Req (in peer-to-peer transparent clock) */ + #define ETH_DMARXNDESCWBF_PMT_PDRESP ( ( uint32_t ) 0x00000600U ) /*!< PTP Message Type: PDelay_Resp (in peer-to-peer transparent clock) */ + #define ETH_DMARXNDESCWBF_PMT_PDRESPFUP ( ( uint32_t ) 0x00000700U ) /*!< PTP Message Type: PDelay_Resp_Follow_Up (in peer-to-peer transparent clock) */ #define ETH_DMARXNDESCWBF_PMT_ANNOUNCE ( ( uint32_t ) 0x00000800U ) /*!< PTP Message Type: Announce */ #define ETH_DMARXNDESCWBF_PMT_MANAG ( ( uint32_t ) 0x00000900U ) /*!< PTP Message Type: Management */ #define ETH_DMARXNDESCWBF_PMT_SIGN ( ( uint32_t ) 0x00000A00U ) /*!< PTP Message Type: Signaling */ @@ -1460,8 +1460,8 @@ /** @defgroup ETH_MAC_Wake_Up_Event ETH MAC Wake Up Event * @{ */ - #define ETH_WAKEUP_PACKET_RECIEVED ETH_MACPCSR_RWKPRCVD - #define ETH_MAGIC_PACKET_RECIEVED ETH_MACPCSR_MGKPRCVD + #define ETH_WAKEUP_PACKET_RECEIVED ETH_MACPCSR_RWKPRCVD + #define ETH_MAGIC_PACKET_RECEIVED ETH_MACPCSR_MGKPRCVD /** * @} @@ -1719,22 +1719,22 @@ * @{ */ /* Initialization and de initialization functions **********************************/ - HAL_StatusTypeDef HAL_ETH_Init( ETH_HandleTypeDef * heth ); - HAL_StatusTypeDef HAL_ETH_DeInit( ETH_HandleTypeDef * heth ); - void HAL_ETH_MspInit( ETH_HandleTypeDef * heth ); - void HAL_ETH_MspDeInit( ETH_HandleTypeDef * heth ); - HAL_StatusTypeDef HAL_ETH_DescAssignMemory( ETH_HandleTypeDef * heth, - uint32_t Index, - uint8_t * pBuffer1, - uint8_t * pBuffer2 ); + HAL_StatusTypeDef HAL_ETH_Init( ETH_HandleTypeDef * heth ); + HAL_StatusTypeDef HAL_ETH_DeInit( ETH_HandleTypeDef * heth ); + void HAL_ETH_MspInit( ETH_HandleTypeDef * heth ); + void HAL_ETH_MspDeInit( ETH_HandleTypeDef * heth ); + HAL_StatusTypeDef HAL_ETH_DescAssignMemory( ETH_HandleTypeDef * heth, + uint32_t Index, + uint8_t * pBuffer1, + uint8_t * pBuffer2 ); /* Callbacks Register/UnRegister functions ***********************************/ #if ( USE_HAL_ETH_REGISTER_CALLBACKS == 1 ) - HAL_StatusTypeDef HAL_ETH_RegisterCallback( ETH_HandleTypeDef * heth, - HAL_ETH_CallbackIDTypeDef CallbackID, - pETH_CallbackTypeDef pCallback ); - HAL_StatusTypeDef HAL_ETH_UnRegisterCallback( ETH_HandleTypeDef * heth, - HAL_ETH_CallbackIDTypeDef CallbackID ); + HAL_StatusTypeDef HAL_ETH_RegisterCallback( ETH_HandleTypeDef * heth, + HAL_ETH_CallbackIDTypeDef CallbackID, + pETH_CallbackTypeDef pCallback ); + HAL_StatusTypeDef HAL_ETH_UnRegisterCallback( ETH_HandleTypeDef * heth, + HAL_ETH_CallbackIDTypeDef CallbackID ); #endif /* USE_HAL_ETH_REGISTER_CALLBACKS */ /** @@ -1745,50 +1745,50 @@ * @{ */ /* IO operation functions *******************************************************/ - HAL_StatusTypeDef HAL_ETH_Start( ETH_HandleTypeDef * heth ); - HAL_StatusTypeDef HAL_ETH_Start_IT( ETH_HandleTypeDef * heth ); - HAL_StatusTypeDef HAL_ETH_Stop( ETH_HandleTypeDef * heth ); - HAL_StatusTypeDef HAL_ETH_Stop_IT( ETH_HandleTypeDef * heth ); + HAL_StatusTypeDef HAL_ETH_Start( ETH_HandleTypeDef * heth ); + HAL_StatusTypeDef HAL_ETH_Start_IT( ETH_HandleTypeDef * heth ); + HAL_StatusTypeDef HAL_ETH_Stop( ETH_HandleTypeDef * heth ); + HAL_StatusTypeDef HAL_ETH_Stop_IT( ETH_HandleTypeDef * heth ); - uint8_t HAL_ETH_IsRxDataAvailable( ETH_HandleTypeDef * heth ); + uint8_t HAL_ETH_IsRxDataAvailable( ETH_HandleTypeDef * heth ); /* The following 2 functions are replaced with a single function: HAL_ETH_GetRxData(). */ /* HAL_StatusTypeDef HAL_ETH_GetRxDataBuffer(ETH_HandleTypeDef *heth, ETH_BufferTypeDef *RxBuffer); */ /* HAL_StatusTypeDef HAL_ETH_GetRxDataLength(ETH_HandleTypeDef *heth, uint32_t *Length); */ - size_t HAL_ETH_GetRxData( ETH_HandleTypeDef * heth, - ETH_BufferTypeDef * RxBuffer ); + size_t HAL_ETH_GetRxData( ETH_HandleTypeDef * heth, + ETH_BufferTypeDef * RxBuffer ); - HAL_StatusTypeDef HAL_ETH_GetRxDataInfo( ETH_HandleTypeDef * heth, - ETH_RxPacketInfo * RxPacketInfo ); - HAL_StatusTypeDef HAL_ETH_BuildRxDescriptors( ETH_HandleTypeDef * heth, - uint8_t * pucNewBuffer ); + HAL_StatusTypeDef HAL_ETH_GetRxDataInfo( ETH_HandleTypeDef * heth, + ETH_RxPacketInfo * RxPacketInfo ); + HAL_StatusTypeDef HAL_ETH_BuildRxDescriptors( ETH_HandleTypeDef * heth, + uint8_t * pucNewBuffer ); - HAL_StatusTypeDef HAL_ETH_Transmit( ETH_HandleTypeDef * heth, - ETH_TxPacketConfig * pTxConfig, - uint32_t Timeout ); - HAL_StatusTypeDef HAL_ETH_Transmit_IT( ETH_HandleTypeDef * heth, - ETH_TxPacketConfig * pTxConfig ); + HAL_StatusTypeDef HAL_ETH_Transmit( ETH_HandleTypeDef * heth, + ETH_TxPacketConfig * pTxConfig, + uint32_t Timeout ); + HAL_StatusTypeDef HAL_ETH_Transmit_IT( ETH_HandleTypeDef * heth, + ETH_TxPacketConfig * pTxConfig ); - void ETH_Clear_Tx_Descriptors( ETH_HandleTypeDef * heth ); + void ETH_Clear_Tx_Descriptors( ETH_HandleTypeDef * heth ); - HAL_StatusTypeDef HAL_ETH_WritePHYRegister( ETH_HandleTypeDef * heth, - uint32_t PHYAddr, - uint32_t PHYReg, - uint32_t RegValue ); - HAL_StatusTypeDef HAL_ETH_ReadPHYRegister( ETH_HandleTypeDef * heth, - uint32_t PHYAddr, - uint32_t PHYReg, - uint32_t * pRegValue ); + HAL_StatusTypeDef HAL_ETH_WritePHYRegister( ETH_HandleTypeDef * heth, + uint32_t PHYAddr, + uint32_t PHYReg, + uint32_t RegValue ); + HAL_StatusTypeDef HAL_ETH_ReadPHYRegister( ETH_HandleTypeDef * heth, + uint32_t PHYAddr, + uint32_t PHYReg, + uint32_t * pRegValue ); - void HAL_ETH_IRQHandler( ETH_HandleTypeDef * heth ); - void HAL_ETH_TxCpltCallback( ETH_HandleTypeDef * heth ); - void HAL_ETH_RxCpltCallback( ETH_HandleTypeDef * heth ); - void HAL_ETH_DMAErrorCallback( ETH_HandleTypeDef * heth ); - void HAL_ETH_MACErrorCallback( ETH_HandleTypeDef * heth ); - void HAL_ETH_PMTCallback( ETH_HandleTypeDef * heth ); - void HAL_ETH_EEECallback( ETH_HandleTypeDef * heth ); - void HAL_ETH_WakeUpCallback( ETH_HandleTypeDef * heth ); + void HAL_ETH_IRQHandler( ETH_HandleTypeDef * heth ); + void HAL_ETH_TxCpltCallback( ETH_HandleTypeDef * heth ); + void HAL_ETH_RxCpltCallback( ETH_HandleTypeDef * heth ); + void HAL_ETH_DMAErrorCallback( ETH_HandleTypeDef * heth ); + void HAL_ETH_MACErrorCallback( ETH_HandleTypeDef * heth ); + void HAL_ETH_PMTCallback( ETH_HandleTypeDef * heth ); + void HAL_ETH_EEECallback( ETH_HandleTypeDef * heth ); + void HAL_ETH_WakeUpCallback( ETH_HandleTypeDef * heth ); /** * @} @@ -1799,38 +1799,38 @@ */ /* Peripheral Control functions **********************************************/ /* MAC & DMA Configuration APIs **********************************************/ - HAL_StatusTypeDef HAL_ETH_GetMACConfig( ETH_HandleTypeDef * heth, - ETH_MACConfigTypeDef * macconf ); - HAL_StatusTypeDef HAL_ETH_GetDMAConfig( ETH_HandleTypeDef * heth, - ETH_DMAConfigTypeDef * dmaconf ); - HAL_StatusTypeDef HAL_ETH_SetMACConfig( ETH_HandleTypeDef * heth, - ETH_MACConfigTypeDef * macconf ); - HAL_StatusTypeDef HAL_ETH_SetDMAConfig( ETH_HandleTypeDef * heth, - ETH_DMAConfigTypeDef * dmaconf ); + HAL_StatusTypeDef HAL_ETH_GetMACConfig( ETH_HandleTypeDef * heth, + ETH_MACConfigTypeDef * macconf ); + HAL_StatusTypeDef HAL_ETH_GetDMAConfig( ETH_HandleTypeDef * heth, + ETH_DMAConfigTypeDef * dmaconf ); + HAL_StatusTypeDef HAL_ETH_SetMACConfig( ETH_HandleTypeDef * heth, + ETH_MACConfigTypeDef * macconf ); + HAL_StatusTypeDef HAL_ETH_SetDMAConfig( ETH_HandleTypeDef * heth, + ETH_DMAConfigTypeDef * dmaconf ); /* MAC VLAN Processing APIs ************************************************/ - void HAL_ETH_SetRxVLANIdentifier( ETH_HandleTypeDef * heth, - uint32_t ComparisonBits, - uint32_t VLANIdentifier ); + void HAL_ETH_SetRxVLANIdentifier( ETH_HandleTypeDef * heth, + uint32_t ComparisonBits, + uint32_t VLANIdentifier ); /* MAC L2 Packet Filtering APIs **********************************************/ - HAL_StatusTypeDef HAL_ETH_GetMACFilterConfig( ETH_HandleTypeDef * heth, - ETH_MACFilterConfigTypeDef * pFilterConfig ); - HAL_StatusTypeDef HAL_ETH_SetMACFilterConfig( ETH_HandleTypeDef * heth, - ETH_MACFilterConfigTypeDef * pFilterConfig ); - HAL_StatusTypeDef HAL_ETH_SetHashTable( ETH_HandleTypeDef * heth, - uint32_t * pHashTable ); - HAL_StatusTypeDef HAL_ETH_SetSourceMACAddrMatch( ETH_HandleTypeDef * heth, - uint32_t AddrNbr, - uint8_t * pMACAddr ); + HAL_StatusTypeDef HAL_ETH_GetMACFilterConfig( ETH_HandleTypeDef * heth, + ETH_MACFilterConfigTypeDef * pFilterConfig ); + HAL_StatusTypeDef HAL_ETH_SetMACFilterConfig( ETH_HandleTypeDef * heth, + ETH_MACFilterConfigTypeDef * pFilterConfig ); + HAL_StatusTypeDef HAL_ETH_SetHashTable( ETH_HandleTypeDef * heth, + uint32_t * pHashTable ); + HAL_StatusTypeDef HAL_ETH_SetSourceMACAddrMatch( ETH_HandleTypeDef * heth, + uint32_t AddrNbr, + uint8_t * pMACAddr ); /* MAC Power Down APIs *****************************************************/ - void HAL_ETH_EnterPowerDownMode( ETH_HandleTypeDef * heth, - ETH_PowerDownConfigTypeDef * pPowerDownConfig ); - void HAL_ETH_ExitPowerDownMode( ETH_HandleTypeDef * heth ); - HAL_StatusTypeDef HAL_ETH_SetWakeUpFilter( ETH_HandleTypeDef * heth, - uint32_t * pFilter, - uint32_t Count ); + void HAL_ETH_EnterPowerDownMode( ETH_HandleTypeDef * heth, + ETH_PowerDownConfigTypeDef * pPowerDownConfig ); + void HAL_ETH_ExitPowerDownMode( ETH_HandleTypeDef * heth ); + HAL_StatusTypeDef HAL_ETH_SetWakeUpFilter( ETH_HandleTypeDef * heth, + uint32_t * pFilter, + uint32_t Count ); /** * @} @@ -1840,11 +1840,11 @@ * @{ */ /* Peripheral State functions **************************************************/ - HAL_ETH_StateTypeDef HAL_ETH_GetState( ETH_HandleTypeDef * heth ); - uint32_t HAL_ETH_GetError( ETH_HandleTypeDef * heth ); - uint32_t HAL_ETH_GetDMAError( ETH_HandleTypeDef * heth ); - uint32_t HAL_ETH_GetMACError( ETH_HandleTypeDef * heth ); - uint32_t HAL_ETH_GetMACWakeUpSource( ETH_HandleTypeDef * heth ); + HAL_ETH_StateTypeDef HAL_ETH_GetState( ETH_HandleTypeDef * heth ); + uint32_t HAL_ETH_GetError( ETH_HandleTypeDef * heth ); + uint32_t HAL_ETH_GetDMAError( ETH_HandleTypeDef * heth ); + uint32_t HAL_ETH_GetMACError( ETH_HandleTypeDef * heth ); + uint32_t HAL_ETH_GetMACWakeUpSource( ETH_HandleTypeDef * heth ); /** * @} diff --git a/source/portable/NetworkInterface/TM4C/README.md b/source/portable/NetworkInterface/TM4C/README.md index 66bd4ff20a..4bb07d3602 100644 --- a/source/portable/NetworkInterface/TM4C/README.md +++ b/source/portable/NetworkInterface/TM4C/README.md @@ -1,9 +1,9 @@ -## Disclaimer : +## Disclaimer : Please note that TM4C port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting TM4C port to use it. diff --git a/source/portable/NetworkInterface/TM4C/TM4C-README.md b/source/portable/NetworkInterface/TM4C/TM4C-README.md index cf976a8023..453e603803 100644 --- a/source/portable/NetworkInterface/TM4C/TM4C-README.md +++ b/source/portable/NetworkInterface/TM4C/TM4C-README.md @@ -3,7 +3,7 @@ This driver was written and tested using the Texas Instruments (TI) TM4C1294NCPDT microcontroller using version the TivaWare((C) TI) driver library. This MCU includes built-in MAC and PHY which this driver assumes is to be used. -This is a zero-copy driver uses the TivaWare ((C) TI) ROM function mapping macros, is intended for use with FreeRTOS+TCP BufferManagmeent_1, and is loosely modeled after the example lwIP Ethernet driver provided by TI in their TivaWare library. The driver utilizes the Ethernet (MAC) DMA engine. +This is a zero-copy driver uses the TivaWare ((C) TI) ROM function mapping macros, is intended for use with FreeRTOS+TCP BufferManagement_1, and is loosely modeled after the example lwIP Ethernet driver provided by TI in their TivaWare library. The driver utilizes the Ethernet (MAC) DMA engine. ## Vendor Provided Version Numbers Used The following versions for tools/libraries were used during development and testing of this driver: diff --git a/source/portable/NetworkInterface/ThirdParty/MSP432/README.md b/source/portable/NetworkInterface/ThirdParty/MSP432/README.md index 07e6a3eb8b..9115a4f9bf 100644 --- a/source/portable/NetworkInterface/ThirdParty/MSP432/README.md +++ b/source/portable/NetworkInterface/ThirdParty/MSP432/README.md @@ -1,8 +1,8 @@ -## Disclaimer : +## Disclaimer : Please note that MSP432 port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting MSP432 port to use it. diff --git a/source/portable/NetworkInterface/WinPCap/NetworkInterface.c b/source/portable/NetworkInterface/WinPCap/NetworkInterface.c index 4398aedaa0..f0a70bb7ff 100644 --- a/source/portable/NetworkInterface/WinPCap/NetworkInterface.c +++ b/source/portable/NetworkInterface/WinPCap/NetworkInterface.c @@ -460,16 +460,16 @@ static pcap_if_t * prvPrintAvailableNetworkInterfaces( void ) printf( " (%s)\n", prvRemoveSpaces( cBuffer, sizeof( cBuffer ), xInterface->description ? xInterface->description : "No description" ) ); printf( "\n" ); #ifdef configNETWORK_INTERFACE_TYPE_TO_USE + { + if( xInterface->description != NULL ) { - if( xInterface->description != NULL ) + if( xDesiredAdapter( xInterface->description ) ) { - if( xDesiredAdapter( xInterface->description ) ) - { - printf( "The description of adapter %d matches with '%s'\n", lInterfaceNumber, configNETWORK_INTERFACE_TYPE_TO_USE ); - xConfigNetworkInterfaceToUse = lInterfaceNumber; - } + printf( "The description of adapter %d matches with '%s'\n", lInterfaceNumber, configNETWORK_INTERFACE_TYPE_TO_USE ); + xConfigNetworkInterfaceToUse = lInterfaceNumber; } } + } #endif /* ifdef configNETWORK_INTERFACE_TYPE_TO_USE */ lInterfaceNumber++; } @@ -848,9 +848,9 @@ static void prvInterruptSimulatorTask( void * pvParameters ) pxNetworkBuffer->xDataLength = ( size_t ) pxHeader->len; #if ( niDISRUPT_PACKETS == 1 ) - { - pxNetworkBuffer = vRxFaultInjection( pxNetworkBuffer, pucPacketData ); - } + { + pxNetworkBuffer = vRxFaultInjection( pxNetworkBuffer, pucPacketData ); + } #endif /* niDISRUPT_PACKETS */ if( pxNetworkBuffer != NULL ) diff --git a/source/portable/NetworkInterface/Zynq/NetworkInterface.c b/source/portable/NetworkInterface/Zynq/NetworkInterface.c index 924f4f4994..086125e650 100644 --- a/source/portable/NetworkInterface/Zynq/NetworkInterface.c +++ b/source/portable/NetworkInterface/Zynq/NetworkInterface.c @@ -104,7 +104,7 @@ * many outgoing packets seem to get dropped. */ #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) - #warning ipconfigNIC_LINKSPEED100 is btoken. Are you sure? + #warning ipconfigNIC_LINKSPEED100 is broken. Are you sure? #endif #endif @@ -272,40 +272,40 @@ static BaseType_t xZynqNetworkInterfaceInitialise( NetworkInterface_t * pxInterf XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) pxEndPoint->xMACAddress.ucBytes, 1 ); #if ( ipconfigUSE_LLMNR == 1 ) + { + /* Also add LLMNR multicast MAC address. */ + #if ( ipconfigUSE_IPv6 == 0 ) { - /* Also add LLMNR multicast MAC address. */ - #if ( ipconfigUSE_IPv6 == 0 ) - { - XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAdress.ucBytes ); - } - #else + XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddress.ucBytes ); + } + #else + { + NetworkEndPoint_t * pxEndPoint; + NetworkInterface_t * pxInterface = pxMyInterfaces[ xEMACIndex ]; + + for( pxEndPoint = FreeRTOS_FirstEndPoint( pxInterface ); + pxEndPoint != NULL; + pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint ) ) + { + if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) { - NetworkEndPoint_t * pxEndPoint; - NetworkInterface_t * pxInterface = pxMyInterfaces[ xEMACIndex ]; - - for( pxEndPoint = FreeRTOS_FirstEndPoint( pxInterface ); - pxEndPoint != NULL; - pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint ) ) - { - if( pxEndPoint->bits.bIPv6 != pdFALSE_UNSIGNED ) - { - unsigned char ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; - ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; - ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; - ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; - XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucMACAddress ); - } - } - - XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAdressIPv6.ucBytes ); + unsigned char ucMACAddress[ 6 ] = { 0x33, 0x33, 0xff, 0, 0, 0 }; + ucMACAddress[ 3 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 13 ]; + ucMACAddress[ 4 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 14 ]; + ucMACAddress[ 5 ] = pxEndPoint->ipv6_settings.xIPAddress.ucBytes[ 15 ]; + XEmacPs_SetHash( pxEMAC_PS, ( void * ) ucMACAddress ); } - #endif /* if ( ipconfigUSE_IPv6 == 0 ) */ + } + + XEmacPs_SetHash( pxEMAC_PS, ( void * ) xLLMNR_MacAddressIPv6.ucBytes ); } + #endif /* if ( ipconfigUSE_IPv6 == 0 ) */ + } #endif /* ipconfigUSE_LLMNR == 1 */ #if ( ( ipconfigUSE_MDNS == 1 ) && ( ipconfigUSE_IPv6 != 0 ) ) - XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAdress.ucBytes ); - XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MACAdressIPv6.ucBytes ); + XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MacAddress.ucBytes ); + XEmacPs_SetHash( pxEMAC_PS, ( void * ) xMDNS_MACAddressIPv6.ucBytes ); #endif pxEndPoint = FreeRTOS_NextEndPoint( pxInterface, pxEndPoint ); @@ -388,35 +388,35 @@ static BaseType_t xZynqNetworkInterfaceOutput( NetworkInterface_t * pxInterface, configASSERT( xEMACIndex < XPAR_XEMACPS_NUM_INSTANCES ); #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - ProtocolPacket_t * pxPacket; - - /* If the peripheral must calculate the checksum, it wants - * the protocol checksum to have a value of zero. */ - pxPacket = ( ProtocolPacket_t * ) ( pxBuffer->pucEthernetBuffer ); + { + ProtocolPacket_t * pxPacket; - #if ( ipconfigUSE_IPv6 != 0 ) - ICMPPacket_IPv6_t * pxICMPPacket = ( ICMPPacket_IPv6_t * ) pxBuffer->pucEthernetBuffer; + /* If the peripheral must calculate the checksum, it wants + * the protocol checksum to have a value of zero. */ + pxPacket = ( ProtocolPacket_t * ) ( pxBuffer->pucEthernetBuffer ); - if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE ) && - ( pxICMPPacket->xIPHeader.ucNextHeader == ipPROTOCOL_ICMP_IPv6 ) ) - { - /* The EMAC will calculate the checksum of the IP-header. - * It can only calculate protocol checksums of UDP and TCP, - * so for ICMP and other protocols it must be done manually. */ - usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE ); - } - #endif + #if ( ipconfigUSE_IPv6 != 0 ) + ICMPPacket_IPv6_t * pxICMPPacket = ( ICMPPacket_IPv6_t * ) pxBuffer->pucEthernetBuffer; - if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) && - ( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP ) ) + if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv6_FRAME_TYPE ) && + ( pxICMPPacket->xIPHeader.ucNextHeader == ipPROTOCOL_ICMP_IPv6 ) ) { /* The EMAC will calculate the checksum of the IP-header. * It can only calculate protocol checksums of UDP and TCP, * so for ICMP and other protocols it must be done manually. */ usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE ); } + #endif + + if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) && + ( pxPacket->xICMPPacket.xIPHeader.ucProtocol == ipPROTOCOL_ICMP ) ) + { + /* The EMAC will calculate the checksum of the IP-header. + * It can only calculate protocol checksums of UDP and TCP, + * so for ICMP and other protocols it must be done manually. */ + usGenerateProtocolChecksum( pxBuffer->pucEthernetBuffer, pxBuffer->xDataLength, pdTRUE ); } + } #endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM */ if( ( ulPHYLinkStates[ xEMACIndex ] & niBMSR_LINK_STATUS ) != 0UL ) @@ -610,12 +610,12 @@ static void prvEMACHandlerTask( void * pvParameters ) for( ; ; ) { #if ( ipconfigHAS_PRINTF != 0 ) - { - /* Call a function that monitors resources: the amount of free network - * buffers and the amount of free space on the heap. See FreeRTOS_IP.c - * for more detailed comments. */ - vPrintResourceStats(); - } + { + /* Call a function that monitors resources: the amount of free network + * buffers and the amount of free space on the heap. See FreeRTOS_IP.c + * for more detailed comments. */ + vPrintResourceStats(); + } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ if( ( pxEMAC_PS->isr_events & EMAC_IF_ALL_EVENT ) == 0 ) diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif.h b/source/portable/NetworkInterface/Zynq/x_emacpsif.h index 82fc9df1d8..ab3d8423d2 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif.h +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif.h @@ -35,7 +35,7 @@ #include "xemacps.h" /* defines XEmacPs API */ #ifdef __cplusplus - extern "C" { + extern "C" { #endif #define XPAR_PS7_ETHERNET_1_DEVICE_ID 1 diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c b/source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c index 5aba5007e5..f1684982bb 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif_dma.c @@ -391,18 +391,18 @@ static void prvPassEthMessages( NetworkBufferDescriptor_t * pxDescriptor ) * This is a deferred handler taskr, not a real interrupt, so it is ok to * use the task level function here. */ #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) + { + do { - do - { - NetworkBufferDescriptor_t * pxNext = pxDescriptor->pxNextBuffer; - vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - pxDescriptor = pxNext; - } while( pxDescriptor != NULL ); - } - #else - { + NetworkBufferDescriptor_t * pxNext = pxDescriptor->pxNextBuffer; vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - } + pxDescriptor = pxNext; + } while( pxDescriptor != NULL ); + } + #else + { + vReleaseNetworkBufferAndDescriptor( pxDescriptor ); + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ iptraceETHERNET_RX_EVENT_LOST(); FreeRTOS_printf( ( "prvPassEthMessages: Can not queue return packet!\n" ) ); @@ -434,51 +434,51 @@ BaseType_t xMayAcceptPacket( uint8_t * pucEthernetBuffer ) } #if ( ipconfigETHERNET_DRIVER_FILTERS_PACKETS == 1 ) + { + const IPHeader_t * pxIPHeader = &( pxProtPacket->xTCPPacket.xIPHeader ); + + /* Ensure that the incoming packet is not fragmented (only outgoing packets + * can be fragmented) as these are the only handled IP frames currently. */ + if( ( pxIPHeader->usFragmentOffset & FreeRTOS_ntohs( ipFRAGMENT_OFFSET_BIT_MASK ) ) != 0U ) { - const IPHeader_t * pxIPHeader = &( pxProtPacket->xTCPPacket.xIPHeader ); + return pdFALSE; + } - /* Ensure that the incoming packet is not fragmented (only outgoing packets - * can be fragmented) as these are the only handled IP frames currently. */ - if( ( pxIPHeader->usFragmentOffset & FreeRTOS_ntohs( ipFRAGMENT_OFFSET_BIT_MASK ) ) != 0U ) - { - return pdFALSE; - } + /* HT: Might want to make the following configurable because + * most IP messages have a standard length of 20 bytes */ - /* HT: Might want to make the following configurable because - * most IP messages have a standard length of 20 bytes */ + /* 0x45 means: IPv4 with an IP header of 5 x 4 = 20 bytes + * 0x47 means: IPv4 with an IP header of 7 x 4 = 28 bytes */ + if( ( pxIPHeader->ucVersionHeaderLength < 0x45 ) || ( pxIPHeader->ucVersionHeaderLength > 0x4F ) ) + { + return pdFALSE; + } - /* 0x45 means: IPv4 with an IP header of 5 x 4 = 20 bytes - * 0x47 means: IPv4 with an IP header of 7 x 4 = 28 bytes */ - if( ( pxIPHeader->ucVersionHeaderLength < 0x45 ) || ( pxIPHeader->ucVersionHeaderLength > 0x4F ) ) + if( pxIPHeader->ucProtocol == ipPROTOCOL_UDP ) + { + uint16_t usSourcePort = FreeRTOS_ntohs( pxProtPacket->xUDPPacket.xUDPHeader.usSourcePort ); + uint16_t usDestinationPort = FreeRTOS_ntohs( pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort ); + + if( ( xPortHasUDPSocket( pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort ) == pdFALSE ) + #if ipconfigUSE_LLMNR == 1 + && ( usDestinationPort != ipLLMNR_PORT ) && + ( usSourcePort != ipLLMNR_PORT ) + #endif + #if ipconfigUSE_NBNS == 1 + && ( usDestinationPort != ipNBNS_PORT ) && + ( usSourcePort != ipNBNS_PORT ) + #endif + #if ipconfigUSE_DNS == 1 + && ( usSourcePort != ipDNS_PORT ) + #endif + ) { + /* Drop this packet, not for this device. */ + /* FreeRTOS_printf( ( "Drop: UDP port %d -> %d\n", usSourcePort, usDestinationPort ) ); */ return pdFALSE; } - - if( pxIPHeader->ucProtocol == ipPROTOCOL_UDP ) - { - uint16_t usSourcePort = FreeRTOS_ntohs( pxProtPacket->xUDPPacket.xUDPHeader.usSourcePort ); - uint16_t usDestinationPort = FreeRTOS_ntohs( pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort ); - - if( ( xPortHasUDPSocket( pxProtPacket->xUDPPacket.xUDPHeader.usDestinationPort ) == pdFALSE ) - #if ipconfigUSE_LLMNR == 1 - && ( usDestinationPort != ipLLMNR_PORT ) && - ( usSourcePort != ipLLMNR_PORT ) - #endif - #if ipconfigUSE_NBNS == 1 - && ( usDestinationPort != ipNBNS_PORT ) && - ( usSourcePort != ipNBNS_PORT ) - #endif - #if ipconfigUSE_DNS == 1 - && ( usSourcePort != ipDNS_PORT ) - #endif - ) - { - /* Drop this packet, not for this device. */ - /* FreeRTOS_printf( ( "Drop: UDP port %d -> %d\n", usSourcePort, usDestinationPort ) ); */ - return pdFALSE; - } - } } + } #endif /* ipconfigETHERNET_DRIVER_FILTERS_PACKETS */ return pdTRUE; } @@ -559,26 +559,26 @@ int emacps_check_rx( xemacpsif_s * xemacpsif, * different handler. */ iptraceNETWORK_INTERFACE_RECEIVE(); #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) + { + pxBuffer->pxNextBuffer = NULL; + + if( pxFirstDescriptor == NULL ) { - pxBuffer->pxNextBuffer = NULL; - - if( pxFirstDescriptor == NULL ) - { - /* Becomes the first message */ - pxFirstDescriptor = pxBuffer; - } - else if( pxLastDescriptor != NULL ) - { - /* Add to the tail */ - pxLastDescriptor->pxNextBuffer = pxBuffer; - } - - pxLastDescriptor = pxBuffer; + /* Becomes the first message */ + pxFirstDescriptor = pxBuffer; } - #else /* if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) */ + else if( pxLastDescriptor != NULL ) { - prvPassEthMessages( pxBuffer ); + /* Add to the tail */ + pxLastDescriptor->pxNextBuffer = pxBuffer; } + + pxLastDescriptor = pxBuffer; + } + #else /* if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) */ + { + prvPassEthMessages( pxBuffer ); + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ msgCount++; @@ -617,12 +617,12 @@ int emacps_check_rx( xemacpsif_s * xemacpsif, } #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) + { + if( pxFirstDescriptor != NULL ) { - if( pxFirstDescriptor != NULL ) - { - prvPassEthMessages( pxFirstDescriptor ); - } + prvPassEthMessages( pxFirstDescriptor ); } + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ return msgCount; @@ -731,10 +731,10 @@ XStatus init_dma( xemacpsif_s * xemacpsif ) #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) value |= XEMACPS_DMACR_TCPCKSUM_MASK; #else - #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) - { - #warning Are you sure the EMAC should not calculate outgoing checksums? - } + #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) + { + #warning Are you sure the EMAC should not calculate outgoing checksums? + } #endif value &= ~XEMACPS_DMACR_TCPCKSUM_MASK; @@ -752,10 +752,10 @@ XStatus init_dma( xemacpsif_s * xemacpsif ) #if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 ) value |= XEMACPS_NWCFG_RXCHKSUMEN_MASK; #else - #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) - { - #warning Are you sure the EMAC should not calculate incoming checksums? - } + #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) + { + #warning Are you sure the EMAC should not calculate incoming checksums? + } #endif value &= ~( ( uint32_t ) XEMACPS_NWCFG_RXCHKSUMEN_MASK ); diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c b/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c index 5eb9530f67..b73a06e9e0 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.c @@ -210,7 +210,7 @@ static void emacps_handle_error( void * arg, if( ( ErrorWord & XEMACPS_TXSR_RXOVR_MASK ) != 0 ) { - last_err_msg = "Transmit retry excessed limits"; + last_err_msg = "Transmit retry exceeded limits"; HandleTxErrors( xemacpsif ); } diff --git a/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.h b/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.h index 1b9a5bdaf0..8dd594ae8f 100644 --- a/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.h +++ b/source/portable/NetworkInterface/Zynq/x_emacpsif_hw.h @@ -23,7 +23,7 @@ /*#include "lwip/netif.h" */ #ifdef __cplusplus - extern "C" { + extern "C" { #endif XEmacPs_Config * lookup_config( unsigned mac_base ); diff --git a/source/portable/NetworkInterface/Zynq/x_topology.h b/source/portable/NetworkInterface/Zynq/x_topology.h index 84138d157c..540818827a 100644 --- a/source/portable/NetworkInterface/Zynq/x_topology.h +++ b/source/portable/NetworkInterface/Zynq/x_topology.h @@ -20,7 +20,7 @@ #define __XTOPOLOGY_H_ #ifdef __cplusplus - extern "C" { + extern "C" { #endif enum xemac_types diff --git a/source/portable/NetworkInterface/esp32/NetworkInterface.c b/source/portable/NetworkInterface/esp32/NetworkInterface.c index 5df6045fcb..ac4d0dce50 100644 --- a/source/portable/NetworkInterface/esp32/NetworkInterface.c +++ b/source/portable/NetworkInterface/esp32/NetworkInterface.c @@ -160,12 +160,12 @@ static BaseType_t xESP32_Eth_NetworkInterfaceOutput( NetworkInterface_t * pxInte } #if ( ipconfigHAS_PRINTF != 0 ) - { - /* Call a function that monitors resources: the amount of free network - * buffers and the amount of free space on the heap. See FreeRTOS_IP.c - * for more detailed comments. */ - vPrintResourceStats(); - } + { + /* Call a function that monitors resources: the amount of free network + * buffers and the amount of free space on the heap. See FreeRTOS_IP.c + * for more detailed comments. */ + vPrintResourceStats(); + } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ if( xReleaseAfterSend == pdTRUE ) @@ -202,9 +202,9 @@ esp_err_t wlanif_input( void * netif, const TickType_t xDescriptorWaitTime = pdMS_TO_TICKS( 250 ); #if ( ipconfigHAS_PRINTF != 0 ) - { - vPrintResourceStats(); - } + { + vPrintResourceStats(); + } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ if( eConsiderFrameForProcessing( buffer ) != eProcessBuffer ) diff --git a/source/portable/NetworkInterface/esp32/README.md b/source/portable/NetworkInterface/esp32/README.md index cdea9ee399..903b3d48cc 100644 --- a/source/portable/NetworkInterface/esp32/README.md +++ b/source/portable/NetworkInterface/esp32/README.md @@ -1,9 +1,9 @@ -## Disclaimer : +## Disclaimer : Please note that esp32 port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting esp32 port to use it. diff --git a/source/portable/NetworkInterface/include/phyHandling.h b/source/portable/NetworkInterface/include/phyHandling.h index efeb660463..adf1ceb3e7 100644 --- a/source/portable/NetworkInterface/include/phyHandling.h +++ b/source/portable/NetworkInterface/include/phyHandling.h @@ -40,7 +40,7 @@ #define PHYHANDLING_H #ifdef __cplusplus - extern "C" { + extern "C" { #endif diff --git a/source/portable/NetworkInterface/ksz8851snl/NetworkInterface.c b/source/portable/NetworkInterface/ksz8851snl/NetworkInterface.c index d3002900fb..e7536bd076 100644 --- a/source/portable/NetworkInterface/ksz8851snl/NetworkInterface.c +++ b/source/portable/NetworkInterface/ksz8851snl/NetworkInterface.c @@ -425,10 +425,10 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkB } #if ( ipconfigZERO_COPY_TX_DRIVER != 1 ) - #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) - { - #warning Please ipconfigZERO_COPY_TX_DRIVER as 1 - } + #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) + { + #warning Please ipconfigZERO_COPY_TX_DRIVER as 1 + } #endif #endif configASSERT( bReleaseAfterSend != pdFALSE ); @@ -1251,17 +1251,17 @@ static void prvEMACHandlerTask( void * pvParameters ) } #if ( ipconfigCHECK_IP_QUEUE_SPACE != 0 ) - { - uxCurrentCount = uxGetMinimumIPQueueSpace(); + { + uxCurrentCount = uxGetMinimumIPQueueSpace(); - if( uxLastMinQueueSpace != uxCurrentCount ) - { - /* The logging produced below may be helpful - * while tuning +TCP: see how many buffers are in use. */ - uxLastMinQueueSpace = uxCurrentCount; - FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); - } + if( uxLastMinQueueSpace != uxCurrentCount ) + { + /* The logging produced below may be helpful + * while tuning +TCP: see how many buffers are in use. */ + uxLastMinQueueSpace = uxCurrentCount; + FreeRTOS_printf( ( "Queue space: lowest %lu\n", uxCurrentCount ) ); } + } #endif /* ipconfigCHECK_IP_QUEUE_SPACE */ /* Run the state-machine of the ksz8851 driver. */ diff --git a/source/portable/NetworkInterface/ksz8851snl/ksz8851snl.c b/source/portable/NetworkInterface/ksz8851snl/ksz8851snl.c index 3a23334c0f..66df4a8e6f 100644 --- a/source/portable/NetworkInterface/ksz8851snl/ksz8851snl.c +++ b/source/portable/NetworkInterface/ksz8851snl/ksz8851snl.c @@ -480,9 +480,9 @@ void ksz8851snl_set_registers( void ) /*#define RXQ_TWOBYTE_OFFSET (0x0200) / * Enable adding 2-byte before frame header for IP aligned with DWORD * / */ #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) - { - #warning Remember to try the above option to get a 2-byte offset - } + { + #warning Remember to try the above option to get a 2-byte offset + } #endif /* Init step11: configure QMU receive queue: trigger INT and auto-dequeue frame. */ diff --git a/source/portable/NetworkInterface/ksz8851snl/ksz8851snl_reg.h b/source/portable/NetworkInterface/ksz8851snl/ksz8851snl_reg.h index 9fb5cc5058..ca06e4a407 100644 --- a/source/portable/NetworkInterface/ksz8851snl/ksz8851snl_reg.h +++ b/source/portable/NetworkInterface/ksz8851snl/ksz8851snl_reg.h @@ -109,7 +109,7 @@ #define EEPROM_CHIP_SELECT ( 0x0001 ) /* EEPROM chip select (EECS pin) */ #define REG_MEM_BIST_INFO ( 0x24 ) /* MBIR */ -#define TX_MEM_TEST_FINISHED ( 0x1000 ) /* TX memeory BIST test finish */ +#define TX_MEM_TEST_FINISHED ( 0x1000 ) /* TX memory BIST test finish */ #define TX_MEM_TEST_FAILED ( 0x0800 ) /* TX memory BIST test fail */ #define TX_MEM_TEST_FAILED_COUNT ( 0x0700 ) /* TX memory BIST test fail count */ #define RX_MEM_TEST_FINISHED ( 0x0010 ) /* RX memory BIST test finish */ @@ -362,7 +362,7 @@ #define PME_FROM_ENERGY ( 0x0100 ) /* PME asserted when energy is detected */ #define PME_EVENT_MASK ( 0x0F00 ) /* PME asserted event mask */ #define WAKEUP_AUTO_ENABLE ( 0x0080 ) /* Enable auto wake-up in energy mode */ -#define WAKEUP_NORMAL_AUTO_ENABLE ( 0x0040 ) /* Enable auto goto normal mode from energy detecion mode */ +#define WAKEUP_NORMAL_AUTO_ENABLE ( 0x0040 ) /* Enable auto goto normal mode from energy detection mode */ #define WAKEUP_FROM_WKFRAME ( 0x0020 ) /* Wake-up from wake-up frame event detected */ #define WAKEUP_FROM_MAGIC ( 0x0010 ) /* Wake-up from magic packet event detected */ #define WAKEUP_FROM_LINKUP ( 0x0008 ) /* Wake-up from link up event detected */ diff --git a/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c b/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c index 17ef28f8c6..85760bcbd9 100644 --- a/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c +++ b/source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c @@ -163,7 +163,7 @@ static THREAD_RETURN THREAD_FUNC_DEF vTransmitThread( void * pvParameters ); * * @param[out] pxSendMsgBuffer Location to store the handle of the send message buffer. * @param[out] pxRecvMsgBuffer Location to store the handle of the receive message buffer. - * @param[in] pvSendEvent Pointer of the event struct which the implemenbtation should pend on to receive frames. + * @param[in] pvSendEvent Pointer of the event struct which the implementation should pend on to receive frames. * @param[out] ppvBackendContext Location to store an implementation specific void pointer. */ void vMBuffNetifBackendInit( MessageBufferHandle_t * pxSendMsgBuffer, @@ -402,7 +402,7 @@ void vMBuffNetifBackendDeInit( void * pvBackendContext ) } /** - * @brief Callback called by libslirp when an incomming frame is available. + * @brief Callback called by libslirp when an incoming frame is available. * * @param [in] pvBuffer Pointer to a buffer containing the incoming frame. * @param [in] uxLen Length of the incoming frame. @@ -447,7 +447,7 @@ static slirp_ssize_t xSlirp_WriteCallback( const void * pvBuffer, /** - * @brief Checks that pxPollFdArray is large enough to accomodate the specified number of file descriptors. + * @brief Checks that pxPollFdArray is large enough to accommodate the specified number of file descriptors. * * @param [in] pxCtx Pointer to the relevant SlirpBackendContext_t. * @param [in] xDesiredSize Desired number of file descriptors to store. @@ -779,7 +779,7 @@ static THREAD_RETURN THREAD_FUNC_DEF vReceiveThread( void * pvParameters ) #endif /* if defined( _WIN32 ) */ /** - * @brief Callback funciton passed to libslirp to report a runtime error. + * @brief Callback function passed to libslirp to report a runtime error. * * @param [in] msg Error message * @param pvOpaque Opaque context pointer (unused). @@ -868,7 +868,7 @@ static void vSlirp_TimerModify( void * pvTimer, #endif /* SLIRP_CHECK_VERSION( 4U, 7U, 0U ) */ /** - * @brief Called by libslipr when a new file descriptor / socket is opened. + * @brief Called by libslirp when a new file descriptor / socket is opened. * * @param lFd File descriptor to watch. * @param pvOpaque Pointer to driver context. diff --git a/source/portable/NetworkInterface/libslirp/MBuffNetworkInterface.c b/source/portable/NetworkInterface/libslirp/MBuffNetworkInterface.c index 08bfcbb043..3c2699acd0 100644 --- a/source/portable/NetworkInterface/libslirp/MBuffNetworkInterface.c +++ b/source/portable/NetworkInterface/libslirp/MBuffNetworkInterface.c @@ -253,7 +253,7 @@ static void vNetifReceiveTask( void * pvParameters ) { FreeRTOS_debug_printf( ( "Dropping TX frame of length: %lu. FreeRTOS+TCP event queue is full.\n", pxDescriptor->xDataLength ) ); - /* Drop the frame and reuse the descriptor for the next incomming frame */ + /* Drop the frame and reuse the descriptor for the next incoming frame */ iptraceETHERNET_RX_EVENT_LOST(); } } diff --git a/source/portable/NetworkInterface/linux/NetworkInterface.c b/source/portable/NetworkInterface/linux/NetworkInterface.c index 2732d33947..9ad95e0067 100644 --- a/source/portable/NetworkInterface/linux/NetworkInterface.c +++ b/source/portable/NetworkInterface/linux/NetworkInterface.c @@ -498,7 +498,7 @@ static int prvSetDeviceModes() if( ( ret != 0 ) && ( ret != PCAP_ERROR_ACTIVATED ) ) { - FreeRTOS_printf( ( "coult not activate promisuous mode\n" ) ); + FreeRTOS_printf( ( "could not activate promiscuous mode\n" ) ); break; } @@ -507,7 +507,7 @@ static int prvSetDeviceModes() if( ( ret != 0 ) && ( ret != PCAP_ERROR_ACTIVATED ) ) { - FreeRTOS_printf( ( "coult not set snaplen\n" ) ); + FreeRTOS_printf( ( "could not set snaplen\n" ) ); break; } @@ -515,7 +515,7 @@ static int prvSetDeviceModes() if( ( ret != 0 ) && ( ret != PCAP_ERROR_ACTIVATED ) ) { - FreeRTOS_printf( ( "coult not set timeout\n" ) ); + FreeRTOS_printf( ( "could not set timeout\n" ) ); break; } @@ -524,7 +524,7 @@ static int prvSetDeviceModes() if( ( ret != 0 ) && ( ret != PCAP_ERROR_ACTIVATED ) ) { - FreeRTOS_printf( ( "coult not set buffer size\n" ) ); + FreeRTOS_printf( ( "could not set buffer size\n" ) ); break; } @@ -858,7 +858,7 @@ static void * prvLinuxPcapSendThread( void * pvParam ) { uxStreamBufferGet( xSendBuffer, 0, ( uint8_t * ) &xLength, sizeof( xLength ), pdFALSE ); uxStreamBufferGet( xSendBuffer, 0, ( uint8_t * ) ucBuffer, xLength, pdFALSE ); - FreeRTOS_debug_printf( ( "Sending ========== > data pcap_sendpadcket %lu\n", xLength ) ); + FreeRTOS_debug_printf( ( "Sending ========== > data pcap_sendpacket %lu\n", xLength ) ); print_hex( ucBuffer, xLength ); if( pcap_sendpacket( pxOpenedInterfaceHandle, ucBuffer, ( int ) xLength ) != 0 ) @@ -979,9 +979,9 @@ static void prvInterruptSimulatorTask( void * pvParameters ) pxNetworkBuffer->xDataLength = ( size_t ) pxHeader->len; #if ( niDISRUPT_PACKETS == 1 ) - { - pxNetworkBuffer = vRxFaultInjection( pxNetworkBuffer, pucPacketData ); - } + { + pxNetworkBuffer = vRxFaultInjection( pxNetworkBuffer, pucPacketData ); + } #endif /* niDISRUPT_PACKETS */ if( pxNetworkBuffer != NULL ) diff --git a/source/portable/NetworkInterface/mw300_rd/README.md b/source/portable/NetworkInterface/mw300_rd/README.md index 6de77d15ab..1abd27fc89 100644 --- a/source/portable/NetworkInterface/mw300_rd/README.md +++ b/source/portable/NetworkInterface/mw300_rd/README.md @@ -1,9 +1,9 @@ -## Disclaimer : +## Disclaimer : Please note that mw300_rd port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting mw300_rd port to use it. diff --git a/source/portable/NetworkInterface/pic32mzef/BufferAllocation_2.c b/source/portable/NetworkInterface/pic32mzef/BufferAllocation_2.c index 6e5cd4f833..266b3ade04 100644 --- a/source/portable/NetworkInterface/pic32mzef/BufferAllocation_2.c +++ b/source/portable/NetworkInterface/pic32mzef/BufferAllocation_2.c @@ -269,19 +269,19 @@ BaseType_t xNetworkBuffersInitialise( void ) if( xNetworkBufferSemaphore != NULL ) { #if ( configQUEUE_REGISTRY_SIZE > 0 ) - { - vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" ); - } + { + vQueueAddToRegistry( xNetworkBufferSemaphore, "NetBufSem" ); + } #endif /* configQUEUE_REGISTRY_SIZE */ /* If the trace recorder code is included name the semaphore for viewing * in FreeRTOS+Trace. */ #if ( ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 ) - { - extern QueueHandle_t xNetworkEventQueue; - vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" ); - vTraceSetQueueName( xNetworkBufferSemaphore, "NetworkBufferCount" ); - } + { + extern QueueHandle_t xNetworkEventQueue; + vTraceSetQueueName( xNetworkEventQueue, "IPStackEvent" ); + vTraceSetQueueName( xNetworkBufferSemaphore, "NetworkBufferCount" ); + } #endif /* ipconfigINCLUDE_EXAMPLE_FREERTOS_PLUS_TRACE_CALLS == 1 */ vListInitialise( &xFreeBuffersList ); @@ -467,10 +467,10 @@ NetworkBufferDescriptor_t * pxGetNetworkBufferWithDescriptor( size_t xRequestedS pxReturn->xDataLength = xRequestedSizeBytes; #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) - { - /* make sure the buffer is not linked */ - pxReturn->pxNextBuffer = NULL; - } + { + /* make sure the buffer is not linked */ + pxReturn->pxNextBuffer = NULL; + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ } } diff --git a/source/portable/NetworkInterface/pic32mzef/README.md b/source/portable/NetworkInterface/pic32mzef/README.md index 9aa0076fac..d561c4dd15 100644 --- a/source/portable/NetworkInterface/pic32mzef/README.md +++ b/source/portable/NetworkInterface/pic32mzef/README.md @@ -1,8 +1,8 @@ -## Disclaimer : +## Disclaimer : Please note that pic32mzef port has not been tested with IPv6, Multiple endpoint and interfaces which are supported by the latest TCP release V4.0.0. This needs to be used with caution in IPv6 environment as there can be potential compatibility issues. -## Last Git Release : +## Last Git Release : You can find the last release supporting this port on our GitHub repository here : [V3.1.0](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/releases/tag/V3.1.0). Visit the mentioned link to access the repository and download the version supporting pic32mzef port to use it. diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c b/source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c index f4a4b1a5b1..8af4e9e843 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/NetworkInterface.c @@ -163,7 +163,7 @@ XEmacPs_Config mac_config = static uint32_t ulPHYLinkStatus = 0uL; #if ( ipconfigUSE_LLMNR == 1 ) - static const uint8_t xLLMNR_MACAddress[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; +static const uint8_t xLLMNR_MACAddress[] = { 0x01, 0x00, 0x5E, 0x00, 0x00, 0xFC }; #endif /* Holds the handle of the task used as a deferred interrupt processor. The @@ -228,14 +228,14 @@ BaseType_t xNetworkInterfaceInitialise( void ) XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) ipLOCAL_MAC_ADDRESS, 1 ); #if ( ipconfigUSE_LLMNR == 1 ) - { - /* Also add LLMNR multicast MAC address. */ - XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) xLLMNR_MACAddress, 2 ); - } + { + /* Also add LLMNR multicast MAC address. */ + XEmacPs_SetMacAddress( pxEMAC_PS, ( void * ) xLLMNR_MACAddress, 2 ); + } #endif /* ipconfigUSE_LLMNR == 1 */ XEmacPs_SetMdioDivisor( pxEMAC_PS, MDC_DIV_224 ); - ulPHYIndex = ulDetecPHY( pxEMAC_PS ); + ulPHYIndex = ulDetectPHY( pxEMAC_PS ); if( ulPHYIndex == ~0U ) { @@ -330,23 +330,23 @@ BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxBuffer, BaseType_t bReleaseAfterSend ) { #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) - { - ProtocolPacket_t * pxPacket; + { + ProtocolPacket_t * pxPacket; - /* If the peripheral must calculate the checksum, it wants - * the protocol checksum to have a value of zero. */ - pxPacket = ( ProtocolPacket_t * ) ( pxBuffer->pucEthernetBuffer ); + /* If the peripheral must calculate the checksum, it wants + * the protocol checksum to have a value of zero. */ + pxPacket = ( ProtocolPacket_t * ) ( pxBuffer->pucEthernetBuffer ); - if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) && - ( pxPacket->xICMPPacket.xIPHeader.ucProtocol != ipPROTOCOL_UDP ) && - ( pxPacket->xICMPPacket.xIPHeader.ucProtocol != ipPROTOCOL_TCP ) ) - { - /* The EMAC will calculate the checksum of the IP-header. - * It can only calculate protocol checksums of UDP and TCP, - * so for ICMP and other protocols it must be done manually. */ - usGenerateProtocolChecksum( ( uint8_t * ) &( pxPacket->xUDPPacket ), pxBuffer->xDataLength, pdTRUE ); - } + if( ( pxPacket->xICMPPacket.xEthernetHeader.usFrameType == ipIPv4_FRAME_TYPE ) && + ( pxPacket->xICMPPacket.xIPHeader.ucProtocol != ipPROTOCOL_UDP ) && + ( pxPacket->xICMPPacket.xIPHeader.ucProtocol != ipPROTOCOL_TCP ) ) + { + /* The EMAC will calculate the checksum of the IP-header. + * It can only calculate protocol checksums of UDP and TCP, + * so for ICMP and other protocols it must be done manually. */ + usGenerateProtocolChecksum( ( uint8_t * ) &( pxPacket->xUDPPacket ), pxBuffer->xDataLength, pdTRUE ); } + } #endif /* ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM */ if( ( ulPHYLinkStatus & niBMSR_LINK_STATUS ) != 0UL ) @@ -484,12 +484,12 @@ static void prvEMACHandlerTask( void * pvParameters ) for( ; ; ) { #if ( ipconfigHAS_PRINTF != 0 ) - { - /* Call a function that monitors resources: the amount of free network - * buffers and the amount of free space on the heap. See FreeRTOS_IP.c - * for more detailed comments. */ - vPrintResourceStats(); - } + { + /* Call a function that monitors resources: the amount of free network + * buffers and the amount of free space on the heap. See FreeRTOS_IP.c + * for more detailed comments. */ + vPrintResourceStats(); + } #endif /* ( ipconfigHAS_PRINTF != 0 ) */ if( ( xEMACpsif.isr_events & EMAC_IF_ALL_EVENT ) == 0 ) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif.h b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif.h index 39b48d7d22..66c64f87e1 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif.h +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif.h @@ -36,7 +36,7 @@ #include "xemacps.h" /* defines XEmacPs API */ #ifdef __cplusplus - extern "C" { + extern "C" { #endif void xemacpsif_setmac( uint32_t index, diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c index d361308824..34ec35a46e 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_dma.c @@ -374,18 +374,18 @@ static void prvPassEthMessages( NetworkBufferDescriptor_t * pxDescriptor ) * This is a deferred handler taskr, not a real interrupt, so it is ok to * use the task level function here. */ #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) + { + do { - do - { - NetworkBufferDescriptor_t * pxNext = pxDescriptor->pxNextBuffer; - vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - pxDescriptor = pxNext; - } while( pxDescriptor != NULL ); - } - #else - { + NetworkBufferDescriptor_t * pxNext = pxDescriptor->pxNextBuffer; vReleaseNetworkBufferAndDescriptor( pxDescriptor ); - } + pxDescriptor = pxNext; + } while( pxDescriptor != NULL ); + } + #else + { + vReleaseNetworkBufferAndDescriptor( pxDescriptor ); + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ iptraceETHERNET_RX_EVENT_LOST(); FreeRTOS_printf( ( "prvPassEthMessages: Can not queue return packet!\n" ) ); @@ -441,13 +441,13 @@ int emacps_check_rx( xemacpsif_s * xemacpsif ) * XEMACPS_RXBUF_LEN_MASK can be used. */ #if ( USE_JUMBO_FRAMES == 1 ) - { - rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_JUMBO_MASK; - } + { + rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_JUMBO_MASK; + } #else - { - rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_MASK; - } + { + rx_bytes = xemacpsif->rxSegments[ head ].flags & XEMACPS_RXBUF_LEN_MASK; + } #endif /* ( USE_JUMBO_FRAMES == 1 ) */ pxBuffer->xDataLength = rx_bytes; @@ -461,26 +461,26 @@ int emacps_check_rx( xemacpsif_s * xemacpsif ) * different handler. */ iptraceNETWORK_INTERFACE_RECEIVE(); #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) + { + pxBuffer->pxNextBuffer = NULL; + + if( pxFirstDescriptor == NULL ) { - pxBuffer->pxNextBuffer = NULL; - - if( pxFirstDescriptor == NULL ) - { - /* Becomes the first message */ - pxFirstDescriptor = pxBuffer; - } - else if( pxLastDescriptor != NULL ) - { - /* Add to the tail */ - pxLastDescriptor->pxNextBuffer = pxBuffer; - } - - pxLastDescriptor = pxBuffer; + /* Becomes the first message */ + pxFirstDescriptor = pxBuffer; } - #else /* if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) */ + else if( pxLastDescriptor != NULL ) { - prvPassEthMessages( pxBuffer ); + /* Add to the tail */ + pxLastDescriptor->pxNextBuffer = pxBuffer; } + + pxLastDescriptor = pxBuffer; + } + #else /* if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) */ + { + prvPassEthMessages( pxBuffer ); + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ msgCount++; @@ -517,12 +517,12 @@ int emacps_check_rx( xemacpsif_s * xemacpsif ) } #if ( ipconfigUSE_LINKED_RX_MESSAGES != 0 ) + { + if( pxFirstDescriptor != NULL ) { - if( pxFirstDescriptor != NULL ) - { - prvPassEthMessages( pxFirstDescriptor ); - } + prvPassEthMessages( pxFirstDescriptor ); } + } #endif /* ipconfigUSE_LINKED_RX_MESSAGES */ return msgCount; @@ -665,10 +665,10 @@ XStatus init_dma( xemacpsif_s * xemacpsif ) #if ( ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM != 0 ) value |= XEMACPS_DMACR_TCPCKSUM_MASK; #else - #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) - { - #warning Are you sure the EMAC should not calculate outgoing checksums? - } + #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) + { + #warning Are you sure the EMAC should not calculate outgoing checksums? + } #endif value &= ~XEMACPS_DMACR_TCPCKSUM_MASK; @@ -686,10 +686,10 @@ XStatus init_dma( xemacpsif_s * xemacpsif ) #if ( ipconfigDRIVER_INCLUDED_RX_IP_CHECKSUM != 0 ) value |= XEMACPS_NWCFG_RXCHKSUMEN_MASK; #else - #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) - { - #warning Are you sure the EMAC should not calculate incoming checksums? - } + #if ( ipconfigPORT_SUPPRESS_WARNING == 0 ) + { + #warning Are you sure the EMAC should not calculate incoming checksums? + } #endif value &= ~( ( uint32_t ) XEMACPS_NWCFG_RXCHKSUMEN_MASK ); diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c index 80b9386735..03db01d3bd 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.c @@ -212,7 +212,7 @@ static void emacps_handle_error( void * arg, if( ( ErrorWord & XEMACPS_TXSR_RXOVR_MASK ) != 0 ) { - last_err_msg = "Transmit retry excessed limits"; + last_err_msg = "Transmit retry exceeded limits"; HandleTxErrors( xemacpsif ); } diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.h b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.h index c71215fdeb..efc30a91bb 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.h +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_hw.h @@ -23,7 +23,7 @@ /*#include "lwip/netif.h" */ #ifdef __cplusplus - extern "C" { + extern "C" { #endif XEmacPs_Config * lookup_config( unsigned mac_base ); @@ -33,7 +33,7 @@ int emacps_check_errors( xemacpsif_s * xemacps ); /* Defined in x_emacpsif_physpeed.c. */ - uint32_t ulDetecPHY( XEmacPs * xemacpsp ); + uint32_t ulDetectPHY( XEmacPs * xemacpsp ); #ifdef __cplusplus diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c index a23fdf9708..7960b8d310 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_emacpsif_physpeed.c @@ -236,7 +236,7 @@ static uint16_t prvAR803x_debug_reg_write( XEmacPs * xemacpsp, static void prvSET_AR803x_TX_Timing( XEmacPs * xemacpsp, uint32_t phy_addr ); -uint32_t ulDetecPHY( XEmacPs * xemacpsp ) +uint32_t ulDetectPHY( XEmacPs * xemacpsp ) { u16 PhyReg1; u16 PhyReg2; @@ -933,7 +933,7 @@ static const char * pcGetPHIName( uint16_t usID ) break; default: - snprintf( pcName, sizeof pcName, "Unkkwn PHY %04X", usID ); + snprintf( pcName, sizeof pcName, "Unknown PHY %04X", usID ); pcReturn = pcName; break; } @@ -954,7 +954,7 @@ static uint32_t get_IEEE_phy_speed_US( XEmacPs * xemacpsp, FreeRTOS_printf( ( "Start %s PHY autonegotiation. ID = 0x%04X\n", pcPHYName, phy_identity ) ); - /* Just to prevent compiler warnings about unused variablies. */ + /* Just to prevent compiler warnings about unused variables. */ ( void ) pcPHYName; switch( phy_identity ) diff --git a/source/portable/NetworkInterface/xilinx_ultrascale/x_topology.h b/source/portable/NetworkInterface/xilinx_ultrascale/x_topology.h index c08ff3b085..2f22a4fd05 100644 --- a/source/portable/NetworkInterface/xilinx_ultrascale/x_topology.h +++ b/source/portable/NetworkInterface/xilinx_ultrascale/x_topology.h @@ -20,7 +20,7 @@ #define __XTOPOLOGY_H_ #ifdef __cplusplus - extern "C" { + extern "C" { #endif enum xemac_types diff --git a/test/Coverity/README.md b/test/Coverity/README.md index 1ae4da20b1..db4579b585 100644 --- a/test/Coverity/README.md +++ b/test/Coverity/README.md @@ -54,7 +54,7 @@ Go to the root directory of the FreeRTOS-Plus-TCP repo and run the following com ~~~ You should now have the HTML formatted violations list in a directory named `html-output`. -With the current configuration and the provided project, you should see only one deviation from advisory rule 8.13 in file +With the current configuration and the provided project, you should see only one deviation from advisory rule 8.13 in file FreeRTOS_IP.c [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/4ac10c84a384f0414f4aec0d4be0ee7c345f2f8b/source/FreeRTOS_IP.c#L236). This deviation has a justification outlined [here](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/blob/main/MISRA.md#rule-813). With that justification in place, a coverity suppression statement has been added to the code. However, even with that suppression in diff --git a/test/build-combination/Common/FreeRTOSConfig.h b/test/build-combination/Common/FreeRTOSConfig.h index 22469a3493..fbfac53dff 100644 --- a/test/build-combination/Common/FreeRTOSConfig.h +++ b/test/build-combination/Common/FreeRTOSConfig.h @@ -155,7 +155,7 @@ void vLoggingPrintf( char const * pcFormat, /* The address of an echo server that will be used by the two demo echo client * tasks: - * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.html, + * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.html * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_Echo_Clients.html. */ #define configECHO_SERVER_ADDR0 192 #define configECHO_SERVER_ADDR1 168 diff --git a/test/build-combination/Header_Self_Contain/FreeRTOSConfig.h b/test/build-combination/Header_Self_Contain/FreeRTOSConfig.h index 22469a3493..fbfac53dff 100644 --- a/test/build-combination/Header_Self_Contain/FreeRTOSConfig.h +++ b/test/build-combination/Header_Self_Contain/FreeRTOSConfig.h @@ -155,7 +155,7 @@ void vLoggingPrintf( char const * pcFormat, /* The address of an echo server that will be used by the two demo echo client * tasks: - * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.html, + * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.html * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_Echo_Clients.html. */ #define configECHO_SERVER_ADDR0 192 #define configECHO_SERVER_ADDR1 168 diff --git a/test/cbmc/README.md b/test/cbmc/README.md index 09d5e14810..d0afb54ae7 100644 --- a/test/cbmc/README.md +++ b/test/cbmc/README.md @@ -84,7 +84,7 @@ and Linux, you will need Make. package into the top-level CBMC source directory. - Change into the top-level CBMC source directory and run ``` - cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DWITH_JBMC=OFF + cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -DWITH_CBMC=OFF cmake --build build ``` diff --git a/test/cbmc/patches/FreeRTOSConfig.h b/test/cbmc/patches/FreeRTOSConfig.h index 784babdfe7..e0d033b4fb 100644 --- a/test/cbmc/patches/FreeRTOSConfig.h +++ b/test/cbmc/patches/FreeRTOSConfig.h @@ -170,7 +170,7 @@ extern void vAssertCalled( const char * pcFile, /* The address of an echo server that will be used by the two demo echo client * tasks: - * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.html, + * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Echo_Clients.html * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_Echo_Clients.html. */ #define configECHO_SERVER_ADDR0 192 #define configECHO_SERVER_ADDR1 168 diff --git a/test/cbmc/proofs/ARP/ARPSendGratuitous/README.md b/test/cbmc/proofs/ARP/ARPSendGratuitous/README.md index 5bb155221f..af13a1c296 100644 --- a/test/cbmc/proofs/ARP/ARPSendGratuitous/README.md +++ b/test/cbmc/proofs/ARP/ARPSendGratuitous/README.md @@ -1,6 +1,6 @@ Abstracting xQueueGenericSend away and including tasks.c and FreeRTOS_IP.c: -The ARPSendGratutious function is memory safe, +The ARPSendGratuitous function is memory safe, if xQueueGenericSend is memory safe. queue.c is not compiled into the proof binary. \ No newline at end of file diff --git a/test/cbmc/proofs/CheckOptions/CheckOptions_harness.c b/test/cbmc/proofs/CheckOptions/CheckOptions_harness.c index f1834b2b4f..134d73c550 100644 --- a/test/cbmc/proofs/CheckOptions/CheckOptions_harness.c +++ b/test/cbmc/proofs/CheckOptions/CheckOptions_harness.c @@ -75,7 +75,7 @@ int32_t __CPROVER_file_local_FreeRTOS_TCP_Reception_c_prvSingleStepTCPHeaderOpti size_t uxIPHeaderSizePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer ) { - __CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer shouldnt be NULL" ); + __CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer should not be NULL" ); return uxIPHeaderSizePacket_uxResult; } diff --git a/test/cbmc/proofs/DHCP/DHCPProcessEndPoint/README.md b/test/cbmc/proofs/DHCP/DHCPProcessEndPoint/README.md index 20473f25b9..da31b22123 100644 --- a/test/cbmc/proofs/DHCP/DHCPProcessEndPoint/README.md +++ b/test/cbmc/proofs/DHCP/DHCPProcessEndPoint/README.md @@ -2,7 +2,7 @@ This is the memory safety proof for DHCPProcessEndPoint function, which is the function that triggers the DHCP protocol. The main stubs in this proof deal with buffer management, which assume -that the buffer is large enough to accomodate a DHCP message plus a +that the buffer is large enough to accommodate a DHCP message plus a few additional bytes for options (which is the last, variable-sized field in a DHCP message). We have abstracted away sockets, concurrency and third-party code. For more details, please check the comments on diff --git a/test/cbmc/proofs/DNS/DNSHandlePacket/DNShandlePacket_harness.c b/test/cbmc/proofs/DNS/DNSHandlePacket/DNShandlePacket_harness.c index 36b19cfce7..983f1f1092 100644 --- a/test/cbmc/proofs/DNS/DNSHandlePacket/DNShandlePacket_harness.c +++ b/test/cbmc/proofs/DNS/DNSHandlePacket/DNShandlePacket_harness.c @@ -7,8 +7,7 @@ #include "FreeRTOS_DNS.h" #include "FreeRTOS_IP_Private.h" -/* Function prvParseDNSReply is proven to be correct separately. - * The proof can be found here: https://github.com/aws/amazon-freertos/tree/master/tools/cbmc/proofs/ParseDNSReply */ +/* Function prvParseDNSReply is proven to be correct separately. */ uint32_t prvParseDNSReply( uint8_t * pucUDPPayloadBuffer, size_t xBufferLength, BaseType_t xExpected ) diff --git a/test/cbmc/proofs/IPUtils/pxDuplicateNetworkBufferWithDescriptor/pxDuplicateNetworkBufferWithDescriptor_harness.c b/test/cbmc/proofs/IPUtils/pxDuplicateNetworkBufferWithDescriptor/pxDuplicateNetworkBufferWithDescriptor_harness.c index 7ab7f772ee..c6b93500e0 100644 --- a/test/cbmc/proofs/IPUtils/pxDuplicateNetworkBufferWithDescriptor/pxDuplicateNetworkBufferWithDescriptor_harness.c +++ b/test/cbmc/proofs/IPUtils/pxDuplicateNetworkBufferWithDescriptor/pxDuplicateNetworkBufferWithDescriptor_harness.c @@ -61,7 +61,7 @@ size_t uxIPHeaderSizePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer ) { size_t xReturn; - __CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer shouldnt be NULL" ); + __CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer should not be NULL" ); __CPROVER_assume( ( xReturn == ipSIZE_OF_IPv4_HEADER ) || ( xReturn == ipSIZE_OF_IPv6_HEADER ) ); return xReturn; diff --git a/test/cbmc/proofs/ReadNameField/ReadNameField_harness.c b/test/cbmc/proofs/ReadNameField/ReadNameField_harness.c index fd886e1afc..61deb44cb9 100644 --- a/test/cbmc/proofs/ReadNameField/ReadNameField_harness.c +++ b/test/cbmc/proofs/ReadNameField/ReadNameField_harness.c @@ -43,7 +43,7 @@ size_t DNS_ReadNameField( ParseSet_t * pxSet, size_t uxDestLen ); { __CPROVER_assert( pxSet != NULL, - "pxSet shouldnt be NULL" ); + "pxSet should not be NULL" ); return 0; } diff --git a/test/cbmc/proofs/Socket/vSocketBind/ALLOW_ETHERNET_DRIVER_FILTERS_PACKETS/vSocketBind_harness.c b/test/cbmc/proofs/Socket/vSocketBind/ALLOW_ETHERNET_DRIVER_FILTERS_PACKETS/vSocketBind_harness.c index 6c798acf58..61aba733d2 100644 --- a/test/cbmc/proofs/Socket/vSocketBind/ALLOW_ETHERNET_DRIVER_FILTERS_PACKETS/vSocketBind_harness.c +++ b/test/cbmc/proofs/Socket/vSocketBind/ALLOW_ETHERNET_DRIVER_FILTERS_PACKETS/vSocketBind_harness.c @@ -30,7 +30,7 @@ BaseType_t xIPIsNetworkTaskReady( void ) /* Random number generator provided by the application. In our case, CBMC provides - * an indeterministic value. */ + * an non-deterministic value. */ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ) { __CPROVER_assert( pulNumber != NULL, "Argument to xApplicationGetRandomNumber cannot be NULL" ); diff --git a/test/cbmc/proofs/Socket/vSocketBind/ALLOW_SOCKET_SEND_WITHOUT_BIND/vSocketBind_harness.c b/test/cbmc/proofs/Socket/vSocketBind/ALLOW_SOCKET_SEND_WITHOUT_BIND/vSocketBind_harness.c index 5d7a6bc9cc..1b12c8f5ca 100644 --- a/test/cbmc/proofs/Socket/vSocketBind/ALLOW_SOCKET_SEND_WITHOUT_BIND/vSocketBind_harness.c +++ b/test/cbmc/proofs/Socket/vSocketBind/ALLOW_SOCKET_SEND_WITHOUT_BIND/vSocketBind_harness.c @@ -28,7 +28,7 @@ BaseType_t xIPIsNetworkTaskReady( void ) /* Random number generator provided by the application. In our case, CBMC provides - * an indeterministic value. */ + * an non-deterministic value. */ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ) { __CPROVER_assert( pulNumber != NULL, "Argument to xApplicationGetRandomNumber cannot be NULL" ); diff --git a/test/cbmc/proofs/Socket/vSocketBind/DONT_ALLOW_SOCKET_SEND_WITHOUT_BIND/vSocketBind_harness.c b/test/cbmc/proofs/Socket/vSocketBind/DONT_ALLOW_SOCKET_SEND_WITHOUT_BIND/vSocketBind_harness.c index c963061200..0e81321ceb 100644 --- a/test/cbmc/proofs/Socket/vSocketBind/DONT_ALLOW_SOCKET_SEND_WITHOUT_BIND/vSocketBind_harness.c +++ b/test/cbmc/proofs/Socket/vSocketBind/DONT_ALLOW_SOCKET_SEND_WITHOUT_BIND/vSocketBind_harness.c @@ -28,7 +28,7 @@ BaseType_t xIPIsNetworkTaskReady( void ) /* Random number generator provided by the application. In our case, CBMC provides - * an indeterministic value. */ + * an non-deterministic value. */ BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber ) { __CPROVER_assert( pulNumber != NULL, "Argument to xApplicationGetRandomNumber cannot be NULL" ); diff --git a/test/cbmc/proofs/TCP/prvSendData/SendData_harness.c b/test/cbmc/proofs/TCP/prvSendData/SendData_harness.c index 7fcc088b51..83da8405bb 100644 --- a/test/cbmc/proofs/TCP/prvSendData/SendData_harness.c +++ b/test/cbmc/proofs/TCP/prvSendData/SendData_harness.c @@ -46,7 +46,7 @@ size_t uxIPHeaderSizePacket_uxResult; size_t uxIPHeaderSizePacket( const NetworkBufferDescriptor_t * pxNetworkBuffer ) { - __CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer shouldnt be NULL" ); + __CPROVER_assert( pxNetworkBuffer != NULL, "pxNetworkBuffer should not be NULL" ); __CPROVER_assert( pxNetworkBuffer->pucEthernetBuffer != NULL, "pucEthernetBuffer should not be NULL" ); return uxIPHeaderSizePacket_uxResult; diff --git a/test/cbmc/proofs/__pycache__/make_cbmc_batch_files.cpython-36.pyc b/test/cbmc/proofs/__pycache__/make_cbmc_batch_files.cpython-36.pyc deleted file mode 100644 index 5eb255ce92..0000000000 Binary files a/test/cbmc/proofs/__pycache__/make_cbmc_batch_files.cpython-36.pyc and /dev/null differ diff --git a/test/cbmc/proofs/__pycache__/make_common_makefile.cpython-36.pyc b/test/cbmc/proofs/__pycache__/make_common_makefile.cpython-36.pyc deleted file mode 100644 index 3404c1e803..0000000000 Binary files a/test/cbmc/proofs/__pycache__/make_common_makefile.cpython-36.pyc and /dev/null differ diff --git a/test/cbmc/proofs/__pycache__/make_configuration_directories.cpython-36.pyc b/test/cbmc/proofs/__pycache__/make_configuration_directories.cpython-36.pyc deleted file mode 100644 index 72492f5551..0000000000 Binary files a/test/cbmc/proofs/__pycache__/make_configuration_directories.cpython-36.pyc and /dev/null differ diff --git a/test/cbmc/proofs/__pycache__/make_proof_makefiles.cpython-36.pyc b/test/cbmc/proofs/__pycache__/make_proof_makefiles.cpython-36.pyc deleted file mode 100644 index d5ad6054c7..0000000000 Binary files a/test/cbmc/proofs/__pycache__/make_proof_makefiles.cpython-36.pyc and /dev/null differ diff --git a/test/cbmc/proofs/prepare.py b/test/cbmc/proofs/prepare.py index 8000c17be6..480384bf30 100755 --- a/test/cbmc/proofs/prepare.py +++ b/test/cbmc/proofs/prepare.py @@ -89,7 +89,7 @@ def build(): create_cbmc_yaml_files() except CalledProcessError as e: logging.error(textwrap.dedent("""\ - An error occured during cbmc-batch generation. + An error occurred during cbmc-batch generation. The error message is: {} """.format(str(e)))) exit(1) @@ -102,7 +102,7 @@ def build(): # create_patches(HEADERS) #except (DirtyGitError, PatchCreationError) as e: # logging.error(textwrap.dedent("""\ - # An error occured during patch creation. + # An error occurred during patch creation. # The error message is: {} # """.format(str(e)))) # exit(1) diff --git a/test/unit-test/CMakeLists.txt b/test/unit-test/CMakeLists.txt index a715d9f004..79e538bcc3 100644 --- a/test/unit-test/CMakeLists.txt +++ b/test/unit-test/CMakeLists.txt @@ -200,7 +200,7 @@ include( ${UNIT_TEST_DIR}/TCPFilePaths.cmake ) # =========================================================================== -# Remove static qualifier from the souce files so that internal functions +# Remove static qualifier from the source files so that internal functions # can be called directly. file( MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources ) diff --git a/test/unit-test/ConfigFiles/IPTraceMacroDefaults.h b/test/unit-test/ConfigFiles/IPTraceMacroDefaults.h index beac53e5b4..85b9811961 100644 --- a/test/unit-test/ConfigFiles/IPTraceMacroDefaults.h +++ b/test/unit-test/ConfigFiles/IPTraceMacroDefaults.h @@ -140,8 +140,8 @@ #define iptraceSENDING_DHCP_REQUEST() #endif -#ifndef iptraceDHCP_SUCCEDEED - #define iptraceDHCP_SUCCEDEED( address ) +#ifndef iptraceDHCP_SUCCEEDED + #define iptraceDHCP_SUCCEEDED( address ) #endif #ifndef iptraceNETWORK_INTERFACE_TRANSMIT diff --git a/test/unit-test/ConfigFiles/NetworkBufferManagement.h b/test/unit-test/ConfigFiles/NetworkBufferManagement.h index ccb75e4a57..0b3b3e9aa0 100644 --- a/test/unit-test/ConfigFiles/NetworkBufferManagement.h +++ b/test/unit-test/ConfigFiles/NetworkBufferManagement.h @@ -29,7 +29,7 @@ #define NETWORK_BUFFER_MANAGEMENT_H #ifdef __cplusplus - extern "C" { + extern "C" { #endif /* NOTE PUBLIC API FUNCTIONS. */ diff --git a/test/unit-test/ConfigFiles/NetworkInterface.h b/test/unit-test/ConfigFiles/NetworkInterface.h index bc935cbdb9..d682fcfa92 100644 --- a/test/unit-test/ConfigFiles/NetworkInterface.h +++ b/test/unit-test/ConfigFiles/NetworkInterface.h @@ -29,7 +29,7 @@ #define NETWORK_INTERFACE_H #ifdef __cplusplus - extern "C" { + extern "C" { #endif /* NOTE PUBLIC API FUNCTIONS. */ diff --git a/test/unit-test/ConfigFiles/portmacro.h b/test/unit-test/ConfigFiles/portmacro.h index 25dae85e8f..e57917690c 100644 --- a/test/unit-test/ConfigFiles/portmacro.h +++ b/test/unit-test/ConfigFiles/portmacro.h @@ -31,7 +31,7 @@ #include #ifdef __cplusplus - extern "C" { + extern "C" { #endif /*----------------------------------------------------------- diff --git a/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c b/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c index 9f7f4abff1..f6b20ecb91 100644 --- a/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c +++ b/test/unit-test/FreeRTOS_DHCP/FreeRTOS_DHCP_utest.c @@ -3128,7 +3128,7 @@ void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsIncorrectServerTimeoutGNBfai TEST_ASSERT_EQUAL_MEMORY( &( pxEndPoint->ipv4_settings ), &( testMemory ), sizeof( IPV4Parameters_t ) ); } -void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsIncorrectServerTimeoutGNBsucceeds( void ) +void test_vDHCPProcess_eWaitingAcknowledgeTwoOptionsIncorrectServerTimeoutGNBSucceeds( void ) { struct xSOCKET xTestSocket; TickType_t xTimeValue = 1234; @@ -5312,7 +5312,7 @@ void test_vDHCPProcess_eWaitingAcknowledge_LeaseTimeIncorrectLength2( void ) } -void test_vDHCPProcess_eWaitingAcknowledge_IncorrectLengthofpacket( void ) +void test_vDHCPProcess_eWaitingAcknowledge_IncorrectLengthOfPacket( void ) { struct xSOCKET xTestSocket; TickType_t xTimeValue = 1234; @@ -5560,7 +5560,7 @@ void test_vDHCPProcess_eLeasedAddress_EndPointDown( void ) TEST_ASSERT_EQUAL( eLeasedAddress, pxEndPoint->xDHCPData.eDHCPState ); } -void test_vDHCPProcess_eLeasedAddress_NetworkUp_SokcetCreated_RNGPass_GNBfail( void ) +void test_vDHCPProcess_eLeasedAddress_NetworkUp_SocketCreated_RNGPass_GNBfail( void ) { struct xSOCKET xTestSocket; BaseType_t xTimeValue = 300; @@ -5595,7 +5595,7 @@ void test_vDHCPProcess_eLeasedAddress_NetworkUp_SokcetCreated_RNGPass_GNBfail( v TEST_ASSERT_EQUAL( dhcpINITIAL_DHCP_TX_PERIOD, pxEndPoint->xDHCPData.xDHCPTxPeriod ); } -void test_vDHCPProcess_eLeasedAddress_NetworkUp_SokcetCreated_RNGFail( void ) +void test_vDHCPProcess_eLeasedAddress_NetworkUp_SocketCreated_RNGFail( void ) { struct xSOCKET xTestSocket; BaseType_t xTimeValue = 300; diff --git a/test/unit-test/FreeRTOS_DHCPv6/FreeRTOS_DHCPv6_utest.c b/test/unit-test/FreeRTOS_DHCPv6/FreeRTOS_DHCPv6_utest.c index 89238129ff..7a1136b5dc 100644 --- a/test/unit-test/FreeRTOS_DHCPv6/FreeRTOS_DHCPv6_utest.c +++ b/test/unit-test/FreeRTOS_DHCPv6/FreeRTOS_DHCPv6_utest.c @@ -3470,7 +3470,7 @@ void test_vDHCPv6Process_prvSendDHCPMessage_BitConfigInitFail() /** * @brief Check if prvSendDHCPMessage stop sending when the state is unexpected. */ -void test_prvSendDHCPMessage_UnexpectState() +void test_prvSendDHCPMessage_UnexpectedState() { NetworkEndPoint_t xEndPoint; DHCPMessage_IPv6_t xDHCPMessage; diff --git a/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_utest.c b/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_utest.c index 6ff3b01bae..0037524f25 100644 --- a/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_utest.c +++ b/test/unit-test/FreeRTOS_DNS_Parser/FreeRTOS_DNS_Parser_utest.c @@ -1406,7 +1406,7 @@ void test_DNS_ParseDNSReply_fail_not_enough_space_lt_32( void ) /** * @brief */ -void test_DNS_ParseDNSReply_ansswer_record_no_answers( void ) +void test_DNS_ParseDNSReply_answer_record_no_answers( void ) { uint32_t ret; uint8_t pucUDPPayloadBuffer[ 250 ]; @@ -1442,7 +1442,7 @@ void test_DNS_ParseDNSReply_ansswer_record_no_answers( void ) /** * @brief */ -void test_DNS_ParseDNSReply_ansswer_record_too_many_answers( void ) +void test_DNS_ParseDNSReply_answer_record_too_many_answers( void ) { uint32_t ret; uint8_t pucUDPPayloadBuffer[ 250 ] = { 0 }; @@ -1873,7 +1873,7 @@ void test_DNS_ParseDNSReply_answer_lmmnr_reply_diffUsType( void ) * @brief ensures that the ip set in Setup is passed to the network with * vReturnEthernetFrame : pxNetworkBuffer = NULL */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_NullNetworkBuffer( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply_NullNetworkBuffer( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; @@ -1950,7 +1950,7 @@ void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_NullNetworkBuffer( void ) * @brief ensures that the ip set in Setup is passed to the network with * vReturnEthernetFrame : usType = 0 */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply2( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply4( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; @@ -2021,7 +2021,7 @@ void test_DNS_ParseDNSReply_ansswer_lmmnr_reply2( void ) * @brief ensures that the ip set in Setup is passed to the network with * vReturnEthernetFrame : usClass != dnsCLASS_IN */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply3( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply5( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; @@ -2093,7 +2093,7 @@ void test_DNS_ParseDNSReply_ansswer_lmmnr_reply3( void ) * @brief ensures that when the dns query hook returns pdFALSE, the ip is not * set and no packet is sent over the network */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_query_hook_false( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply_query_hook_false( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; @@ -2165,7 +2165,7 @@ void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_query_hook_false( void ) * @brief ensures that when the duplicated network buffer is null, no packet is * sent over the network */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_null_new_netbuffer( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply_null_new_netbuffer( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; @@ -2238,7 +2238,7 @@ void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_null_new_netbuffer( void ) * @brief ensures that when the duplicated network buffer is null, no packet is * sent over the network */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_null_new_netbuffer2( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply_null_new_netbuffer2( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; @@ -2311,7 +2311,7 @@ void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_null_new_netbuffer2( void ) * @brief ensures that when the duplicated network buffer is valid, packet is * sent over the network */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_valid_new_netbuffer( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply_valid_new_netbuffer( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; @@ -2402,7 +2402,7 @@ void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_valid_new_netbuffer( void ) * @brief ensures that when the duplicated network buffer is valid, packet is * sent over the network */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_valid_new_netbuffer2( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply_valid_new_netbuffer2( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; @@ -2493,7 +2493,7 @@ void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_valid_new_netbuffer2( void ) * @brief ensures that when the duplicated network buffer is valid, packet is * sent over the network, buffer allocation 1 scheme is used */ -void test_DNS_ParseDNSReply_ansswer_lmmnr_reply_valid_new_netbuffer3( void ) +void test_DNS_ParseDNSReply_answer_lmmnr_reply_valid_new_netbuffer3( void ) { uint32_t ret; uint8_t udp_buffer[ 250 + ipUDP_PAYLOAD_OFFSET_IPv4 ] = { 0 }; diff --git a/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c b/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c index fc5e071250..ce7fa9c1b6 100644 --- a/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c +++ b/test/unit-test/FreeRTOS_ICMP/FreeRTOS_ICMP_stubs.c @@ -45,7 +45,7 @@ volatile BaseType_t xInsideInterrupt = pdFALSE; /** @brief The expected IP version and header length coded into the IP header itself. */ #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; UDPPacketHeader_t xDefaultPartUDPPacketHeader = { diff --git a/test/unit-test/FreeRTOS_ICMP_wo_assert/FreeRTOS_ICMP_wo_assert_stubs.c b/test/unit-test/FreeRTOS_ICMP_wo_assert/FreeRTOS_ICMP_wo_assert_stubs.c index fc5e071250..ce7fa9c1b6 100644 --- a/test/unit-test/FreeRTOS_ICMP_wo_assert/FreeRTOS_ICMP_wo_assert_stubs.c +++ b/test/unit-test/FreeRTOS_ICMP_wo_assert/FreeRTOS_ICMP_wo_assert_stubs.c @@ -45,7 +45,7 @@ volatile BaseType_t xInsideInterrupt = pdFALSE; /** @brief The expected IP version and header length coded into the IP header itself. */ #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; UDPPacketHeader_t xDefaultPartUDPPacketHeader = { diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c index 3eb9d84ab6..4caeb375ee 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_stubs.c @@ -54,7 +54,7 @@ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; /** @brief The expected IP version and header length coded into the IP header itself. */ #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; UDPPacketHeader_t xDefaultPartUDPPacketHeader = { diff --git a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c index 374c69f63b..277081b0f3 100644 --- a/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c +++ b/test/unit-test/FreeRTOS_IP/FreeRTOS_IP_utest.c @@ -1620,7 +1620,7 @@ void test_eConsiderFrameForProcessing_LLMNR_MACMatch( void ) memset( ucEthernetBuffer, 0x00, ipconfigTCP_MSS ); - memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xLLMNR_MacAdress.ucBytes, sizeof( MACAddress_t ) ); + memcpy( pxEthernetHeader->xDestinationAddress.ucBytes, xLLMNR_MacAddress.ucBytes, sizeof( MACAddress_t ) ); pxEthernetHeader->usFrameType = 0xFFFF; eResult = eConsiderFrameForProcessing( ucEthernetBuffer ); diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c index ef5f65b527..0ab6842348 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig/FreeRTOS_IP_DiffConfig_stubs.c @@ -53,7 +53,7 @@ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; /** @brief The expected IP version and header length coded into the IP header itself. */ #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; UDPPacketHeader_t xDefaultPartUDPPacketHeader = { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c index 3eb9d84ab6..4caeb375ee 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig1/FreeRTOS_IP_DiffConfig1_stubs.c @@ -54,7 +54,7 @@ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; /** @brief The expected IP version and header length coded into the IP header itself. */ #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; UDPPacketHeader_t xDefaultPartUDPPacketHeader = { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c index 54101f3d46..d7eb64001a 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig2/FreeRTOS_IP_DiffConfig2_stubs.c @@ -52,7 +52,7 @@ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; /** @brief The expected IP version and header length coded into the IP header itself. */ #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; UDPPacketHeader_t xDefaultPartUDPPacketHeader = { diff --git a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c index ef5f65b527..0ab6842348 100644 --- a/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c +++ b/test/unit-test/FreeRTOS_IP_DiffConfig3/FreeRTOS_IP_DiffConfig3_stubs.c @@ -53,7 +53,7 @@ struct xNetworkEndPoint * pxNetworkEndPoints = NULL; /** @brief The expected IP version and header length coded into the IP header itself. */ #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; UDPPacketHeader_t xDefaultPartUDPPacketHeader = { diff --git a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c index c1fdb9f956..4df9845007 100644 --- a/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c +++ b/test/unit-test/FreeRTOS_IP_Timers/FreeRTOS_IP_Timers_stubs.c @@ -52,7 +52,7 @@ struct xNetworkInterface * pxNetworkInterfaces; /** @brief The expected IP version and header length coded into the IP header itself. */ #define ipIP_VERSION_AND_HEADER_LENGTH_BYTE ( ( uint8_t ) 0x45 ) -const MACAddress_t xLLMNR_MacAdress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; +const MACAddress_t xLLMNR_MacAddress = { { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfc } }; QueueHandle_t xNetworkEventQueue; diff --git a/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c b/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c index af09192c64..24e8df2760 100644 --- a/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c +++ b/test/unit-test/FreeRTOS_IP_Utils/FreeRTOS_IP_Utils_utest.c @@ -282,10 +282,10 @@ void test_prvPacketBuffer_to_NetworkBuffer_NULLParam( void ) } /** - * @brief test_prvPacketBuffer_to_NetworkBuffer_Unalligned + * @brief test_prvPacketBuffer_to_NetworkBuffer_Unaligned * To validate if prvPacketBuffer_to_NetworkBuffer returns NULL when byte not aligned. */ -void test_prvPacketBuffer_to_NetworkBuffer_Unalligned( void ) +void test_prvPacketBuffer_to_NetworkBuffer_Unaligned( void ) { NetworkBufferDescriptor_t * pxNetworkBuffer, xNetBufferToReturn; const void * pvBuffer; @@ -302,10 +302,10 @@ void test_prvPacketBuffer_to_NetworkBuffer_Unalligned( void ) } /** - * @brief test_prvPacketBuffer_to_NetworkBuffer_Unalligned + * @brief test_prvPacketBuffer_to_NetworkBuffer_Unaligned * To validate if prvPacketBuffer_to_NetworkBuffer moves offset&padding correctly. */ -void test_prvPacketBuffer_to_NetworkBuffer_Alligned( void ) +void test_prvPacketBuffer_to_NetworkBuffer_Aligned( void ) { NetworkBufferDescriptor_t * pxNetworkBuffer, xNetBufferToReturn; const void * pvBuffer; @@ -2074,28 +2074,28 @@ void test_usGenerateProtocolChecksum_ICMPv6LessHeaderLength( void ) } /** - * @brief test_usGenerateChecksum_UnallignedAccess + * @brief test_usGenerateChecksum_UnalignedAccess * To toggle address that is not aligned in usGenerateChecksum. */ -void test_usGenerateChecksum_UnallignedAccess( void ) +void test_usGenerateChecksum_UnalignedAccess( void ) { uint16_t usResult; uint16_t usSum = 0; uint8_t pucNextData[ ipconfigTCP_MSS ]; size_t uxByteCount = 10; - size_t uxUnalligned = 0; + size_t uxUnaligned = 0; memset( pucNextData, 0xAB, ipconfigTCP_MSS ); - for( uxUnalligned = 0; uxUnalligned < 4; uxUnalligned++ ) + for( uxUnaligned = 0; uxUnaligned < 4; uxUnaligned++ ) { - if( ( ( uintptr_t ) &pucNextData[ uxUnalligned ] ) & 0x01U ) + if( ( ( uintptr_t ) &pucNextData[ uxUnaligned ] ) & 0x01U ) { break; } } - usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnalligned ], uxByteCount ); + usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnaligned ], uxByteCount ); TEST_ASSERT_EQUAL( 0x5A5A, usResult ); } @@ -2110,181 +2110,181 @@ void test_usGenerateChecksum_OneByteToChecksum( void ) uint16_t usSum = 0; uint8_t pucNextData[ ipconfigTCP_MSS ]; size_t uxByteCount = 1; - size_t uxUnalligned = 0; + size_t uxUnaligned = 0; memset( pucNextData, 0xAB, ipconfigTCP_MSS ); - for( uxUnalligned = 0; uxUnalligned < 4; uxUnalligned++ ) + for( uxUnaligned = 0; uxUnaligned < 4; uxUnaligned++ ) { - if( ( ( uintptr_t ) &pucNextData[ uxUnalligned ] ) & 0x01U ) + if( ( ( uintptr_t ) &pucNextData[ uxUnaligned ] ) & 0x01U ) { break; } } - usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnalligned ], uxByteCount ); + usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnaligned ], uxByteCount ); TEST_ASSERT_EQUAL( 0xAB00, usResult ); } /** - * @brief test_usGenerateChecksum_OneByteAllignedButZeroLength + * @brief test_usGenerateChecksum_OneByteAlignedButZeroLength * To validate usGenerateChecksum with one byte align but zero length. */ -void test_usGenerateChecksum_OneByteAllignedButZeroLength( void ) +void test_usGenerateChecksum_OneByteAlignedButZeroLength( void ) { uint16_t usResult; uint16_t usSum = 0; uint8_t pucNextData[ ipconfigTCP_MSS ]; size_t uxByteCount = 0; - size_t uxUnalligned = 0; + size_t uxUnaligned = 0; memset( pucNextData, 0xAB, ipconfigTCP_MSS ); - for( uxUnalligned = 0; uxUnalligned < 4; uxUnalligned++ ) + for( uxUnaligned = 0; uxUnaligned < 4; uxUnaligned++ ) { - if( ( ( uintptr_t ) &pucNextData[ uxUnalligned ] ) & 0x01U ) + if( ( ( uintptr_t ) &pucNextData[ uxUnaligned ] ) & 0x01U ) { break; } } - usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnalligned ], uxByteCount ); + usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnaligned ], uxByteCount ); TEST_ASSERT_EQUAL( 0, usResult ); } /** - * @brief test_usGenerateChecksum_TwoByteAlligned + * @brief test_usGenerateChecksum_TwoByteAligned * To validate usGenerateChecksum with two byte align and 1 length. */ -void test_usGenerateChecksum_TwoByteAlligned( void ) +void test_usGenerateChecksum_TwoByteAligned( void ) { uint16_t usResult; uint16_t usSum = 0; uint8_t pucNextData[ ipconfigTCP_MSS ]; size_t uxByteCount = 1; - size_t uxUnalligned = 0; + size_t uxUnaligned = 0; memset( pucNextData, 0xAB, ipconfigTCP_MSS ); - for( uxUnalligned = 0; uxUnalligned < 4; uxUnalligned++ ) + for( uxUnaligned = 0; uxUnaligned < 4; uxUnaligned++ ) { - if( ( ( uintptr_t ) &pucNextData[ uxUnalligned ] ) & 0x02U ) + if( ( ( uintptr_t ) &pucNextData[ uxUnaligned ] ) & 0x02U ) { break; } } - usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnalligned ], uxByteCount ); + usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnaligned ], uxByteCount ); TEST_ASSERT_EQUAL( 43776, usResult ); } /** - * @brief test_usGenerateChecksum_TwoByteAllignedTwoLength + * @brief test_usGenerateChecksum_TwoByteAlignedTwoLength * To validate usGenerateChecksum with two byte align and 2 length. */ -void test_usGenerateChecksum_TwoByteAllignedTwoLength( void ) +void test_usGenerateChecksum_TwoByteAlignedTwoLength( void ) { uint16_t usResult; uint16_t usSum = 0; uint8_t pucNextData[ ipconfigTCP_MSS ]; size_t uxByteCount = 2; - size_t uxUnalligned = 0; + size_t uxUnaligned = 0; memset( pucNextData, 0xAB, ipconfigTCP_MSS ); - for( uxUnalligned = 0; uxUnalligned < 4; uxUnalligned++ ) + for( uxUnaligned = 0; uxUnaligned < 4; uxUnaligned++ ) { - if( ( ( uintptr_t ) &pucNextData[ uxUnalligned ] ) & 0x02U ) + if( ( ( uintptr_t ) &pucNextData[ uxUnaligned ] ) & 0x02U ) { break; } } - usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnalligned ], uxByteCount ); + usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnaligned ], uxByteCount ); TEST_ASSERT_EQUAL( 43947, usResult ); } /** - * @brief test_usGenerateChecksum_FourByteAlligned + * @brief test_usGenerateChecksum_FourByteAligned * To validate usGenerateChecksum with four byte align and 2 length. */ -void test_usGenerateChecksum_FourByteAlligned( void ) +void test_usGenerateChecksum_FourByteAligned( void ) { uint16_t usResult; uint16_t usSum = 0; uint8_t pucNextData[ ipconfigTCP_MSS ]; size_t uxByteCount = 2; - size_t uxUnalligned = 0; + size_t uxUnaligned = 0; memset( pucNextData, 0xAB, ipconfigTCP_MSS ); - for( uxUnalligned = 0; uxUnalligned < 4; uxUnalligned++ ) + for( uxUnaligned = 0; uxUnaligned < 4; uxUnaligned++ ) { - if( ( ( uintptr_t ) &pucNextData[ uxUnalligned ] ) & 0x04U ) + if( ( ( uintptr_t ) &pucNextData[ uxUnaligned ] ) & 0x04U ) { break; } } - usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnalligned ], uxByteCount ); + usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnaligned ], uxByteCount ); TEST_ASSERT_EQUAL( 43947, usResult ); } /** - * @brief test_usGenerateChecksum_FourByteAllignedSumOverflow + * @brief test_usGenerateChecksum_FourByteAlignedSumOverflow * To validate usGenerateChecksum with four byte align and sum overflow. */ -void test_usGenerateChecksum_FourByteAllignedSumOverflow( void ) +void test_usGenerateChecksum_FourByteAlignedSumOverflow( void ) { uint16_t usResult; uint16_t usSum = FreeRTOS_htons( 0xFFFF - 0xAB ); uint8_t pucNextData[ ipconfigTCP_MSS ]; size_t uxByteCount = 20; - size_t uxUnalligned = 0; + size_t uxUnaligned = 0; memset( pucNextData, 0xAB, ipconfigTCP_MSS ); - for( uxUnalligned = 0; uxUnalligned < 4; uxUnalligned++ ) + for( uxUnaligned = 0; uxUnaligned < 4; uxUnaligned++ ) { - if( ( ( uintptr_t ) &pucNextData[ uxUnalligned ] ) & 0x04U ) + if( ( ( uintptr_t ) &pucNextData[ uxUnaligned ] ) & 0x04U ) { break; } } - usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnalligned ], uxByteCount ); + usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnaligned ], uxByteCount ); TEST_ASSERT_EQUAL( 2484, usResult ); } /** - * @brief test_usGenerateChecksum_FourByteAllignedSumOverflow2 + * @brief test_usGenerateChecksum_FourByteAlignedSumOverflow2 * To validate usGenerateChecksum with four byte align and sum overflow. */ -void test_usGenerateChecksum_FourByteAllignedSumOverflow2( void ) +void test_usGenerateChecksum_FourByteAlignedSumOverflow2( void ) { uint16_t usResult; uint16_t usSum = FreeRTOS_htons( 0xFFFF - 0xAB ); uint8_t pucNextData[ ipconfigTCP_MSS ]; size_t uxByteCount = 20; - size_t uxUnalligned = 0; + size_t uxUnaligned = 0; memset( pucNextData, 0xFF, ipconfigTCP_MSS ); - for( uxUnalligned = 0; uxUnalligned < 4; uxUnalligned++ ) + for( uxUnaligned = 0; uxUnaligned < 4; uxUnaligned++ ) { - if( ( ( uintptr_t ) &pucNextData[ uxUnalligned ] ) & 0x04U ) + if( ( ( uintptr_t ) &pucNextData[ uxUnaligned ] ) & 0x04U ) { break; } } - usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnalligned ], uxByteCount ); + usResult = usGenerateChecksum( usSum, &pucNextData[ uxUnaligned ], uxByteCount ); TEST_ASSERT_EQUAL( 21759, usResult ); } diff --git a/test/unit-test/FreeRTOS_IPv6/FreeRTOS_IPv6_stubs.c b/test/unit-test/FreeRTOS_IPv6/FreeRTOS_IPv6_stubs.c index 582c4cdedc..03ba1b2c32 100644 --- a/test/unit-test/FreeRTOS_IPv6/FreeRTOS_IPv6_stubs.c +++ b/test/unit-test/FreeRTOS_IPv6/FreeRTOS_IPv6_stubs.c @@ -43,10 +43,10 @@ /* =========================== EXTERN VARIABLES =========================== */ /* The basic length for one IPv6 extension headers. */ -#define TEST_IPv6_EXTESION_HEADER_LENGTH ( 8U ) +#define TEST_IPv6_EXTENSION_HEADER_LENGTH ( 8U ) /* The default length ofIPv6 extension headers in unit test. */ -#define TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH ( 7U * TEST_IPv6_EXTESION_HEADER_LENGTH ) +#define TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH ( 7U * TEST_IPv6_EXTENSION_HEADER_LENGTH ) /* First IPv6 address is 2001:1234:5678::5 */ const IPv6_Address_t xIPAddressFive = { 0x20, 0x01, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; @@ -109,7 +109,7 @@ static NetworkBufferDescriptor_t * prvInitializeNetworkDescriptorWithExtensionHe { static NetworkBufferDescriptor_t xNetworkBuffer; /* Ethernet header + IPv6 header + Maximum protocol header + IPv6 Extension Headers + 1 payload */ - static uint8_t pcNetworkBuffer[ sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH + sizeof( ICMPHeader_IPv6_t ) + 1U ]; + static uint8_t pcNetworkBuffer[ sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH + sizeof( ICMPHeader_IPv6_t ) + 1U ]; EthernetHeader_t * pxEthHeader = ( EthernetHeader_t * ) pcNetworkBuffer; IPHeader_IPv6_t * pxIPv6Header = ( IPHeader_IPv6_t * ) &( pcNetworkBuffer[ sizeof( EthernetHeader_t ) ] ); uint8_t * pxIPv6ExtHeader = ( uint8_t * ) &( pcNetworkBuffer[ sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) ] ); @@ -137,7 +137,7 @@ static NetworkBufferDescriptor_t * prvInitializeNetworkDescriptorWithExtensionHe memset( &xNetworkBuffer, 0, sizeof( xNetworkBuffer ) ); xNetworkBuffer.pxEndPoint = prvInitializeEndpoint(); xNetworkBuffer.pucEthernetBuffer = ( uint8_t * ) pcNetworkBuffer; - xNetworkBuffer.xDataLength = sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH + ucProtocolHeaderSize + 1U; + xNetworkBuffer.xDataLength = sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH + ucProtocolHeaderSize + 1U; /* Initialize network buffer. */ memset( pcNetworkBuffer, 0, sizeof( pcNetworkBuffer ) ); @@ -148,7 +148,7 @@ static NetworkBufferDescriptor_t * prvInitializeNetworkDescriptorWithExtensionHe /* IP part. */ memcpy( pxIPv6Header->xSourceAddress.ucBytes, xIPAddressTen.ucBytes, sizeof( IPv6_Address_t ) ); memcpy( pxIPv6Header->xDestinationAddress.ucBytes, xIPAddressFive.ucBytes, sizeof( IPv6_Address_t ) ); - pxIPv6Header->usPayloadLength = FreeRTOS_htons( TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH + ucProtocolHeaderSize + 1U ); /* Extension header length + protocol header + payload */ + pxIPv6Header->usPayloadLength = FreeRTOS_htons( TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH + ucProtocolHeaderSize + 1U ); /* Extension header length + protocol header + payload */ pxIPv6Header->ucNextHeader = ipIPv6_EXT_HEADER_HOP_BY_HOP; /* Append extension headers */ pcNetworkBuffer[ uxIndex ] = ipIPv6_EXT_HEADER_ROUTING_HEADER; diff --git a/test/unit-test/FreeRTOS_IPv6/FreeRTOS_IPv6_utest.c b/test/unit-test/FreeRTOS_IPv6/FreeRTOS_IPv6_utest.c index b2e2006dae..9870ce093c 100644 --- a/test/unit-test/FreeRTOS_IPv6/FreeRTOS_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_IPv6/FreeRTOS_IPv6_utest.c @@ -306,7 +306,7 @@ void test_eHandleIPv6ExtensionHeaders_TCPHappyPath() uint8_t ucExtHeaderNum = 7U; uint8_t ucProtocol = ipPROTOCOL_TCP; NetworkBufferDescriptor_t * pxNetworkBuffer = prvInitializeNetworkDescriptorWithExtensionHeader( ucProtocol ); - TCPHeader_t * pxProtocolHeader = ( TCPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH ] ); + TCPHeader_t * pxProtocolHeader = ( TCPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH ] ); uint8_t * pxPayload; pxPayload = ( uint8_t * ) ( pxProtocolHeader + 1 ); @@ -339,7 +339,7 @@ void test_eHandleIPv6ExtensionHeaders_UDPHappyPath() uint8_t ucExtHeaderNum = 7U; uint8_t ucProtocol = ipPROTOCOL_UDP; NetworkBufferDescriptor_t * pxNetworkBuffer = prvInitializeNetworkDescriptorWithExtensionHeader( ucProtocol ); - UDPHeader_t * pxProtocolHeader = ( UDPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH ] ); + UDPHeader_t * pxProtocolHeader = ( UDPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH ] ); uint8_t * pxPayload; pxPayload = ( uint8_t * ) ( pxProtocolHeader + 1 ); @@ -372,7 +372,7 @@ void test_eHandleIPv6ExtensionHeaders_ICMPv6HappyPath() uint8_t ucExtHeaderNum = 7U; uint8_t ucProtocol = ipPROTOCOL_ICMP_IPv6; NetworkBufferDescriptor_t * pxNetworkBuffer = prvInitializeNetworkDescriptorWithExtensionHeader( ucProtocol ); - ICMPHeader_IPv6_t * pxProtocolHeader = ( ICMPHeader_IPv6_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH ] ); + ICMPHeader_IPv6_t * pxProtocolHeader = ( ICMPHeader_IPv6_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH ] ); uint8_t * pxPayload; pxPayload = ( uint8_t * ) ( pxProtocolHeader + 1 ); @@ -406,7 +406,7 @@ void test_eHandleIPv6ExtensionHeaders_TCPHappyPathNotRemove() uint8_t ucExtHeaderNum = 7U; uint8_t ucProtocol = ipPROTOCOL_TCP; NetworkBufferDescriptor_t * pxNetworkBuffer = prvInitializeNetworkDescriptorWithExtensionHeader( ucProtocol ); - TCPHeader_t * pxProtocolHeader = ( TCPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH ] ); + TCPHeader_t * pxProtocolHeader = ( TCPHeader_t * ) &( pxNetworkBuffer->pucEthernetBuffer[ ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH ] ); uint8_t * pxPayload; pxPayload = ( uint8_t * ) ( pxProtocolHeader + 1 ); @@ -418,7 +418,7 @@ void test_eHandleIPv6ExtensionHeaders_TCPHappyPathNotRemove() eResult = eHandleIPv6ExtensionHeaders( pxNetworkBuffer, pdFALSE ); TEST_ASSERT_EQUAL( eReleaseBuffer, eResult ); - TEST_ASSERT_EQUAL( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH + sizeof( TCPHeader_t ) + 1U, pxNetworkBuffer->xDataLength ); + TEST_ASSERT_EQUAL( ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH + sizeof( TCPHeader_t ) + 1U, pxNetworkBuffer->xDataLength ); } /** diff --git a/test/unit-test/FreeRTOS_IPv6_ConfigDriverCheckChecksum/FreeRTOS_IPv6_ConfigDriverCheckChecksum_utest.c b/test/unit-test/FreeRTOS_IPv6_ConfigDriverCheckChecksum/FreeRTOS_IPv6_ConfigDriverCheckChecksum_utest.c index 00aef5bd76..823b77e67c 100644 --- a/test/unit-test/FreeRTOS_IPv6_ConfigDriverCheckChecksum/FreeRTOS_IPv6_ConfigDriverCheckChecksum_utest.c +++ b/test/unit-test/FreeRTOS_IPv6_ConfigDriverCheckChecksum/FreeRTOS_IPv6_ConfigDriverCheckChecksum_utest.c @@ -174,10 +174,10 @@ void test_prvAllowIPPacketIPv6_xCheckIPv6SizeFields_large_ext_header_length() } /** - * @brief test_prvAllowIPPacketIPv6_xCheckIPv6SizeFields_unknown_procotol + * @brief test_prvAllowIPPacketIPv6_xCheckIPv6SizeFields_unknown_protocol * The protocol in IP header is unknown. Check if prvAllowIPPacketIPv6 determines to release it. */ -void test_prvAllowIPPacketIPv6_xCheckIPv6SizeFields_unknown_procotol() +void test_prvAllowIPPacketIPv6_xCheckIPv6SizeFields_unknown_protocol() { eFrameProcessingResult_t eResult; NetworkBufferDescriptor_t * pxNetworkBuffer = prvInitializeNetworkDescriptor(); diff --git a/test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_stubs.c b/test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_stubs.c index 16f0e69891..d5da988477 100644 --- a/test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_stubs.c +++ b/test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_stubs.c @@ -43,10 +43,10 @@ /* =========================== EXTERN VARIABLES =========================== */ /* The basic length for one IPv6 extension headers. */ -#define TEST_IPv6_EXTESION_HEADER_LENGTH ( 8U ) +#define TEST_IPv6_EXTENSION_HEADER_LENGTH ( 8U ) /* The default length ofIPv6 extension headers in unit test. */ -#define TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH ( 7U * TEST_IPv6_EXTESION_HEADER_LENGTH ) +#define TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH ( 7U * TEST_IPv6_EXTENSION_HEADER_LENGTH ) /* First IPv6 address is 2001:1234:5678::5 */ const IPv6_Address_t xIPAddressFive = { 0x20, 0x01, 0x12, 0x34, 0x56, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05 }; @@ -84,7 +84,7 @@ static NetworkBufferDescriptor_t * prvInitializeNetworkDescriptorWithExtensionHe { static NetworkBufferDescriptor_t xNetworkBuffer; /* Ethernet header + IPv6 header + Maximum protocol header + IPv6 Extension Headers + 1 payload */ - static uint8_t pcNetworkBuffer[ sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH + sizeof( ICMPHeader_IPv6_t ) + 1U ]; + static uint8_t pcNetworkBuffer[ sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH + sizeof( ICMPHeader_IPv6_t ) + 1U ]; EthernetHeader_t * pxEthHeader = ( EthernetHeader_t * ) pcNetworkBuffer; IPHeader_IPv6_t * pxIPv6Header = ( IPHeader_IPv6_t * ) &( pcNetworkBuffer[ sizeof( EthernetHeader_t ) ] ); uint8_t * pxIPv6ExtHeader = ( uint8_t * ) &( pcNetworkBuffer[ sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) ] ); @@ -112,7 +112,7 @@ static NetworkBufferDescriptor_t * prvInitializeNetworkDescriptorWithExtensionHe memset( &xNetworkBuffer, 0, sizeof( xNetworkBuffer ) ); xNetworkBuffer.pxEndPoint = prvInitializeEndpoint(); xNetworkBuffer.pucEthernetBuffer = ( uint8_t * ) pcNetworkBuffer; - xNetworkBuffer.xDataLength = sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) + TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH + ucProtocolHeaderSize + 1U; + xNetworkBuffer.xDataLength = sizeof( EthernetHeader_t ) + sizeof( IPHeader_IPv6_t ) + TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH + ucProtocolHeaderSize + 1U; /* Initialize network buffer. */ memset( pcNetworkBuffer, 0, sizeof( pcNetworkBuffer ) ); @@ -123,7 +123,7 @@ static NetworkBufferDescriptor_t * prvInitializeNetworkDescriptorWithExtensionHe /* IP part. */ memcpy( pxIPv6Header->xSourceAddress.ucBytes, xIPAddressTen.ucBytes, sizeof( IPv6_Address_t ) ); memcpy( pxIPv6Header->xDestinationAddress.ucBytes, xIPAddressFive.ucBytes, sizeof( IPv6_Address_t ) ); - pxIPv6Header->usPayloadLength = FreeRTOS_htons( TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH + ucProtocolHeaderSize + 1U ); /* Extension header length + protocol header + payload */ + pxIPv6Header->usPayloadLength = FreeRTOS_htons( TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH + ucProtocolHeaderSize + 1U ); /* Extension header length + protocol header + payload */ pxIPv6Header->ucNextHeader = ipIPv6_EXT_HEADER_HOP_BY_HOP; /* Append extension headers */ pcNetworkBuffer[ uxIndex ] = ipIPv6_EXT_HEADER_ROUTING_HEADER; diff --git a/test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_utest.c b/test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_utest.c index 0e2762536f..8eaf9f7ffa 100644 --- a/test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_utest.c +++ b/test/unit-test/FreeRTOS_IPv6_Utils/FreeRTOS_IPv6_Utils_utest.c @@ -491,7 +491,7 @@ void test_usGetExtensionHeaderLength_TCPExtensionSuccess( void ) xReturn = usGetExtensionHeaderLength( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, &ucProtocol ); - TEST_ASSERT_EQUAL( TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH, xReturn ); + TEST_ASSERT_EQUAL( TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH, xReturn ); TEST_ASSERT_EQUAL( ipPROTOCOL_TCP, ucProtocol ); } @@ -530,7 +530,7 @@ void test_usGetExtensionHeaderLength_UDPExtensionSuccess( void ) xReturn = usGetExtensionHeaderLength( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, &ucProtocol ); - TEST_ASSERT_EQUAL( TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH, xReturn ); + TEST_ASSERT_EQUAL( TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH, xReturn ); TEST_ASSERT_EQUAL( ipPROTOCOL_UDP, ucProtocol ); } @@ -569,7 +569,7 @@ void test_usGetExtensionHeaderLength_ICMPv6ExtensionSuccess( void ) xReturn = usGetExtensionHeaderLength( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength, &ucProtocol ); - TEST_ASSERT_EQUAL( TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH, xReturn ); + TEST_ASSERT_EQUAL( TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH, xReturn ); TEST_ASSERT_EQUAL( ipPROTOCOL_ICMP_IPv6, ucProtocol ); } @@ -591,7 +591,7 @@ void test_usGetExtensionHeaderLength_ShortBufferLength( void ) uint8_t ucProtocol = 0; NetworkBufferDescriptor_t * pxNetworkBuffer = prvInitializeNetworkDescriptorWithExtensionHeader( ipPROTOCOL_TCP ); - pxNetworkBuffer->xDataLength = ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + ( TEST_IPv6_DEFAULT_EXTESION_HEADERS_LENGTH - 1 ); + pxNetworkBuffer->xDataLength = ipSIZE_OF_ETH_HEADER + ipSIZE_OF_IPv6_HEADER + ( TEST_IPv6_DEFAULT_EXTENSION_HEADERS_LENGTH - 1 ); xGetExtensionOrder_ExpectAndReturn( ipIPv6_EXT_HEADER_HOP_BY_HOP, 0U, 2 ); xGetExtensionOrder_ExpectAndReturn( ipIPv6_EXT_HEADER_HOP_BY_HOP, ipIPv6_EXT_HEADER_ROUTING_HEADER, 2 ); diff --git a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c index d15d77445c..9bedde2486 100644 --- a/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c +++ b/test/unit-test/FreeRTOS_ND/FreeRTOS_ND_utest.c @@ -980,7 +980,7 @@ void test_SendPingRequestIPv6_bIPv6_NotEnoughSpace( void ) * @brief This function handles case when we do not * have enough space for the Number of bytes to be send. */ -void test_SendPingRequestIPv6_IncorectBytesSend( void ) +void test_SendPingRequestIPv6_IncorrectBytesSend( void ) { NetworkEndPoint_t xEndPoint, * pxEndPoint = &xEndPoint; IPv6_Address_t xIPAddress; @@ -1209,9 +1209,9 @@ void test_prvProcessICMPMessage_IPv6_ipICMP_PACKET_TOO_BIG_IPv6( void ) /** * @brief This function process ICMP message when message type is - * ipICMP_TIME_EXEEDED_IPv6. + * ipICMP_TIME_EXCEEDED_IPv6. */ -void test_prvProcessICMPMessage_IPv6_ipICMP_TIME_EXEEDED_IPv6( void ) +void test_prvProcessICMPMessage_IPv6_ipICMP_TIME_EXCEEDED_IPv6( void ) { NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer = &xNetworkBuffer; ICMPPacket_IPv6_t xICMPPacket; @@ -1219,7 +1219,7 @@ void test_prvProcessICMPMessage_IPv6_ipICMP_TIME_EXEEDED_IPv6( void ) eFrameProcessingResult_t eReturn; xEndPoint.bits.bIPv6 = pdTRUE_UNSIGNED; - xICMPPacket.xICMPHeaderIPv6.ucTypeOfMessage = ipICMP_TIME_EXEEDED_IPv6; + xICMPPacket.xICMPHeaderIPv6.ucTypeOfMessage = ipICMP_TIME_EXCEEDED_IPv6; pxNetworkBuffer->pxEndPoint = &xEndPoint; pxNetworkBuffer->pucEthernetBuffer = ( uint8_t * ) &xICMPPacket; @@ -1489,7 +1489,7 @@ void test_prvProcessICMPMessage_IPv6_NeighborSolicitationNullEP( void ) * It handles case where when data length is less than * expected. */ -void test_prvProcessICMPMessage_IPv6_NeighborSolicitationInorrectLen( void ) +void test_prvProcessICMPMessage_IPv6_NeighborSolicitationIncorrectLen( void ) { NetworkBufferDescriptor_t xNetworkBuffer, * pxNetworkBuffer = &xNetworkBuffer; ICMPPacket_IPv6_t xICMPPacket; @@ -1947,7 +1947,7 @@ void test_pcMessageType_All( void ) xType = ipICMP_PACKET_TOO_BIG_IPv6; ( void ) pcMessageType( xType ); - xType = ipICMP_TIME_EXEEDED_IPv6; + xType = ipICMP_TIME_EXCEEDED_IPv6; ( void ) pcMessageType( xType ); xType = ipICMP_PARAMETER_PROBLEM_IPv6; diff --git a/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_utest.c b/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_utest.c index 0d77637d70..a1dfca94e0 100644 --- a/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_utest.c +++ b/test/unit-test/FreeRTOS_RA/FreeRTOS_RA_utest.c @@ -864,7 +864,7 @@ void test_vReceiveRA_ValidICMPPrefix_IncorrectOption( void ) /** * @brief This function verify vReceiveRA success case. */ -void test_vReceiveRA_vRAProcesss( void ) +void test_vReceiveRA_vRAProccess( void ) { NetworkBufferDescriptor_t * pxNetworkBuffer, xNetworkBuffer, xNetworkBuffer2; ICMPPacket_IPv6_t xICMPPacket; diff --git a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c index f10c454972..8a87630435 100644 --- a/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c +++ b/test/unit-test/FreeRTOS_Sockets/FreeRTOS_Sockets_TCP_API_utest.c @@ -751,7 +751,7 @@ void test_FreeRTOS_recv_SocketClosing( void ) } /** - * @brief Socket is in eClise_Wait in receive procedure. + * @brief Socket is in eClose_Wait in receive procedure. */ void test_FreeRTOS_recv_SocketCloseWait( void ) { diff --git a/test/unit-test/FreeRTOS_Sockets_IPv6/FreeRTOS_Sockets_IPv6_utest.c b/test/unit-test/FreeRTOS_Sockets_IPv6/FreeRTOS_Sockets_IPv6_utest.c index 77c6de2f6d..8a3c26f5b6 100644 --- a/test/unit-test/FreeRTOS_Sockets_IPv6/FreeRTOS_Sockets_IPv6_utest.c +++ b/test/unit-test/FreeRTOS_Sockets_IPv6/FreeRTOS_Sockets_IPv6_utest.c @@ -676,7 +676,7 @@ void test_prv_ntop6_write_zeros_NotEnoughSpaceInBuffer_2( void ) /** * @brief Case were target index is greater than size of the destination buffer. */ -void test_prv_ntop6_write_zeros_TargetndexGreater( void ) +void test_prv_ntop6_write_zeros_TargetIndexGreater( void ) { struct sNTOP6_Set xSet; BaseType_t xReturn; diff --git a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c index b2194f5ec3..51a35261da 100644 --- a/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c +++ b/test/unit-test/FreeRTOS_TCP_Transmission/FreeRTOS_TCP_Transmission_utest.c @@ -679,7 +679,7 @@ void test_prvTCPReturnPacket_Assert_InterfaceOutput_NULL( void ) * @brief This function validates sending packet back to * peer socket is set to NULL and release is set to true. */ -void test_prvTCPReturnPacket_Null_Socket_Relase_True( void ) +void test_prvTCPReturnPacket_Null_Socket_Release_True( void ) { struct xNetworkEndPoint xEndPoint = { 0 }; struct xNetworkInterface xInterface; diff --git a/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c b/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c index 05cbce4049..0327188851 100644 --- a/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c +++ b/test/unit-test/FreeRTOS_TCP_WIN/FreeRTOS_TCP_WIN_utest.c @@ -1193,7 +1193,7 @@ void test_lTCPWindowTxAdd_len_gt_max_len( void ) xTCPWindowLoggingLevel = xBackup; } -void test_lTCPWindowTxAdd_lBytsLeft_gt_zero_pxSegment_NULL( void ) +void test_lTCPWindowTxAdd_lBytesLeft_gt_zero_pxSegment_NULL( void ) { int32_t lDone; TCPWindow_t xWindow = { 0 }; @@ -1219,7 +1219,7 @@ void test_lTCPWindowTxAdd_lBytsLeft_gt_zero_pxSegment_NULL( void ) free( xWindow.pxHeadSegment ); } -void test_lTCPWindowTxAdd_lBytsLeft_gt_zero_data_length_gt_maxlen( void ) +void test_lTCPWindowTxAdd_lBytesLeft_gt_zero_data_length_gt_maxlen( void ) { int32_t lDone; TCPWindow_t xWindow = { 0 }; diff --git a/test/unit-test/README.md b/test/unit-test/README.md index f3dd7e8ef0..4d563ba4ac 100644 --- a/test/unit-test/README.md +++ b/test/unit-test/README.md @@ -1,35 +1,50 @@ # Unit Tests for FreeRTOS-Plus-TCP library -This directory is made for the purpose of Unit testing and tries to provide the tools for developing unit tests. To that end, this directory submodules the [CMock](https://github.com/ThrowTheSwitch/CMock) framework (which submodules [Unity](https://github.com/throwtheswitch/unity/tree/cf949f45ca6d172a177b00da2.3.1607b97bc7a7)) and the [FreeRTOS-Kernel](https://github.com/FreeRTOS/FreeRTOS-Kernel/). + +This directory is made for the purpose of Unit testing and tries to provide the +tools for developing unit tests. To that end, this directory submodules the +[CMock](https://github.com/ThrowTheSwitch/CMock) framework (which submodules +[Unity](https://github.com/throwtheswitch/unity/)) +and the [FreeRTOS-Kernel](https://github.com/FreeRTOS/FreeRTOS-Kernel/). ## Getting Started + ### Prerequisites -You can run this on any GNU Make compatible systems. But in case of DOS based systems some tweaking is required with the makefile. -To compile and run this project successfully, you must have the following: + +You can run this on any GNU Make compatible systems. But in case of DOS based +systems some tweaking is required with the makefile. To compile and run this +project successfully, you must have the following: + 1. Make (You can check whether you have this by typing `make --version`) - - Not found? Try `apt-get install make`. + - Not found? Try `apt-get install make`. 2. Ruby (You can check whether you have this by typing `ruby --version`) - - Not found? Try `apt-get install ruby`. -3. CMake version > 3.13.0 (You can check whether you have this by typing `cmake --version`) - - Not found? Try `apt-get install cmake` - - Try the `cmake --version` command. If still the version number is >= 3.13.0, skip to (4.) or else, continue. - - You will need to get the latest CMake version using curl or wget (or similar command). - - Uninstall the current version of CMake using `sudo apt remove --purge --auto-remove cmake`. - - Download the 3.13.0 version using `wget https://cmake.org/files/v3.13/cmake-3.13.0.tar.gz`. - - Extract the cmake download using `tar -xzvf cmake-3.13.0.tar.gz`. - - Go to the extracted folder (`cd cmake-3.13.0`) and run `./bootstrap`. - - Run `make -j$(nproc)' and then run `sudo make install`. - - Check the version using `cmake --version` command. + - Not found? Try `apt-get install ruby`. +3. CMake version > 3.13.0 (You can check whether you have this by typing + `cmake --version`) + - Not found? Try `apt-get install cmake` + - Try the `cmake --version` command. If still the version number is >= + 3.13.0, skip to (4.) or else, continue. + - You will need to get the latest CMake version using curl or wget (or + similar command). + - Uninstall the current version of CMake using + `sudo apt remove --purge --auto-remove cmake`. + - Download the [CMAKE version 3.13.0](https://cmake.org/files/v3.13/). + - Extract the cmake download using `tar -xzvf cmake-3.13.0.tar.gz`. + - Go to the extracted folder (`cd cmake-3.13.0`) and run `./bootstrap`. + - Run `make -j$(nproc)' and then run `sudo make install`. + - Check the version using `cmake --version` command. 4. lcov version 1.14 ( check with --version option ) - - 'sudo apt-get install lcov' + - 'sudo apt-get install lcov' 5. unifdef version 2.10 ( check with -V option ) - - 'sudo apt-get install unifdef' + - 'sudo apt-get install unifdef' 6. Download the repo and include the submodules using the following commands. - - `git clone https://github.com/FreeRTOS/FreeRTOS.git ./FreeRTOS_Dir` - - `git submodule update --checkout --init --recursive tools/CMock test/FreeRTOS-Kernel` + - `git clone https://github.com/FreeRTOS/FreeRTOS.git ./FreeRTOS_Dir` + - `git submodule update --checkout --init --recursive tools/CMock test/FreeRTOS-Kernel` ### To run the Unit tests: + Go to the root directory of the FreeRTOS+TCP repo and run the following script: -~~~ + +``` #!/bin/bash # This script should be run from the root directory of the FreeRTOS+TCP repo. @@ -56,13 +71,13 @@ popd # Calculate the coverage make -C ${BUILD_DIR} coverage lcov --list --rc lcov_branch_coverage=1 ${BUILD_DIR}coverage.info -~~~ +``` You should see an output similar to this: ``` ----------------------- -6 Tests 0 Failures 0 Ignored +6 Tests 0 Failures 0 Ignored OK Capturing coverage data from . ... @@ -76,7 +91,7 @@ And also: ``` Reading tracefile test/unit-test/build/coverage.info - |Lines |Functions |Branches + |Lines |Functions |Branches Filename |Rate Num|Rate Num|Rate Num ====================================================================== [/home/hein/freertos_plus_tcp/] diff --git a/tools/tcp_utilities/NTPDemo.c b/tools/tcp_utilities/NTPDemo.c index b92dc6cb83..e90e1c2cc0 100644 --- a/tools/tcp_utilities/NTPDemo.c +++ b/tools/tcp_utilities/NTPDemo.c @@ -143,9 +143,9 @@ void vNTPClearCache( void ) { ulIPAddressFound = 0U; #if ( ipconfigUSE_IPv6 != 0 ) - { - memset( &( xIPAddressFound ), 0, sizeof xIPAddressFound ); - } + { + memset( &( xIPAddressFound ), 0, sizeof xIPAddressFound ); + } #endif xHasIPAddress = pdFALSE; } @@ -508,22 +508,22 @@ static void prvNTPTask( void * pvParameters ) xStatus = EStatusLookup; #if ( ipconfigSOCKET_HAS_USER_SEMAPHORE != 0 ) || ( ipconfigUSE_CALLBACKS != 0 ) - { - xNTPWakeupSem = xSemaphoreCreateBinary(); - } + { + xNTPWakeupSem = xSemaphoreCreateBinary(); + } #endif #if ( ipconfigUSE_CALLBACKS != 0 ) - { - memset( &xHandler, '\0', sizeof( xHandler ) ); - xHandler.pxOnUDPReceive = xOnUDPReceive; - FreeRTOS_setsockopt( xNTP_UDPSocket, 0, FREERTOS_SO_UDP_RECV_HANDLER, ( void * ) &xHandler, sizeof( xHandler ) ); - } + { + memset( &xHandler, '\0', sizeof( xHandler ) ); + xHandler.pxOnUDPReceive = xOnUDPReceive; + FreeRTOS_setsockopt( xNTP_UDPSocket, 0, FREERTOS_SO_UDP_RECV_HANDLER, ( void * ) &xHandler, sizeof( xHandler ) ); + } #endif #if ( ipconfigSOCKET_HAS_USER_SEMAPHORE != 0 ) - { - FreeRTOS_setsockopt( xNTP_UDPSocket, 0, FREERTOS_SO_SET_SEMAPHORE, ( void * ) &xNTPWakeupSem, sizeof( xNTPWakeupSem ) ); - } + { + FreeRTOS_setsockopt( xNTP_UDPSocket, 0, FREERTOS_SO_SET_SEMAPHORE, ( void * ) &xNTPWakeupSem, sizeof( xNTPWakeupSem ) ); + } #endif for( ; ; ) @@ -561,19 +561,19 @@ static void prvNTPTask( void * pvParameters ) if( xDNSAsynchronous != 0 ) { #if ( ipconfigDNS_USE_CALLBACKS != 0 ) - { - FreeRTOS_getaddrinfo_a( pcServerName, /* The name of the node or device */ - NULL, /* Ignored for now. */ - &( xHints ), /* If not NULL: preferences. */ - &( pxResults ), /* An allocated struct, containing the results. */ - vDNS_callback, - ( void * ) NULL, /* An object or a reference. */ - pdMS_TO_TICKS( 2500U ) ); - } + { + FreeRTOS_getaddrinfo_a( pcServerName, /* The name of the node or device */ + NULL, /* Ignored for now. */ + &( xHints ), /* If not NULL: preferences. */ + &( pxResults ), /* An allocated struct, containing the results. */ + vDNS_callback, + ( void * ) NULL, /* An object or a reference. */ + pdMS_TO_TICKS( 2500U ) ); + } #else - { - FreeRTOS_printf( ( "ipconfigDNS_USE_CALLBACKS is not defined\n" ) ); - } + { + FreeRTOS_printf( ( "ipconfigDNS_USE_CALLBACKS is not defined\n" ) ); + } #endif /* if ( ipconfigDNS_USE_CALLBACKS != 0 ) */ } else @@ -652,43 +652,43 @@ static void prvNTPTask( void * pvParameters ) } #if ( ipconfigUSE_CALLBACKS != 0 ) - { - xSemaphoreTake( xNTPWakeupSem, 5000 ); - } + { + xSemaphoreTake( xNTPWakeupSem, 5000 ); + } #else - { - uint32_t xAddressSize; - BaseType_t xReturned; + { + uint32_t xAddressSize; + BaseType_t xReturned; - xAddressSize = sizeof( xAddress ); - xReturned = FreeRTOS_recvfrom( xNTP_UDPSocket, ( void * ) cRecvBuffer, sizeof( cRecvBuffer ), 0, &xAddress, &xAddressSize ); + xAddressSize = sizeof( xAddress ); + xReturned = FreeRTOS_recvfrom( xNTP_UDPSocket, ( void * ) cRecvBuffer, sizeof( cRecvBuffer ), 0, &xAddress, &xAddressSize ); - switch( xReturned ) - { - case 0: - case -pdFREERTOS_ERRNO_EAGAIN: - case -pdFREERTOS_ERRNO_EINTR: - break; + switch( xReturned ) + { + case 0: + case -pdFREERTOS_ERRNO_EAGAIN: + case -pdFREERTOS_ERRNO_EINTR: + break; - default: + default: - if( xReturned < sizeof( xNTPPacket ) ) - { - FreeRTOS_printf( ( "FreeRTOS_recvfrom: returns %ld\n", xReturned ) ); - } - else - { - prvReadTime( ( struct SNtpPacket * ) cRecvBuffer ); + if( xReturned < sizeof( xNTPPacket ) ) + { + FreeRTOS_printf( ( "FreeRTOS_recvfrom: returns %ld\n", xReturned ) ); + } + else + { + prvReadTime( ( struct SNtpPacket * ) cRecvBuffer ); - if( xStatus != EStatusPause ) - { - xStatus = EStatusPause; - } + if( xStatus != EStatusPause ) + { + xStatus = EStatusPause; } + } - break; - } + break; } + } #endif /* if ( ipconfigUSE_CALLBACKS != 0 ) */ } } diff --git a/tools/tcp_utilities/http_client_test.c b/tools/tcp_utilities/http_client_test.c index 1a9e58bc6d..fbdc3e75eb 100644 --- a/tools/tcp_utilities/http_client_test.c +++ b/tools/tcp_utilities/http_client_test.c @@ -419,10 +419,10 @@ FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xSendTimeOut, sizeof( xSendTimeOut ) ); #if ( ipconfigUSE_TCP_WIN == 1 ) - { - /* Set the window and buffer sizes. */ - FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_WIN_PROPERTIES, ( void * ) &xWinProps, sizeof( xWinProps ) ); - } + { + /* Set the window and buffer sizes. */ + FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_WIN_PROPERTIES, ( void * ) &xWinProps, sizeof( xWinProps ) ); + } #endif /* ipconfigUSE_TCP_WIN */ FreeRTOS_GetLocalAddress( xSocket, &xLocalAddress ); diff --git a/tools/tcp_utilities/include/date_and_time.h b/tools/tcp_utilities/include/date_and_time.h index 56cb04f545..299afb47b9 100644 --- a/tools/tcp_utilities/include/date_and_time.h +++ b/tools/tcp_utilities/include/date_and_time.h @@ -31,7 +31,7 @@ #include #ifdef __cplusplus - extern "C" { + extern "C" { #endif extern uint32_t ulSeconds, ulMsec; diff --git a/tools/tcp_utilities/include/plus_tcp_demo_cli.h b/tools/tcp_utilities/include/plus_tcp_demo_cli.h index 4ff6049acf..0e9422accd 100644 --- a/tools/tcp_utilities/include/plus_tcp_demo_cli.h +++ b/tools/tcp_utilities/include/plus_tcp_demo_cli.h @@ -28,7 +28,7 @@ #ifndef PLUS_TCP_DEMO_CLI_H #if __cplusplus - extern "C" { + extern "C" { #endif /* diff --git a/tools/tcp_utilities/include/tcp_mem_stats.h b/tools/tcp_utilities/include/tcp_mem_stats.h index 2dba94b294..ec0d5bd69b 100644 --- a/tools/tcp_utilities/include/tcp_mem_stats.h +++ b/tools/tcp_utilities/include/tcp_mem_stats.h @@ -30,7 +30,7 @@ #define TCP_MEM_STATS_H #ifdef __cplusplus - extern "C" { + extern "C" { #endif typedef enum xTCP_MEMORY diff --git a/tools/tcp_utilities/plus_tcp_demo_cli.c b/tools/tcp_utilities/plus_tcp_demo_cli.c index 9d94ad63f2..b6c005f1af 100644 --- a/tools/tcp_utilities/plus_tcp_demo_cli.c +++ b/tools/tcp_utilities/plus_tcp_demo_cli.c @@ -181,7 +181,7 @@ static struct xCommandCouple xCommands[] = { "ifconfig", 8U, handle_ifconfig, "Show a few network parameters\n" }, { "help", 4U, handle_help, "Show this help\n" }, #if ( ipconfigUSE_NTP_DEMO != 0 ) - { "ntp", 3U, handle_ntp, "Contact an NTP server and ask the time.\n" }, + { "ntp", 3U, handle_ntp, "Contact an NTP server and ask the time.\n" }, #endif }; @@ -690,10 +690,10 @@ static void handle_arpq( char * pcBuffer ) if( xOptions.xDoClear ) { #if ( ipconfigUSE_DNS_CACHE != 0 ) - { - FreeRTOS_dnsclear(); - FreeRTOS_printf( ( "Clear DNS cache and ARP\n" ) ); - } + { + FreeRTOS_dnsclear(); + FreeRTOS_printf( ( "Clear DNS cache and ARP\n" ) ); + } #endif /* ipconfigUSE_DNS_CACHE */ #if ( ipconfigMULTI_INTERFACE != 0 ) FreeRTOS_ClearARP( NULL ); @@ -745,32 +745,32 @@ static void handle_arpq( char * pcBuffer ) FreeRTOS_printf( ( "%s : %xip\n", ptr, ( unsigned ) FreeRTOS_ntohl( ip ) ) ); #if ( ipconfigUSE_DNS_CACHE == 0 ) - { - FreeRTOS_printf( ( "DNS caching not enabled\n" ) ); - } + { + FreeRTOS_printf( ( "DNS caching not enabled\n" ) ); + } #else + { + uint32_t ulFirstIPAddress = 0U; + BaseType_t xIndex; + + for( xIndex = 0; xIndex < ( BaseType_t ) ipconfigDNS_CACHE_ENTRIES; xIndex++ ) { - uint32_t ulFirstIPAddress = 0U; - BaseType_t xIndex; + /* Note: 'FreeRTOS_dnslookup' is only defined when + * 'ipconfigUSE_DNS_CACHE' is enabled. */ + uint32_t ulThisIPAddress = FreeRTOS_dnslookup( ptr ); - for( xIndex = 0; xIndex < ( BaseType_t ) ipconfigDNS_CACHE_ENTRIES; xIndex++ ) + if( xIndex == 0 ) { - /* Note: 'FreeRTOS_dnslookup' is only defined when - * 'ipconfigUSE_DNS_CACHE' is enabled. */ - uint32_t ulThisIPAddress = FreeRTOS_dnslookup( ptr ); - - if( xIndex == 0 ) - { - ulFirstIPAddress = ulThisIPAddress; - } - else if( ulFirstIPAddress == ulThisIPAddress ) - { - break; - } - - FreeRTOS_printf( ( "Cache[%d]: %xip\n", ( int ) xIndex, ( unsigned ) FreeRTOS_ntohl( ulThisIPAddress ) ) ); + ulFirstIPAddress = ulThisIPAddress; } + else if( ulFirstIPAddress == ulThisIPAddress ) + { + break; + } + + FreeRTOS_printf( ( "Cache[%d]: %xip\n", ( int ) xIndex, ( unsigned ) FreeRTOS_ntohl( ulThisIPAddress ) ) ); } + } #endif /* ( ipconfigUSE_DNS_CACHE == 0 ) */ } else @@ -1317,10 +1317,10 @@ void xHandleTesting() if( xDoClear ) { #if ( ipconfigUSE_DNS_CACHE != 0 ) - { - FreeRTOS_dnsclear(); - FreeRTOS_printf( ( "Clear DNS cache\n" ) ); - } + { + FreeRTOS_dnsclear(); + FreeRTOS_printf( ( "Clear DNS cache\n" ) ); + } #endif /* ipconfigUSE_DNS_CACHE */ #if ( ipconfigMULTI_INTERFACE != 0 ) FreeRTOS_ClearARP( NULL ); @@ -1647,12 +1647,12 @@ static void vDNSEvent( const char * pcName, static void clear_caches() { #if ( ipconfigUSE_DNS_CACHE != 0 ) - { - FreeRTOS_dnsclear(); - #if ( ipconfigUSE_IPv6 != 0 ) - FreeRTOS_ClearND(); - #endif /* ( ipconfigUSE_IPv6 != 0 ) */ - } + { + FreeRTOS_dnsclear(); + #if ( ipconfigUSE_IPv6 != 0 ) + FreeRTOS_ClearND(); + #endif /* ( ipconfigUSE_IPv6 != 0 ) */ + } #endif /* ipconfigUSE_DNS_CACHE */ #if ( ipconfigMULTI_INTERFACE != 0 ) FreeRTOS_ClearARP( NULL ); diff --git a/tools/tcp_utilities/tcp_mem_stats.c b/tools/tcp_utilities/tcp_mem_stats.c index 3ed5159637..b7b4754d5e 100644 --- a/tools/tcp_utilities/tcp_mem_stats.c +++ b/tools/tcp_utilities/tcp_mem_stats.c @@ -266,14 +266,14 @@ { #if ( ipconfigUSE_TCP_WIN != 0 ) - { - STATS_PRINTF( ( "TCPMemStat,TCP_WIN_SEG_COUNT,%u,%u,=B%d*C%d\n", - ipconfigTCP_WIN_SEG_COUNT, sizeof( TCPSegment_t ), xCurrentLine, xCurrentLine ) ); - } + { + STATS_PRINTF( ( "TCPMemStat,TCP_WIN_SEG_COUNT,%u,%u,=B%d*C%d\n", + ipconfigTCP_WIN_SEG_COUNT, sizeof( TCPSegment_t ), xCurrentLine, xCurrentLine ) ); + } #else - { - STATS_PRINTF( ( "TCPMemStat,TCP_WIN_SEG_COUNT,%u,%u\n", 0, 0 ) ); - } + { + STATS_PRINTF( ( "TCPMemStat,TCP_WIN_SEG_COUNT,%u,%u\n", 0, 0 ) ); + } #endif } { @@ -305,14 +305,14 @@ uxStaticSize += uxBytes; #if ( ipconfigUSE_DNS_CACHE == 1 ) - { - uxEntrySize = 3u * sizeof( uint32_t ) + ( ( ipconfigDNS_CACHE_NAME_LENGTH + 3 ) & ~0x3u ); - STATS_PRINTF( ( "TCPMemStat,DNS_CACHE_ENTRIES,%u,%u,=B%d*C%d\n", - ipconfigDNS_CACHE_ENTRIES, - uxEntrySize, - xCurrentLine, - xCurrentLine ) ); - } + { + uxEntrySize = 3u * sizeof( uint32_t ) + ( ( ipconfigDNS_CACHE_NAME_LENGTH + 3 ) & ~0x3u ); + STATS_PRINTF( ( "TCPMemStat,DNS_CACHE_ENTRIES,%u,%u,=B%d*C%d\n", + ipconfigDNS_CACHE_ENTRIES, + uxEntrySize, + xCurrentLine, + xCurrentLine ) ); + } #endif } diff --git a/tools/tcp_utilities/tcp_netstat.c b/tools/tcp_utilities/tcp_netstat.c index 4de6790e30..c0db5f0008 100644 --- a/tools/tcp_utilities/tcp_netstat.c +++ b/tools/tcp_utilities/tcp_netstat.c @@ -78,42 +78,42 @@ BaseType_t vGetMetrics( MetricsType_t * pxMetrics ) usLastPort = 0U; #if ( ipconfigUSE_TCP == 1 ) + { + vTaskSuspendAll(); { - vTaskSuspendAll(); + for( pxIterator = listGET_HEAD_ENTRY( &xBoundTCPSocketsList ); + pxIterator != pxEndTCP; + pxIterator = listGET_NEXT( pxIterator ) ) { - for( pxIterator = listGET_HEAD_ENTRY( &xBoundTCPSocketsList ); - pxIterator != pxEndTCP; - pxIterator = listGET_NEXT( pxIterator ) ) - { - const FreeRTOS_Socket_t * pxSocket = ( const FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); + const FreeRTOS_Socket_t * pxSocket = ( const FreeRTOS_Socket_t * ) listGET_LIST_ITEM_OWNER( pxIterator ); - if( pxMetrics->xTCPPortList.uxCount < nstatMAX_TCP_PORTS ) + if( pxMetrics->xTCPPortList.uxCount < nstatMAX_TCP_PORTS ) + { + if( usLastPort != pxSocket->usLocalPort ) { - if( usLastPort != pxSocket->usLocalPort ) - { - pxMetrics->xTCPPortList.usTCPPortList[ pxMetrics->xTCPPortList.uxCount ] = pxSocket->usLocalPort; - pxMetrics->xTCPPortList.uxCount++; - usLastPort = pxSocket->usLocalPort; - } + pxMetrics->xTCPPortList.usTCPPortList[ pxMetrics->xTCPPortList.uxCount ] = pxSocket->usLocalPort; + pxMetrics->xTCPPortList.uxCount++; + usLastPort = pxSocket->usLocalPort; } + } - if( pxMetrics->xTCPSocketList.uxCount < nstatMAX_TCP_PORTS ) - { - size_t uxCount = pxMetrics->xTCPSocketList.uxCount; + if( pxMetrics->xTCPSocketList.uxCount < nstatMAX_TCP_PORTS ) + { + size_t uxCount = pxMetrics->xTCPSocketList.uxCount; - pxMetrics->xTCPSocketList.xTCPList[ uxCount ].usLocalPort = pxSocket->usLocalPort; - pxMetrics->xTCPSocketList.xTCPList[ uxCount ].ulRemoteIP = pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4; - pxMetrics->xTCPSocketList.xTCPList[ uxCount ].usRemotePort = pxSocket->u.xTCP.usRemotePort; - pxMetrics->xTCPSocketList.uxCount++; - } + pxMetrics->xTCPSocketList.xTCPList[ uxCount ].usLocalPort = pxSocket->usLocalPort; + pxMetrics->xTCPSocketList.xTCPList[ uxCount ].ulRemoteIP = pxSocket->u.xTCP.xRemoteIP.ulIP_IPv4; + pxMetrics->xTCPSocketList.xTCPList[ uxCount ].usRemotePort = pxSocket->u.xTCP.usRemotePort; + pxMetrics->xTCPSocketList.uxCount++; } } + } - if( xTaskResumeAll() == 0 ) - { - taskYIELD(); - } + if( xTaskResumeAll() == 0 ) + { + taskYIELD(); } + } #endif /* ( ipconfigUSE_TCP == 1 ) */ vTaskSuspendAll(); @@ -157,25 +157,25 @@ void vShowMetrics( const MetricsType_t * pxMetrics ) pxMetrics->xOutput.uxByteCount ) ); #if ( ipconfigUSE_TCP == 1 ) - { - FreeRTOS_printf( ( "TCP ports:\n" ) ); + { + FreeRTOS_printf( ( "TCP ports:\n" ) ); - for( uxIndex = 0; uxIndex < pxMetrics->xTCPPortList.uxCount; uxIndex++ ) - { - FreeRTOS_printf( ( " local port: %u\n", - pxMetrics->xTCPPortList.usTCPPortList[ uxIndex ] ) ); - } + for( uxIndex = 0; uxIndex < pxMetrics->xTCPPortList.uxCount; uxIndex++ ) + { + FreeRTOS_printf( ( " local port: %u\n", + pxMetrics->xTCPPortList.usTCPPortList[ uxIndex ] ) ); + } - FreeRTOS_printf( ( "TCP sockets:\n" ) ); + FreeRTOS_printf( ( "TCP sockets:\n" ) ); - for( uxIndex = 0; uxIndex < pxMetrics->xTCPSocketList.uxCount; uxIndex++ ) - { - FreeRTOS_printf( ( " local port: %u remote IP %xip:%u\n", - pxMetrics->xTCPSocketList.xTCPList[ uxIndex ].usLocalPort, - pxMetrics->xTCPSocketList.xTCPList[ uxIndex ].ulRemoteIP, - pxMetrics->xTCPSocketList.xTCPList[ uxIndex ].usRemotePort ) ); - } + for( uxIndex = 0; uxIndex < pxMetrics->xTCPSocketList.uxCount; uxIndex++ ) + { + FreeRTOS_printf( ( " local port: %u remote IP %xip:%u\n", + pxMetrics->xTCPSocketList.xTCPList[ uxIndex ].usLocalPort, + pxMetrics->xTCPSocketList.xTCPList[ uxIndex ].ulRemoteIP, + pxMetrics->xTCPSocketList.xTCPList[ uxIndex ].usRemotePort ) ); } + } #endif /* ( ipconfigUSE_TCP == 1 ) */ FreeRTOS_printf( ( "UDP ports:\n" ) ); diff --git a/tools/uncrustify.cfg b/tools/uncrustify.cfg deleted file mode 100644 index 0cb7d3fbd6..0000000000 --- a/tools/uncrustify.cfg +++ /dev/null @@ -1,160 +0,0 @@ -# Uncrustify-0.67 -input_tab_size = 4 # unsigned number -output_tab_size = 4 # unsigned number -sp_arith = force # ignore/add/remove/force -sp_assign = force # ignore/add/remove/force -sp_assign_default = force # ignore/add/remove/force -sp_before_assign = force # ignore/add/remove/force -sp_after_assign = force # ignore/add/remove/force -sp_enum_assign = force # ignore/add/remove/force -sp_enum_before_assign = force # ignore/add/remove/force -sp_enum_after_assign = force # ignore/add/remove/force -sp_pp_stringify = add # ignore/add/remove/force -sp_bool = force # ignore/add/remove/force -sp_compare = force # ignore/add/remove/force -sp_inside_paren = force # ignore/add/remove/force -sp_paren_paren = force # ignore/add/remove/force -sp_paren_brace = force # ignore/add/remove/force -sp_before_ptr_star = force # ignore/add/remove/force -sp_before_unnamed_ptr_star = force # ignore/add/remove/force -sp_between_ptr_star = remove # ignore/add/remove/force -sp_after_ptr_star = force # ignore/add/remove/force -sp_before_byref = force # ignore/add/remove/force -sp_after_byref = remove # ignore/add/remove/force -sp_after_byref_func = remove # ignore/add/remove/force -sp_before_angle = remove # ignore/add/remove/force -sp_inside_angle = remove # ignore/add/remove/force -sp_after_angle = force # ignore/add/remove/force -sp_before_sparen = remove # ignore/add/remove/force -sp_inside_sparen = force # ignore/add/remove/force -sp_after_sparen = force # ignore/add/remove/force -sp_sparen_brace = force # ignore/add/remove/force -sp_before_semi_for = remove # ignore/add/remove/force -sp_before_semi_for_empty = add # ignore/add/remove/force -sp_after_semi_for_empty = force # ignore/add/remove/force -sp_before_square = remove # ignore/add/remove/force -sp_before_squares = remove # ignore/add/remove/force -sp_inside_square = force # ignore/add/remove/force -sp_after_comma = force # ignore/add/remove/force -sp_after_cast = force # ignore/add/remove/force -sp_inside_paren_cast = force # ignore/add/remove/force -sp_sizeof_paren = remove # ignore/add/remove/force -sp_inside_braces_enum = force # ignore/add/remove/force -sp_inside_braces_struct = force # ignore/add/remove/force -sp_inside_braces = force # ignore/add/remove/force -sp_inside_braces_empty = remove # ignore/add/remove/force -sp_type_func = force # ignore/add/remove/force -sp_func_proto_paren = remove # ignore/add/remove/force -sp_func_def_paren = remove # ignore/add/remove/force -sp_inside_fparens = remove # ignore/add/remove/force -sp_inside_fparen = force # ignore/add/remove/force -sp_fparen_brace = add # ignore/add/remove/force -sp_func_call_paren = remove # ignore/add/remove/force -sp_func_class_paren = remove # ignore/add/remove/force -sp_return_paren = remove # ignore/add/remove/force -sp_attribute_paren = remove # ignore/add/remove/force -sp_defined_paren = remove # ignore/add/remove/force -sp_macro = force # ignore/add/remove/force -sp_macro_func = force # ignore/add/remove/force -sp_brace_typedef = force # ignore/add/remove/force -sp_before_dc = remove # ignore/add/remove/force -sp_after_dc = remove # ignore/add/remove/force -sp_cond_colon = force # ignore/add/remove/force -sp_cond_question = force # ignore/add/remove/force -sp_case_label = force # ignore/add/remove/force -sp_endif_cmt = force # ignore/add/remove/force -sp_before_tr_emb_cmt = force # ignore/add/remove/force -sp_num_before_tr_emb_cmt = 1 # unsigned number -indent_columns = 4 # unsigned number -indent_with_tabs = 0 # unsigned number -indent_align_string = true # false/true -indent_class = true # false/true -indent_class_colon = true # false/true -indent_member = 3 # unsigned number -indent_switch_case = 4 # unsigned number -indent_case_brace = 3 # number -nl_assign_leave_one_liners = true # false/true -nl_class_leave_one_liners = true # false/true -nl_start_of_file = remove # ignore/add/remove/force -nl_end_of_file = force # ignore/add/remove/force -nl_end_of_file_min = 1 # unsigned number -nl_assign_brace = add # ignore/add/remove/force -nl_func_var_def_blk = 1 # unsigned number -nl_fcall_brace = add # ignore/add/remove/force -nl_enum_brace = force # ignore/add/remove/force -nl_struct_brace = force # ignore/add/remove/force -nl_union_brace = force # ignore/add/remove/force -nl_if_brace = add # ignore/add/remove/force -nl_brace_else = add # ignore/add/remove/force -nl_else_brace = add # ignore/add/remove/force -nl_getset_brace = force # ignore/add/remove/force -nl_for_brace = add # ignore/add/remove/force -nl_while_brace = add # ignore/add/remove/force -nl_do_brace = add # ignore/add/remove/force -nl_switch_brace = add # ignore/add/remove/force -nl_multi_line_define = true # false/true -nl_before_case = true # false/true -nl_after_case = true # false/true -nl_func_type_name = remove # ignore/add/remove/force -nl_func_proto_type_name = remove # ignore/add/remove/force -nl_func_paren = remove # ignore/add/remove/force -nl_func_def_paren = remove # ignore/add/remove/force -nl_func_decl_start = remove # ignore/add/remove/force -nl_func_def_start = remove # ignore/add/remove/force -nl_func_decl_args = add # ignore/add/remove/force -nl_func_def_args = add # ignore/add/remove/force -nl_func_decl_end = remove # ignore/add/remove/force -nl_func_def_end = remove # ignore/add/remove/force -nl_fdef_brace = add # ignore/add/remove/force -nl_after_semicolon = true # false/true -nl_after_brace_open = true # false/true -nl_after_brace_close = true # false/true -nl_squeeze_ifdef = true # false/true -nl_before_if = force # ignore/add/remove/force -nl_after_if = force # ignore/add/remove/force -nl_before_for = force # ignore/add/remove/force -nl_after_for = force # ignore/add/remove/force -nl_before_while = force # ignore/add/remove/force -nl_after_while = force # ignore/add/remove/force -nl_before_switch = force # ignore/add/remove/force -nl_after_switch = force # ignore/add/remove/force -nl_before_do = force # ignore/add/remove/force -nl_after_do = force # ignore/add/remove/force -nl_max = 4 # unsigned number -nl_after_func_proto_group = 1 # unsigned number -nl_after_func_body_class = 2 # unsigned number -nl_before_block_comment = 2 # unsigned number -eat_blanks_after_open_brace = true # false/true -eat_blanks_before_close_brace = true # false/true -nl_after_return = true # false/true -pos_bool = trail # ignore/join/lead/lead_break/lead_force/trail/trail_break/trail_force -align_var_def_amp_style = 1 # unsigned number -align_var_def_thresh = 16 # unsigned number -align_assign_thresh = 12 # unsigned number -align_struct_init_span = 3 # unsigned number -align_typedef_gap = 3 # unsigned number -align_typedef_span = 5 # unsigned number -align_typedef_star_style = 1 # unsigned number -align_typedef_amp_style = 1 # unsigned number -align_right_cmt_span = 3 # unsigned number -align_nl_cont = true # false/true -align_pp_define_gap = 4 # unsigned number -align_pp_define_span = 3 # unsigned number -cmt_cpp_to_c = true # false/true -cmt_star_cont = true # false/true -mod_full_brace_do = add # ignore/add/remove/force -mod_full_brace_for = add # ignore/add/remove/force -mod_full_brace_if = add # ignore/add/remove/force -mod_full_brace_while = add # ignore/add/remove/force -mod_full_paren_if_bool = true # false/true -mod_remove_extra_semicolon = true # false/true -mod_add_long_ifdef_endif_comment = 10 # unsigned number -mod_add_long_ifdef_else_comment = 10 # unsigned number -mod_case_brace = remove # ignore/add/remove/force -mod_remove_empty_return = true # false/true -pp_indent = force # ignore/add/remove/force -pp_indent_at_level = true # false/true -pp_indent_count = 4 # unsigned number -pp_space = remove # ignore/add/remove/force -pp_if_indent_code = true # false/true -# option(s) with 'not default' value: 158