123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128 |
- /**
- * @file
- * Management Information Base II (RFC1213) objects and functions.
- *
- * @note the object identifiers for this MIB-2 and private MIB tree
- * must be kept in sorted ascending order. This to ensure correct getnext operation.
- */
- /*
- * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
- * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
- * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
- * OF SUCH DAMAGE.
- *
- * Author: Christiaan Simons <christiaan.simons@axon.tv>
- */
- #include "lwip/opt.h"
- #if LWIP_SNMP /* don't build if not configured for use in lwipopts.h */
- #include "lwip/snmp.h"
- #include "lwip/netif.h"
- #include "lwip/ip.h"
- #include "lwip/ip_frag.h"
- #include "lwip/tcp.h"
- #include "lwip/udp.h"
- #include "lwip/snmp_asn1.h"
- #include "lwip/snmp_structs.h"
- #include "netif/etharp.h"
- /**
- * IANA assigned enterprise ID for lwIP is 26381
- * @see http://www.iana.org/assignments/enterprise-numbers
- *
- * @note this enterprise ID is assigned to the lwIP project,
- * all object identifiers living under this ID are assigned
- * by the lwIP maintainers (contact Christiaan Simons)!
- * @note don't change this define, use snmp_set_sysobjid()
- *
- * If you need to create your own private MIB you'll need
- * to apply for your own enterprise ID with IANA:
- * http://www.iana.org/numbers.html
- */
- #define SNMP_ENTERPRISE_ID 26381
- #define SNMP_SYSOBJID_LEN 7
- #define SNMP_SYSOBJID {1, 3, 6, 1, 4, 1, SNMP_ENTERPRISE_ID}
- #ifndef SNMP_SYSSERVICES
- #define SNMP_SYSSERVICES ((1 << 6) | (1 << 3) | ((IP_FORWARD) << 2))
- #endif
- #ifndef SNMP_GET_SYSUPTIME
- #define SNMP_GET_SYSUPTIME(sysuptime)
- #endif
- static void system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void system_get_value(struct obj_def *od, u16_t len, void *value);
- static u8_t system_set_test(struct obj_def *od, u16_t len, void *value);
- static void system_set_value(struct obj_def *od, u16_t len, void *value);
- static void interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void interfaces_get_value(struct obj_def *od, u16_t len, void *value);
- static void ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void ifentry_get_value(struct obj_def *od, u16_t len, void *value);
- #if !SNMP_SAFE_REQUESTS
- static u8_t ifentry_set_test (struct obj_def *od, u16_t len, void *value);
- static void ifentry_set_value (struct obj_def *od, u16_t len, void *value);
- #endif /* SNMP_SAFE_REQUESTS */
- static void atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void atentry_get_value(struct obj_def *od, u16_t len, void *value);
- static void ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void ip_get_value(struct obj_def *od, u16_t len, void *value);
- static u8_t ip_set_test(struct obj_def *od, u16_t len, void *value);
- static void ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value);
- static void ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value);
- static void ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value);
- static void icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void icmp_get_value(struct obj_def *od, u16_t len, void *value);
- #if LWIP_TCP
- static void tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void tcp_get_value(struct obj_def *od, u16_t len, void *value);
- #ifdef THIS_SEEMS_UNUSED
- static void tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value);
- #endif
- #endif
- static void udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void udp_get_value(struct obj_def *od, u16_t len, void *value);
- static void udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void udpentry_get_value(struct obj_def *od, u16_t len, void *value);
- static void snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od);
- static void snmp_get_value(struct obj_def *od, u16_t len, void *value);
- static u8_t snmp_set_test(struct obj_def *od, u16_t len, void *value);
- static void snmp_set_value(struct obj_def *od, u16_t len, void *value);
- /* snmp .1.3.6.1.2.1.11 */
- const mib_scalar_node snmp_scalar = {
- &snmp_get_object_def,
- &snmp_get_value,
- &snmp_set_test,
- &snmp_set_value,
- MIB_NODE_SC,
- 0
- };
- const s32_t snmp_ids[28] = {
- 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 28, 29, 30
- };
- struct mib_node* const snmp_nodes[28] = {
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar,
- (struct mib_node*)&snmp_scalar, (struct mib_node*)&snmp_scalar
- };
- const struct mib_array_node snmp = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 28,
- snmp_ids,
- snmp_nodes
- };
- /* dot3 and EtherLike MIB not planned. (transmission .1.3.6.1.2.1.10) */
- /* historical (some say hysterical). (cmot .1.3.6.1.2.1.9) */
- /* lwIP has no EGP, thus may not implement it. (egp .1.3.6.1.2.1.8) */
- /* udp .1.3.6.1.2.1.7 */
- /** index root node for udpTable */
- struct mib_list_rootnode udp_root = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_LR,
- 0,
- NULL,
- NULL,
- 0
- };
- const s32_t udpentry_ids[2] = { 1, 2 };
- struct mib_node* const udpentry_nodes[2] = {
- (struct mib_node*)&udp_root, (struct mib_node*)&udp_root,
- };
- const struct mib_array_node udpentry = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 2,
- udpentry_ids,
- udpentry_nodes
- };
- s32_t udptable_id = 1;
- struct mib_node* udptable_node = (struct mib_node*)&udpentry;
- struct mib_ram_array_node udptable = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_RA,
- 0,
- &udptable_id,
- &udptable_node
- };
- const mib_scalar_node udp_scalar = {
- &udp_get_object_def,
- &udp_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_SC,
- 0
- };
- const s32_t udp_ids[5] = { 1, 2, 3, 4, 5 };
- struct mib_node* const udp_nodes[5] = {
- (struct mib_node*)&udp_scalar, (struct mib_node*)&udp_scalar,
- (struct mib_node*)&udp_scalar, (struct mib_node*)&udp_scalar,
- (struct mib_node*)&udptable
- };
- const struct mib_array_node udp = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 5,
- udp_ids,
- udp_nodes
- };
- /* tcp .1.3.6.1.2.1.6 */
- #if LWIP_TCP
- /* only if the TCP protocol is available may implement this group */
- /** index root node for tcpConnTable */
- struct mib_list_rootnode tcpconntree_root = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_LR,
- 0,
- NULL,
- NULL,
- 0
- };
- const s32_t tcpconnentry_ids[5] = { 1, 2, 3, 4, 5 };
- struct mib_node* const tcpconnentry_nodes[5] = {
- (struct mib_node*)&tcpconntree_root, (struct mib_node*)&tcpconntree_root,
- (struct mib_node*)&tcpconntree_root, (struct mib_node*)&tcpconntree_root,
- (struct mib_node*)&tcpconntree_root
- };
- const struct mib_array_node tcpconnentry = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 5,
- tcpconnentry_ids,
- tcpconnentry_nodes
- };
- s32_t tcpconntable_id = 1;
- struct mib_node* tcpconntable_node = (struct mib_node*)&tcpconnentry;
- struct mib_ram_array_node tcpconntable = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_RA,
- /** @todo update maxlength when inserting / deleting from table
- 0 when table is empty, 1 when more than one entry */
- 0,
- &tcpconntable_id,
- &tcpconntable_node
- };
- const mib_scalar_node tcp_scalar = {
- &tcp_get_object_def,
- &tcp_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_SC,
- 0
- };
- const s32_t tcp_ids[15] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
- struct mib_node* const tcp_nodes[15] = {
- (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
- (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
- (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
- (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
- (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
- (struct mib_node*)&tcp_scalar, (struct mib_node*)&tcp_scalar,
- (struct mib_node*)&tcpconntable, (struct mib_node*)&tcp_scalar,
- (struct mib_node*)&tcp_scalar
- };
- const struct mib_array_node tcp = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 15,
- tcp_ids,
- tcp_nodes
- };
- #endif
- /* icmp .1.3.6.1.2.1.5 */
- const mib_scalar_node icmp_scalar = {
- &icmp_get_object_def,
- &icmp_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_SC,
- 0
- };
- const s32_t icmp_ids[26] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 };
- struct mib_node* const icmp_nodes[26] = {
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar,
- (struct mib_node*)&icmp_scalar, (struct mib_node*)&icmp_scalar
- };
- const struct mib_array_node icmp = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 26,
- icmp_ids,
- icmp_nodes
- };
- /** index root node for ipNetToMediaTable */
- struct mib_list_rootnode ipntomtree_root = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_LR,
- 0,
- NULL,
- NULL,
- 0
- };
- const s32_t ipntomentry_ids[4] = { 1, 2, 3, 4 };
- struct mib_node* const ipntomentry_nodes[4] = {
- (struct mib_node*)&ipntomtree_root, (struct mib_node*)&ipntomtree_root,
- (struct mib_node*)&ipntomtree_root, (struct mib_node*)&ipntomtree_root
- };
- const struct mib_array_node ipntomentry = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 4,
- ipntomentry_ids,
- ipntomentry_nodes
- };
- s32_t ipntomtable_id = 1;
- struct mib_node* ipntomtable_node = (struct mib_node*)&ipntomentry;
- struct mib_ram_array_node ipntomtable = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_RA,
- 0,
- &ipntomtable_id,
- &ipntomtable_node
- };
- /** index root node for ipRouteTable */
- struct mib_list_rootnode iprtetree_root = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_LR,
- 0,
- NULL,
- NULL,
- 0
- };
- const s32_t iprteentry_ids[13] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
- struct mib_node* const iprteentry_nodes[13] = {
- (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
- (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
- (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
- (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
- (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
- (struct mib_node*)&iprtetree_root, (struct mib_node*)&iprtetree_root,
- (struct mib_node*)&iprtetree_root
- };
- const struct mib_array_node iprteentry = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 13,
- iprteentry_ids,
- iprteentry_nodes
- };
- s32_t iprtetable_id = 1;
- struct mib_node* iprtetable_node = (struct mib_node*)&iprteentry;
- struct mib_ram_array_node iprtetable = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_RA,
- 0,
- &iprtetable_id,
- &iprtetable_node
- };
- /** index root node for ipAddrTable */
- struct mib_list_rootnode ipaddrtree_root = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_LR,
- 0,
- NULL,
- NULL,
- 0
- };
- const s32_t ipaddrentry_ids[5] = { 1, 2, 3, 4, 5 };
- struct mib_node* const ipaddrentry_nodes[5] = {
- (struct mib_node*)&ipaddrtree_root,
- (struct mib_node*)&ipaddrtree_root,
- (struct mib_node*)&ipaddrtree_root,
- (struct mib_node*)&ipaddrtree_root,
- (struct mib_node*)&ipaddrtree_root
- };
- const struct mib_array_node ipaddrentry = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 5,
- ipaddrentry_ids,
- ipaddrentry_nodes
- };
- s32_t ipaddrtable_id = 1;
- struct mib_node* ipaddrtable_node = (struct mib_node*)&ipaddrentry;
- struct mib_ram_array_node ipaddrtable = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_RA,
- 0,
- &ipaddrtable_id,
- &ipaddrtable_node
- };
- /* ip .1.3.6.1.2.1.4 */
- const mib_scalar_node ip_scalar = {
- &ip_get_object_def,
- &ip_get_value,
- &ip_set_test,
- &noleafs_set_value,
- MIB_NODE_SC,
- 0
- };
- const s32_t ip_ids[23] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
- struct mib_node* const ip_nodes[23] = {
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ip_scalar,
- (struct mib_node*)&ip_scalar, (struct mib_node*)&ipaddrtable,
- (struct mib_node*)&iprtetable, (struct mib_node*)&ipntomtable,
- (struct mib_node*)&ip_scalar
- };
- const struct mib_array_node mib2_ip = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 23,
- ip_ids,
- ip_nodes
- };
- /** index root node for atTable */
- struct mib_list_rootnode arptree_root = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_LR,
- 0,
- NULL,
- NULL,
- 0
- };
- const s32_t atentry_ids[3] = { 1, 2, 3 };
- struct mib_node* const atentry_nodes[3] = {
- (struct mib_node*)&arptree_root,
- (struct mib_node*)&arptree_root,
- (struct mib_node*)&arptree_root
- };
- const struct mib_array_node atentry = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 3,
- atentry_ids,
- atentry_nodes
- };
- const s32_t attable_id = 1;
- struct mib_node* const attable_node = (struct mib_node*)&atentry;
- const struct mib_array_node attable = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 1,
- &attable_id,
- &attable_node
- };
- /* at .1.3.6.1.2.1.3 */
- s32_t at_id = 1;
- struct mib_node* mib2_at_node = (struct mib_node*)&attable;
- struct mib_ram_array_node at = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_RA,
- 0,
- &at_id,
- &mib2_at_node
- };
- /** index root node for ifTable */
- struct mib_list_rootnode iflist_root = {
- &ifentry_get_object_def,
- &ifentry_get_value,
- #if SNMP_SAFE_REQUESTS
- &noleafs_set_test,
- &noleafs_set_value,
- #else /* SNMP_SAFE_REQUESTS */
- &ifentry_set_test,
- &ifentry_set_value,
- #endif /* SNMP_SAFE_REQUESTS */
- MIB_NODE_LR,
- 0,
- NULL,
- NULL,
- 0
- };
- const s32_t ifentry_ids[22] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 };
- struct mib_node* const ifentry_nodes[22] = {
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root,
- (struct mib_node*)&iflist_root, (struct mib_node*)&iflist_root
- };
- const struct mib_array_node ifentry = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 22,
- ifentry_ids,
- ifentry_nodes
- };
- s32_t iftable_id = 1;
- struct mib_node* iftable_node = (struct mib_node*)&ifentry;
- struct mib_ram_array_node iftable = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_RA,
- 0,
- &iftable_id,
- &iftable_node
- };
- /* interfaces .1.3.6.1.2.1.2 */
- const mib_scalar_node interfaces_scalar = {
- &interfaces_get_object_def,
- &interfaces_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_SC,
- 0
- };
- const s32_t interfaces_ids[2] = { 1, 2 };
- struct mib_node* const interfaces_nodes[2] = {
- (struct mib_node*)&interfaces_scalar, (struct mib_node*)&iftable
- };
- const struct mib_array_node interfaces = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 2,
- interfaces_ids,
- interfaces_nodes
- };
- /* 0 1 2 3 4 5 6 */
- /* system .1.3.6.1.2.1.1 */
- const mib_scalar_node sys_tem_scalar = {
- &system_get_object_def,
- &system_get_value,
- &system_set_test,
- &system_set_value,
- MIB_NODE_SC,
- 0
- };
- const s32_t sys_tem_ids[7] = { 1, 2, 3, 4, 5, 6, 7 };
- struct mib_node* const sys_tem_nodes[7] = {
- (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar,
- (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar,
- (struct mib_node*)&sys_tem_scalar, (struct mib_node*)&sys_tem_scalar,
- (struct mib_node*)&sys_tem_scalar
- };
- /* work around name issue with 'sys_tem', some compiler(s?) seem to reserve 'system' */
- const struct mib_array_node sys_tem = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 7,
- sys_tem_ids,
- sys_tem_nodes
- };
- /* mib-2 .1.3.6.1.2.1 */
- #if LWIP_TCP
- #define MIB2_GROUPS 8
- #else
- #define MIB2_GROUPS 7
- #endif
- const s32_t mib2_ids[MIB2_GROUPS] =
- {
- 1,
- 2,
- 3,
- 4,
- 5,
- #if LWIP_TCP
- 6,
- #endif
- 7,
- 11
- };
- struct mib_node* const mib2_nodes[MIB2_GROUPS] = {
- (struct mib_node*)&sys_tem,
- (struct mib_node*)&interfaces,
- (struct mib_node*)&at,
- (struct mib_node*)&mib2_ip,
- (struct mib_node*)&icmp,
- #if LWIP_TCP
- (struct mib_node*)&tcp,
- #endif
- (struct mib_node*)&udp,
- (struct mib_node*)&snmp
- };
- const struct mib_array_node mib2 = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- MIB2_GROUPS,
- mib2_ids,
- mib2_nodes
- };
- /* mgmt .1.3.6.1.2 */
- const s32_t mgmt_ids[1] = { 1 };
- struct mib_node* const mgmt_nodes[1] = { (struct mib_node*)&mib2 };
- const struct mib_array_node mgmt = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 1,
- mgmt_ids,
- mgmt_nodes
- };
- /* internet .1.3.6.1 */
- #if SNMP_PRIVATE_MIB
- s32_t internet_ids[2] = { 2, 4 };
- struct mib_node* const internet_nodes[2] = { (struct mib_node*)&mgmt, (struct mib_node*)&mib_private };
- const struct mib_array_node internet = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 2,
- internet_ids,
- internet_nodes
- };
- #else
- const s32_t internet_ids[1] = { 2 };
- struct mib_node* const internet_nodes[1] = { (struct mib_node*)&mgmt };
- const struct mib_array_node internet = {
- &noleafs_get_object_def,
- &noleafs_get_value,
- &noleafs_set_test,
- &noleafs_set_value,
- MIB_NODE_AR,
- 1,
- internet_ids,
- internet_nodes
- };
- #endif
- /** mib-2.system.sysObjectID */
- static struct snmp_obj_id sysobjid = {SNMP_SYSOBJID_LEN, SNMP_SYSOBJID};
- /** enterprise ID for generic TRAPs, .iso.org.dod.internet.mgmt.mib-2.snmp */
- static struct snmp_obj_id snmpgrp_id = {7,{1,3,6,1,2,1,11}};
- /** mib-2.system.sysServices */
- static const s32_t sysservices = SNMP_SYSSERVICES;
- /** mib-2.system.sysDescr */
- static const u8_t sysdescr_len_default = 4;
- static const u8_t sysdescr_default[] = "lwIP";
- static u8_t* sysdescr_len_ptr = (u8_t*)&sysdescr_len_default;
- static u8_t* sysdescr_ptr = (u8_t*)&sysdescr_default[0];
- /** mib-2.system.sysContact */
- static const u8_t syscontact_len_default = 0;
- static const u8_t syscontact_default[] = "";
- static u8_t* syscontact_len_ptr = (u8_t*)&syscontact_len_default;
- static u8_t* syscontact_ptr = (u8_t*)&syscontact_default[0];
- /** mib-2.system.sysName */
- static const u8_t sysname_len_default = 8;
- static const u8_t sysname_default[] = "FQDN-unk";
- static u8_t* sysname_len_ptr = (u8_t*)&sysname_len_default;
- static u8_t* sysname_ptr = (u8_t*)&sysname_default[0];
- /** mib-2.system.sysLocation */
- static const u8_t syslocation_len_default = 0;
- static const u8_t syslocation_default[] = "";
- static u8_t* syslocation_len_ptr = (u8_t*)&syslocation_len_default;
- static u8_t* syslocation_ptr = (u8_t*)&syslocation_default[0];
- /** mib-2.snmp.snmpEnableAuthenTraps */
- static const u8_t snmpenableauthentraps_default = 2; /* disabled */
- static u8_t* snmpenableauthentraps_ptr = (u8_t*)&snmpenableauthentraps_default;
- /** mib-2.interfaces.ifTable.ifEntry.ifSpecific (zeroDotZero) */
- static const struct snmp_obj_id ifspecific = {2, {0, 0}};
- /** mib-2.ip.ipRouteTable.ipRouteEntry.ipRouteInfo (zeroDotZero) */
- static const struct snmp_obj_id iprouteinfo = {2, {0, 0}};
- /* mib-2.system counter(s) */
- static u32_t sysuptime = 0;
- /* mib-2.ip counter(s) */
- static u32_t ipinreceives = 0,
- ipinhdrerrors = 0,
- ipinaddrerrors = 0,
- ipforwdatagrams = 0,
- ipinunknownprotos = 0,
- ipindiscards = 0,
- ipindelivers = 0,
- ipoutrequests = 0,
- ipoutdiscards = 0,
- ipoutnoroutes = 0,
- ipreasmreqds = 0,
- ipreasmoks = 0,
- ipreasmfails = 0,
- ipfragoks = 0,
- ipfragfails = 0,
- ipfragcreates = 0,
- iproutingdiscards = 0;
- /* mib-2.icmp counter(s) */
- static u32_t icmpinmsgs = 0,
- icmpinerrors = 0,
- icmpindestunreachs = 0,
- icmpintimeexcds = 0,
- icmpinparmprobs = 0,
- icmpinsrcquenchs = 0,
- icmpinredirects = 0,
- icmpinechos = 0,
- icmpinechoreps = 0,
- icmpintimestamps = 0,
- icmpintimestampreps = 0,
- icmpinaddrmasks = 0,
- icmpinaddrmaskreps = 0,
- icmpoutmsgs = 0,
- icmpouterrors = 0,
- icmpoutdestunreachs = 0,
- icmpouttimeexcds = 0,
- icmpoutparmprobs = 0,
- icmpoutsrcquenchs = 0,
- icmpoutredirects = 0,
- icmpoutechos = 0,
- icmpoutechoreps = 0,
- icmpouttimestamps = 0,
- icmpouttimestampreps = 0,
- icmpoutaddrmasks = 0,
- icmpoutaddrmaskreps = 0;
- /* mib-2.tcp counter(s) */
- static u32_t tcpactiveopens = 0,
- tcppassiveopens = 0,
- tcpattemptfails = 0,
- tcpestabresets = 0,
- tcpinsegs = 0,
- tcpoutsegs = 0,
- tcpretranssegs = 0,
- tcpinerrs = 0,
- tcpoutrsts = 0;
- /* mib-2.udp counter(s) */
- static u32_t udpindatagrams = 0,
- udpnoports = 0,
- udpinerrors = 0,
- udpoutdatagrams = 0;
- /* mib-2.snmp counter(s) */
- static u32_t snmpinpkts = 0,
- snmpoutpkts = 0,
- snmpinbadversions = 0,
- snmpinbadcommunitynames = 0,
- snmpinbadcommunityuses = 0,
- snmpinasnparseerrs = 0,
- snmpintoobigs = 0,
- snmpinnosuchnames = 0,
- snmpinbadvalues = 0,
- snmpinreadonlys = 0,
- snmpingenerrs = 0,
- snmpintotalreqvars = 0,
- snmpintotalsetvars = 0,
- snmpingetrequests = 0,
- snmpingetnexts = 0,
- snmpinsetrequests = 0,
- snmpingetresponses = 0,
- snmpintraps = 0,
- snmpouttoobigs = 0,
- snmpoutnosuchnames = 0,
- snmpoutbadvalues = 0,
- snmpoutgenerrs = 0,
- snmpoutgetrequests = 0,
- snmpoutgetnexts = 0,
- snmpoutsetrequests = 0,
- snmpoutgetresponses = 0,
- snmpouttraps = 0;
- /* prototypes of the following functions are in lwip/src/include/lwip/snmp.h */
- /**
- * Copy octet string.
- *
- * @param dst points to destination
- * @param src points to source
- * @param n number of octets to copy.
- */
- void ocstrncpy(u8_t *dst, u8_t *src, u8_t n)
- {
- while (n > 0)
- {
- n--;
- *dst++ = *src++;
- }
- }
- /**
- * Copy object identifier (s32_t) array.
- *
- * @param dst points to destination
- * @param src points to source
- * @param n number of sub identifiers to copy.
- */
- void objectidncpy(s32_t *dst, s32_t *src, u8_t n)
- {
- while(n > 0)
- {
- n--;
- *dst++ = *src++;
- }
- }
- /**
- * Initializes sysDescr pointers.
- *
- * @param str if non-NULL then copy str pointer
- * @param len points to string length, excluding zero terminator
- */
- void snmp_set_sysdesr(u8_t *str, u8_t *len)
- {
- if (str != NULL)
- {
- sysdescr_ptr = str;
- sysdescr_len_ptr = len;
- }
- }
- void snmp_get_sysobjid_ptr(struct snmp_obj_id **oid)
- {
- *oid = &sysobjid;
- }
- /**
- * Initializes sysObjectID value.
- *
- * @param oid points to stuct snmp_obj_id to copy
- */
- void snmp_set_sysobjid(struct snmp_obj_id *oid)
- {
- sysobjid = *oid;
- }
- /**
- * Must be called at regular 10 msec interval from a timer interrupt
- * or signal handler depending on your runtime environment.
- */
- void snmp_inc_sysuptime(void)
- {
- sysuptime++;
- }
- void snmp_add_sysuptime(u32_t value)
- {
- sysuptime+=value;
- }
- void snmp_get_sysuptime(u32_t *value)
- {
- SNMP_GET_SYSUPTIME(sysuptime);
- *value = sysuptime;
- }
- /**
- * Initializes sysContact pointers,
- * e.g. ptrs to non-volatile memory external to lwIP.
- *
- * @param ocstr if non-NULL then copy str pointer
- * @param ocstrlen points to string length, excluding zero terminator
- */
- void snmp_set_syscontact(u8_t *ocstr, u8_t *ocstrlen)
- {
- if (ocstr != NULL)
- {
- syscontact_ptr = ocstr;
- syscontact_len_ptr = ocstrlen;
- }
- }
- /**
- * Initializes sysName pointers,
- * e.g. ptrs to non-volatile memory external to lwIP.
- *
- * @param ocstr if non-NULL then copy str pointer
- * @param ocstrlen points to string length, excluding zero terminator
- */
- void snmp_set_sysname(u8_t *ocstr, u8_t *ocstrlen)
- {
- if (ocstr != NULL)
- {
- sysname_ptr = ocstr;
- sysname_len_ptr = ocstrlen;
- }
- }
- /**
- * Initializes sysLocation pointers,
- * e.g. ptrs to non-volatile memory external to lwIP.
- *
- * @param ocstr if non-NULL then copy str pointer
- * @param ocstrlen points to string length, excluding zero terminator
- */
- void snmp_set_syslocation(u8_t *ocstr, u8_t *ocstrlen)
- {
- if (ocstr != NULL)
- {
- syslocation_ptr = ocstr;
- syslocation_len_ptr = ocstrlen;
- }
- }
- void snmp_add_ifinoctets(struct netif *ni, u32_t value)
- {
- ni->ifinoctets += value;
- }
- void snmp_inc_ifinucastpkts(struct netif *ni)
- {
- (ni->ifinucastpkts)++;
- }
- void snmp_inc_ifinnucastpkts(struct netif *ni)
- {
- (ni->ifinnucastpkts)++;
- }
- void snmp_inc_ifindiscards(struct netif *ni)
- {
- (ni->ifindiscards)++;
- }
- void snmp_add_ifoutoctets(struct netif *ni, u32_t value)
- {
- ni->ifoutoctets += value;
- }
- void snmp_inc_ifoutucastpkts(struct netif *ni)
- {
- (ni->ifoutucastpkts)++;
- }
- void snmp_inc_ifoutnucastpkts(struct netif *ni)
- {
- (ni->ifoutnucastpkts)++;
- }
- void snmp_inc_ifoutdiscards(struct netif *ni)
- {
- (ni->ifoutdiscards)++;
- }
- void snmp_inc_iflist(void)
- {
- struct mib_list_node *if_node = NULL;
- snmp_mib_node_insert(&iflist_root, iflist_root.count + 1, &if_node);
- /* enable getnext traversal on filled table */
- iftable.maxlength = 1;
- }
- void snmp_dec_iflist(void)
- {
- snmp_mib_node_delete(&iflist_root, iflist_root.tail);
- /* disable getnext traversal on empty table */
- if(iflist_root.count == 0) iftable.maxlength = 0;
- }
- /**
- * Inserts ARP table indexes (.xIfIndex.xNetAddress)
- * into arp table index trees (both atTable and ipNetToMediaTable).
- */
- void snmp_insert_arpidx_tree(struct netif *ni, struct ip_addr *ip)
- {
- struct mib_list_rootnode *at_rn;
- struct mib_list_node *at_node;
- struct ip_addr hip;
- s32_t arpidx[5];
- u8_t level, tree;
- LWIP_ASSERT("ni != NULL", ni != NULL);
- snmp_netiftoifindex(ni, &arpidx[0]);
- hip.addr = ntohl(ip->addr);
- snmp_iptooid(&hip, &arpidx[1]);
- for (tree = 0; tree < 2; tree++)
- {
- if (tree == 0)
- {
- at_rn = &arptree_root;
- }
- else
- {
- at_rn = &ipntomtree_root;
- }
- for (level = 0; level < 5; level++)
- {
- at_node = NULL;
- snmp_mib_node_insert(at_rn, arpidx[level], &at_node);
- if ((level != 4) && (at_node != NULL))
- {
- if (at_node->nptr == NULL)
- {
- at_rn = snmp_mib_lrn_alloc();
- at_node->nptr = (struct mib_node*)at_rn;
- if (at_rn != NULL)
- {
- if (level == 3)
- {
- if (tree == 0)
- {
- at_rn->get_object_def = atentry_get_object_def;
- at_rn->get_value = atentry_get_value;
- }
- else
- {
- at_rn->get_object_def = ip_ntomentry_get_object_def;
- at_rn->get_value = ip_ntomentry_get_value;
- }
- at_rn->set_test = noleafs_set_test;
- at_rn->set_value = noleafs_set_value;
- }
- }
- else
- {
- /* at_rn == NULL, malloc failure */
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_arpidx_tree() insert failed, mem full"));
- break;
- }
- }
- else
- {
- at_rn = (struct mib_list_rootnode*)at_node->nptr;
- }
- }
- }
- }
- /* enable getnext traversal on filled tables */
- at.maxlength = 1;
- ipntomtable.maxlength = 1;
- }
- /**
- * Removes ARP table indexes (.xIfIndex.xNetAddress)
- * from arp table index trees.
- */
- void snmp_delete_arpidx_tree(struct netif *ni, struct ip_addr *ip)
- {
- struct mib_list_rootnode *at_rn, *next, *del_rn[5];
- struct mib_list_node *at_n, *del_n[5];
- struct ip_addr hip;
- s32_t arpidx[5];
- u8_t fc, tree, level, del_cnt;
- snmp_netiftoifindex(ni, &arpidx[0]);
- hip.addr = ntohl(ip->addr);
- snmp_iptooid(&hip, &arpidx[1]);
- for (tree = 0; tree < 2; tree++)
- {
- /* mark nodes for deletion */
- if (tree == 0)
- {
- at_rn = &arptree_root;
- }
- else
- {
- at_rn = &ipntomtree_root;
- }
- level = 0;
- del_cnt = 0;
- while ((level < 5) && (at_rn != NULL))
- {
- fc = snmp_mib_node_find(at_rn, arpidx[level], &at_n);
- if (fc == 0)
- {
- /* arpidx[level] does not exist */
- del_cnt = 0;
- at_rn = NULL;
- }
- else if (fc == 1)
- {
- del_rn[del_cnt] = at_rn;
- del_n[del_cnt] = at_n;
- del_cnt++;
- at_rn = (struct mib_list_rootnode*)(at_n->nptr);
- }
- else if (fc == 2)
- {
- /* reset delete (2 or more childs) */
- del_cnt = 0;
- at_rn = (struct mib_list_rootnode*)(at_n->nptr);
- }
- level++;
- }
- /* delete marked index nodes */
- while (del_cnt > 0)
- {
- del_cnt--;
- at_rn = del_rn[del_cnt];
- at_n = del_n[del_cnt];
- next = snmp_mib_node_delete(at_rn, at_n);
- if (next != NULL)
- {
- LWIP_ASSERT("next_count == 0",next->count == 0);
- snmp_mib_lrn_free(next);
- }
- }
- }
- /* disable getnext traversal on empty tables */
- if(arptree_root.count == 0) at.maxlength = 0;
- if(ipntomtree_root.count == 0) ipntomtable.maxlength = 0;
- }
- void snmp_inc_ipinreceives(void)
- {
- ipinreceives++;
- }
- void snmp_inc_ipinhdrerrors(void)
- {
- ipinhdrerrors++;
- }
- void snmp_inc_ipinaddrerrors(void)
- {
- ipinaddrerrors++;
- }
- void snmp_inc_ipforwdatagrams(void)
- {
- ipforwdatagrams++;
- }
- void snmp_inc_ipinunknownprotos(void)
- {
- ipinunknownprotos++;
- }
- void snmp_inc_ipindiscards(void)
- {
- ipindiscards++;
- }
- void snmp_inc_ipindelivers(void)
- {
- ipindelivers++;
- }
- void snmp_inc_ipoutrequests(void)
- {
- ipoutrequests++;
- }
- void snmp_inc_ipoutdiscards(void)
- {
- ipoutdiscards++;
- }
- void snmp_inc_ipoutnoroutes(void)
- {
- ipoutnoroutes++;
- }
- void snmp_inc_ipreasmreqds(void)
- {
- ipreasmreqds++;
- }
- void snmp_inc_ipreasmoks(void)
- {
- ipreasmoks++;
- }
- void snmp_inc_ipreasmfails(void)
- {
- ipreasmfails++;
- }
- void snmp_inc_ipfragoks(void)
- {
- ipfragoks++;
- }
- void snmp_inc_ipfragfails(void)
- {
- ipfragfails++;
- }
- void snmp_inc_ipfragcreates(void)
- {
- ipfragcreates++;
- }
- void snmp_inc_iproutingdiscards(void)
- {
- iproutingdiscards++;
- }
- /**
- * Inserts ipAddrTable indexes (.ipAdEntAddr)
- * into index tree.
- */
- void snmp_insert_ipaddridx_tree(struct netif *ni)
- {
- struct mib_list_rootnode *ipa_rn;
- struct mib_list_node *ipa_node;
- struct ip_addr ip;
- s32_t ipaddridx[4];
- u8_t level;
- LWIP_ASSERT("ni != NULL", ni != NULL);
- ip.addr = ntohl(ni->ip_addr.addr);
- snmp_iptooid(&ip, &ipaddridx[0]);
- level = 0;
- ipa_rn = &ipaddrtree_root;
- while (level < 4)
- {
- ipa_node = NULL;
- snmp_mib_node_insert(ipa_rn, ipaddridx[level], &ipa_node);
- if ((level != 3) && (ipa_node != NULL))
- {
- if (ipa_node->nptr == NULL)
- {
- ipa_rn = snmp_mib_lrn_alloc();
- ipa_node->nptr = (struct mib_node*)ipa_rn;
- if (ipa_rn != NULL)
- {
- if (level == 2)
- {
- ipa_rn->get_object_def = ip_addrentry_get_object_def;
- ipa_rn->get_value = ip_addrentry_get_value;
- ipa_rn->set_test = noleafs_set_test;
- ipa_rn->set_value = noleafs_set_value;
- }
- }
- else
- {
- /* ipa_rn == NULL, malloc failure */
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_ipaddridx_tree() insert failed, mem full"));
- break;
- }
- }
- else
- {
- ipa_rn = (struct mib_list_rootnode*)ipa_node->nptr;
- }
- }
- level++;
- }
- /* enable getnext traversal on filled table */
- ipaddrtable.maxlength = 1;
- }
- /**
- * Removes ipAddrTable indexes (.ipAdEntAddr)
- * from index tree.
- */
- void snmp_delete_ipaddridx_tree(struct netif *ni)
- {
- struct mib_list_rootnode *ipa_rn, *next, *del_rn[4];
- struct mib_list_node *ipa_n, *del_n[4];
- struct ip_addr ip;
- s32_t ipaddridx[4];
- u8_t fc, level, del_cnt;
- LWIP_ASSERT("ni != NULL", ni != NULL);
- ip.addr = ntohl(ni->ip_addr.addr);
- snmp_iptooid(&ip, &ipaddridx[0]);
- /* mark nodes for deletion */
- level = 0;
- del_cnt = 0;
- ipa_rn = &ipaddrtree_root;
- while ((level < 4) && (ipa_rn != NULL))
- {
- fc = snmp_mib_node_find(ipa_rn, ipaddridx[level], &ipa_n);
- if (fc == 0)
- {
- /* ipaddridx[level] does not exist */
- del_cnt = 0;
- ipa_rn = NULL;
- }
- else if (fc == 1)
- {
- del_rn[del_cnt] = ipa_rn;
- del_n[del_cnt] = ipa_n;
- del_cnt++;
- ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr);
- }
- else if (fc == 2)
- {
- /* reset delete (2 or more childs) */
- del_cnt = 0;
- ipa_rn = (struct mib_list_rootnode*)(ipa_n->nptr);
- }
- level++;
- }
- /* delete marked index nodes */
- while (del_cnt > 0)
- {
- del_cnt--;
- ipa_rn = del_rn[del_cnt];
- ipa_n = del_n[del_cnt];
- next = snmp_mib_node_delete(ipa_rn, ipa_n);
- if (next != NULL)
- {
- LWIP_ASSERT("next_count == 0",next->count == 0);
- snmp_mib_lrn_free(next);
- }
- }
- /* disable getnext traversal on empty table */
- if (ipaddrtree_root.count == 0) ipaddrtable.maxlength = 0;
- }
- /**
- * Inserts ipRouteTable indexes (.ipRouteDest)
- * into index tree.
- *
- * @param dflt non-zero for the default rte, zero for network rte
- * @param ni points to network interface for this rte
- *
- * @todo record sysuptime for _this_ route when it is installed
- * (needed for ipRouteAge) in the netif.
- */
- void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni)
- {
- u8_t insert = 0;
- struct ip_addr dst;
- if (dflt != 0)
- {
- /* the default route 0.0.0.0 */
- dst.addr = 0;
- insert = 1;
- }
- else
- {
- /* route to the network address */
- dst.addr = ntohl(ni->ip_addr.addr & ni->netmask.addr);
- /* exclude 0.0.0.0 network (reserved for default rte) */
- if (dst.addr != 0) insert = 1;
- }
- if (insert)
- {
- struct mib_list_rootnode *iprte_rn;
- struct mib_list_node *iprte_node;
- s32_t iprteidx[4];
- u8_t level;
- snmp_iptooid(&dst, &iprteidx[0]);
- level = 0;
- iprte_rn = &iprtetree_root;
- while (level < 4)
- {
- iprte_node = NULL;
- snmp_mib_node_insert(iprte_rn, iprteidx[level], &iprte_node);
- if ((level != 3) && (iprte_node != NULL))
- {
- if (iprte_node->nptr == NULL)
- {
- iprte_rn = snmp_mib_lrn_alloc();
- iprte_node->nptr = (struct mib_node*)iprte_rn;
- if (iprte_rn != NULL)
- {
- if (level == 2)
- {
- iprte_rn->get_object_def = ip_rteentry_get_object_def;
- iprte_rn->get_value = ip_rteentry_get_value;
- iprte_rn->set_test = noleafs_set_test;
- iprte_rn->set_value = noleafs_set_value;
- }
- }
- else
- {
- /* iprte_rn == NULL, malloc failure */
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_iprteidx_tree() insert failed, mem full"));
- break;
- }
- }
- else
- {
- iprte_rn = (struct mib_list_rootnode*)iprte_node->nptr;
- }
- }
- level++;
- }
- }
- /* enable getnext traversal on filled table */
- iprtetable.maxlength = 1;
- }
- /**
- * Removes ipRouteTable indexes (.ipRouteDest)
- * from index tree.
- *
- * @param dflt non-zero for the default rte, zero for network rte
- * @param ni points to network interface for this rte or NULL
- * for default route to be removed.
- */
- void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni)
- {
- u8_t delete = 0;
- struct ip_addr dst;
- if (dflt != 0)
- {
- /* the default route 0.0.0.0 */
- dst.addr = 0;
- delete = 1;
- }
- else
- {
- /* route to the network address */
- dst.addr = ntohl(ni->ip_addr.addr & ni->netmask.addr);
- /* exclude 0.0.0.0 network (reserved for default rte) */
- if (dst.addr != 0) delete = 1;
- }
- if (delete)
- {
- struct mib_list_rootnode *iprte_rn, *next, *del_rn[4];
- struct mib_list_node *iprte_n, *del_n[4];
- s32_t iprteidx[4];
- u8_t fc, level, del_cnt;
- snmp_iptooid(&dst, &iprteidx[0]);
- /* mark nodes for deletion */
- level = 0;
- del_cnt = 0;
- iprte_rn = &iprtetree_root;
- while ((level < 4) && (iprte_rn != NULL))
- {
- fc = snmp_mib_node_find(iprte_rn, iprteidx[level], &iprte_n);
- if (fc == 0)
- {
- /* iprteidx[level] does not exist */
- del_cnt = 0;
- iprte_rn = NULL;
- }
- else if (fc == 1)
- {
- del_rn[del_cnt] = iprte_rn;
- del_n[del_cnt] = iprte_n;
- del_cnt++;
- iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr);
- }
- else if (fc == 2)
- {
- /* reset delete (2 or more childs) */
- del_cnt = 0;
- iprte_rn = (struct mib_list_rootnode*)(iprte_n->nptr);
- }
- level++;
- }
- /* delete marked index nodes */
- while (del_cnt > 0)
- {
- del_cnt--;
- iprte_rn = del_rn[del_cnt];
- iprte_n = del_n[del_cnt];
- next = snmp_mib_node_delete(iprte_rn, iprte_n);
- if (next != NULL)
- {
- LWIP_ASSERT("next_count == 0",next->count == 0);
- snmp_mib_lrn_free(next);
- }
- }
- }
- /* disable getnext traversal on empty table */
- if (iprtetree_root.count == 0) iprtetable.maxlength = 0;
- }
- void snmp_inc_icmpinmsgs(void)
- {
- icmpinmsgs++;
- }
- void snmp_inc_icmpinerrors(void)
- {
- icmpinerrors++;
- }
- void snmp_inc_icmpindestunreachs(void)
- {
- icmpindestunreachs++;
- }
- void snmp_inc_icmpintimeexcds(void)
- {
- icmpintimeexcds++;
- }
- void snmp_inc_icmpinparmprobs(void)
- {
- icmpinparmprobs++;
- }
- void snmp_inc_icmpinsrcquenchs(void)
- {
- icmpinsrcquenchs++;
- }
- void snmp_inc_icmpinredirects(void)
- {
- icmpinredirects++;
- }
- void snmp_inc_icmpinechos(void)
- {
- icmpinechos++;
- }
- void snmp_inc_icmpinechoreps(void)
- {
- icmpinechoreps++;
- }
- void snmp_inc_icmpintimestamps(void)
- {
- icmpintimestamps++;
- }
- void snmp_inc_icmpintimestampreps(void)
- {
- icmpintimestampreps++;
- }
- void snmp_inc_icmpinaddrmasks(void)
- {
- icmpinaddrmasks++;
- }
- void snmp_inc_icmpinaddrmaskreps(void)
- {
- icmpinaddrmaskreps++;
- }
- void snmp_inc_icmpoutmsgs(void)
- {
- icmpoutmsgs++;
- }
- void snmp_inc_icmpouterrors(void)
- {
- icmpouterrors++;
- }
- void snmp_inc_icmpoutdestunreachs(void)
- {
- icmpoutdestunreachs++;
- }
- void snmp_inc_icmpouttimeexcds(void)
- {
- icmpouttimeexcds++;
- }
- void snmp_inc_icmpoutparmprobs(void)
- {
- icmpoutparmprobs++;
- }
- void snmp_inc_icmpoutsrcquenchs(void)
- {
- icmpoutsrcquenchs++;
- }
- void snmp_inc_icmpoutredirects(void)
- {
- icmpoutredirects++;
- }
- void snmp_inc_icmpoutechos(void)
- {
- icmpoutechos++;
- }
- void snmp_inc_icmpoutechoreps(void)
- {
- icmpoutechoreps++;
- }
- void snmp_inc_icmpouttimestamps(void)
- {
- icmpouttimestamps++;
- }
- void snmp_inc_icmpouttimestampreps(void)
- {
- icmpouttimestampreps++;
- }
- void snmp_inc_icmpoutaddrmasks(void)
- {
- icmpoutaddrmasks++;
- }
- void snmp_inc_icmpoutaddrmaskreps(void)
- {
- icmpoutaddrmaskreps++;
- }
- void snmp_inc_tcpactiveopens(void)
- {
- tcpactiveopens++;
- }
- void snmp_inc_tcppassiveopens(void)
- {
- tcppassiveopens++;
- }
- void snmp_inc_tcpattemptfails(void)
- {
- tcpattemptfails++;
- }
- void snmp_inc_tcpestabresets(void)
- {
- tcpestabresets++;
- }
- void snmp_inc_tcpinsegs(void)
- {
- tcpinsegs++;
- }
- void snmp_inc_tcpoutsegs(void)
- {
- tcpoutsegs++;
- }
- void snmp_inc_tcpretranssegs(void)
- {
- tcpretranssegs++;
- }
- void snmp_inc_tcpinerrs(void)
- {
- tcpinerrs++;
- }
- void snmp_inc_tcpoutrsts(void)
- {
- tcpoutrsts++;
- }
- void snmp_inc_udpindatagrams(void)
- {
- udpindatagrams++;
- }
- void snmp_inc_udpnoports(void)
- {
- udpnoports++;
- }
- void snmp_inc_udpinerrors(void)
- {
- udpinerrors++;
- }
- void snmp_inc_udpoutdatagrams(void)
- {
- udpoutdatagrams++;
- }
- /**
- * Inserts udpTable indexes (.udpLocalAddress.udpLocalPort)
- * into index tree.
- */
- void snmp_insert_udpidx_tree(struct udp_pcb *pcb)
- {
- struct mib_list_rootnode *udp_rn;
- struct mib_list_node *udp_node;
- struct ip_addr ip;
- s32_t udpidx[5];
- u8_t level;
- LWIP_ASSERT("pcb != NULL", pcb != NULL);
- ip.addr = ntohl(pcb->local_ip.addr);
- snmp_iptooid(&ip, &udpidx[0]);
- udpidx[4] = pcb->local_port;
- udp_rn = &udp_root;
- for (level = 0; level < 5; level++)
- {
- udp_node = NULL;
- snmp_mib_node_insert(udp_rn, udpidx[level], &udp_node);
- if ((level != 4) && (udp_node != NULL))
- {
- if (udp_node->nptr == NULL)
- {
- udp_rn = snmp_mib_lrn_alloc();
- udp_node->nptr = (struct mib_node*)udp_rn;
- if (udp_rn != NULL)
- {
- if (level == 3)
- {
- udp_rn->get_object_def = udpentry_get_object_def;
- udp_rn->get_value = udpentry_get_value;
- udp_rn->set_test = noleafs_set_test;
- udp_rn->set_value = noleafs_set_value;
- }
- }
- else
- {
- /* udp_rn == NULL, malloc failure */
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_insert_udpidx_tree() insert failed, mem full"));
- break;
- }
- }
- else
- {
- udp_rn = (struct mib_list_rootnode*)udp_node->nptr;
- }
- }
- }
- udptable.maxlength = 1;
- }
- /**
- * Removes udpTable indexes (.udpLocalAddress.udpLocalPort)
- * from index tree.
- */
- void snmp_delete_udpidx_tree(struct udp_pcb *pcb)
- {
- struct mib_list_rootnode *udp_rn, *next, *del_rn[5];
- struct mib_list_node *udp_n, *del_n[5];
- struct ip_addr ip;
- s32_t udpidx[5];
- u8_t bindings, fc, level, del_cnt;
- LWIP_ASSERT("pcb != NULL", pcb != NULL);
- ip.addr = ntohl(pcb->local_ip.addr);
- snmp_iptooid(&ip, &udpidx[0]);
- udpidx[4] = pcb->local_port;
- /* count PCBs for a given binding
- (e.g. when reusing ports or for temp output PCBs) */
- bindings = 0;
- pcb = udp_pcbs;
- while ((pcb != NULL))
- {
- if ((pcb->local_ip.addr == ip.addr) &&
- (pcb->local_port == udpidx[4]))
- {
- bindings++;
- }
- pcb = pcb->next;
- }
- if (bindings == 1)
- {
- /* selectively remove */
- /* mark nodes for deletion */
- level = 0;
- del_cnt = 0;
- udp_rn = &udp_root;
- while ((level < 5) && (udp_rn != NULL))
- {
- fc = snmp_mib_node_find(udp_rn, udpidx[level], &udp_n);
- if (fc == 0)
- {
- /* udpidx[level] does not exist */
- del_cnt = 0;
- udp_rn = NULL;
- }
- else if (fc == 1)
- {
- del_rn[del_cnt] = udp_rn;
- del_n[del_cnt] = udp_n;
- del_cnt++;
- udp_rn = (struct mib_list_rootnode*)(udp_n->nptr);
- }
- else if (fc == 2)
- {
- /* reset delete (2 or more childs) */
- del_cnt = 0;
- udp_rn = (struct mib_list_rootnode*)(udp_n->nptr);
- }
- level++;
- }
- /* delete marked index nodes */
- while (del_cnt > 0)
- {
- del_cnt--;
- udp_rn = del_rn[del_cnt];
- udp_n = del_n[del_cnt];
- next = snmp_mib_node_delete(udp_rn, udp_n);
- if (next != NULL)
- {
- LWIP_ASSERT("next_count == 0",next->count == 0);
- snmp_mib_lrn_free(next);
- }
- }
- }
- /* disable getnext traversal on empty table */
- if (udp_root.count == 0) udptable.maxlength = 0;
- }
- void snmp_inc_snmpinpkts(void)
- {
- snmpinpkts++;
- }
- void snmp_inc_snmpoutpkts(void)
- {
- snmpoutpkts++;
- }
- void snmp_inc_snmpinbadversions(void)
- {
- snmpinbadversions++;
- }
- void snmp_inc_snmpinbadcommunitynames(void)
- {
- snmpinbadcommunitynames++;
- }
- void snmp_inc_snmpinbadcommunityuses(void)
- {
- snmpinbadcommunityuses++;
- }
- void snmp_inc_snmpinasnparseerrs(void)
- {
- snmpinasnparseerrs++;
- }
- void snmp_inc_snmpintoobigs(void)
- {
- snmpintoobigs++;
- }
- void snmp_inc_snmpinnosuchnames(void)
- {
- snmpinnosuchnames++;
- }
- void snmp_inc_snmpinbadvalues(void)
- {
- snmpinbadvalues++;
- }
- void snmp_inc_snmpinreadonlys(void)
- {
- snmpinreadonlys++;
- }
- void snmp_inc_snmpingenerrs(void)
- {
- snmpingenerrs++;
- }
- void snmp_add_snmpintotalreqvars(u8_t value)
- {
- snmpintotalreqvars += value;
- }
- void snmp_add_snmpintotalsetvars(u8_t value)
- {
- snmpintotalsetvars += value;
- }
- void snmp_inc_snmpingetrequests(void)
- {
- snmpingetrequests++;
- }
- void snmp_inc_snmpingetnexts(void)
- {
- snmpingetnexts++;
- }
- void snmp_inc_snmpinsetrequests(void)
- {
- snmpinsetrequests++;
- }
- void snmp_inc_snmpingetresponses(void)
- {
- snmpingetresponses++;
- }
- void snmp_inc_snmpintraps(void)
- {
- snmpintraps++;
- }
- void snmp_inc_snmpouttoobigs(void)
- {
- snmpouttoobigs++;
- }
- void snmp_inc_snmpoutnosuchnames(void)
- {
- snmpoutnosuchnames++;
- }
- void snmp_inc_snmpoutbadvalues(void)
- {
- snmpoutbadvalues++;
- }
- void snmp_inc_snmpoutgenerrs(void)
- {
- snmpoutgenerrs++;
- }
- void snmp_inc_snmpoutgetrequests(void)
- {
- snmpoutgetrequests++;
- }
- void snmp_inc_snmpoutgetnexts(void)
- {
- snmpoutgetnexts++;
- }
- void snmp_inc_snmpoutsetrequests(void)
- {
- snmpoutsetrequests++;
- }
- void snmp_inc_snmpoutgetresponses(void)
- {
- snmpoutgetresponses++;
- }
- void snmp_inc_snmpouttraps(void)
- {
- snmpouttraps++;
- }
- void snmp_get_snmpgrpid_ptr(struct snmp_obj_id **oid)
- {
- *oid = &snmpgrp_id;
- }
- void snmp_set_snmpenableauthentraps(u8_t *value)
- {
- if (value != NULL)
- {
- snmpenableauthentraps_ptr = value;
- }
- }
- void snmp_get_snmpenableauthentraps(u8_t *value)
- {
- *value = *snmpenableauthentraps_ptr;
- }
- void
- noleafs_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- LWIP_UNUSED_ARG(ident_len);
- LWIP_UNUSED_ARG(ident);
- od->instance = MIB_OBJECT_NONE;
- }
- void
- noleafs_get_value(struct obj_def *od, u16_t len, void *value)
- {
- LWIP_UNUSED_ARG(od);
- LWIP_UNUSED_ARG(len);
- LWIP_UNUSED_ARG(value);
- }
- u8_t
- noleafs_set_test(struct obj_def *od, u16_t len, void *value)
- {
- LWIP_UNUSED_ARG(od);
- LWIP_UNUSED_ARG(len);
- LWIP_UNUSED_ARG(value);
- /* can't set */
- return 0;
- }
- void
- noleafs_set_value(struct obj_def *od, u16_t len, void *value)
- {
- LWIP_UNUSED_ARG(od);
- LWIP_UNUSED_ARG(len);
- LWIP_UNUSED_ARG(value);
- }
- /**
- * Returns systems object definitions.
- *
- * @param ident_len the address length (2)
- * @param ident points to objectname.0 (object id trailer)
- * @param od points to object definition.
- */
- static void
- system_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- u8_t id;
- /* return to object name, adding index depth (1) */
- ident_len += 1;
- ident -= 1;
- if (ident_len == 2)
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def system.%"U16_F".0\n",(u16_t)id));
- switch (id)
- {
- case 1: /* sysDescr */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
- od->v_len = *sysdescr_len_ptr;
- break;
- case 2: /* sysObjectID */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
- od->v_len = sysobjid.len * sizeof(s32_t);
- break;
- case 3: /* sysUpTime */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS);
- od->v_len = sizeof(u32_t);
- break;
- case 4: /* sysContact */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
- od->v_len = *syscontact_len_ptr;
- break;
- case 5: /* sysName */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
- od->v_len = *sysname_len_ptr;
- break;
- case 6: /* sysLocation */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
- od->v_len = *syslocation_len_ptr;
- break;
- case 7: /* sysServices */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- };
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- /**
- * Returns system object value.
- *
- * @param ident_len the address length (2)
- * @param ident points to objectname.0 (object id trailer)
- * @param len return value space (in bytes)
- * @param value points to (varbind) space to copy value into.
- */
- static void
- system_get_value(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id;
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* sysDescr */
- ocstrncpy(value,sysdescr_ptr, len);
- break;
- case 2: /* sysObjectID */
- objectidncpy((s32_t*)value, (s32_t*)sysobjid.id, (u8_t)(len / sizeof(s32_t)));
- break;
- case 3: /* sysUpTime */
- {
- snmp_get_sysuptime(value);
- }
- break;
- case 4: /* sysContact */
- ocstrncpy(value,syscontact_ptr,len);
- break;
- case 5: /* sysName */
- ocstrncpy(value,sysname_ptr,len);
- break;
- case 6: /* sysLocation */
- ocstrncpy(value,syslocation_ptr,len);
- break;
- case 7: /* sysServices */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = sysservices;
- }
- break;
- };
- }
- static u8_t
- system_set_test(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id, set_ok;
- LWIP_UNUSED_ARG(value);
- set_ok = 0;
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 4: /* sysContact */
- if ((syscontact_ptr != syscontact_default) &&
- (len <= 255))
- {
- set_ok = 1;
- }
- break;
- case 5: /* sysName */
- if ((sysname_ptr != sysname_default) &&
- (len <= 255))
- {
- set_ok = 1;
- }
- break;
- case 6: /* sysLocation */
- if ((syslocation_ptr != syslocation_default) &&
- (len <= 255))
- {
- set_ok = 1;
- }
- break;
- };
- return set_ok;
- }
- static void
- system_set_value(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id;
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 4: /* sysContact */
- ocstrncpy(syscontact_ptr,value,len);
- *syscontact_len_ptr = len;
- break;
- case 5: /* sysName */
- ocstrncpy(sysname_ptr,value,len);
- *sysname_len_ptr = len;
- break;
- case 6: /* sysLocation */
- ocstrncpy(syslocation_ptr,value,len);
- *syslocation_len_ptr = len;
- break;
- };
- }
- /**
- * Returns interfaces.ifnumber object definition.
- *
- * @param ident_len the address length (2)
- * @param ident points to objectname.index
- * @param od points to object definition.
- */
- static void
- interfaces_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (1) */
- ident_len += 1;
- ident -= 1;
- if (ident_len == 2)
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("interfaces_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- /**
- * Returns interfaces.ifnumber object value.
- *
- * @param ident_len the address length (2)
- * @param ident points to objectname.0 (object id trailer)
- * @param len return value space (in bytes)
- * @param value points to (varbind) space to copy value into.
- */
- static void
- interfaces_get_value(struct obj_def *od, u16_t len, void *value)
- {
- LWIP_UNUSED_ARG(len);
- if (od->id_inst_ptr[0] == 1)
- {
- s32_t *sint_ptr = value;
- *sint_ptr = iflist_root.count;
- }
- }
- /**
- * Returns ifentry object definitions.
- *
- * @param ident_len the address length (2)
- * @param ident points to objectname.index
- * @param od points to object definition.
- */
- static void
- ifentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- u8_t id;
- /* return to object name, adding index depth (1) */
- ident_len += 1;
- ident -= 1;
- if (ident_len == 2)
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ifentry.%"U16_F"\n",(u16_t)id));
- switch (id)
- {
- case 1: /* ifIndex */
- case 3: /* ifType */
- case 4: /* ifMtu */
- case 8: /* ifOperStatus */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 2: /* ifDescr */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
- /** @todo this should be some sort of sizeof(struct netif.name) */
- od->v_len = 2;
- break;
- case 5: /* ifSpeed */
- case 21: /* ifOutQLen */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE);
- od->v_len = sizeof(u32_t);
- break;
- case 6: /* ifPhysAddress */
- {
- struct netif *netif;
- snmp_ifindextonetif(ident[1], &netif);
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
- od->v_len = netif->hwaddr_len;
- }
- break;
- case 7: /* ifAdminStatus */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 9: /* ifLastChange */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_TIMETICKS);
- od->v_len = sizeof(u32_t);
- break;
- case 10: /* ifInOctets */
- case 11: /* ifInUcastPkts */
- case 12: /* ifInNUcastPkts */
- case 13: /* ifInDiscarts */
- case 14: /* ifInErrors */
- case 15: /* ifInUnkownProtos */
- case 16: /* ifOutOctets */
- case 17: /* ifOutUcastPkts */
- case 18: /* ifOutNUcastPkts */
- case 19: /* ifOutDiscarts */
- case 20: /* ifOutErrors */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
- od->v_len = sizeof(u32_t);
- break;
- case 22: /* ifSpecific */
- /** @note returning zeroDotZero (0.0) no media specific MIB support */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
- od->v_len = ifspecific.len * sizeof(s32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- };
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ifentry_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- /**
- * Returns ifentry object value.
- *
- * @param ident_len the address length (2)
- * @param ident points to objectname.0 (object id trailer)
- * @param len return value space (in bytes)
- * @param value points to (varbind) space to copy value into.
- */
- static void
- ifentry_get_value(struct obj_def *od, u16_t len, void *value)
- {
- struct netif *netif;
- u8_t id;
- snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* ifIndex */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = od->id_inst_ptr[1];
- }
- break;
- case 2: /* ifDescr */
- ocstrncpy(value,(u8_t*)netif->name,len);
- break;
- case 3: /* ifType */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = netif->link_type;
- }
- break;
- case 4: /* ifMtu */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = netif->mtu;
- }
- break;
- case 5: /* ifSpeed */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->link_speed;
- }
- break;
- case 6: /* ifPhysAddress */
- ocstrncpy(value,netif->hwaddr,len);
- break;
- case 7: /* ifAdminStatus */
- #if LWIP_NETIF_LINK_CALLBACK
- {
- s32_t *sint_ptr = value;
- if (netif_is_up(netif))
- {
- if (netif_is_link_up(netif))
- {
- *sint_ptr = 1; /* up */
- }
- else
- {
- *sint_ptr = 7; /* lowerLayerDown */
- }
- }
- else
- {
- *sint_ptr = 2; /* down */
- }
- }
- break;
- #endif
- case 8: /* ifOperStatus */
- {
- s32_t *sint_ptr = value;
- if (netif_is_up(netif))
- {
- *sint_ptr = 1;
- }
- else
- {
- *sint_ptr = 2;
- }
- }
- break;
- case 9: /* ifLastChange */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ts;
- }
- break;
- case 10: /* ifInOctets */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ifinoctets;
- }
- break;
- case 11: /* ifInUcastPkts */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ifinucastpkts;
- }
- break;
- case 12: /* ifInNUcastPkts */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ifinnucastpkts;
- }
- break;
- case 13: /* ifInDiscarts */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ifindiscards;
- }
- break;
- case 14: /* ifInErrors */
- case 15: /* ifInUnkownProtos */
- /** @todo add these counters! */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = 0;
- }
- break;
- case 16: /* ifOutOctets */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ifoutoctets;
- }
- break;
- case 17: /* ifOutUcastPkts */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ifoutucastpkts;
- }
- break;
- case 18: /* ifOutNUcastPkts */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ifoutnucastpkts;
- }
- break;
- case 19: /* ifOutDiscarts */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = netif->ifoutdiscards;
- }
- break;
- case 20: /* ifOutErrors */
- /** @todo add this counter! */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = 0;
- }
- break;
- case 21: /* ifOutQLen */
- /** @todo figure out if this must be 0 (no queue) or 1? */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = 0;
- }
- break;
- case 22: /* ifSpecific */
- objectidncpy((s32_t*)value, (s32_t*)ifspecific.id, (u8_t)(len / sizeof(s32_t)));
- break;
- };
- }
- #if !SNMP_SAFE_REQUESTS
- static u8_t
- ifentry_set_test (struct obj_def *od, u16_t len, void *value)
- {
- struct netif *netif;
- u8_t id, set_ok;
- set_ok = 0;
- snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 7: /* ifAdminStatus */
- {
- s32_t *sint_ptr = value;
- if (*sint_ptr == 1 || *sint_ptr == 2)
- set_ok = 1;
- }
- break;
- }
- return set_ok;
- }
- static void
- ifentry_set_value (struct obj_def *od, u16_t len, void *value)
- {
- struct netif *netif;
- u8_t id;
- snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 7: /* ifAdminStatus */
- {
- s32_t *sint_ptr = value;
- if (*sint_ptr == 1)
- {
- netif_set_up(netif);
- }
- else if (*sint_ptr == 2)
- {
- netif_set_down(netif);
- }
- }
- break;
- }
- }
- #endif /* SNMP_SAFE_REQUESTS */
- /**
- * Returns atentry object definitions.
- *
- * @param ident_len the address length (6)
- * @param ident points to objectname.atifindex.atnetaddress
- * @param od points to object definition.
- */
- static void
- atentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (5) */
- ident_len += 5;
- ident -= 5;
- if (ident_len == 6)
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- switch (ident[0])
- {
- case 1: /* atIfIndex */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 2: /* atPhysAddress */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
- od->v_len = 6; /** @todo try to use netif::hwaddr_len */
- break;
- case 3: /* atNetAddress */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
- od->v_len = 4;
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- }
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("atentry_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- atentry_get_value(struct obj_def *od, u16_t len, void *value)
- {
- #if LWIP_ARP
- u8_t id;
- struct eth_addr* ethaddr_ret;
- struct ip_addr* ipaddr_ret;
- #endif /* LWIP_ARP */
- struct ip_addr ip;
- struct netif *netif;
- LWIP_UNUSED_ARG(len);
- LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */
- snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
- snmp_oidtoip(&od->id_inst_ptr[2], &ip);
- ip.addr = htonl(ip.addr);
- #if LWIP_ARP /** @todo implement a netif_find_addr */
- if (etharp_find_addr(netif, &ip, ðaddr_ret, &ipaddr_ret) > -1)
- {
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* atIfIndex */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = od->id_inst_ptr[1];
- }
- break;
- case 2: /* atPhysAddress */
- {
- struct eth_addr *dst = value;
- *dst = *ethaddr_ret;
- }
- break;
- case 3: /* atNetAddress */
- {
- struct ip_addr *dst = value;
- *dst = *ipaddr_ret;
- }
- break;
- }
- }
- #endif /* LWIP_ARP */
- }
- static void
- ip_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- u8_t id;
- /* return to object name, adding index depth (1) */
- ident_len += 1;
- ident -= 1;
- if (ident_len == 2)
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def ip.%"U16_F".0\n",(u16_t)id));
- switch (id)
- {
- case 1: /* ipForwarding */
- case 2: /* ipDefaultTTL */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 3: /* ipInReceives */
- case 4: /* ipInHdrErrors */
- case 5: /* ipInAddrErrors */
- case 6: /* ipForwDatagrams */
- case 7: /* ipInUnknownProtos */
- case 8: /* ipInDiscards */
- case 9: /* ipInDelivers */
- case 10: /* ipOutRequests */
- case 11: /* ipOutDiscards */
- case 12: /* ipOutNoRoutes */
- case 14: /* ipReasmReqds */
- case 15: /* ipReasmOKs */
- case 16: /* ipReasmFails */
- case 17: /* ipFragOKs */
- case 18: /* ipFragFails */
- case 19: /* ipFragCreates */
- case 23: /* ipRoutingDiscards */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
- od->v_len = sizeof(u32_t);
- break;
- case 13: /* ipReasmTimeout */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- };
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- ip_get_value(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id;
- LWIP_UNUSED_ARG(len);
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* ipForwarding */
- {
- s32_t *sint_ptr = value;
- #if IP_FORWARD
- /* forwarding */
- *sint_ptr = 1;
- #else
- /* not-forwarding */
- *sint_ptr = 2;
- #endif
- }
- break;
- case 2: /* ipDefaultTTL */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = IP_DEFAULT_TTL;
- }
- break;
- case 3: /* ipInReceives */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipinreceives;
- }
- break;
- case 4: /* ipInHdrErrors */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipinhdrerrors;
- }
- break;
- case 5: /* ipInAddrErrors */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipinaddrerrors;
- }
- break;
- case 6: /* ipForwDatagrams */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipforwdatagrams;
- }
- break;
- case 7: /* ipInUnknownProtos */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipinunknownprotos;
- }
- break;
- case 8: /* ipInDiscards */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipindiscards;
- }
- break;
- case 9: /* ipInDelivers */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipindelivers;
- }
- break;
- case 10: /* ipOutRequests */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipoutrequests;
- }
- break;
- case 11: /* ipOutDiscards */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipoutdiscards;
- }
- break;
- case 12: /* ipOutNoRoutes */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipoutnoroutes;
- }
- break;
- case 13: /* ipReasmTimeout */
- {
- s32_t *sint_ptr = value;
- #if IP_REASSEMBLY
- *sint_ptr = IP_REASS_MAXAGE;
- #else
- *sint_ptr = 0;
- #endif
- }
- break;
- case 14: /* ipReasmReqds */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipreasmreqds;
- }
- break;
- case 15: /* ipReasmOKs */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipreasmoks;
- }
- break;
- case 16: /* ipReasmFails */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipreasmfails;
- }
- break;
- case 17: /* ipFragOKs */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipfragoks;
- }
- break;
- case 18: /* ipFragFails */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipfragfails;
- }
- break;
- case 19: /* ipFragCreates */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = ipfragcreates;
- }
- break;
- case 23: /* ipRoutingDiscards */
- /** @todo can lwIP discard routes at all?? hardwire this to 0?? */
- {
- u32_t *uint_ptr = value;
- *uint_ptr = iproutingdiscards;
- }
- break;
- };
- }
- /**
- * Test ip object value before setting.
- *
- * @param od is the object definition
- * @param len return value space (in bytes)
- * @param value points to (varbind) space to copy value from.
- *
- * @note we allow set if the value matches the hardwired value,
- * otherwise return badvalue.
- */
- static u8_t
- ip_set_test(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id, set_ok;
- s32_t *sint_ptr = value;
- LWIP_UNUSED_ARG(len);
- set_ok = 0;
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* ipForwarding */
- #if IP_FORWARD
- /* forwarding */
- if (*sint_ptr == 1)
- #else
- /* not-forwarding */
- if (*sint_ptr == 2)
- #endif
- {
- set_ok = 1;
- }
- break;
- case 2: /* ipDefaultTTL */
- if (*sint_ptr == IP_DEFAULT_TTL)
- {
- set_ok = 1;
- }
- break;
- };
- return set_ok;
- }
- static void
- ip_addrentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (4) */
- ident_len += 4;
- ident -= 4;
- if (ident_len == 5)
- {
- u8_t id;
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- switch (id)
- {
- case 1: /* ipAdEntAddr */
- case 3: /* ipAdEntNetMask */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
- od->v_len = 4;
- break;
- case 2: /* ipAdEntIfIndex */
- case 4: /* ipAdEntBcastAddr */
- case 5: /* ipAdEntReasmMaxSize */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- }
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_addrentry_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- ip_addrentry_get_value(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id;
- u16_t ifidx;
- struct ip_addr ip;
- struct netif *netif = netif_list;
- LWIP_UNUSED_ARG(len);
- snmp_oidtoip(&od->id_inst_ptr[1], &ip);
- ip.addr = htonl(ip.addr);
- ifidx = 0;
- while ((netif != NULL) && !ip_addr_cmp(&ip, &netif->ip_addr))
- {
- netif = netif->next;
- ifidx++;
- }
- if (netif != NULL)
- {
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* ipAdEntAddr */
- {
- struct ip_addr *dst = value;
- *dst = netif->ip_addr;
- }
- break;
- case 2: /* ipAdEntIfIndex */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = ifidx + 1;
- }
- break;
- case 3: /* ipAdEntNetMask */
- {
- struct ip_addr *dst = value;
- *dst = netif->netmask;
- }
- break;
- case 4: /* ipAdEntBcastAddr */
- {
- s32_t *sint_ptr = value;
- /* lwIP oddity, there's no broadcast
- address in the netif we can rely on */
- *sint_ptr = ip_addr_broadcast.addr & 1;
- }
- break;
- case 5: /* ipAdEntReasmMaxSize */
- {
- s32_t *sint_ptr = value;
- #if IP_REASSEMBLY
- /* @todo The theoretical maximum is IP_REASS_MAX_PBUFS * size of the pbufs,
- * but only if receiving one fragmented packet at a time.
- * The current solution is to calculate for 2 simultaneous packets...
- */
- *sint_ptr = (IP_HLEN + ((IP_REASS_MAX_PBUFS/2) *
- (PBUF_POOL_BUFSIZE - PBUF_LINK_HLEN - IP_HLEN)));
- #else
- /** @todo returning MTU would be a bad thing and
- returning a wild guess like '576' isn't good either */
- *sint_ptr = 0;
- #endif
- }
- break;
- }
- }
- }
- /**
- * @note
- * lwIP IP routing is currently using the network addresses in netif_list.
- * if no suitable network IP is found in netif_list, the default_netif is used.
- */
- static void
- ip_rteentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- u8_t id;
- /* return to object name, adding index depth (4) */
- ident_len += 4;
- ident -= 4;
- if (ident_len == 5)
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- switch (id)
- {
- case 1: /* ipRouteDest */
- case 7: /* ipRouteNextHop */
- case 11: /* ipRouteMask */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
- od->v_len = 4;
- break;
- case 2: /* ipRouteIfIndex */
- case 3: /* ipRouteMetric1 */
- case 4: /* ipRouteMetric2 */
- case 5: /* ipRouteMetric3 */
- case 6: /* ipRouteMetric4 */
- case 8: /* ipRouteType */
- case 10: /* ipRouteAge */
- case 12: /* ipRouteMetric5 */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 9: /* ipRouteProto */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 13: /* ipRouteInfo */
- /** @note returning zeroDotZero (0.0) no routing protocol specific MIB */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OBJ_ID);
- od->v_len = iprouteinfo.len * sizeof(s32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- }
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_rteentry_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
- {
- struct netif *netif;
- struct ip_addr dest;
- s32_t *ident;
- u8_t id;
- ident = od->id_inst_ptr;
- snmp_oidtoip(&ident[1], &dest);
- dest.addr = htonl(dest.addr);
- if (dest.addr == 0)
- {
- /* ip_route() uses default netif for default route */
- netif = netif_default;
- }
- else
- {
- /* not using ip_route(), need exact match! */
- netif = netif_list;
- while ((netif != NULL) &&
- !ip_addr_netcmp(&dest, &(netif->ip_addr), &(netif->netmask)) )
- {
- netif = netif->next;
- }
- }
- if (netif != NULL)
- {
- id = ident[0];
- switch (id)
- {
- case 1: /* ipRouteDest */
- {
- struct ip_addr *dst = value;
- if (dest.addr == 0)
- {
- /* default rte has 0.0.0.0 dest */
- dst->addr = 0;
- }
- else
- {
- /* netifs have netaddress dest */
- dst->addr = netif->ip_addr.addr & netif->netmask.addr;
- }
- }
- break;
- case 2: /* ipRouteIfIndex */
- {
- s32_t *sint_ptr = value;
- snmp_netiftoifindex(netif, sint_ptr);
- }
- break;
- case 3: /* ipRouteMetric1 */
- {
- s32_t *sint_ptr = value;
- if (dest.addr == 0)
- {
- /* default rte has metric 1 */
- *sint_ptr = 1;
- }
- else
- {
- /* other rtes have metric 0 */
- *sint_ptr = 0;
- }
- }
- break;
- case 4: /* ipRouteMetric2 */
- case 5: /* ipRouteMetric3 */
- case 6: /* ipRouteMetric4 */
- case 12: /* ipRouteMetric5 */
- {
- s32_t *sint_ptr = value;
- /* not used */
- *sint_ptr = -1;
- }
- break;
- case 7: /* ipRouteNextHop */
- {
- struct ip_addr *dst = value;
- if (dest.addr == 0)
- {
- /* default rte: gateway */
- *dst = netif->gw;
- }
- else
- {
- /* other rtes: netif ip_addr */
- *dst = netif->ip_addr;
- }
- }
- break;
- case 8: /* ipRouteType */
- {
- s32_t *sint_ptr = value;
- if (dest.addr == 0)
- {
- /* default rte is indirect */
- *sint_ptr = 4;
- }
- else
- {
- /* other rtes are direct */
- *sint_ptr = 3;
- }
- }
- break;
- case 9: /* ipRouteProto */
- {
- s32_t *sint_ptr = value;
- /* locally defined routes */
- *sint_ptr = 2;
- }
- break;
- case 10: /* ipRouteAge */
- {
- s32_t *sint_ptr = value;
- /** @todo (sysuptime - timestamp last change) / 100
- @see snmp_insert_iprteidx_tree() */
- *sint_ptr = 0;
- }
- break;
- case 11: /* ipRouteMask */
- {
- struct ip_addr *dst = value;
- if (dest.addr == 0)
- {
- /* default rte use 0.0.0.0 mask */
- dst->addr = 0;
- }
- else
- {
- /* other rtes use netmask */
- *dst = netif->netmask;
- }
- }
- break;
- case 13: /* ipRouteInfo */
- objectidncpy((s32_t*)value, (s32_t*)iprouteinfo.id, (u8_t)(len / sizeof(s32_t)));
- break;
- }
- }
- }
- static void
- ip_ntomentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (5) */
- ident_len += 5;
- ident -= 5;
- if (ident_len == 6)
- {
- u8_t id;
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- switch (id)
- {
- case 1: /* ipNetToMediaIfIndex */
- case 4: /* ipNetToMediaType */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 2: /* ipNetToMediaPhysAddress */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_OC_STR);
- od->v_len = 6; /** @todo try to use netif::hwaddr_len */
- break;
- case 3: /* ipNetToMediaNetAddress */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
- od->v_len = 4;
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- }
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("ip_ntomentry_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- ip_ntomentry_get_value(struct obj_def *od, u16_t len, void *value)
- {
- #if LWIP_ARP
- u8_t id;
- struct eth_addr* ethaddr_ret;
- struct ip_addr* ipaddr_ret;
- #endif /* LWIP_ARP */
- struct ip_addr ip;
- struct netif *netif;
- LWIP_UNUSED_ARG(len);
- LWIP_UNUSED_ARG(value);/* if !LWIP_ARP */
- snmp_ifindextonetif(od->id_inst_ptr[1], &netif);
- snmp_oidtoip(&od->id_inst_ptr[2], &ip);
- ip.addr = htonl(ip.addr);
- #if LWIP_ARP /** @todo implement a netif_find_addr */
- if (etharp_find_addr(netif, &ip, ðaddr_ret, &ipaddr_ret) > -1)
- {
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* ipNetToMediaIfIndex */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = od->id_inst_ptr[1];
- }
- break;
- case 2: /* ipNetToMediaPhysAddress */
- {
- struct eth_addr *dst = value;
- *dst = *ethaddr_ret;
- }
- break;
- case 3: /* ipNetToMediaNetAddress */
- {
- struct ip_addr *dst = value;
- *dst = *ipaddr_ret;
- }
- break;
- case 4: /* ipNetToMediaType */
- {
- s32_t *sint_ptr = value;
- /* dynamic (?) */
- *sint_ptr = 3;
- }
- break;
- }
- }
- #endif /* LWIP_ARP */
- }
- static void
- icmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (1) */
- ident_len += 1;
- ident -= 1;
- if ((ident_len == 2) &&
- (ident[0] > 0) && (ident[0] < 27))
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
- od->v_len = sizeof(u32_t);
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("icmp_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- icmp_get_value(struct obj_def *od, u16_t len, void *value)
- {
- u32_t *uint_ptr = value;
- u8_t id;
- LWIP_UNUSED_ARG(len);
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* icmpInMsgs */
- *uint_ptr = icmpinmsgs;
- break;
- case 2: /* icmpInErrors */
- *uint_ptr = icmpinerrors;
- break;
- case 3: /* icmpInDestUnreachs */
- *uint_ptr = icmpindestunreachs;
- break;
- case 4: /* icmpInTimeExcds */
- *uint_ptr = icmpintimeexcds;
- break;
- case 5: /* icmpInParmProbs */
- *uint_ptr = icmpinparmprobs;
- break;
- case 6: /* icmpInSrcQuenchs */
- *uint_ptr = icmpinsrcquenchs;
- break;
- case 7: /* icmpInRedirects */
- *uint_ptr = icmpinredirects;
- break;
- case 8: /* icmpInEchos */
- *uint_ptr = icmpinechos;
- break;
- case 9: /* icmpInEchoReps */
- *uint_ptr = icmpinechoreps;
- break;
- case 10: /* icmpInTimestamps */
- *uint_ptr = icmpintimestamps;
- break;
- case 11: /* icmpInTimestampReps */
- *uint_ptr = icmpintimestampreps;
- break;
- case 12: /* icmpInAddrMasks */
- *uint_ptr = icmpinaddrmasks;
- break;
- case 13: /* icmpInAddrMaskReps */
- *uint_ptr = icmpinaddrmaskreps;
- break;
- case 14: /* icmpOutMsgs */
- *uint_ptr = icmpoutmsgs;
- break;
- case 15: /* icmpOutErrors */
- *uint_ptr = icmpouterrors;
- break;
- case 16: /* icmpOutDestUnreachs */
- *uint_ptr = icmpoutdestunreachs;
- break;
- case 17: /* icmpOutTimeExcds */
- *uint_ptr = icmpouttimeexcds;
- break;
- case 18: /* icmpOutParmProbs */
- *uint_ptr = icmpoutparmprobs;
- break;
- case 19: /* icmpOutSrcQuenchs */
- *uint_ptr = icmpoutsrcquenchs;
- break;
- case 20: /* icmpOutRedirects */
- *uint_ptr = icmpoutredirects;
- break;
- case 21: /* icmpOutEchos */
- *uint_ptr = icmpoutechos;
- break;
- case 22: /* icmpOutEchoReps */
- *uint_ptr = icmpoutechoreps;
- break;
- case 23: /* icmpOutTimestamps */
- *uint_ptr = icmpouttimestamps;
- break;
- case 24: /* icmpOutTimestampReps */
- *uint_ptr = icmpouttimestampreps;
- break;
- case 25: /* icmpOutAddrMasks */
- *uint_ptr = icmpoutaddrmasks;
- break;
- case 26: /* icmpOutAddrMaskReps */
- *uint_ptr = icmpoutaddrmaskreps;
- break;
- }
- }
- #if LWIP_TCP
- /** @todo tcp grp */
- static void
- tcp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- u8_t id;
- /* return to object name, adding index depth (1) */
- ident_len += 1;
- ident -= 1;
- if (ident_len == 2)
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id));
- switch (id)
- {
- case 1: /* tcpRtoAlgorithm */
- case 2: /* tcpRtoMin */
- case 3: /* tcpRtoMax */
- case 4: /* tcpMaxConn */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 5: /* tcpActiveOpens */
- case 6: /* tcpPassiveOpens */
- case 7: /* tcpAttemptFails */
- case 8: /* tcpEstabResets */
- case 10: /* tcpInSegs */
- case 11: /* tcpOutSegs */
- case 12: /* tcpRetransSegs */
- case 14: /* tcpInErrs */
- case 15: /* tcpOutRsts */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
- od->v_len = sizeof(u32_t);
- break;
- case 9: /* tcpCurrEstab */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_GAUGE);
- od->v_len = sizeof(u32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- };
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcp_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- tcp_get_value(struct obj_def *od, u16_t len, void *value)
- {
- u32_t *uint_ptr = value;
- s32_t *sint_ptr = value;
- u8_t id;
- LWIP_UNUSED_ARG(len);
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* tcpRtoAlgorithm, vanj(4) */
- *sint_ptr = 4;
- break;
- case 2: /* tcpRtoMin */
- /* @todo not the actual value, a guess,
- needs to be calculated */
- *sint_ptr = 1000;
- break;
- case 3: /* tcpRtoMax */
- /* @todo not the actual value, a guess,
- needs to be calculated */
- *sint_ptr = 60000;
- break;
- case 4: /* tcpMaxConn */
- *sint_ptr = MEMP_NUM_TCP_PCB;
- break;
- case 5: /* tcpActiveOpens */
- *uint_ptr = tcpactiveopens;
- break;
- case 6: /* tcpPassiveOpens */
- *uint_ptr = tcppassiveopens;
- break;
- case 7: /* tcpAttemptFails */
- *uint_ptr = tcpattemptfails;
- break;
- case 8: /* tcpEstabResets */
- *uint_ptr = tcpestabresets;
- break;
- case 9: /* tcpCurrEstab */
- {
- u16_t tcpcurrestab = 0;
- struct tcp_pcb *pcb = tcp_active_pcbs;
- while (pcb != NULL)
- {
- if ((pcb->state == ESTABLISHED) ||
- (pcb->state == CLOSE_WAIT))
- {
- tcpcurrestab++;
- }
- pcb = pcb->next;
- }
- *uint_ptr = tcpcurrestab;
- }
- break;
- case 10: /* tcpInSegs */
- *uint_ptr = tcpinsegs;
- break;
- case 11: /* tcpOutSegs */
- *uint_ptr = tcpoutsegs;
- break;
- case 12: /* tcpRetransSegs */
- *uint_ptr = tcpretranssegs;
- break;
- case 14: /* tcpInErrs */
- *uint_ptr = tcpinerrs;
- break;
- case 15: /* tcpOutRsts */
- *uint_ptr = tcpoutrsts;
- break;
- }
- }
- #ifdef THIS_SEEMS_UNUSED
- static void
- tcpconnentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (10) */
- ident_len += 10;
- ident -= 10;
- if (ident_len == 11)
- {
- u8_t id;
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("get_object_def tcp.%"U16_F".0\n",(u16_t)id));
- switch (id)
- {
- case 1: /* tcpConnState */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- case 2: /* tcpConnLocalAddress */
- case 4: /* tcpConnRemAddress */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
- od->v_len = 4;
- break;
- case 3: /* tcpConnLocalPort */
- case 5: /* tcpConnRemPort */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- };
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("tcpconnentry_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- tcpconnentry_get_value(struct obj_def *od, u16_t len, void *value)
- {
- struct ip_addr lip, rip;
- u16_t lport, rport;
- s32_t *ident;
- ident = od->id_inst_ptr;
- snmp_oidtoip(&ident[1], &lip);
- lip.addr = htonl(lip.addr);
- lport = ident[5];
- snmp_oidtoip(&ident[6], &rip);
- rip.addr = htonl(rip.addr);
- rport = ident[10];
- /** @todo find matching PCB */
- }
- #endif /* if 0 */
- #endif
- static void
- udp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (1) */
- ident_len += 1;
- ident -= 1;
- if ((ident_len == 2) &&
- (ident[0] > 0) && (ident[0] < 6))
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
- od->v_len = sizeof(u32_t);
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("udp_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- udp_get_value(struct obj_def *od, u16_t len, void *value)
- {
- u32_t *uint_ptr = value;
- u8_t id;
- LWIP_UNUSED_ARG(len);
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* udpInDatagrams */
- *uint_ptr = udpindatagrams;
- break;
- case 2: /* udpNoPorts */
- *uint_ptr = udpnoports;
- break;
- case 3: /* udpInErrors */
- *uint_ptr = udpinerrors;
- break;
- case 4: /* udpOutDatagrams */
- *uint_ptr = udpoutdatagrams;
- break;
- }
- }
- static void
- udpentry_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (5) */
- ident_len += 5;
- ident -= 5;
- if (ident_len == 6)
- {
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- switch (ident[0])
- {
- case 1: /* udpLocalAddress */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_IPADDR);
- od->v_len = 4;
- break;
- case 2: /* udpLocalPort */
- od->instance = MIB_OBJECT_TAB;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- }
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("udpentry_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- udpentry_get_value(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id;
- struct udp_pcb *pcb;
- struct ip_addr ip;
- u16_t port;
- LWIP_UNUSED_ARG(len);
- snmp_oidtoip(&od->id_inst_ptr[1], &ip);
- ip.addr = htonl(ip.addr);
- port = od->id_inst_ptr[5];
- pcb = udp_pcbs;
- while ((pcb != NULL) &&
- !((pcb->local_ip.addr == ip.addr) &&
- (pcb->local_port == port)))
- {
- pcb = pcb->next;
- }
- if (pcb != NULL)
- {
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* udpLocalAddress */
- {
- struct ip_addr *dst = value;
- *dst = pcb->local_ip;
- }
- break;
- case 2: /* udpLocalPort */
- {
- s32_t *sint_ptr = value;
- *sint_ptr = pcb->local_port;
- }
- break;
- }
- }
- }
- static void
- snmp_get_object_def(u8_t ident_len, s32_t *ident, struct obj_def *od)
- {
- /* return to object name, adding index depth (1) */
- ident_len += 1;
- ident -= 1;
- if (ident_len == 2)
- {
- u8_t id;
- od->id_inst_len = ident_len;
- od->id_inst_ptr = ident;
- id = ident[0];
- switch (id)
- {
- case 1: /* snmpInPkts */
- case 2: /* snmpOutPkts */
- case 3: /* snmpInBadVersions */
- case 4: /* snmpInBadCommunityNames */
- case 5: /* snmpInBadCommunityUses */
- case 6: /* snmpInASNParseErrs */
- case 8: /* snmpInTooBigs */
- case 9: /* snmpInNoSuchNames */
- case 10: /* snmpInBadValues */
- case 11: /* snmpInReadOnlys */
- case 12: /* snmpInGenErrs */
- case 13: /* snmpInTotalReqVars */
- case 14: /* snmpInTotalSetVars */
- case 15: /* snmpInGetRequests */
- case 16: /* snmpInGetNexts */
- case 17: /* snmpInSetRequests */
- case 18: /* snmpInGetResponses */
- case 19: /* snmpInTraps */
- case 20: /* snmpOutTooBigs */
- case 21: /* snmpOutNoSuchNames */
- case 22: /* snmpOutBadValues */
- case 24: /* snmpOutGenErrs */
- case 25: /* snmpOutGetRequests */
- case 26: /* snmpOutGetNexts */
- case 27: /* snmpOutSetRequests */
- case 28: /* snmpOutGetResponses */
- case 29: /* snmpOutTraps */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_ONLY;
- od->asn_type = (SNMP_ASN1_APPLIC | SNMP_ASN1_PRIMIT | SNMP_ASN1_COUNTER);
- od->v_len = sizeof(u32_t);
- break;
- case 30: /* snmpEnableAuthenTraps */
- od->instance = MIB_OBJECT_SCALAR;
- od->access = MIB_OBJECT_READ_WRITE;
- od->asn_type = (SNMP_ASN1_UNIV | SNMP_ASN1_PRIMIT | SNMP_ASN1_INTEG);
- od->v_len = sizeof(s32_t);
- break;
- default:
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no such object\n"));
- od->instance = MIB_OBJECT_NONE;
- break;
- };
- }
- else
- {
- LWIP_DEBUGF(SNMP_MIB_DEBUG,("snmp_get_object_def: no scalar\n"));
- od->instance = MIB_OBJECT_NONE;
- }
- }
- static void
- snmp_get_value(struct obj_def *od, u16_t len, void *value)
- {
- u32_t *uint_ptr = value;
- u8_t id;
- LWIP_UNUSED_ARG(len);
- id = od->id_inst_ptr[0];
- switch (id)
- {
- case 1: /* snmpInPkts */
- *uint_ptr = snmpinpkts;
- break;
- case 2: /* snmpOutPkts */
- *uint_ptr = snmpoutpkts;
- break;
- case 3: /* snmpInBadVersions */
- *uint_ptr = snmpinbadversions;
- break;
- case 4: /* snmpInBadCommunityNames */
- *uint_ptr = snmpinbadcommunitynames;
- break;
- case 5: /* snmpInBadCommunityUses */
- *uint_ptr = snmpinbadcommunityuses;
- break;
- case 6: /* snmpInASNParseErrs */
- *uint_ptr = snmpinasnparseerrs;
- break;
- case 8: /* snmpInTooBigs */
- *uint_ptr = snmpintoobigs;
- break;
- case 9: /* snmpInNoSuchNames */
- *uint_ptr = snmpinnosuchnames;
- break;
- case 10: /* snmpInBadValues */
- *uint_ptr = snmpinbadvalues;
- break;
- case 11: /* snmpInReadOnlys */
- *uint_ptr = snmpinreadonlys;
- break;
- case 12: /* snmpInGenErrs */
- *uint_ptr = snmpingenerrs;
- break;
- case 13: /* snmpInTotalReqVars */
- *uint_ptr = snmpintotalreqvars;
- break;
- case 14: /* snmpInTotalSetVars */
- *uint_ptr = snmpintotalsetvars;
- break;
- case 15: /* snmpInGetRequests */
- *uint_ptr = snmpingetrequests;
- break;
- case 16: /* snmpInGetNexts */
- *uint_ptr = snmpingetnexts;
- break;
- case 17: /* snmpInSetRequests */
- *uint_ptr = snmpinsetrequests;
- break;
- case 18: /* snmpInGetResponses */
- *uint_ptr = snmpingetresponses;
- break;
- case 19: /* snmpInTraps */
- *uint_ptr = snmpintraps;
- break;
- case 20: /* snmpOutTooBigs */
- *uint_ptr = snmpouttoobigs;
- break;
- case 21: /* snmpOutNoSuchNames */
- *uint_ptr = snmpoutnosuchnames;
- break;
- case 22: /* snmpOutBadValues */
- *uint_ptr = snmpoutbadvalues;
- break;
- case 24: /* snmpOutGenErrs */
- *uint_ptr = snmpoutgenerrs;
- break;
- case 25: /* snmpOutGetRequests */
- *uint_ptr = snmpoutgetrequests;
- break;
- case 26: /* snmpOutGetNexts */
- *uint_ptr = snmpoutgetnexts;
- break;
- case 27: /* snmpOutSetRequests */
- *uint_ptr = snmpoutsetrequests;
- break;
- case 28: /* snmpOutGetResponses */
- *uint_ptr = snmpoutgetresponses;
- break;
- case 29: /* snmpOutTraps */
- *uint_ptr = snmpouttraps;
- break;
- case 30: /* snmpEnableAuthenTraps */
- *uint_ptr = *snmpenableauthentraps_ptr;
- break;
- };
- }
- /**
- * Test snmp object value before setting.
- *
- * @param od is the object definition
- * @param len return value space (in bytes)
- * @param value points to (varbind) space to copy value from.
- */
- static u8_t
- snmp_set_test(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id, set_ok;
- LWIP_UNUSED_ARG(len);
- set_ok = 0;
- id = od->id_inst_ptr[0];
- if (id == 30)
- {
- /* snmpEnableAuthenTraps */
- s32_t *sint_ptr = value;
- if (snmpenableauthentraps_ptr != &snmpenableauthentraps_default)
- {
- /* we should have writable non-volatile mem here */
- if ((*sint_ptr == 1) || (*sint_ptr == 2))
- {
- set_ok = 1;
- }
- }
- else
- {
- /* const or hardwired value */
- if (*sint_ptr == snmpenableauthentraps_default)
- {
- set_ok = 1;
- }
- }
- }
- return set_ok;
- }
- static void
- snmp_set_value(struct obj_def *od, u16_t len, void *value)
- {
- u8_t id;
- LWIP_UNUSED_ARG(len);
- id = od->id_inst_ptr[0];
- if (id == 30)
- {
- /* snmpEnableAuthenTraps */
- s32_t *sint_ptr = value;
- *snmpenableauthentraps_ptr = *sint_ptr;
- }
- }
- #endif /* LWIP_SNMP */
|