zmsg.go 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615
  1. // Code generated by "go run msg_generate.go"; DO NOT EDIT.
  2. package dns
  3. // pack*() functions
  4. func (rr *A) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  5. off, err := rr.Hdr.pack(msg, off, compression, compress)
  6. if err != nil {
  7. return off, err
  8. }
  9. headerEnd := off
  10. off, err = packDataA(rr.A, msg, off)
  11. if err != nil {
  12. return off, err
  13. }
  14. rr.Header().Rdlength = uint16(off - headerEnd)
  15. return off, nil
  16. }
  17. func (rr *AAAA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  18. off, err := rr.Hdr.pack(msg, off, compression, compress)
  19. if err != nil {
  20. return off, err
  21. }
  22. headerEnd := off
  23. off, err = packDataAAAA(rr.AAAA, msg, off)
  24. if err != nil {
  25. return off, err
  26. }
  27. rr.Header().Rdlength = uint16(off - headerEnd)
  28. return off, nil
  29. }
  30. func (rr *AFSDB) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  31. off, err := rr.Hdr.pack(msg, off, compression, compress)
  32. if err != nil {
  33. return off, err
  34. }
  35. headerEnd := off
  36. off, err = packUint16(rr.Subtype, msg, off)
  37. if err != nil {
  38. return off, err
  39. }
  40. off, err = PackDomainName(rr.Hostname, msg, off, compression, compress)
  41. if err != nil {
  42. return off, err
  43. }
  44. rr.Header().Rdlength = uint16(off - headerEnd)
  45. return off, nil
  46. }
  47. func (rr *ANY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  48. off, err := rr.Hdr.pack(msg, off, compression, compress)
  49. if err != nil {
  50. return off, err
  51. }
  52. headerEnd := off
  53. rr.Header().Rdlength = uint16(off - headerEnd)
  54. return off, nil
  55. }
  56. func (rr *AVC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  57. off, err := rr.Hdr.pack(msg, off, compression, compress)
  58. if err != nil {
  59. return off, err
  60. }
  61. headerEnd := off
  62. off, err = packStringTxt(rr.Txt, msg, off)
  63. if err != nil {
  64. return off, err
  65. }
  66. rr.Header().Rdlength = uint16(off - headerEnd)
  67. return off, nil
  68. }
  69. func (rr *CAA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  70. off, err := rr.Hdr.pack(msg, off, compression, compress)
  71. if err != nil {
  72. return off, err
  73. }
  74. headerEnd := off
  75. off, err = packUint8(rr.Flag, msg, off)
  76. if err != nil {
  77. return off, err
  78. }
  79. off, err = packString(rr.Tag, msg, off)
  80. if err != nil {
  81. return off, err
  82. }
  83. off, err = packStringOctet(rr.Value, msg, off)
  84. if err != nil {
  85. return off, err
  86. }
  87. rr.Header().Rdlength = uint16(off - headerEnd)
  88. return off, nil
  89. }
  90. func (rr *CDNSKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  91. off, err := rr.Hdr.pack(msg, off, compression, compress)
  92. if err != nil {
  93. return off, err
  94. }
  95. headerEnd := off
  96. off, err = packUint16(rr.Flags, msg, off)
  97. if err != nil {
  98. return off, err
  99. }
  100. off, err = packUint8(rr.Protocol, msg, off)
  101. if err != nil {
  102. return off, err
  103. }
  104. off, err = packUint8(rr.Algorithm, msg, off)
  105. if err != nil {
  106. return off, err
  107. }
  108. off, err = packStringBase64(rr.PublicKey, msg, off)
  109. if err != nil {
  110. return off, err
  111. }
  112. rr.Header().Rdlength = uint16(off - headerEnd)
  113. return off, nil
  114. }
  115. func (rr *CDS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  116. off, err := rr.Hdr.pack(msg, off, compression, compress)
  117. if err != nil {
  118. return off, err
  119. }
  120. headerEnd := off
  121. off, err = packUint16(rr.KeyTag, msg, off)
  122. if err != nil {
  123. return off, err
  124. }
  125. off, err = packUint8(rr.Algorithm, msg, off)
  126. if err != nil {
  127. return off, err
  128. }
  129. off, err = packUint8(rr.DigestType, msg, off)
  130. if err != nil {
  131. return off, err
  132. }
  133. off, err = packStringHex(rr.Digest, msg, off)
  134. if err != nil {
  135. return off, err
  136. }
  137. rr.Header().Rdlength = uint16(off - headerEnd)
  138. return off, nil
  139. }
  140. func (rr *CERT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  141. off, err := rr.Hdr.pack(msg, off, compression, compress)
  142. if err != nil {
  143. return off, err
  144. }
  145. headerEnd := off
  146. off, err = packUint16(rr.Type, msg, off)
  147. if err != nil {
  148. return off, err
  149. }
  150. off, err = packUint16(rr.KeyTag, msg, off)
  151. if err != nil {
  152. return off, err
  153. }
  154. off, err = packUint8(rr.Algorithm, msg, off)
  155. if err != nil {
  156. return off, err
  157. }
  158. off, err = packStringBase64(rr.Certificate, msg, off)
  159. if err != nil {
  160. return off, err
  161. }
  162. rr.Header().Rdlength = uint16(off - headerEnd)
  163. return off, nil
  164. }
  165. func (rr *CNAME) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  166. off, err := rr.Hdr.pack(msg, off, compression, compress)
  167. if err != nil {
  168. return off, err
  169. }
  170. headerEnd := off
  171. off, err = PackDomainName(rr.Target, msg, off, compression, compress)
  172. if err != nil {
  173. return off, err
  174. }
  175. rr.Header().Rdlength = uint16(off - headerEnd)
  176. return off, nil
  177. }
  178. func (rr *CSYNC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  179. off, err := rr.Hdr.pack(msg, off, compression, compress)
  180. if err != nil {
  181. return off, err
  182. }
  183. headerEnd := off
  184. off, err = packUint32(rr.Serial, msg, off)
  185. if err != nil {
  186. return off, err
  187. }
  188. off, err = packUint16(rr.Flags, msg, off)
  189. if err != nil {
  190. return off, err
  191. }
  192. off, err = packDataNsec(rr.TypeBitMap, msg, off)
  193. if err != nil {
  194. return off, err
  195. }
  196. rr.Header().Rdlength = uint16(off - headerEnd)
  197. return off, nil
  198. }
  199. func (rr *DHCID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  200. off, err := rr.Hdr.pack(msg, off, compression, compress)
  201. if err != nil {
  202. return off, err
  203. }
  204. headerEnd := off
  205. off, err = packStringBase64(rr.Digest, msg, off)
  206. if err != nil {
  207. return off, err
  208. }
  209. rr.Header().Rdlength = uint16(off - headerEnd)
  210. return off, nil
  211. }
  212. func (rr *DLV) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  213. off, err := rr.Hdr.pack(msg, off, compression, compress)
  214. if err != nil {
  215. return off, err
  216. }
  217. headerEnd := off
  218. off, err = packUint16(rr.KeyTag, msg, off)
  219. if err != nil {
  220. return off, err
  221. }
  222. off, err = packUint8(rr.Algorithm, msg, off)
  223. if err != nil {
  224. return off, err
  225. }
  226. off, err = packUint8(rr.DigestType, msg, off)
  227. if err != nil {
  228. return off, err
  229. }
  230. off, err = packStringHex(rr.Digest, msg, off)
  231. if err != nil {
  232. return off, err
  233. }
  234. rr.Header().Rdlength = uint16(off - headerEnd)
  235. return off, nil
  236. }
  237. func (rr *DNAME) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  238. off, err := rr.Hdr.pack(msg, off, compression, compress)
  239. if err != nil {
  240. return off, err
  241. }
  242. headerEnd := off
  243. off, err = PackDomainName(rr.Target, msg, off, compression, false)
  244. if err != nil {
  245. return off, err
  246. }
  247. rr.Header().Rdlength = uint16(off - headerEnd)
  248. return off, nil
  249. }
  250. func (rr *DNSKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  251. off, err := rr.Hdr.pack(msg, off, compression, compress)
  252. if err != nil {
  253. return off, err
  254. }
  255. headerEnd := off
  256. off, err = packUint16(rr.Flags, msg, off)
  257. if err != nil {
  258. return off, err
  259. }
  260. off, err = packUint8(rr.Protocol, msg, off)
  261. if err != nil {
  262. return off, err
  263. }
  264. off, err = packUint8(rr.Algorithm, msg, off)
  265. if err != nil {
  266. return off, err
  267. }
  268. off, err = packStringBase64(rr.PublicKey, msg, off)
  269. if err != nil {
  270. return off, err
  271. }
  272. rr.Header().Rdlength = uint16(off - headerEnd)
  273. return off, nil
  274. }
  275. func (rr *DS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  276. off, err := rr.Hdr.pack(msg, off, compression, compress)
  277. if err != nil {
  278. return off, err
  279. }
  280. headerEnd := off
  281. off, err = packUint16(rr.KeyTag, msg, off)
  282. if err != nil {
  283. return off, err
  284. }
  285. off, err = packUint8(rr.Algorithm, msg, off)
  286. if err != nil {
  287. return off, err
  288. }
  289. off, err = packUint8(rr.DigestType, msg, off)
  290. if err != nil {
  291. return off, err
  292. }
  293. off, err = packStringHex(rr.Digest, msg, off)
  294. if err != nil {
  295. return off, err
  296. }
  297. rr.Header().Rdlength = uint16(off - headerEnd)
  298. return off, nil
  299. }
  300. func (rr *EID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  301. off, err := rr.Hdr.pack(msg, off, compression, compress)
  302. if err != nil {
  303. return off, err
  304. }
  305. headerEnd := off
  306. off, err = packStringHex(rr.Endpoint, msg, off)
  307. if err != nil {
  308. return off, err
  309. }
  310. rr.Header().Rdlength = uint16(off - headerEnd)
  311. return off, nil
  312. }
  313. func (rr *EUI48) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  314. off, err := rr.Hdr.pack(msg, off, compression, compress)
  315. if err != nil {
  316. return off, err
  317. }
  318. headerEnd := off
  319. off, err = packUint48(rr.Address, msg, off)
  320. if err != nil {
  321. return off, err
  322. }
  323. rr.Header().Rdlength = uint16(off - headerEnd)
  324. return off, nil
  325. }
  326. func (rr *EUI64) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  327. off, err := rr.Hdr.pack(msg, off, compression, compress)
  328. if err != nil {
  329. return off, err
  330. }
  331. headerEnd := off
  332. off, err = packUint64(rr.Address, msg, off)
  333. if err != nil {
  334. return off, err
  335. }
  336. rr.Header().Rdlength = uint16(off - headerEnd)
  337. return off, nil
  338. }
  339. func (rr *GID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  340. off, err := rr.Hdr.pack(msg, off, compression, compress)
  341. if err != nil {
  342. return off, err
  343. }
  344. headerEnd := off
  345. off, err = packUint32(rr.Gid, msg, off)
  346. if err != nil {
  347. return off, err
  348. }
  349. rr.Header().Rdlength = uint16(off - headerEnd)
  350. return off, nil
  351. }
  352. func (rr *GPOS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  353. off, err := rr.Hdr.pack(msg, off, compression, compress)
  354. if err != nil {
  355. return off, err
  356. }
  357. headerEnd := off
  358. off, err = packString(rr.Longitude, msg, off)
  359. if err != nil {
  360. return off, err
  361. }
  362. off, err = packString(rr.Latitude, msg, off)
  363. if err != nil {
  364. return off, err
  365. }
  366. off, err = packString(rr.Altitude, msg, off)
  367. if err != nil {
  368. return off, err
  369. }
  370. rr.Header().Rdlength = uint16(off - headerEnd)
  371. return off, nil
  372. }
  373. func (rr *HINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  374. off, err := rr.Hdr.pack(msg, off, compression, compress)
  375. if err != nil {
  376. return off, err
  377. }
  378. headerEnd := off
  379. off, err = packString(rr.Cpu, msg, off)
  380. if err != nil {
  381. return off, err
  382. }
  383. off, err = packString(rr.Os, msg, off)
  384. if err != nil {
  385. return off, err
  386. }
  387. rr.Header().Rdlength = uint16(off - headerEnd)
  388. return off, nil
  389. }
  390. func (rr *HIP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  391. off, err := rr.Hdr.pack(msg, off, compression, compress)
  392. if err != nil {
  393. return off, err
  394. }
  395. headerEnd := off
  396. off, err = packUint8(rr.HitLength, msg, off)
  397. if err != nil {
  398. return off, err
  399. }
  400. off, err = packUint8(rr.PublicKeyAlgorithm, msg, off)
  401. if err != nil {
  402. return off, err
  403. }
  404. off, err = packUint16(rr.PublicKeyLength, msg, off)
  405. if err != nil {
  406. return off, err
  407. }
  408. off, err = packStringHex(rr.Hit, msg, off)
  409. if err != nil {
  410. return off, err
  411. }
  412. off, err = packStringBase64(rr.PublicKey, msg, off)
  413. if err != nil {
  414. return off, err
  415. }
  416. off, err = packDataDomainNames(rr.RendezvousServers, msg, off, compression, compress)
  417. if err != nil {
  418. return off, err
  419. }
  420. rr.Header().Rdlength = uint16(off - headerEnd)
  421. return off, nil
  422. }
  423. func (rr *KEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  424. off, err := rr.Hdr.pack(msg, off, compression, compress)
  425. if err != nil {
  426. return off, err
  427. }
  428. headerEnd := off
  429. off, err = packUint16(rr.Flags, msg, off)
  430. if err != nil {
  431. return off, err
  432. }
  433. off, err = packUint8(rr.Protocol, msg, off)
  434. if err != nil {
  435. return off, err
  436. }
  437. off, err = packUint8(rr.Algorithm, msg, off)
  438. if err != nil {
  439. return off, err
  440. }
  441. off, err = packStringBase64(rr.PublicKey, msg, off)
  442. if err != nil {
  443. return off, err
  444. }
  445. rr.Header().Rdlength = uint16(off - headerEnd)
  446. return off, nil
  447. }
  448. func (rr *KX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  449. off, err := rr.Hdr.pack(msg, off, compression, compress)
  450. if err != nil {
  451. return off, err
  452. }
  453. headerEnd := off
  454. off, err = packUint16(rr.Preference, msg, off)
  455. if err != nil {
  456. return off, err
  457. }
  458. off, err = PackDomainName(rr.Exchanger, msg, off, compression, false)
  459. if err != nil {
  460. return off, err
  461. }
  462. rr.Header().Rdlength = uint16(off - headerEnd)
  463. return off, nil
  464. }
  465. func (rr *L32) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  466. off, err := rr.Hdr.pack(msg, off, compression, compress)
  467. if err != nil {
  468. return off, err
  469. }
  470. headerEnd := off
  471. off, err = packUint16(rr.Preference, msg, off)
  472. if err != nil {
  473. return off, err
  474. }
  475. off, err = packDataA(rr.Locator32, msg, off)
  476. if err != nil {
  477. return off, err
  478. }
  479. rr.Header().Rdlength = uint16(off - headerEnd)
  480. return off, nil
  481. }
  482. func (rr *L64) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  483. off, err := rr.Hdr.pack(msg, off, compression, compress)
  484. if err != nil {
  485. return off, err
  486. }
  487. headerEnd := off
  488. off, err = packUint16(rr.Preference, msg, off)
  489. if err != nil {
  490. return off, err
  491. }
  492. off, err = packUint64(rr.Locator64, msg, off)
  493. if err != nil {
  494. return off, err
  495. }
  496. rr.Header().Rdlength = uint16(off - headerEnd)
  497. return off, nil
  498. }
  499. func (rr *LOC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  500. off, err := rr.Hdr.pack(msg, off, compression, compress)
  501. if err != nil {
  502. return off, err
  503. }
  504. headerEnd := off
  505. off, err = packUint8(rr.Version, msg, off)
  506. if err != nil {
  507. return off, err
  508. }
  509. off, err = packUint8(rr.Size, msg, off)
  510. if err != nil {
  511. return off, err
  512. }
  513. off, err = packUint8(rr.HorizPre, msg, off)
  514. if err != nil {
  515. return off, err
  516. }
  517. off, err = packUint8(rr.VertPre, msg, off)
  518. if err != nil {
  519. return off, err
  520. }
  521. off, err = packUint32(rr.Latitude, msg, off)
  522. if err != nil {
  523. return off, err
  524. }
  525. off, err = packUint32(rr.Longitude, msg, off)
  526. if err != nil {
  527. return off, err
  528. }
  529. off, err = packUint32(rr.Altitude, msg, off)
  530. if err != nil {
  531. return off, err
  532. }
  533. rr.Header().Rdlength = uint16(off - headerEnd)
  534. return off, nil
  535. }
  536. func (rr *LP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  537. off, err := rr.Hdr.pack(msg, off, compression, compress)
  538. if err != nil {
  539. return off, err
  540. }
  541. headerEnd := off
  542. off, err = packUint16(rr.Preference, msg, off)
  543. if err != nil {
  544. return off, err
  545. }
  546. off, err = PackDomainName(rr.Fqdn, msg, off, compression, false)
  547. if err != nil {
  548. return off, err
  549. }
  550. rr.Header().Rdlength = uint16(off - headerEnd)
  551. return off, nil
  552. }
  553. func (rr *MB) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  554. off, err := rr.Hdr.pack(msg, off, compression, compress)
  555. if err != nil {
  556. return off, err
  557. }
  558. headerEnd := off
  559. off, err = PackDomainName(rr.Mb, msg, off, compression, compress)
  560. if err != nil {
  561. return off, err
  562. }
  563. rr.Header().Rdlength = uint16(off - headerEnd)
  564. return off, nil
  565. }
  566. func (rr *MD) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  567. off, err := rr.Hdr.pack(msg, off, compression, compress)
  568. if err != nil {
  569. return off, err
  570. }
  571. headerEnd := off
  572. off, err = PackDomainName(rr.Md, msg, off, compression, compress)
  573. if err != nil {
  574. return off, err
  575. }
  576. rr.Header().Rdlength = uint16(off - headerEnd)
  577. return off, nil
  578. }
  579. func (rr *MF) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  580. off, err := rr.Hdr.pack(msg, off, compression, compress)
  581. if err != nil {
  582. return off, err
  583. }
  584. headerEnd := off
  585. off, err = PackDomainName(rr.Mf, msg, off, compression, compress)
  586. if err != nil {
  587. return off, err
  588. }
  589. rr.Header().Rdlength = uint16(off - headerEnd)
  590. return off, nil
  591. }
  592. func (rr *MG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  593. off, err := rr.Hdr.pack(msg, off, compression, compress)
  594. if err != nil {
  595. return off, err
  596. }
  597. headerEnd := off
  598. off, err = PackDomainName(rr.Mg, msg, off, compression, compress)
  599. if err != nil {
  600. return off, err
  601. }
  602. rr.Header().Rdlength = uint16(off - headerEnd)
  603. return off, nil
  604. }
  605. func (rr *MINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  606. off, err := rr.Hdr.pack(msg, off, compression, compress)
  607. if err != nil {
  608. return off, err
  609. }
  610. headerEnd := off
  611. off, err = PackDomainName(rr.Rmail, msg, off, compression, compress)
  612. if err != nil {
  613. return off, err
  614. }
  615. off, err = PackDomainName(rr.Email, msg, off, compression, compress)
  616. if err != nil {
  617. return off, err
  618. }
  619. rr.Header().Rdlength = uint16(off - headerEnd)
  620. return off, nil
  621. }
  622. func (rr *MR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  623. off, err := rr.Hdr.pack(msg, off, compression, compress)
  624. if err != nil {
  625. return off, err
  626. }
  627. headerEnd := off
  628. off, err = PackDomainName(rr.Mr, msg, off, compression, compress)
  629. if err != nil {
  630. return off, err
  631. }
  632. rr.Header().Rdlength = uint16(off - headerEnd)
  633. return off, nil
  634. }
  635. func (rr *MX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  636. off, err := rr.Hdr.pack(msg, off, compression, compress)
  637. if err != nil {
  638. return off, err
  639. }
  640. headerEnd := off
  641. off, err = packUint16(rr.Preference, msg, off)
  642. if err != nil {
  643. return off, err
  644. }
  645. off, err = PackDomainName(rr.Mx, msg, off, compression, compress)
  646. if err != nil {
  647. return off, err
  648. }
  649. rr.Header().Rdlength = uint16(off - headerEnd)
  650. return off, nil
  651. }
  652. func (rr *NAPTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  653. off, err := rr.Hdr.pack(msg, off, compression, compress)
  654. if err != nil {
  655. return off, err
  656. }
  657. headerEnd := off
  658. off, err = packUint16(rr.Order, msg, off)
  659. if err != nil {
  660. return off, err
  661. }
  662. off, err = packUint16(rr.Preference, msg, off)
  663. if err != nil {
  664. return off, err
  665. }
  666. off, err = packString(rr.Flags, msg, off)
  667. if err != nil {
  668. return off, err
  669. }
  670. off, err = packString(rr.Service, msg, off)
  671. if err != nil {
  672. return off, err
  673. }
  674. off, err = packString(rr.Regexp, msg, off)
  675. if err != nil {
  676. return off, err
  677. }
  678. off, err = PackDomainName(rr.Replacement, msg, off, compression, false)
  679. if err != nil {
  680. return off, err
  681. }
  682. rr.Header().Rdlength = uint16(off - headerEnd)
  683. return off, nil
  684. }
  685. func (rr *NID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  686. off, err := rr.Hdr.pack(msg, off, compression, compress)
  687. if err != nil {
  688. return off, err
  689. }
  690. headerEnd := off
  691. off, err = packUint16(rr.Preference, msg, off)
  692. if err != nil {
  693. return off, err
  694. }
  695. off, err = packUint64(rr.NodeID, msg, off)
  696. if err != nil {
  697. return off, err
  698. }
  699. rr.Header().Rdlength = uint16(off - headerEnd)
  700. return off, nil
  701. }
  702. func (rr *NIMLOC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  703. off, err := rr.Hdr.pack(msg, off, compression, compress)
  704. if err != nil {
  705. return off, err
  706. }
  707. headerEnd := off
  708. off, err = packStringHex(rr.Locator, msg, off)
  709. if err != nil {
  710. return off, err
  711. }
  712. rr.Header().Rdlength = uint16(off - headerEnd)
  713. return off, nil
  714. }
  715. func (rr *NINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  716. off, err := rr.Hdr.pack(msg, off, compression, compress)
  717. if err != nil {
  718. return off, err
  719. }
  720. headerEnd := off
  721. off, err = packStringTxt(rr.ZSData, msg, off)
  722. if err != nil {
  723. return off, err
  724. }
  725. rr.Header().Rdlength = uint16(off - headerEnd)
  726. return off, nil
  727. }
  728. func (rr *NS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  729. off, err := rr.Hdr.pack(msg, off, compression, compress)
  730. if err != nil {
  731. return off, err
  732. }
  733. headerEnd := off
  734. off, err = PackDomainName(rr.Ns, msg, off, compression, compress)
  735. if err != nil {
  736. return off, err
  737. }
  738. rr.Header().Rdlength = uint16(off - headerEnd)
  739. return off, nil
  740. }
  741. func (rr *NSAPPTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  742. off, err := rr.Hdr.pack(msg, off, compression, compress)
  743. if err != nil {
  744. return off, err
  745. }
  746. headerEnd := off
  747. off, err = PackDomainName(rr.Ptr, msg, off, compression, false)
  748. if err != nil {
  749. return off, err
  750. }
  751. rr.Header().Rdlength = uint16(off - headerEnd)
  752. return off, nil
  753. }
  754. func (rr *NSEC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  755. off, err := rr.Hdr.pack(msg, off, compression, compress)
  756. if err != nil {
  757. return off, err
  758. }
  759. headerEnd := off
  760. off, err = PackDomainName(rr.NextDomain, msg, off, compression, false)
  761. if err != nil {
  762. return off, err
  763. }
  764. off, err = packDataNsec(rr.TypeBitMap, msg, off)
  765. if err != nil {
  766. return off, err
  767. }
  768. rr.Header().Rdlength = uint16(off - headerEnd)
  769. return off, nil
  770. }
  771. func (rr *NSEC3) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  772. off, err := rr.Hdr.pack(msg, off, compression, compress)
  773. if err != nil {
  774. return off, err
  775. }
  776. headerEnd := off
  777. off, err = packUint8(rr.Hash, msg, off)
  778. if err != nil {
  779. return off, err
  780. }
  781. off, err = packUint8(rr.Flags, msg, off)
  782. if err != nil {
  783. return off, err
  784. }
  785. off, err = packUint16(rr.Iterations, msg, off)
  786. if err != nil {
  787. return off, err
  788. }
  789. off, err = packUint8(rr.SaltLength, msg, off)
  790. if err != nil {
  791. return off, err
  792. }
  793. // Only pack salt if value is not "-", i.e. empty
  794. if rr.Salt != "-" {
  795. off, err = packStringHex(rr.Salt, msg, off)
  796. if err != nil {
  797. return off, err
  798. }
  799. }
  800. off, err = packUint8(rr.HashLength, msg, off)
  801. if err != nil {
  802. return off, err
  803. }
  804. off, err = packStringBase32(rr.NextDomain, msg, off)
  805. if err != nil {
  806. return off, err
  807. }
  808. off, err = packDataNsec(rr.TypeBitMap, msg, off)
  809. if err != nil {
  810. return off, err
  811. }
  812. rr.Header().Rdlength = uint16(off - headerEnd)
  813. return off, nil
  814. }
  815. func (rr *NSEC3PARAM) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  816. off, err := rr.Hdr.pack(msg, off, compression, compress)
  817. if err != nil {
  818. return off, err
  819. }
  820. headerEnd := off
  821. off, err = packUint8(rr.Hash, msg, off)
  822. if err != nil {
  823. return off, err
  824. }
  825. off, err = packUint8(rr.Flags, msg, off)
  826. if err != nil {
  827. return off, err
  828. }
  829. off, err = packUint16(rr.Iterations, msg, off)
  830. if err != nil {
  831. return off, err
  832. }
  833. off, err = packUint8(rr.SaltLength, msg, off)
  834. if err != nil {
  835. return off, err
  836. }
  837. // Only pack salt if value is not "-", i.e. empty
  838. if rr.Salt != "-" {
  839. off, err = packStringHex(rr.Salt, msg, off)
  840. if err != nil {
  841. return off, err
  842. }
  843. }
  844. rr.Header().Rdlength = uint16(off - headerEnd)
  845. return off, nil
  846. }
  847. func (rr *OPENPGPKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  848. off, err := rr.Hdr.pack(msg, off, compression, compress)
  849. if err != nil {
  850. return off, err
  851. }
  852. headerEnd := off
  853. off, err = packStringBase64(rr.PublicKey, msg, off)
  854. if err != nil {
  855. return off, err
  856. }
  857. rr.Header().Rdlength = uint16(off - headerEnd)
  858. return off, nil
  859. }
  860. func (rr *OPT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  861. off, err := rr.Hdr.pack(msg, off, compression, compress)
  862. if err != nil {
  863. return off, err
  864. }
  865. headerEnd := off
  866. off, err = packDataOpt(rr.Option, msg, off)
  867. if err != nil {
  868. return off, err
  869. }
  870. rr.Header().Rdlength = uint16(off - headerEnd)
  871. return off, nil
  872. }
  873. func (rr *PTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  874. off, err := rr.Hdr.pack(msg, off, compression, compress)
  875. if err != nil {
  876. return off, err
  877. }
  878. headerEnd := off
  879. off, err = PackDomainName(rr.Ptr, msg, off, compression, compress)
  880. if err != nil {
  881. return off, err
  882. }
  883. rr.Header().Rdlength = uint16(off - headerEnd)
  884. return off, nil
  885. }
  886. func (rr *PX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  887. off, err := rr.Hdr.pack(msg, off, compression, compress)
  888. if err != nil {
  889. return off, err
  890. }
  891. headerEnd := off
  892. off, err = packUint16(rr.Preference, msg, off)
  893. if err != nil {
  894. return off, err
  895. }
  896. off, err = PackDomainName(rr.Map822, msg, off, compression, false)
  897. if err != nil {
  898. return off, err
  899. }
  900. off, err = PackDomainName(rr.Mapx400, msg, off, compression, false)
  901. if err != nil {
  902. return off, err
  903. }
  904. rr.Header().Rdlength = uint16(off - headerEnd)
  905. return off, nil
  906. }
  907. func (rr *RFC3597) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  908. off, err := rr.Hdr.pack(msg, off, compression, compress)
  909. if err != nil {
  910. return off, err
  911. }
  912. headerEnd := off
  913. off, err = packStringHex(rr.Rdata, msg, off)
  914. if err != nil {
  915. return off, err
  916. }
  917. rr.Header().Rdlength = uint16(off - headerEnd)
  918. return off, nil
  919. }
  920. func (rr *RKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  921. off, err := rr.Hdr.pack(msg, off, compression, compress)
  922. if err != nil {
  923. return off, err
  924. }
  925. headerEnd := off
  926. off, err = packUint16(rr.Flags, msg, off)
  927. if err != nil {
  928. return off, err
  929. }
  930. off, err = packUint8(rr.Protocol, msg, off)
  931. if err != nil {
  932. return off, err
  933. }
  934. off, err = packUint8(rr.Algorithm, msg, off)
  935. if err != nil {
  936. return off, err
  937. }
  938. off, err = packStringBase64(rr.PublicKey, msg, off)
  939. if err != nil {
  940. return off, err
  941. }
  942. rr.Header().Rdlength = uint16(off - headerEnd)
  943. return off, nil
  944. }
  945. func (rr *RP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  946. off, err := rr.Hdr.pack(msg, off, compression, compress)
  947. if err != nil {
  948. return off, err
  949. }
  950. headerEnd := off
  951. off, err = PackDomainName(rr.Mbox, msg, off, compression, false)
  952. if err != nil {
  953. return off, err
  954. }
  955. off, err = PackDomainName(rr.Txt, msg, off, compression, false)
  956. if err != nil {
  957. return off, err
  958. }
  959. rr.Header().Rdlength = uint16(off - headerEnd)
  960. return off, nil
  961. }
  962. func (rr *RRSIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  963. off, err := rr.Hdr.pack(msg, off, compression, compress)
  964. if err != nil {
  965. return off, err
  966. }
  967. headerEnd := off
  968. off, err = packUint16(rr.TypeCovered, msg, off)
  969. if err != nil {
  970. return off, err
  971. }
  972. off, err = packUint8(rr.Algorithm, msg, off)
  973. if err != nil {
  974. return off, err
  975. }
  976. off, err = packUint8(rr.Labels, msg, off)
  977. if err != nil {
  978. return off, err
  979. }
  980. off, err = packUint32(rr.OrigTtl, msg, off)
  981. if err != nil {
  982. return off, err
  983. }
  984. off, err = packUint32(rr.Expiration, msg, off)
  985. if err != nil {
  986. return off, err
  987. }
  988. off, err = packUint32(rr.Inception, msg, off)
  989. if err != nil {
  990. return off, err
  991. }
  992. off, err = packUint16(rr.KeyTag, msg, off)
  993. if err != nil {
  994. return off, err
  995. }
  996. off, err = PackDomainName(rr.SignerName, msg, off, compression, false)
  997. if err != nil {
  998. return off, err
  999. }
  1000. off, err = packStringBase64(rr.Signature, msg, off)
  1001. if err != nil {
  1002. return off, err
  1003. }
  1004. rr.Header().Rdlength = uint16(off - headerEnd)
  1005. return off, nil
  1006. }
  1007. func (rr *RT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1008. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1009. if err != nil {
  1010. return off, err
  1011. }
  1012. headerEnd := off
  1013. off, err = packUint16(rr.Preference, msg, off)
  1014. if err != nil {
  1015. return off, err
  1016. }
  1017. off, err = PackDomainName(rr.Host, msg, off, compression, compress)
  1018. if err != nil {
  1019. return off, err
  1020. }
  1021. rr.Header().Rdlength = uint16(off - headerEnd)
  1022. return off, nil
  1023. }
  1024. func (rr *SIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1025. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1026. if err != nil {
  1027. return off, err
  1028. }
  1029. headerEnd := off
  1030. off, err = packUint16(rr.TypeCovered, msg, off)
  1031. if err != nil {
  1032. return off, err
  1033. }
  1034. off, err = packUint8(rr.Algorithm, msg, off)
  1035. if err != nil {
  1036. return off, err
  1037. }
  1038. off, err = packUint8(rr.Labels, msg, off)
  1039. if err != nil {
  1040. return off, err
  1041. }
  1042. off, err = packUint32(rr.OrigTtl, msg, off)
  1043. if err != nil {
  1044. return off, err
  1045. }
  1046. off, err = packUint32(rr.Expiration, msg, off)
  1047. if err != nil {
  1048. return off, err
  1049. }
  1050. off, err = packUint32(rr.Inception, msg, off)
  1051. if err != nil {
  1052. return off, err
  1053. }
  1054. off, err = packUint16(rr.KeyTag, msg, off)
  1055. if err != nil {
  1056. return off, err
  1057. }
  1058. off, err = PackDomainName(rr.SignerName, msg, off, compression, false)
  1059. if err != nil {
  1060. return off, err
  1061. }
  1062. off, err = packStringBase64(rr.Signature, msg, off)
  1063. if err != nil {
  1064. return off, err
  1065. }
  1066. rr.Header().Rdlength = uint16(off - headerEnd)
  1067. return off, nil
  1068. }
  1069. func (rr *SMIMEA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1070. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1071. if err != nil {
  1072. return off, err
  1073. }
  1074. headerEnd := off
  1075. off, err = packUint8(rr.Usage, msg, off)
  1076. if err != nil {
  1077. return off, err
  1078. }
  1079. off, err = packUint8(rr.Selector, msg, off)
  1080. if err != nil {
  1081. return off, err
  1082. }
  1083. off, err = packUint8(rr.MatchingType, msg, off)
  1084. if err != nil {
  1085. return off, err
  1086. }
  1087. off, err = packStringHex(rr.Certificate, msg, off)
  1088. if err != nil {
  1089. return off, err
  1090. }
  1091. rr.Header().Rdlength = uint16(off - headerEnd)
  1092. return off, nil
  1093. }
  1094. func (rr *SOA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1095. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1096. if err != nil {
  1097. return off, err
  1098. }
  1099. headerEnd := off
  1100. off, err = PackDomainName(rr.Ns, msg, off, compression, compress)
  1101. if err != nil {
  1102. return off, err
  1103. }
  1104. off, err = PackDomainName(rr.Mbox, msg, off, compression, compress)
  1105. if err != nil {
  1106. return off, err
  1107. }
  1108. off, err = packUint32(rr.Serial, msg, off)
  1109. if err != nil {
  1110. return off, err
  1111. }
  1112. off, err = packUint32(rr.Refresh, msg, off)
  1113. if err != nil {
  1114. return off, err
  1115. }
  1116. off, err = packUint32(rr.Retry, msg, off)
  1117. if err != nil {
  1118. return off, err
  1119. }
  1120. off, err = packUint32(rr.Expire, msg, off)
  1121. if err != nil {
  1122. return off, err
  1123. }
  1124. off, err = packUint32(rr.Minttl, msg, off)
  1125. if err != nil {
  1126. return off, err
  1127. }
  1128. rr.Header().Rdlength = uint16(off - headerEnd)
  1129. return off, nil
  1130. }
  1131. func (rr *SPF) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1132. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1133. if err != nil {
  1134. return off, err
  1135. }
  1136. headerEnd := off
  1137. off, err = packStringTxt(rr.Txt, msg, off)
  1138. if err != nil {
  1139. return off, err
  1140. }
  1141. rr.Header().Rdlength = uint16(off - headerEnd)
  1142. return off, nil
  1143. }
  1144. func (rr *SRV) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1145. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1146. if err != nil {
  1147. return off, err
  1148. }
  1149. headerEnd := off
  1150. off, err = packUint16(rr.Priority, msg, off)
  1151. if err != nil {
  1152. return off, err
  1153. }
  1154. off, err = packUint16(rr.Weight, msg, off)
  1155. if err != nil {
  1156. return off, err
  1157. }
  1158. off, err = packUint16(rr.Port, msg, off)
  1159. if err != nil {
  1160. return off, err
  1161. }
  1162. off, err = PackDomainName(rr.Target, msg, off, compression, false)
  1163. if err != nil {
  1164. return off, err
  1165. }
  1166. rr.Header().Rdlength = uint16(off - headerEnd)
  1167. return off, nil
  1168. }
  1169. func (rr *SSHFP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1170. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1171. if err != nil {
  1172. return off, err
  1173. }
  1174. headerEnd := off
  1175. off, err = packUint8(rr.Algorithm, msg, off)
  1176. if err != nil {
  1177. return off, err
  1178. }
  1179. off, err = packUint8(rr.Type, msg, off)
  1180. if err != nil {
  1181. return off, err
  1182. }
  1183. off, err = packStringHex(rr.FingerPrint, msg, off)
  1184. if err != nil {
  1185. return off, err
  1186. }
  1187. rr.Header().Rdlength = uint16(off - headerEnd)
  1188. return off, nil
  1189. }
  1190. func (rr *TA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1191. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1192. if err != nil {
  1193. return off, err
  1194. }
  1195. headerEnd := off
  1196. off, err = packUint16(rr.KeyTag, msg, off)
  1197. if err != nil {
  1198. return off, err
  1199. }
  1200. off, err = packUint8(rr.Algorithm, msg, off)
  1201. if err != nil {
  1202. return off, err
  1203. }
  1204. off, err = packUint8(rr.DigestType, msg, off)
  1205. if err != nil {
  1206. return off, err
  1207. }
  1208. off, err = packStringHex(rr.Digest, msg, off)
  1209. if err != nil {
  1210. return off, err
  1211. }
  1212. rr.Header().Rdlength = uint16(off - headerEnd)
  1213. return off, nil
  1214. }
  1215. func (rr *TALINK) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1216. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1217. if err != nil {
  1218. return off, err
  1219. }
  1220. headerEnd := off
  1221. off, err = PackDomainName(rr.PreviousName, msg, off, compression, false)
  1222. if err != nil {
  1223. return off, err
  1224. }
  1225. off, err = PackDomainName(rr.NextName, msg, off, compression, false)
  1226. if err != nil {
  1227. return off, err
  1228. }
  1229. rr.Header().Rdlength = uint16(off - headerEnd)
  1230. return off, nil
  1231. }
  1232. func (rr *TKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1233. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1234. if err != nil {
  1235. return off, err
  1236. }
  1237. headerEnd := off
  1238. off, err = PackDomainName(rr.Algorithm, msg, off, compression, false)
  1239. if err != nil {
  1240. return off, err
  1241. }
  1242. off, err = packUint32(rr.Inception, msg, off)
  1243. if err != nil {
  1244. return off, err
  1245. }
  1246. off, err = packUint32(rr.Expiration, msg, off)
  1247. if err != nil {
  1248. return off, err
  1249. }
  1250. off, err = packUint16(rr.Mode, msg, off)
  1251. if err != nil {
  1252. return off, err
  1253. }
  1254. off, err = packUint16(rr.Error, msg, off)
  1255. if err != nil {
  1256. return off, err
  1257. }
  1258. off, err = packUint16(rr.KeySize, msg, off)
  1259. if err != nil {
  1260. return off, err
  1261. }
  1262. off, err = packStringHex(rr.Key, msg, off)
  1263. if err != nil {
  1264. return off, err
  1265. }
  1266. off, err = packUint16(rr.OtherLen, msg, off)
  1267. if err != nil {
  1268. return off, err
  1269. }
  1270. off, err = packStringHex(rr.OtherData, msg, off)
  1271. if err != nil {
  1272. return off, err
  1273. }
  1274. rr.Header().Rdlength = uint16(off - headerEnd)
  1275. return off, nil
  1276. }
  1277. func (rr *TLSA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1278. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1279. if err != nil {
  1280. return off, err
  1281. }
  1282. headerEnd := off
  1283. off, err = packUint8(rr.Usage, msg, off)
  1284. if err != nil {
  1285. return off, err
  1286. }
  1287. off, err = packUint8(rr.Selector, msg, off)
  1288. if err != nil {
  1289. return off, err
  1290. }
  1291. off, err = packUint8(rr.MatchingType, msg, off)
  1292. if err != nil {
  1293. return off, err
  1294. }
  1295. off, err = packStringHex(rr.Certificate, msg, off)
  1296. if err != nil {
  1297. return off, err
  1298. }
  1299. rr.Header().Rdlength = uint16(off - headerEnd)
  1300. return off, nil
  1301. }
  1302. func (rr *TSIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1303. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1304. if err != nil {
  1305. return off, err
  1306. }
  1307. headerEnd := off
  1308. off, err = PackDomainName(rr.Algorithm, msg, off, compression, false)
  1309. if err != nil {
  1310. return off, err
  1311. }
  1312. off, err = packUint48(rr.TimeSigned, msg, off)
  1313. if err != nil {
  1314. return off, err
  1315. }
  1316. off, err = packUint16(rr.Fudge, msg, off)
  1317. if err != nil {
  1318. return off, err
  1319. }
  1320. off, err = packUint16(rr.MACSize, msg, off)
  1321. if err != nil {
  1322. return off, err
  1323. }
  1324. off, err = packStringHex(rr.MAC, msg, off)
  1325. if err != nil {
  1326. return off, err
  1327. }
  1328. off, err = packUint16(rr.OrigId, msg, off)
  1329. if err != nil {
  1330. return off, err
  1331. }
  1332. off, err = packUint16(rr.Error, msg, off)
  1333. if err != nil {
  1334. return off, err
  1335. }
  1336. off, err = packUint16(rr.OtherLen, msg, off)
  1337. if err != nil {
  1338. return off, err
  1339. }
  1340. off, err = packStringHex(rr.OtherData, msg, off)
  1341. if err != nil {
  1342. return off, err
  1343. }
  1344. rr.Header().Rdlength = uint16(off - headerEnd)
  1345. return off, nil
  1346. }
  1347. func (rr *TXT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1348. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1349. if err != nil {
  1350. return off, err
  1351. }
  1352. headerEnd := off
  1353. off, err = packStringTxt(rr.Txt, msg, off)
  1354. if err != nil {
  1355. return off, err
  1356. }
  1357. rr.Header().Rdlength = uint16(off - headerEnd)
  1358. return off, nil
  1359. }
  1360. func (rr *UID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1361. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1362. if err != nil {
  1363. return off, err
  1364. }
  1365. headerEnd := off
  1366. off, err = packUint32(rr.Uid, msg, off)
  1367. if err != nil {
  1368. return off, err
  1369. }
  1370. rr.Header().Rdlength = uint16(off - headerEnd)
  1371. return off, nil
  1372. }
  1373. func (rr *UINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1374. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1375. if err != nil {
  1376. return off, err
  1377. }
  1378. headerEnd := off
  1379. off, err = packString(rr.Uinfo, msg, off)
  1380. if err != nil {
  1381. return off, err
  1382. }
  1383. rr.Header().Rdlength = uint16(off - headerEnd)
  1384. return off, nil
  1385. }
  1386. func (rr *URI) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1387. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1388. if err != nil {
  1389. return off, err
  1390. }
  1391. headerEnd := off
  1392. off, err = packUint16(rr.Priority, msg, off)
  1393. if err != nil {
  1394. return off, err
  1395. }
  1396. off, err = packUint16(rr.Weight, msg, off)
  1397. if err != nil {
  1398. return off, err
  1399. }
  1400. off, err = packStringOctet(rr.Target, msg, off)
  1401. if err != nil {
  1402. return off, err
  1403. }
  1404. rr.Header().Rdlength = uint16(off - headerEnd)
  1405. return off, nil
  1406. }
  1407. func (rr *X25) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {
  1408. off, err := rr.Hdr.pack(msg, off, compression, compress)
  1409. if err != nil {
  1410. return off, err
  1411. }
  1412. headerEnd := off
  1413. off, err = packString(rr.PSDNAddress, msg, off)
  1414. if err != nil {
  1415. return off, err
  1416. }
  1417. rr.Header().Rdlength = uint16(off - headerEnd)
  1418. return off, nil
  1419. }
  1420. // unpack*() functions
  1421. func unpackA(h RR_Header, msg []byte, off int) (RR, int, error) {
  1422. rr := new(A)
  1423. rr.Hdr = h
  1424. if noRdata(h) {
  1425. return rr, off, nil
  1426. }
  1427. var err error
  1428. rdStart := off
  1429. _ = rdStart
  1430. rr.A, off, err = unpackDataA(msg, off)
  1431. if err != nil {
  1432. return rr, off, err
  1433. }
  1434. return rr, off, err
  1435. }
  1436. func unpackAAAA(h RR_Header, msg []byte, off int) (RR, int, error) {
  1437. rr := new(AAAA)
  1438. rr.Hdr = h
  1439. if noRdata(h) {
  1440. return rr, off, nil
  1441. }
  1442. var err error
  1443. rdStart := off
  1444. _ = rdStart
  1445. rr.AAAA, off, err = unpackDataAAAA(msg, off)
  1446. if err != nil {
  1447. return rr, off, err
  1448. }
  1449. return rr, off, err
  1450. }
  1451. func unpackAFSDB(h RR_Header, msg []byte, off int) (RR, int, error) {
  1452. rr := new(AFSDB)
  1453. rr.Hdr = h
  1454. if noRdata(h) {
  1455. return rr, off, nil
  1456. }
  1457. var err error
  1458. rdStart := off
  1459. _ = rdStart
  1460. rr.Subtype, off, err = unpackUint16(msg, off)
  1461. if err != nil {
  1462. return rr, off, err
  1463. }
  1464. if off == len(msg) {
  1465. return rr, off, nil
  1466. }
  1467. rr.Hostname, off, err = UnpackDomainName(msg, off)
  1468. if err != nil {
  1469. return rr, off, err
  1470. }
  1471. return rr, off, err
  1472. }
  1473. func unpackANY(h RR_Header, msg []byte, off int) (RR, int, error) {
  1474. rr := new(ANY)
  1475. rr.Hdr = h
  1476. if noRdata(h) {
  1477. return rr, off, nil
  1478. }
  1479. var err error
  1480. rdStart := off
  1481. _ = rdStart
  1482. return rr, off, err
  1483. }
  1484. func unpackAVC(h RR_Header, msg []byte, off int) (RR, int, error) {
  1485. rr := new(AVC)
  1486. rr.Hdr = h
  1487. if noRdata(h) {
  1488. return rr, off, nil
  1489. }
  1490. var err error
  1491. rdStart := off
  1492. _ = rdStart
  1493. rr.Txt, off, err = unpackStringTxt(msg, off)
  1494. if err != nil {
  1495. return rr, off, err
  1496. }
  1497. return rr, off, err
  1498. }
  1499. func unpackCAA(h RR_Header, msg []byte, off int) (RR, int, error) {
  1500. rr := new(CAA)
  1501. rr.Hdr = h
  1502. if noRdata(h) {
  1503. return rr, off, nil
  1504. }
  1505. var err error
  1506. rdStart := off
  1507. _ = rdStart
  1508. rr.Flag, off, err = unpackUint8(msg, off)
  1509. if err != nil {
  1510. return rr, off, err
  1511. }
  1512. if off == len(msg) {
  1513. return rr, off, nil
  1514. }
  1515. rr.Tag, off, err = unpackString(msg, off)
  1516. if err != nil {
  1517. return rr, off, err
  1518. }
  1519. if off == len(msg) {
  1520. return rr, off, nil
  1521. }
  1522. rr.Value, off, err = unpackStringOctet(msg, off)
  1523. if err != nil {
  1524. return rr, off, err
  1525. }
  1526. return rr, off, err
  1527. }
  1528. func unpackCDNSKEY(h RR_Header, msg []byte, off int) (RR, int, error) {
  1529. rr := new(CDNSKEY)
  1530. rr.Hdr = h
  1531. if noRdata(h) {
  1532. return rr, off, nil
  1533. }
  1534. var err error
  1535. rdStart := off
  1536. _ = rdStart
  1537. rr.Flags, off, err = unpackUint16(msg, off)
  1538. if err != nil {
  1539. return rr, off, err
  1540. }
  1541. if off == len(msg) {
  1542. return rr, off, nil
  1543. }
  1544. rr.Protocol, off, err = unpackUint8(msg, off)
  1545. if err != nil {
  1546. return rr, off, err
  1547. }
  1548. if off == len(msg) {
  1549. return rr, off, nil
  1550. }
  1551. rr.Algorithm, off, err = unpackUint8(msg, off)
  1552. if err != nil {
  1553. return rr, off, err
  1554. }
  1555. if off == len(msg) {
  1556. return rr, off, nil
  1557. }
  1558. rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1559. if err != nil {
  1560. return rr, off, err
  1561. }
  1562. return rr, off, err
  1563. }
  1564. func unpackCDS(h RR_Header, msg []byte, off int) (RR, int, error) {
  1565. rr := new(CDS)
  1566. rr.Hdr = h
  1567. if noRdata(h) {
  1568. return rr, off, nil
  1569. }
  1570. var err error
  1571. rdStart := off
  1572. _ = rdStart
  1573. rr.KeyTag, off, err = unpackUint16(msg, off)
  1574. if err != nil {
  1575. return rr, off, err
  1576. }
  1577. if off == len(msg) {
  1578. return rr, off, nil
  1579. }
  1580. rr.Algorithm, off, err = unpackUint8(msg, off)
  1581. if err != nil {
  1582. return rr, off, err
  1583. }
  1584. if off == len(msg) {
  1585. return rr, off, nil
  1586. }
  1587. rr.DigestType, off, err = unpackUint8(msg, off)
  1588. if err != nil {
  1589. return rr, off, err
  1590. }
  1591. if off == len(msg) {
  1592. return rr, off, nil
  1593. }
  1594. rr.Digest, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1595. if err != nil {
  1596. return rr, off, err
  1597. }
  1598. return rr, off, err
  1599. }
  1600. func unpackCERT(h RR_Header, msg []byte, off int) (RR, int, error) {
  1601. rr := new(CERT)
  1602. rr.Hdr = h
  1603. if noRdata(h) {
  1604. return rr, off, nil
  1605. }
  1606. var err error
  1607. rdStart := off
  1608. _ = rdStart
  1609. rr.Type, off, err = unpackUint16(msg, off)
  1610. if err != nil {
  1611. return rr, off, err
  1612. }
  1613. if off == len(msg) {
  1614. return rr, off, nil
  1615. }
  1616. rr.KeyTag, off, err = unpackUint16(msg, off)
  1617. if err != nil {
  1618. return rr, off, err
  1619. }
  1620. if off == len(msg) {
  1621. return rr, off, nil
  1622. }
  1623. rr.Algorithm, off, err = unpackUint8(msg, off)
  1624. if err != nil {
  1625. return rr, off, err
  1626. }
  1627. if off == len(msg) {
  1628. return rr, off, nil
  1629. }
  1630. rr.Certificate, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1631. if err != nil {
  1632. return rr, off, err
  1633. }
  1634. return rr, off, err
  1635. }
  1636. func unpackCNAME(h RR_Header, msg []byte, off int) (RR, int, error) {
  1637. rr := new(CNAME)
  1638. rr.Hdr = h
  1639. if noRdata(h) {
  1640. return rr, off, nil
  1641. }
  1642. var err error
  1643. rdStart := off
  1644. _ = rdStart
  1645. rr.Target, off, err = UnpackDomainName(msg, off)
  1646. if err != nil {
  1647. return rr, off, err
  1648. }
  1649. return rr, off, err
  1650. }
  1651. func unpackCSYNC(h RR_Header, msg []byte, off int) (RR, int, error) {
  1652. rr := new(CSYNC)
  1653. rr.Hdr = h
  1654. if noRdata(h) {
  1655. return rr, off, nil
  1656. }
  1657. var err error
  1658. rdStart := off
  1659. _ = rdStart
  1660. rr.Serial, off, err = unpackUint32(msg, off)
  1661. if err != nil {
  1662. return rr, off, err
  1663. }
  1664. if off == len(msg) {
  1665. return rr, off, nil
  1666. }
  1667. rr.Flags, off, err = unpackUint16(msg, off)
  1668. if err != nil {
  1669. return rr, off, err
  1670. }
  1671. if off == len(msg) {
  1672. return rr, off, nil
  1673. }
  1674. rr.TypeBitMap, off, err = unpackDataNsec(msg, off)
  1675. if err != nil {
  1676. return rr, off, err
  1677. }
  1678. return rr, off, err
  1679. }
  1680. func unpackDHCID(h RR_Header, msg []byte, off int) (RR, int, error) {
  1681. rr := new(DHCID)
  1682. rr.Hdr = h
  1683. if noRdata(h) {
  1684. return rr, off, nil
  1685. }
  1686. var err error
  1687. rdStart := off
  1688. _ = rdStart
  1689. rr.Digest, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1690. if err != nil {
  1691. return rr, off, err
  1692. }
  1693. return rr, off, err
  1694. }
  1695. func unpackDLV(h RR_Header, msg []byte, off int) (RR, int, error) {
  1696. rr := new(DLV)
  1697. rr.Hdr = h
  1698. if noRdata(h) {
  1699. return rr, off, nil
  1700. }
  1701. var err error
  1702. rdStart := off
  1703. _ = rdStart
  1704. rr.KeyTag, off, err = unpackUint16(msg, off)
  1705. if err != nil {
  1706. return rr, off, err
  1707. }
  1708. if off == len(msg) {
  1709. return rr, off, nil
  1710. }
  1711. rr.Algorithm, off, err = unpackUint8(msg, off)
  1712. if err != nil {
  1713. return rr, off, err
  1714. }
  1715. if off == len(msg) {
  1716. return rr, off, nil
  1717. }
  1718. rr.DigestType, off, err = unpackUint8(msg, off)
  1719. if err != nil {
  1720. return rr, off, err
  1721. }
  1722. if off == len(msg) {
  1723. return rr, off, nil
  1724. }
  1725. rr.Digest, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1726. if err != nil {
  1727. return rr, off, err
  1728. }
  1729. return rr, off, err
  1730. }
  1731. func unpackDNAME(h RR_Header, msg []byte, off int) (RR, int, error) {
  1732. rr := new(DNAME)
  1733. rr.Hdr = h
  1734. if noRdata(h) {
  1735. return rr, off, nil
  1736. }
  1737. var err error
  1738. rdStart := off
  1739. _ = rdStart
  1740. rr.Target, off, err = UnpackDomainName(msg, off)
  1741. if err != nil {
  1742. return rr, off, err
  1743. }
  1744. return rr, off, err
  1745. }
  1746. func unpackDNSKEY(h RR_Header, msg []byte, off int) (RR, int, error) {
  1747. rr := new(DNSKEY)
  1748. rr.Hdr = h
  1749. if noRdata(h) {
  1750. return rr, off, nil
  1751. }
  1752. var err error
  1753. rdStart := off
  1754. _ = rdStart
  1755. rr.Flags, off, err = unpackUint16(msg, off)
  1756. if err != nil {
  1757. return rr, off, err
  1758. }
  1759. if off == len(msg) {
  1760. return rr, off, nil
  1761. }
  1762. rr.Protocol, off, err = unpackUint8(msg, off)
  1763. if err != nil {
  1764. return rr, off, err
  1765. }
  1766. if off == len(msg) {
  1767. return rr, off, nil
  1768. }
  1769. rr.Algorithm, off, err = unpackUint8(msg, off)
  1770. if err != nil {
  1771. return rr, off, err
  1772. }
  1773. if off == len(msg) {
  1774. return rr, off, nil
  1775. }
  1776. rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1777. if err != nil {
  1778. return rr, off, err
  1779. }
  1780. return rr, off, err
  1781. }
  1782. func unpackDS(h RR_Header, msg []byte, off int) (RR, int, error) {
  1783. rr := new(DS)
  1784. rr.Hdr = h
  1785. if noRdata(h) {
  1786. return rr, off, nil
  1787. }
  1788. var err error
  1789. rdStart := off
  1790. _ = rdStart
  1791. rr.KeyTag, off, err = unpackUint16(msg, off)
  1792. if err != nil {
  1793. return rr, off, err
  1794. }
  1795. if off == len(msg) {
  1796. return rr, off, nil
  1797. }
  1798. rr.Algorithm, off, err = unpackUint8(msg, off)
  1799. if err != nil {
  1800. return rr, off, err
  1801. }
  1802. if off == len(msg) {
  1803. return rr, off, nil
  1804. }
  1805. rr.DigestType, off, err = unpackUint8(msg, off)
  1806. if err != nil {
  1807. return rr, off, err
  1808. }
  1809. if off == len(msg) {
  1810. return rr, off, nil
  1811. }
  1812. rr.Digest, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1813. if err != nil {
  1814. return rr, off, err
  1815. }
  1816. return rr, off, err
  1817. }
  1818. func unpackEID(h RR_Header, msg []byte, off int) (RR, int, error) {
  1819. rr := new(EID)
  1820. rr.Hdr = h
  1821. if noRdata(h) {
  1822. return rr, off, nil
  1823. }
  1824. var err error
  1825. rdStart := off
  1826. _ = rdStart
  1827. rr.Endpoint, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1828. if err != nil {
  1829. return rr, off, err
  1830. }
  1831. return rr, off, err
  1832. }
  1833. func unpackEUI48(h RR_Header, msg []byte, off int) (RR, int, error) {
  1834. rr := new(EUI48)
  1835. rr.Hdr = h
  1836. if noRdata(h) {
  1837. return rr, off, nil
  1838. }
  1839. var err error
  1840. rdStart := off
  1841. _ = rdStart
  1842. rr.Address, off, err = unpackUint48(msg, off)
  1843. if err != nil {
  1844. return rr, off, err
  1845. }
  1846. return rr, off, err
  1847. }
  1848. func unpackEUI64(h RR_Header, msg []byte, off int) (RR, int, error) {
  1849. rr := new(EUI64)
  1850. rr.Hdr = h
  1851. if noRdata(h) {
  1852. return rr, off, nil
  1853. }
  1854. var err error
  1855. rdStart := off
  1856. _ = rdStart
  1857. rr.Address, off, err = unpackUint64(msg, off)
  1858. if err != nil {
  1859. return rr, off, err
  1860. }
  1861. return rr, off, err
  1862. }
  1863. func unpackGID(h RR_Header, msg []byte, off int) (RR, int, error) {
  1864. rr := new(GID)
  1865. rr.Hdr = h
  1866. if noRdata(h) {
  1867. return rr, off, nil
  1868. }
  1869. var err error
  1870. rdStart := off
  1871. _ = rdStart
  1872. rr.Gid, off, err = unpackUint32(msg, off)
  1873. if err != nil {
  1874. return rr, off, err
  1875. }
  1876. return rr, off, err
  1877. }
  1878. func unpackGPOS(h RR_Header, msg []byte, off int) (RR, int, error) {
  1879. rr := new(GPOS)
  1880. rr.Hdr = h
  1881. if noRdata(h) {
  1882. return rr, off, nil
  1883. }
  1884. var err error
  1885. rdStart := off
  1886. _ = rdStart
  1887. rr.Longitude, off, err = unpackString(msg, off)
  1888. if err != nil {
  1889. return rr, off, err
  1890. }
  1891. if off == len(msg) {
  1892. return rr, off, nil
  1893. }
  1894. rr.Latitude, off, err = unpackString(msg, off)
  1895. if err != nil {
  1896. return rr, off, err
  1897. }
  1898. if off == len(msg) {
  1899. return rr, off, nil
  1900. }
  1901. rr.Altitude, off, err = unpackString(msg, off)
  1902. if err != nil {
  1903. return rr, off, err
  1904. }
  1905. return rr, off, err
  1906. }
  1907. func unpackHINFO(h RR_Header, msg []byte, off int) (RR, int, error) {
  1908. rr := new(HINFO)
  1909. rr.Hdr = h
  1910. if noRdata(h) {
  1911. return rr, off, nil
  1912. }
  1913. var err error
  1914. rdStart := off
  1915. _ = rdStart
  1916. rr.Cpu, off, err = unpackString(msg, off)
  1917. if err != nil {
  1918. return rr, off, err
  1919. }
  1920. if off == len(msg) {
  1921. return rr, off, nil
  1922. }
  1923. rr.Os, off, err = unpackString(msg, off)
  1924. if err != nil {
  1925. return rr, off, err
  1926. }
  1927. return rr, off, err
  1928. }
  1929. func unpackHIP(h RR_Header, msg []byte, off int) (RR, int, error) {
  1930. rr := new(HIP)
  1931. rr.Hdr = h
  1932. if noRdata(h) {
  1933. return rr, off, nil
  1934. }
  1935. var err error
  1936. rdStart := off
  1937. _ = rdStart
  1938. rr.HitLength, off, err = unpackUint8(msg, off)
  1939. if err != nil {
  1940. return rr, off, err
  1941. }
  1942. if off == len(msg) {
  1943. return rr, off, nil
  1944. }
  1945. rr.PublicKeyAlgorithm, off, err = unpackUint8(msg, off)
  1946. if err != nil {
  1947. return rr, off, err
  1948. }
  1949. if off == len(msg) {
  1950. return rr, off, nil
  1951. }
  1952. rr.PublicKeyLength, off, err = unpackUint16(msg, off)
  1953. if err != nil {
  1954. return rr, off, err
  1955. }
  1956. if off == len(msg) {
  1957. return rr, off, nil
  1958. }
  1959. rr.Hit, off, err = unpackStringHex(msg, off, off+int(rr.HitLength))
  1960. if err != nil {
  1961. return rr, off, err
  1962. }
  1963. rr.PublicKey, off, err = unpackStringBase64(msg, off, off+int(rr.PublicKeyLength))
  1964. if err != nil {
  1965. return rr, off, err
  1966. }
  1967. rr.RendezvousServers, off, err = unpackDataDomainNames(msg, off, rdStart+int(rr.Hdr.Rdlength))
  1968. if err != nil {
  1969. return rr, off, err
  1970. }
  1971. return rr, off, err
  1972. }
  1973. func unpackKEY(h RR_Header, msg []byte, off int) (RR, int, error) {
  1974. rr := new(KEY)
  1975. rr.Hdr = h
  1976. if noRdata(h) {
  1977. return rr, off, nil
  1978. }
  1979. var err error
  1980. rdStart := off
  1981. _ = rdStart
  1982. rr.Flags, off, err = unpackUint16(msg, off)
  1983. if err != nil {
  1984. return rr, off, err
  1985. }
  1986. if off == len(msg) {
  1987. return rr, off, nil
  1988. }
  1989. rr.Protocol, off, err = unpackUint8(msg, off)
  1990. if err != nil {
  1991. return rr, off, err
  1992. }
  1993. if off == len(msg) {
  1994. return rr, off, nil
  1995. }
  1996. rr.Algorithm, off, err = unpackUint8(msg, off)
  1997. if err != nil {
  1998. return rr, off, err
  1999. }
  2000. if off == len(msg) {
  2001. return rr, off, nil
  2002. }
  2003. rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  2004. if err != nil {
  2005. return rr, off, err
  2006. }
  2007. return rr, off, err
  2008. }
  2009. func unpackKX(h RR_Header, msg []byte, off int) (RR, int, error) {
  2010. rr := new(KX)
  2011. rr.Hdr = h
  2012. if noRdata(h) {
  2013. return rr, off, nil
  2014. }
  2015. var err error
  2016. rdStart := off
  2017. _ = rdStart
  2018. rr.Preference, off, err = unpackUint16(msg, off)
  2019. if err != nil {
  2020. return rr, off, err
  2021. }
  2022. if off == len(msg) {
  2023. return rr, off, nil
  2024. }
  2025. rr.Exchanger, off, err = UnpackDomainName(msg, off)
  2026. if err != nil {
  2027. return rr, off, err
  2028. }
  2029. return rr, off, err
  2030. }
  2031. func unpackL32(h RR_Header, msg []byte, off int) (RR, int, error) {
  2032. rr := new(L32)
  2033. rr.Hdr = h
  2034. if noRdata(h) {
  2035. return rr, off, nil
  2036. }
  2037. var err error
  2038. rdStart := off
  2039. _ = rdStart
  2040. rr.Preference, off, err = unpackUint16(msg, off)
  2041. if err != nil {
  2042. return rr, off, err
  2043. }
  2044. if off == len(msg) {
  2045. return rr, off, nil
  2046. }
  2047. rr.Locator32, off, err = unpackDataA(msg, off)
  2048. if err != nil {
  2049. return rr, off, err
  2050. }
  2051. return rr, off, err
  2052. }
  2053. func unpackL64(h RR_Header, msg []byte, off int) (RR, int, error) {
  2054. rr := new(L64)
  2055. rr.Hdr = h
  2056. if noRdata(h) {
  2057. return rr, off, nil
  2058. }
  2059. var err error
  2060. rdStart := off
  2061. _ = rdStart
  2062. rr.Preference, off, err = unpackUint16(msg, off)
  2063. if err != nil {
  2064. return rr, off, err
  2065. }
  2066. if off == len(msg) {
  2067. return rr, off, nil
  2068. }
  2069. rr.Locator64, off, err = unpackUint64(msg, off)
  2070. if err != nil {
  2071. return rr, off, err
  2072. }
  2073. return rr, off, err
  2074. }
  2075. func unpackLOC(h RR_Header, msg []byte, off int) (RR, int, error) {
  2076. rr := new(LOC)
  2077. rr.Hdr = h
  2078. if noRdata(h) {
  2079. return rr, off, nil
  2080. }
  2081. var err error
  2082. rdStart := off
  2083. _ = rdStart
  2084. rr.Version, off, err = unpackUint8(msg, off)
  2085. if err != nil {
  2086. return rr, off, err
  2087. }
  2088. if off == len(msg) {
  2089. return rr, off, nil
  2090. }
  2091. rr.Size, off, err = unpackUint8(msg, off)
  2092. if err != nil {
  2093. return rr, off, err
  2094. }
  2095. if off == len(msg) {
  2096. return rr, off, nil
  2097. }
  2098. rr.HorizPre, off, err = unpackUint8(msg, off)
  2099. if err != nil {
  2100. return rr, off, err
  2101. }
  2102. if off == len(msg) {
  2103. return rr, off, nil
  2104. }
  2105. rr.VertPre, off, err = unpackUint8(msg, off)
  2106. if err != nil {
  2107. return rr, off, err
  2108. }
  2109. if off == len(msg) {
  2110. return rr, off, nil
  2111. }
  2112. rr.Latitude, off, err = unpackUint32(msg, off)
  2113. if err != nil {
  2114. return rr, off, err
  2115. }
  2116. if off == len(msg) {
  2117. return rr, off, nil
  2118. }
  2119. rr.Longitude, off, err = unpackUint32(msg, off)
  2120. if err != nil {
  2121. return rr, off, err
  2122. }
  2123. if off == len(msg) {
  2124. return rr, off, nil
  2125. }
  2126. rr.Altitude, off, err = unpackUint32(msg, off)
  2127. if err != nil {
  2128. return rr, off, err
  2129. }
  2130. return rr, off, err
  2131. }
  2132. func unpackLP(h RR_Header, msg []byte, off int) (RR, int, error) {
  2133. rr := new(LP)
  2134. rr.Hdr = h
  2135. if noRdata(h) {
  2136. return rr, off, nil
  2137. }
  2138. var err error
  2139. rdStart := off
  2140. _ = rdStart
  2141. rr.Preference, off, err = unpackUint16(msg, off)
  2142. if err != nil {
  2143. return rr, off, err
  2144. }
  2145. if off == len(msg) {
  2146. return rr, off, nil
  2147. }
  2148. rr.Fqdn, off, err = UnpackDomainName(msg, off)
  2149. if err != nil {
  2150. return rr, off, err
  2151. }
  2152. return rr, off, err
  2153. }
  2154. func unpackMB(h RR_Header, msg []byte, off int) (RR, int, error) {
  2155. rr := new(MB)
  2156. rr.Hdr = h
  2157. if noRdata(h) {
  2158. return rr, off, nil
  2159. }
  2160. var err error
  2161. rdStart := off
  2162. _ = rdStart
  2163. rr.Mb, off, err = UnpackDomainName(msg, off)
  2164. if err != nil {
  2165. return rr, off, err
  2166. }
  2167. return rr, off, err
  2168. }
  2169. func unpackMD(h RR_Header, msg []byte, off int) (RR, int, error) {
  2170. rr := new(MD)
  2171. rr.Hdr = h
  2172. if noRdata(h) {
  2173. return rr, off, nil
  2174. }
  2175. var err error
  2176. rdStart := off
  2177. _ = rdStart
  2178. rr.Md, off, err = UnpackDomainName(msg, off)
  2179. if err != nil {
  2180. return rr, off, err
  2181. }
  2182. return rr, off, err
  2183. }
  2184. func unpackMF(h RR_Header, msg []byte, off int) (RR, int, error) {
  2185. rr := new(MF)
  2186. rr.Hdr = h
  2187. if noRdata(h) {
  2188. return rr, off, nil
  2189. }
  2190. var err error
  2191. rdStart := off
  2192. _ = rdStart
  2193. rr.Mf, off, err = UnpackDomainName(msg, off)
  2194. if err != nil {
  2195. return rr, off, err
  2196. }
  2197. return rr, off, err
  2198. }
  2199. func unpackMG(h RR_Header, msg []byte, off int) (RR, int, error) {
  2200. rr := new(MG)
  2201. rr.Hdr = h
  2202. if noRdata(h) {
  2203. return rr, off, nil
  2204. }
  2205. var err error
  2206. rdStart := off
  2207. _ = rdStart
  2208. rr.Mg, off, err = UnpackDomainName(msg, off)
  2209. if err != nil {
  2210. return rr, off, err
  2211. }
  2212. return rr, off, err
  2213. }
  2214. func unpackMINFO(h RR_Header, msg []byte, off int) (RR, int, error) {
  2215. rr := new(MINFO)
  2216. rr.Hdr = h
  2217. if noRdata(h) {
  2218. return rr, off, nil
  2219. }
  2220. var err error
  2221. rdStart := off
  2222. _ = rdStart
  2223. rr.Rmail, off, err = UnpackDomainName(msg, off)
  2224. if err != nil {
  2225. return rr, off, err
  2226. }
  2227. if off == len(msg) {
  2228. return rr, off, nil
  2229. }
  2230. rr.Email, off, err = UnpackDomainName(msg, off)
  2231. if err != nil {
  2232. return rr, off, err
  2233. }
  2234. return rr, off, err
  2235. }
  2236. func unpackMR(h RR_Header, msg []byte, off int) (RR, int, error) {
  2237. rr := new(MR)
  2238. rr.Hdr = h
  2239. if noRdata(h) {
  2240. return rr, off, nil
  2241. }
  2242. var err error
  2243. rdStart := off
  2244. _ = rdStart
  2245. rr.Mr, off, err = UnpackDomainName(msg, off)
  2246. if err != nil {
  2247. return rr, off, err
  2248. }
  2249. return rr, off, err
  2250. }
  2251. func unpackMX(h RR_Header, msg []byte, off int) (RR, int, error) {
  2252. rr := new(MX)
  2253. rr.Hdr = h
  2254. if noRdata(h) {
  2255. return rr, off, nil
  2256. }
  2257. var err error
  2258. rdStart := off
  2259. _ = rdStart
  2260. rr.Preference, off, err = unpackUint16(msg, off)
  2261. if err != nil {
  2262. return rr, off, err
  2263. }
  2264. if off == len(msg) {
  2265. return rr, off, nil
  2266. }
  2267. rr.Mx, off, err = UnpackDomainName(msg, off)
  2268. if err != nil {
  2269. return rr, off, err
  2270. }
  2271. return rr, off, err
  2272. }
  2273. func unpackNAPTR(h RR_Header, msg []byte, off int) (RR, int, error) {
  2274. rr := new(NAPTR)
  2275. rr.Hdr = h
  2276. if noRdata(h) {
  2277. return rr, off, nil
  2278. }
  2279. var err error
  2280. rdStart := off
  2281. _ = rdStart
  2282. rr.Order, off, err = unpackUint16(msg, off)
  2283. if err != nil {
  2284. return rr, off, err
  2285. }
  2286. if off == len(msg) {
  2287. return rr, off, nil
  2288. }
  2289. rr.Preference, off, err = unpackUint16(msg, off)
  2290. if err != nil {
  2291. return rr, off, err
  2292. }
  2293. if off == len(msg) {
  2294. return rr, off, nil
  2295. }
  2296. rr.Flags, off, err = unpackString(msg, off)
  2297. if err != nil {
  2298. return rr, off, err
  2299. }
  2300. if off == len(msg) {
  2301. return rr, off, nil
  2302. }
  2303. rr.Service, off, err = unpackString(msg, off)
  2304. if err != nil {
  2305. return rr, off, err
  2306. }
  2307. if off == len(msg) {
  2308. return rr, off, nil
  2309. }
  2310. rr.Regexp, off, err = unpackString(msg, off)
  2311. if err != nil {
  2312. return rr, off, err
  2313. }
  2314. if off == len(msg) {
  2315. return rr, off, nil
  2316. }
  2317. rr.Replacement, off, err = UnpackDomainName(msg, off)
  2318. if err != nil {
  2319. return rr, off, err
  2320. }
  2321. return rr, off, err
  2322. }
  2323. func unpackNID(h RR_Header, msg []byte, off int) (RR, int, error) {
  2324. rr := new(NID)
  2325. rr.Hdr = h
  2326. if noRdata(h) {
  2327. return rr, off, nil
  2328. }
  2329. var err error
  2330. rdStart := off
  2331. _ = rdStart
  2332. rr.Preference, off, err = unpackUint16(msg, off)
  2333. if err != nil {
  2334. return rr, off, err
  2335. }
  2336. if off == len(msg) {
  2337. return rr, off, nil
  2338. }
  2339. rr.NodeID, off, err = unpackUint64(msg, off)
  2340. if err != nil {
  2341. return rr, off, err
  2342. }
  2343. return rr, off, err
  2344. }
  2345. func unpackNIMLOC(h RR_Header, msg []byte, off int) (RR, int, error) {
  2346. rr := new(NIMLOC)
  2347. rr.Hdr = h
  2348. if noRdata(h) {
  2349. return rr, off, nil
  2350. }
  2351. var err error
  2352. rdStart := off
  2353. _ = rdStart
  2354. rr.Locator, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  2355. if err != nil {
  2356. return rr, off, err
  2357. }
  2358. return rr, off, err
  2359. }
  2360. func unpackNINFO(h RR_Header, msg []byte, off int) (RR, int, error) {
  2361. rr := new(NINFO)
  2362. rr.Hdr = h
  2363. if noRdata(h) {
  2364. return rr, off, nil
  2365. }
  2366. var err error
  2367. rdStart := off
  2368. _ = rdStart
  2369. rr.ZSData, off, err = unpackStringTxt(msg, off)
  2370. if err != nil {
  2371. return rr, off, err
  2372. }
  2373. return rr, off, err
  2374. }
  2375. func unpackNS(h RR_Header, msg []byte, off int) (RR, int, error) {
  2376. rr := new(NS)
  2377. rr.Hdr = h
  2378. if noRdata(h) {
  2379. return rr, off, nil
  2380. }
  2381. var err error
  2382. rdStart := off
  2383. _ = rdStart
  2384. rr.Ns, off, err = UnpackDomainName(msg, off)
  2385. if err != nil {
  2386. return rr, off, err
  2387. }
  2388. return rr, off, err
  2389. }
  2390. func unpackNSAPPTR(h RR_Header, msg []byte, off int) (RR, int, error) {
  2391. rr := new(NSAPPTR)
  2392. rr.Hdr = h
  2393. if noRdata(h) {
  2394. return rr, off, nil
  2395. }
  2396. var err error
  2397. rdStart := off
  2398. _ = rdStart
  2399. rr.Ptr, off, err = UnpackDomainName(msg, off)
  2400. if err != nil {
  2401. return rr, off, err
  2402. }
  2403. return rr, off, err
  2404. }
  2405. func unpackNSEC(h RR_Header, msg []byte, off int) (RR, int, error) {
  2406. rr := new(NSEC)
  2407. rr.Hdr = h
  2408. if noRdata(h) {
  2409. return rr, off, nil
  2410. }
  2411. var err error
  2412. rdStart := off
  2413. _ = rdStart
  2414. rr.NextDomain, off, err = UnpackDomainName(msg, off)
  2415. if err != nil {
  2416. return rr, off, err
  2417. }
  2418. if off == len(msg) {
  2419. return rr, off, nil
  2420. }
  2421. rr.TypeBitMap, off, err = unpackDataNsec(msg, off)
  2422. if err != nil {
  2423. return rr, off, err
  2424. }
  2425. return rr, off, err
  2426. }
  2427. func unpackNSEC3(h RR_Header, msg []byte, off int) (RR, int, error) {
  2428. rr := new(NSEC3)
  2429. rr.Hdr = h
  2430. if noRdata(h) {
  2431. return rr, off, nil
  2432. }
  2433. var err error
  2434. rdStart := off
  2435. _ = rdStart
  2436. rr.Hash, off, err = unpackUint8(msg, off)
  2437. if err != nil {
  2438. return rr, off, err
  2439. }
  2440. if off == len(msg) {
  2441. return rr, off, nil
  2442. }
  2443. rr.Flags, off, err = unpackUint8(msg, off)
  2444. if err != nil {
  2445. return rr, off, err
  2446. }
  2447. if off == len(msg) {
  2448. return rr, off, nil
  2449. }
  2450. rr.Iterations, off, err = unpackUint16(msg, off)
  2451. if err != nil {
  2452. return rr, off, err
  2453. }
  2454. if off == len(msg) {
  2455. return rr, off, nil
  2456. }
  2457. rr.SaltLength, off, err = unpackUint8(msg, off)
  2458. if err != nil {
  2459. return rr, off, err
  2460. }
  2461. if off == len(msg) {
  2462. return rr, off, nil
  2463. }
  2464. rr.Salt, off, err = unpackStringHex(msg, off, off+int(rr.SaltLength))
  2465. if err != nil {
  2466. return rr, off, err
  2467. }
  2468. rr.HashLength, off, err = unpackUint8(msg, off)
  2469. if err != nil {
  2470. return rr, off, err
  2471. }
  2472. if off == len(msg) {
  2473. return rr, off, nil
  2474. }
  2475. rr.NextDomain, off, err = unpackStringBase32(msg, off, off+int(rr.HashLength))
  2476. if err != nil {
  2477. return rr, off, err
  2478. }
  2479. rr.TypeBitMap, off, err = unpackDataNsec(msg, off)
  2480. if err != nil {
  2481. return rr, off, err
  2482. }
  2483. return rr, off, err
  2484. }
  2485. func unpackNSEC3PARAM(h RR_Header, msg []byte, off int) (RR, int, error) {
  2486. rr := new(NSEC3PARAM)
  2487. rr.Hdr = h
  2488. if noRdata(h) {
  2489. return rr, off, nil
  2490. }
  2491. var err error
  2492. rdStart := off
  2493. _ = rdStart
  2494. rr.Hash, off, err = unpackUint8(msg, off)
  2495. if err != nil {
  2496. return rr, off, err
  2497. }
  2498. if off == len(msg) {
  2499. return rr, off, nil
  2500. }
  2501. rr.Flags, off, err = unpackUint8(msg, off)
  2502. if err != nil {
  2503. return rr, off, err
  2504. }
  2505. if off == len(msg) {
  2506. return rr, off, nil
  2507. }
  2508. rr.Iterations, off, err = unpackUint16(msg, off)
  2509. if err != nil {
  2510. return rr, off, err
  2511. }
  2512. if off == len(msg) {
  2513. return rr, off, nil
  2514. }
  2515. rr.SaltLength, off, err = unpackUint8(msg, off)
  2516. if err != nil {
  2517. return rr, off, err
  2518. }
  2519. if off == len(msg) {
  2520. return rr, off, nil
  2521. }
  2522. rr.Salt, off, err = unpackStringHex(msg, off, off+int(rr.SaltLength))
  2523. if err != nil {
  2524. return rr, off, err
  2525. }
  2526. return rr, off, err
  2527. }
  2528. func unpackOPENPGPKEY(h RR_Header, msg []byte, off int) (RR, int, error) {
  2529. rr := new(OPENPGPKEY)
  2530. rr.Hdr = h
  2531. if noRdata(h) {
  2532. return rr, off, nil
  2533. }
  2534. var err error
  2535. rdStart := off
  2536. _ = rdStart
  2537. rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  2538. if err != nil {
  2539. return rr, off, err
  2540. }
  2541. return rr, off, err
  2542. }
  2543. func unpackOPT(h RR_Header, msg []byte, off int) (RR, int, error) {
  2544. rr := new(OPT)
  2545. rr.Hdr = h
  2546. if noRdata(h) {
  2547. return rr, off, nil
  2548. }
  2549. var err error
  2550. rdStart := off
  2551. _ = rdStart
  2552. rr.Option, off, err = unpackDataOpt(msg, off)
  2553. if err != nil {
  2554. return rr, off, err
  2555. }
  2556. return rr, off, err
  2557. }
  2558. func unpackPTR(h RR_Header, msg []byte, off int) (RR, int, error) {
  2559. rr := new(PTR)
  2560. rr.Hdr = h
  2561. if noRdata(h) {
  2562. return rr, off, nil
  2563. }
  2564. var err error
  2565. rdStart := off
  2566. _ = rdStart
  2567. rr.Ptr, off, err = UnpackDomainName(msg, off)
  2568. if err != nil {
  2569. return rr, off, err
  2570. }
  2571. return rr, off, err
  2572. }
  2573. func unpackPX(h RR_Header, msg []byte, off int) (RR, int, error) {
  2574. rr := new(PX)
  2575. rr.Hdr = h
  2576. if noRdata(h) {
  2577. return rr, off, nil
  2578. }
  2579. var err error
  2580. rdStart := off
  2581. _ = rdStart
  2582. rr.Preference, off, err = unpackUint16(msg, off)
  2583. if err != nil {
  2584. return rr, off, err
  2585. }
  2586. if off == len(msg) {
  2587. return rr, off, nil
  2588. }
  2589. rr.Map822, off, err = UnpackDomainName(msg, off)
  2590. if err != nil {
  2591. return rr, off, err
  2592. }
  2593. if off == len(msg) {
  2594. return rr, off, nil
  2595. }
  2596. rr.Mapx400, off, err = UnpackDomainName(msg, off)
  2597. if err != nil {
  2598. return rr, off, err
  2599. }
  2600. return rr, off, err
  2601. }
  2602. func unpackRFC3597(h RR_Header, msg []byte, off int) (RR, int, error) {
  2603. rr := new(RFC3597)
  2604. rr.Hdr = h
  2605. if noRdata(h) {
  2606. return rr, off, nil
  2607. }
  2608. var err error
  2609. rdStart := off
  2610. _ = rdStart
  2611. rr.Rdata, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  2612. if err != nil {
  2613. return rr, off, err
  2614. }
  2615. return rr, off, err
  2616. }
  2617. func unpackRKEY(h RR_Header, msg []byte, off int) (RR, int, error) {
  2618. rr := new(RKEY)
  2619. rr.Hdr = h
  2620. if noRdata(h) {
  2621. return rr, off, nil
  2622. }
  2623. var err error
  2624. rdStart := off
  2625. _ = rdStart
  2626. rr.Flags, off, err = unpackUint16(msg, off)
  2627. if err != nil {
  2628. return rr, off, err
  2629. }
  2630. if off == len(msg) {
  2631. return rr, off, nil
  2632. }
  2633. rr.Protocol, off, err = unpackUint8(msg, off)
  2634. if err != nil {
  2635. return rr, off, err
  2636. }
  2637. if off == len(msg) {
  2638. return rr, off, nil
  2639. }
  2640. rr.Algorithm, off, err = unpackUint8(msg, off)
  2641. if err != nil {
  2642. return rr, off, err
  2643. }
  2644. if off == len(msg) {
  2645. return rr, off, nil
  2646. }
  2647. rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  2648. if err != nil {
  2649. return rr, off, err
  2650. }
  2651. return rr, off, err
  2652. }
  2653. func unpackRP(h RR_Header, msg []byte, off int) (RR, int, error) {
  2654. rr := new(RP)
  2655. rr.Hdr = h
  2656. if noRdata(h) {
  2657. return rr, off, nil
  2658. }
  2659. var err error
  2660. rdStart := off
  2661. _ = rdStart
  2662. rr.Mbox, off, err = UnpackDomainName(msg, off)
  2663. if err != nil {
  2664. return rr, off, err
  2665. }
  2666. if off == len(msg) {
  2667. return rr, off, nil
  2668. }
  2669. rr.Txt, off, err = UnpackDomainName(msg, off)
  2670. if err != nil {
  2671. return rr, off, err
  2672. }
  2673. return rr, off, err
  2674. }
  2675. func unpackRRSIG(h RR_Header, msg []byte, off int) (RR, int, error) {
  2676. rr := new(RRSIG)
  2677. rr.Hdr = h
  2678. if noRdata(h) {
  2679. return rr, off, nil
  2680. }
  2681. var err error
  2682. rdStart := off
  2683. _ = rdStart
  2684. rr.TypeCovered, off, err = unpackUint16(msg, off)
  2685. if err != nil {
  2686. return rr, off, err
  2687. }
  2688. if off == len(msg) {
  2689. return rr, off, nil
  2690. }
  2691. rr.Algorithm, off, err = unpackUint8(msg, off)
  2692. if err != nil {
  2693. return rr, off, err
  2694. }
  2695. if off == len(msg) {
  2696. return rr, off, nil
  2697. }
  2698. rr.Labels, off, err = unpackUint8(msg, off)
  2699. if err != nil {
  2700. return rr, off, err
  2701. }
  2702. if off == len(msg) {
  2703. return rr, off, nil
  2704. }
  2705. rr.OrigTtl, off, err = unpackUint32(msg, off)
  2706. if err != nil {
  2707. return rr, off, err
  2708. }
  2709. if off == len(msg) {
  2710. return rr, off, nil
  2711. }
  2712. rr.Expiration, off, err = unpackUint32(msg, off)
  2713. if err != nil {
  2714. return rr, off, err
  2715. }
  2716. if off == len(msg) {
  2717. return rr, off, nil
  2718. }
  2719. rr.Inception, off, err = unpackUint32(msg, off)
  2720. if err != nil {
  2721. return rr, off, err
  2722. }
  2723. if off == len(msg) {
  2724. return rr, off, nil
  2725. }
  2726. rr.KeyTag, off, err = unpackUint16(msg, off)
  2727. if err != nil {
  2728. return rr, off, err
  2729. }
  2730. if off == len(msg) {
  2731. return rr, off, nil
  2732. }
  2733. rr.SignerName, off, err = UnpackDomainName(msg, off)
  2734. if err != nil {
  2735. return rr, off, err
  2736. }
  2737. if off == len(msg) {
  2738. return rr, off, nil
  2739. }
  2740. rr.Signature, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  2741. if err != nil {
  2742. return rr, off, err
  2743. }
  2744. return rr, off, err
  2745. }
  2746. func unpackRT(h RR_Header, msg []byte, off int) (RR, int, error) {
  2747. rr := new(RT)
  2748. rr.Hdr = h
  2749. if noRdata(h) {
  2750. return rr, off, nil
  2751. }
  2752. var err error
  2753. rdStart := off
  2754. _ = rdStart
  2755. rr.Preference, off, err = unpackUint16(msg, off)
  2756. if err != nil {
  2757. return rr, off, err
  2758. }
  2759. if off == len(msg) {
  2760. return rr, off, nil
  2761. }
  2762. rr.Host, off, err = UnpackDomainName(msg, off)
  2763. if err != nil {
  2764. return rr, off, err
  2765. }
  2766. return rr, off, err
  2767. }
  2768. func unpackSIG(h RR_Header, msg []byte, off int) (RR, int, error) {
  2769. rr := new(SIG)
  2770. rr.Hdr = h
  2771. if noRdata(h) {
  2772. return rr, off, nil
  2773. }
  2774. var err error
  2775. rdStart := off
  2776. _ = rdStart
  2777. rr.TypeCovered, off, err = unpackUint16(msg, off)
  2778. if err != nil {
  2779. return rr, off, err
  2780. }
  2781. if off == len(msg) {
  2782. return rr, off, nil
  2783. }
  2784. rr.Algorithm, off, err = unpackUint8(msg, off)
  2785. if err != nil {
  2786. return rr, off, err
  2787. }
  2788. if off == len(msg) {
  2789. return rr, off, nil
  2790. }
  2791. rr.Labels, off, err = unpackUint8(msg, off)
  2792. if err != nil {
  2793. return rr, off, err
  2794. }
  2795. if off == len(msg) {
  2796. return rr, off, nil
  2797. }
  2798. rr.OrigTtl, off, err = unpackUint32(msg, off)
  2799. if err != nil {
  2800. return rr, off, err
  2801. }
  2802. if off == len(msg) {
  2803. return rr, off, nil
  2804. }
  2805. rr.Expiration, off, err = unpackUint32(msg, off)
  2806. if err != nil {
  2807. return rr, off, err
  2808. }
  2809. if off == len(msg) {
  2810. return rr, off, nil
  2811. }
  2812. rr.Inception, off, err = unpackUint32(msg, off)
  2813. if err != nil {
  2814. return rr, off, err
  2815. }
  2816. if off == len(msg) {
  2817. return rr, off, nil
  2818. }
  2819. rr.KeyTag, off, err = unpackUint16(msg, off)
  2820. if err != nil {
  2821. return rr, off, err
  2822. }
  2823. if off == len(msg) {
  2824. return rr, off, nil
  2825. }
  2826. rr.SignerName, off, err = UnpackDomainName(msg, off)
  2827. if err != nil {
  2828. return rr, off, err
  2829. }
  2830. if off == len(msg) {
  2831. return rr, off, nil
  2832. }
  2833. rr.Signature, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength))
  2834. if err != nil {
  2835. return rr, off, err
  2836. }
  2837. return rr, off, err
  2838. }
  2839. func unpackSMIMEA(h RR_Header, msg []byte, off int) (RR, int, error) {
  2840. rr := new(SMIMEA)
  2841. rr.Hdr = h
  2842. if noRdata(h) {
  2843. return rr, off, nil
  2844. }
  2845. var err error
  2846. rdStart := off
  2847. _ = rdStart
  2848. rr.Usage, off, err = unpackUint8(msg, off)
  2849. if err != nil {
  2850. return rr, off, err
  2851. }
  2852. if off == len(msg) {
  2853. return rr, off, nil
  2854. }
  2855. rr.Selector, off, err = unpackUint8(msg, off)
  2856. if err != nil {
  2857. return rr, off, err
  2858. }
  2859. if off == len(msg) {
  2860. return rr, off, nil
  2861. }
  2862. rr.MatchingType, off, err = unpackUint8(msg, off)
  2863. if err != nil {
  2864. return rr, off, err
  2865. }
  2866. if off == len(msg) {
  2867. return rr, off, nil
  2868. }
  2869. rr.Certificate, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  2870. if err != nil {
  2871. return rr, off, err
  2872. }
  2873. return rr, off, err
  2874. }
  2875. func unpackSOA(h RR_Header, msg []byte, off int) (RR, int, error) {
  2876. rr := new(SOA)
  2877. rr.Hdr = h
  2878. if noRdata(h) {
  2879. return rr, off, nil
  2880. }
  2881. var err error
  2882. rdStart := off
  2883. _ = rdStart
  2884. rr.Ns, off, err = UnpackDomainName(msg, off)
  2885. if err != nil {
  2886. return rr, off, err
  2887. }
  2888. if off == len(msg) {
  2889. return rr, off, nil
  2890. }
  2891. rr.Mbox, off, err = UnpackDomainName(msg, off)
  2892. if err != nil {
  2893. return rr, off, err
  2894. }
  2895. if off == len(msg) {
  2896. return rr, off, nil
  2897. }
  2898. rr.Serial, off, err = unpackUint32(msg, off)
  2899. if err != nil {
  2900. return rr, off, err
  2901. }
  2902. if off == len(msg) {
  2903. return rr, off, nil
  2904. }
  2905. rr.Refresh, off, err = unpackUint32(msg, off)
  2906. if err != nil {
  2907. return rr, off, err
  2908. }
  2909. if off == len(msg) {
  2910. return rr, off, nil
  2911. }
  2912. rr.Retry, off, err = unpackUint32(msg, off)
  2913. if err != nil {
  2914. return rr, off, err
  2915. }
  2916. if off == len(msg) {
  2917. return rr, off, nil
  2918. }
  2919. rr.Expire, off, err = unpackUint32(msg, off)
  2920. if err != nil {
  2921. return rr, off, err
  2922. }
  2923. if off == len(msg) {
  2924. return rr, off, nil
  2925. }
  2926. rr.Minttl, off, err = unpackUint32(msg, off)
  2927. if err != nil {
  2928. return rr, off, err
  2929. }
  2930. return rr, off, err
  2931. }
  2932. func unpackSPF(h RR_Header, msg []byte, off int) (RR, int, error) {
  2933. rr := new(SPF)
  2934. rr.Hdr = h
  2935. if noRdata(h) {
  2936. return rr, off, nil
  2937. }
  2938. var err error
  2939. rdStart := off
  2940. _ = rdStart
  2941. rr.Txt, off, err = unpackStringTxt(msg, off)
  2942. if err != nil {
  2943. return rr, off, err
  2944. }
  2945. return rr, off, err
  2946. }
  2947. func unpackSRV(h RR_Header, msg []byte, off int) (RR, int, error) {
  2948. rr := new(SRV)
  2949. rr.Hdr = h
  2950. if noRdata(h) {
  2951. return rr, off, nil
  2952. }
  2953. var err error
  2954. rdStart := off
  2955. _ = rdStart
  2956. rr.Priority, off, err = unpackUint16(msg, off)
  2957. if err != nil {
  2958. return rr, off, err
  2959. }
  2960. if off == len(msg) {
  2961. return rr, off, nil
  2962. }
  2963. rr.Weight, off, err = unpackUint16(msg, off)
  2964. if err != nil {
  2965. return rr, off, err
  2966. }
  2967. if off == len(msg) {
  2968. return rr, off, nil
  2969. }
  2970. rr.Port, off, err = unpackUint16(msg, off)
  2971. if err != nil {
  2972. return rr, off, err
  2973. }
  2974. if off == len(msg) {
  2975. return rr, off, nil
  2976. }
  2977. rr.Target, off, err = UnpackDomainName(msg, off)
  2978. if err != nil {
  2979. return rr, off, err
  2980. }
  2981. return rr, off, err
  2982. }
  2983. func unpackSSHFP(h RR_Header, msg []byte, off int) (RR, int, error) {
  2984. rr := new(SSHFP)
  2985. rr.Hdr = h
  2986. if noRdata(h) {
  2987. return rr, off, nil
  2988. }
  2989. var err error
  2990. rdStart := off
  2991. _ = rdStart
  2992. rr.Algorithm, off, err = unpackUint8(msg, off)
  2993. if err != nil {
  2994. return rr, off, err
  2995. }
  2996. if off == len(msg) {
  2997. return rr, off, nil
  2998. }
  2999. rr.Type, off, err = unpackUint8(msg, off)
  3000. if err != nil {
  3001. return rr, off, err
  3002. }
  3003. if off == len(msg) {
  3004. return rr, off, nil
  3005. }
  3006. rr.FingerPrint, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  3007. if err != nil {
  3008. return rr, off, err
  3009. }
  3010. return rr, off, err
  3011. }
  3012. func unpackTA(h RR_Header, msg []byte, off int) (RR, int, error) {
  3013. rr := new(TA)
  3014. rr.Hdr = h
  3015. if noRdata(h) {
  3016. return rr, off, nil
  3017. }
  3018. var err error
  3019. rdStart := off
  3020. _ = rdStart
  3021. rr.KeyTag, off, err = unpackUint16(msg, off)
  3022. if err != nil {
  3023. return rr, off, err
  3024. }
  3025. if off == len(msg) {
  3026. return rr, off, nil
  3027. }
  3028. rr.Algorithm, off, err = unpackUint8(msg, off)
  3029. if err != nil {
  3030. return rr, off, err
  3031. }
  3032. if off == len(msg) {
  3033. return rr, off, nil
  3034. }
  3035. rr.DigestType, off, err = unpackUint8(msg, off)
  3036. if err != nil {
  3037. return rr, off, err
  3038. }
  3039. if off == len(msg) {
  3040. return rr, off, nil
  3041. }
  3042. rr.Digest, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  3043. if err != nil {
  3044. return rr, off, err
  3045. }
  3046. return rr, off, err
  3047. }
  3048. func unpackTALINK(h RR_Header, msg []byte, off int) (RR, int, error) {
  3049. rr := new(TALINK)
  3050. rr.Hdr = h
  3051. if noRdata(h) {
  3052. return rr, off, nil
  3053. }
  3054. var err error
  3055. rdStart := off
  3056. _ = rdStart
  3057. rr.PreviousName, off, err = UnpackDomainName(msg, off)
  3058. if err != nil {
  3059. return rr, off, err
  3060. }
  3061. if off == len(msg) {
  3062. return rr, off, nil
  3063. }
  3064. rr.NextName, off, err = UnpackDomainName(msg, off)
  3065. if err != nil {
  3066. return rr, off, err
  3067. }
  3068. return rr, off, err
  3069. }
  3070. func unpackTKEY(h RR_Header, msg []byte, off int) (RR, int, error) {
  3071. rr := new(TKEY)
  3072. rr.Hdr = h
  3073. if noRdata(h) {
  3074. return rr, off, nil
  3075. }
  3076. var err error
  3077. rdStart := off
  3078. _ = rdStart
  3079. rr.Algorithm, off, err = UnpackDomainName(msg, off)
  3080. if err != nil {
  3081. return rr, off, err
  3082. }
  3083. if off == len(msg) {
  3084. return rr, off, nil
  3085. }
  3086. rr.Inception, off, err = unpackUint32(msg, off)
  3087. if err != nil {
  3088. return rr, off, err
  3089. }
  3090. if off == len(msg) {
  3091. return rr, off, nil
  3092. }
  3093. rr.Expiration, off, err = unpackUint32(msg, off)
  3094. if err != nil {
  3095. return rr, off, err
  3096. }
  3097. if off == len(msg) {
  3098. return rr, off, nil
  3099. }
  3100. rr.Mode, off, err = unpackUint16(msg, off)
  3101. if err != nil {
  3102. return rr, off, err
  3103. }
  3104. if off == len(msg) {
  3105. return rr, off, nil
  3106. }
  3107. rr.Error, off, err = unpackUint16(msg, off)
  3108. if err != nil {
  3109. return rr, off, err
  3110. }
  3111. if off == len(msg) {
  3112. return rr, off, nil
  3113. }
  3114. rr.KeySize, off, err = unpackUint16(msg, off)
  3115. if err != nil {
  3116. return rr, off, err
  3117. }
  3118. if off == len(msg) {
  3119. return rr, off, nil
  3120. }
  3121. rr.Key, off, err = unpackStringHex(msg, off, off+int(rr.KeySize))
  3122. if err != nil {
  3123. return rr, off, err
  3124. }
  3125. rr.OtherLen, off, err = unpackUint16(msg, off)
  3126. if err != nil {
  3127. return rr, off, err
  3128. }
  3129. if off == len(msg) {
  3130. return rr, off, nil
  3131. }
  3132. rr.OtherData, off, err = unpackStringHex(msg, off, off+int(rr.OtherLen))
  3133. if err != nil {
  3134. return rr, off, err
  3135. }
  3136. return rr, off, err
  3137. }
  3138. func unpackTLSA(h RR_Header, msg []byte, off int) (RR, int, error) {
  3139. rr := new(TLSA)
  3140. rr.Hdr = h
  3141. if noRdata(h) {
  3142. return rr, off, nil
  3143. }
  3144. var err error
  3145. rdStart := off
  3146. _ = rdStart
  3147. rr.Usage, off, err = unpackUint8(msg, off)
  3148. if err != nil {
  3149. return rr, off, err
  3150. }
  3151. if off == len(msg) {
  3152. return rr, off, nil
  3153. }
  3154. rr.Selector, off, err = unpackUint8(msg, off)
  3155. if err != nil {
  3156. return rr, off, err
  3157. }
  3158. if off == len(msg) {
  3159. return rr, off, nil
  3160. }
  3161. rr.MatchingType, off, err = unpackUint8(msg, off)
  3162. if err != nil {
  3163. return rr, off, err
  3164. }
  3165. if off == len(msg) {
  3166. return rr, off, nil
  3167. }
  3168. rr.Certificate, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength))
  3169. if err != nil {
  3170. return rr, off, err
  3171. }
  3172. return rr, off, err
  3173. }
  3174. func unpackTSIG(h RR_Header, msg []byte, off int) (RR, int, error) {
  3175. rr := new(TSIG)
  3176. rr.Hdr = h
  3177. if noRdata(h) {
  3178. return rr, off, nil
  3179. }
  3180. var err error
  3181. rdStart := off
  3182. _ = rdStart
  3183. rr.Algorithm, off, err = UnpackDomainName(msg, off)
  3184. if err != nil {
  3185. return rr, off, err
  3186. }
  3187. if off == len(msg) {
  3188. return rr, off, nil
  3189. }
  3190. rr.TimeSigned, off, err = unpackUint48(msg, off)
  3191. if err != nil {
  3192. return rr, off, err
  3193. }
  3194. if off == len(msg) {
  3195. return rr, off, nil
  3196. }
  3197. rr.Fudge, off, err = unpackUint16(msg, off)
  3198. if err != nil {
  3199. return rr, off, err
  3200. }
  3201. if off == len(msg) {
  3202. return rr, off, nil
  3203. }
  3204. rr.MACSize, off, err = unpackUint16(msg, off)
  3205. if err != nil {
  3206. return rr, off, err
  3207. }
  3208. if off == len(msg) {
  3209. return rr, off, nil
  3210. }
  3211. rr.MAC, off, err = unpackStringHex(msg, off, off+int(rr.MACSize))
  3212. if err != nil {
  3213. return rr, off, err
  3214. }
  3215. rr.OrigId, off, err = unpackUint16(msg, off)
  3216. if err != nil {
  3217. return rr, off, err
  3218. }
  3219. if off == len(msg) {
  3220. return rr, off, nil
  3221. }
  3222. rr.Error, off, err = unpackUint16(msg, off)
  3223. if err != nil {
  3224. return rr, off, err
  3225. }
  3226. if off == len(msg) {
  3227. return rr, off, nil
  3228. }
  3229. rr.OtherLen, off, err = unpackUint16(msg, off)
  3230. if err != nil {
  3231. return rr, off, err
  3232. }
  3233. if off == len(msg) {
  3234. return rr, off, nil
  3235. }
  3236. rr.OtherData, off, err = unpackStringHex(msg, off, off+int(rr.OtherLen))
  3237. if err != nil {
  3238. return rr, off, err
  3239. }
  3240. return rr, off, err
  3241. }
  3242. func unpackTXT(h RR_Header, msg []byte, off int) (RR, int, error) {
  3243. rr := new(TXT)
  3244. rr.Hdr = h
  3245. if noRdata(h) {
  3246. return rr, off, nil
  3247. }
  3248. var err error
  3249. rdStart := off
  3250. _ = rdStart
  3251. rr.Txt, off, err = unpackStringTxt(msg, off)
  3252. if err != nil {
  3253. return rr, off, err
  3254. }
  3255. return rr, off, err
  3256. }
  3257. func unpackUID(h RR_Header, msg []byte, off int) (RR, int, error) {
  3258. rr := new(UID)
  3259. rr.Hdr = h
  3260. if noRdata(h) {
  3261. return rr, off, nil
  3262. }
  3263. var err error
  3264. rdStart := off
  3265. _ = rdStart
  3266. rr.Uid, off, err = unpackUint32(msg, off)
  3267. if err != nil {
  3268. return rr, off, err
  3269. }
  3270. return rr, off, err
  3271. }
  3272. func unpackUINFO(h RR_Header, msg []byte, off int) (RR, int, error) {
  3273. rr := new(UINFO)
  3274. rr.Hdr = h
  3275. if noRdata(h) {
  3276. return rr, off, nil
  3277. }
  3278. var err error
  3279. rdStart := off
  3280. _ = rdStart
  3281. rr.Uinfo, off, err = unpackString(msg, off)
  3282. if err != nil {
  3283. return rr, off, err
  3284. }
  3285. return rr, off, err
  3286. }
  3287. func unpackURI(h RR_Header, msg []byte, off int) (RR, int, error) {
  3288. rr := new(URI)
  3289. rr.Hdr = h
  3290. if noRdata(h) {
  3291. return rr, off, nil
  3292. }
  3293. var err error
  3294. rdStart := off
  3295. _ = rdStart
  3296. rr.Priority, off, err = unpackUint16(msg, off)
  3297. if err != nil {
  3298. return rr, off, err
  3299. }
  3300. if off == len(msg) {
  3301. return rr, off, nil
  3302. }
  3303. rr.Weight, off, err = unpackUint16(msg, off)
  3304. if err != nil {
  3305. return rr, off, err
  3306. }
  3307. if off == len(msg) {
  3308. return rr, off, nil
  3309. }
  3310. rr.Target, off, err = unpackStringOctet(msg, off)
  3311. if err != nil {
  3312. return rr, off, err
  3313. }
  3314. return rr, off, err
  3315. }
  3316. func unpackX25(h RR_Header, msg []byte, off int) (RR, int, error) {
  3317. rr := new(X25)
  3318. rr.Hdr = h
  3319. if noRdata(h) {
  3320. return rr, off, nil
  3321. }
  3322. var err error
  3323. rdStart := off
  3324. _ = rdStart
  3325. rr.PSDNAddress, off, err = unpackString(msg, off)
  3326. if err != nil {
  3327. return rr, off, err
  3328. }
  3329. return rr, off, err
  3330. }
  3331. var typeToUnpack = map[uint16]func(RR_Header, []byte, int) (RR, int, error){
  3332. TypeA: unpackA,
  3333. TypeAAAA: unpackAAAA,
  3334. TypeAFSDB: unpackAFSDB,
  3335. TypeANY: unpackANY,
  3336. TypeAVC: unpackAVC,
  3337. TypeCAA: unpackCAA,
  3338. TypeCDNSKEY: unpackCDNSKEY,
  3339. TypeCDS: unpackCDS,
  3340. TypeCERT: unpackCERT,
  3341. TypeCNAME: unpackCNAME,
  3342. TypeCSYNC: unpackCSYNC,
  3343. TypeDHCID: unpackDHCID,
  3344. TypeDLV: unpackDLV,
  3345. TypeDNAME: unpackDNAME,
  3346. TypeDNSKEY: unpackDNSKEY,
  3347. TypeDS: unpackDS,
  3348. TypeEID: unpackEID,
  3349. TypeEUI48: unpackEUI48,
  3350. TypeEUI64: unpackEUI64,
  3351. TypeGID: unpackGID,
  3352. TypeGPOS: unpackGPOS,
  3353. TypeHINFO: unpackHINFO,
  3354. TypeHIP: unpackHIP,
  3355. TypeKEY: unpackKEY,
  3356. TypeKX: unpackKX,
  3357. TypeL32: unpackL32,
  3358. TypeL64: unpackL64,
  3359. TypeLOC: unpackLOC,
  3360. TypeLP: unpackLP,
  3361. TypeMB: unpackMB,
  3362. TypeMD: unpackMD,
  3363. TypeMF: unpackMF,
  3364. TypeMG: unpackMG,
  3365. TypeMINFO: unpackMINFO,
  3366. TypeMR: unpackMR,
  3367. TypeMX: unpackMX,
  3368. TypeNAPTR: unpackNAPTR,
  3369. TypeNID: unpackNID,
  3370. TypeNIMLOC: unpackNIMLOC,
  3371. TypeNINFO: unpackNINFO,
  3372. TypeNS: unpackNS,
  3373. TypeNSAPPTR: unpackNSAPPTR,
  3374. TypeNSEC: unpackNSEC,
  3375. TypeNSEC3: unpackNSEC3,
  3376. TypeNSEC3PARAM: unpackNSEC3PARAM,
  3377. TypeOPENPGPKEY: unpackOPENPGPKEY,
  3378. TypeOPT: unpackOPT,
  3379. TypePTR: unpackPTR,
  3380. TypePX: unpackPX,
  3381. TypeRKEY: unpackRKEY,
  3382. TypeRP: unpackRP,
  3383. TypeRRSIG: unpackRRSIG,
  3384. TypeRT: unpackRT,
  3385. TypeSIG: unpackSIG,
  3386. TypeSMIMEA: unpackSMIMEA,
  3387. TypeSOA: unpackSOA,
  3388. TypeSPF: unpackSPF,
  3389. TypeSRV: unpackSRV,
  3390. TypeSSHFP: unpackSSHFP,
  3391. TypeTA: unpackTA,
  3392. TypeTALINK: unpackTALINK,
  3393. TypeTKEY: unpackTKEY,
  3394. TypeTLSA: unpackTLSA,
  3395. TypeTSIG: unpackTSIG,
  3396. TypeTXT: unpackTXT,
  3397. TypeUID: unpackUID,
  3398. TypeUINFO: unpackUINFO,
  3399. TypeURI: unpackURI,
  3400. TypeX25: unpackX25,
  3401. }