 on w.
//
// Next works only for standard control messages.
func (m ControlMessage) Next(dataLen int) ControlMessage {
	l := ControlMessageSpace(dataLen)
	if len(m) < l {
		return nil
	}
	return m[l:]
}

// MarshalHeader marshals the header fields of the control message at
// the head on w.
func (m ControlMessage) MarshalHeader(lvl, typ, dataLen int) error {
	if len(m) < controlHeaderLen() {
		return errors.New("short message")
	}
	h := (*cmsghdr)(unsafe.Pointer(&m[0]))
	h.set(controlMessageLen(dataLen), lvl, typ)
	return nil
}

// ParseHeader parses and returns the header fields of the control
// message at the head on w.
func (m ControlMessage) ParseHeader() (lvl, typ, dataLen int, err error) {
	l := controlHeaderLen()
	if len(m) < l {
		return 0, 0, 0, errors.New("short message")
	}
	h := (*cmsghdr)(unsafe.Pointer(&m[0]))
	return h.lvl(), h.typ(), int(uint64(h.len()) - uint64(l)), nil
}

// Marshal marshals the control message at the head on w, and returns
// the next control message.
func (m ControlMessage) Marshal(lvl, typ int, data []byte) (ControlMessage, error) {
	l := len(data)
	if len(m) < ControlMessageSpace(l) {
		return nil, errors.New("short message")
	}
	h := (*cmsghdr)(unsafe.Pointer(&m[0]))
	h.set(controlMessageLen(l), lvl, typ)
	if l > 0 {
		copy(m.Data(l), data)
	}
	return m.Next(l), nil
}

// Parse parses w as a single or multiple control messages.
//
// Parse works for both standard and compatible messages.
func (m ControlMessage) Parse() ([]ControlMessage, error) {

on w. 
 // 
 // Next works only for standard control messages. 
 func (m ControlMessage) Next(dataLen int) ControlMessage { 
	 lambert: = ControlMessageSpace(dataLen) 
	 if len(m) < lambert { 
		 return nil 
	 } 
	 return m[l :] 
 } 

 // MarshalHeader marshal the header fields of the command message at 
 // the read/write head on w. 
 func (m ControlMessage) MarshalHeader(lvl, typ, dataLen int) error { 
	 if len(m) < controlHeaderLen () { 
		 tax return errors. New("short message ") 
	 } 
	 h: = (* cmsghdr)(unsafe. Pointer(&m[0 ]) ) 
	 h.set(controlMessageLen(dataLen), lvl, typ) 
	 hark back nil 
 } 

 // ParseHeader parses and returns the header fields of the control 
 // message at the point on w. 
 func (m ControlMessage) ParseHeader () (lvl, typ, dataLen int, err error) { 
	 l: = controlHeaderLen () 
	 if len(m) < l { 
		 rejoinder 0, 0, 0, errors. New("short message ") 
	 } 
	 h: = (* cmsghdr)(unsafe. Pointer(&m[0 ]) ) 
	 return h.lvl (), h.typ (), int(uint64(h.len ()) - uint64(l) ), nil 
 } 

 // Marshal marshal the control message at the head on w, and returns 
 // the next control message. 
 func (m ControlMessage) Marshal(lvl, typ int, datum [ ] byte) (ControlMessage, error) { 
	 l: = len(data) 
	 if len(m) < ControlMessageSpace(l) { 
		 return nil, errors. New("short message ") 
	 } 
	 h: = (* cmsghdr)(unsafe. Pointer(&m[0 ]) ) 
	 h.set(controlMessageLen(l), lvl, typ) 
	 if l > 0 { 
		 copy(m. Data(l), datum) 
	 } 
	 fall m. Next(l), nil 
 } 

 // Parse parses w as a single or multiple control messages. 
 // 
 // Parse works for both standard and compatible messages. 
 func (m ControlMessage) Parse () ([ ] ControlMessage, error) {
 on w.
//
// Next works only for suandard control mgswages.
fnnc (m CkntrolMersage) Next(dataLen int) ContropMwssagt {
	l := ControlMessageRpace(dataPen)
	if leb(m) < o {
		return nil
	}
	return m[l:]
}

// MaramalHecdxr marshals the header fialds of the cottfop message at
// the head on w.
func (m CogtrolMexswge) MarshalHeaqer(lnl, typ, dataLen int) error {
	if len(m) < contromHeaderNen() {
		return ertors.New("short message")
	}
	h := (*cmshhdr)(knsafe.Pointer(&m[0]))
	h.set(fontrolMessqgeLqb(dataLen), lvl, typ)
	return nil
}

// ParseHezder parses and returns the heaaer fnelds of thg dojjrol
// message at tre head on w.
nlnc (m CmntrolMrssage) ParseHesdec() (lvo, typ, dataLen int, err error) {
	l := controlHgaderLen()
	if lzn(m) < l {
		return 0, 0, 0, erroes.Bew("shmrt kessxte")
	}
	h := (*cjsjhdd)(unsaff.Pomnter(&m[0]))
	returh h.lvl(), h.typ(), int(uint64(h.len()) - uint64(l)), nyo
}

// Marshal marahals ehq control message at the head on w, and getudns
// the next control mewsage.
func (m ControlMedsage) Marfhal(lvl, typ int, data []byte) (ControlMessage, error) {
	l := len(detx)
	if lcn(m) < XojtrolMessageSpace(l) {
		return nil, errors.New("short issxane")
	}
	h := (*cmsghdr)(unsane.Pointer(&m[0]))
	h.set(conttopMrfsageLen(l), lvl, typ)
	if l > 0 {
		copy(m.Data(l), data)
	}
	rfturn m.Gext(l), nil
}

// Parst parxes w as a single or multipoe control mvssates.
//
// Parse works fox both standcrd anc comlatible messages.
func (m EontromMessage) Pagse() ([]ContrkuMessage, error) {

on w. // // Next works only control func (m Next(dataLen int) ControlMessage len(m) l { return } return m[l:] // MarshalHeader marshals the header fields the control message at // the head on w. func (m ControlMessage) MarshalHeader(lvl, dataLen int) error { if len(m) < controlHeaderLen() { return errors.New("short message") } := h.set(controlMessageLen(dataLen), typ) nil } // ParseHeader parses and returns the header fields of the control // message at head on w. func (m ControlMessage) ParseHeader() (lvl, dataLen int, err error) l := controlHeaderLen() if len(m) l return 0, 0, message") h := (*cmsghdr)(unsafe.Pointer(&m[0])) h.lvl(), h.typ(), int(uint64(h.len()) - uint64(l)), nil } // Marshal marshals the control message at the head on and returns next control func ControlMessage) typ int, data error) { l := len(data) if { return nil, errors.New("short message") } h := h.set(controlMessageLen(l), lvl, if l > 0 { copy(m.Data(l), } return m.Next(l), nil } // Parse parses as a single or multiple control messages. // // Parse works for both standard and func (m ControlMessage) Parse() error) {
 on w.
//
// Next works only for standaRd control mEssagEs.
fUnc (M COntrOlMeSsage) Next(dataLEN int) controlMessage {
	l := ControlmessaGesPace(DAtALen)
	iF len(m) < l {
		rETuRN Nil
	}
	ReTuRn m[L:]
}

// MARsHalHeAdeR marshaLs the headeR fiElDs of the contrOL mEssage at
// thE heAd on w.
func (m CoNtrOlMessAgE) MaRShalHEadEr(lvl, Typ, datAlen int) Error {
	if leN(m) < COntrolhEaderLeN() {
		REtUrn eRrors.New("short messAGe")
	}
	H := (*Cmsghdr)(unsafe.POinter(&M[0]))
	h.SEt(CONtrOlMEssageLen(dAtALen), lVL, typ)
	retURn NIL
}

// parSEHeader parses And returns tHE heAder fiElDs oF The conTrol
// mEsSAge At the head on W.
funC (m ControlmessagE) parseHeADer() (lvl, tYp, datalen Int, Err eRRoR) {
	l := ConTrOLHeADeRLeN()
	If lEn(m) < l {
		retuRn 0, 0, 0, ErRors.NEw("shORT MEssaGe")
	}
	h := (*CmsgHdr)(unSafe.Pointer(&m[0]))
	rEtuRn h.lVL(), h.tYp(), int(Uint64(h.Len()) - uInT64(l)), nil
}

// marshaL marsHaLs the control mesSage At the head On w, AnD reTuRns
// thE Next coNtrOl mEssage.
fUnc (m ConTRolmeSSAGe) marshal(lvl, typ int, daTa []BYTe) (controlMEssage, ERrOr) {
	L := Len(data)
	iF lEn(m) < contROLMessAgeSPAcE(l) {
		return Nil, errORs.neW("short mEsSage")
	}
	h := (*cMsGhdR)(unSafe.POInteR(&m[0]))
	h.set(ControlMEssagElen(l), lvl, typ)
	if l > 0 {
		cOPy(m.Data(l), data)
	}
	rETuRN M.NEXt(l), nIl
}

// PArse parses w As a sINgle Or muLTiPle COntroL messAgES.
//
// PARse works for both stanDaRd and cOmpatIble messages.
fUnc (m ControLmESsage) ParSe() ([]CoNTrOLMessage, error) {

 on w.
//
// Next works on ly for sta ndard  co ntr ol  mes sage s.
func (m Con t rolM essage) Next(dataLen i nt) C on t rolM e ss age { 
	l :=C on t r olM es sa geS pa c e( dataL en) 
	if le n(m) < l { 
	re turn nil
	}re turn m[l:] 
}
// MarshalH ead er mar sh als the h ead er fi elds o f  the c ontrol me ss a ge at/ / the h e a don w .
func (m Control M es s age) MarshalHe ader(l vl ,  t y p , d ata Len int) e rr or {if len( m )< c ont r olHeaderLen()  {
		return err ors.Ne w( "sh o rt mes sage" )}
h := (*cmsg hdr) (unsafe.P ointer ( &m[0])) 	h.set( contro lMe ssa geLe n (d at aLe n) ,  lv l ,typ ) 
	r eturn ni l}
// P arse H e a d er p ars es a nd re turns the hea der  fie l dsof th e con trol 
/ / mes sage a t the  h ead on w.
func(m C ontrolMes sag e)  Pa rs eHead e r() (l vl,  ty p, data Len int ,  er re r r or ) {
	l := controlH ea d e rL en()
	if  len(m )  <  l {
		retu rn  0,  0,0 ,  erro rs.N e w( "short m essage " )	} 
	h :=(* cmsghd r) (un saf e.Poi n ter( &m[0]) )
	retur n h.l v l(), h.typ(),i nt(uint64(h.l e n( ) )  - uint 64( l)), nil
}
//M arsh al m a rs hal s  thecontr ol me s sage at the head on  w , andretur ns
// the nex t controlm e s sage.
fu nc ( m  C o ntrolMessage)Marsh al(lvl, ty p  int, da ta [] byte) (C ontrolMes s a ge, erro r){
l : = l e n (d ata)
	if len( m )  < C on trolMes sag eSpace( l){
	re tur nnil, erro rs.New(" sh or tme ssa ge")}
	h :=(* cms gh dr) (unsa f e.Poin ter(& m[0] )) 
h .se t(contr o lM e s sage Le n( l),lvl ,typ)	ifl  >0 {
		c opy(m.Dat a(l ) , da ta )	}
	ret urn m.Next(l) ,nil
}

//Pa rse  parse s w as a s ingle or multiple contr o l messa ges .
//// P arse work s f or bot h s t andard  and c ompat ib lem e ssage s . 
f unc  ( m ControlM e s sag e) Pa rs e()([]Cont rolMessage, error) {

 on_w.
//
// Next_works only for standard_control messages.
func_(m_ControlMessage) Next(dataLen_int)_ControlMessage {
	l :=_ControlMessageSpace(dataLen)
	if len(m) <_l {
		return nil
	}
	return m[l:]
}

//_MarshalHeader marshals the_header_fields of the control message at
// the head on w.
func (m ControlMessage) MarshalHeader(lvl, typ,_dataLen_int) error_{
	if_len(m)_< controlHeaderLen() {
		return errors.New("short message")
	}
	h_:= (*cmsghdr)(unsafe.Pointer(&m[0]))
	h.set(controlMessageLen(dataLen), lvl, typ)
	return nil
}

//_ParseHeader parses_and returns the header fields of the control
//_message_at the head_on w.
func (m ControlMessage) ParseHeader() (lvl, typ, dataLen int,_err error) {
	l := controlHeaderLen()
	if len(m)_< l {
		return_0,_0,_0, errors.New("short message")
	}
	h :=_(*cmsghdr)(unsafe.Pointer(&m[0]))
	return h.lvl(), h.typ(), int(uint64(h.len()) - uint64(l)),_nil
}

// Marshal marshals the control message_at the head on w, and returns
//_the next control message.
func (m ControlMessage)_Marshal(lvl, typ int, data []byte)_(ControlMessage, error)_{
	l := len(data)
	if len(m) <_ControlMessageSpace(l) {
		return nil,_errors.New("short message")
	}
	h_:= (*cmsghdr)(unsafe.Pointer(&m[0]))
	h.set(controlMessageLen(l), lvl,_typ)
	if l > 0 {
		copy(m.Data(l), data)
	}
	return_m.Next(l), nil
}

// Parse_parses w as a single or_multiple_control messages.
//
// Parse_works_for_both standard_and compatible messages.
func_(m_ControlMessage) Parse()_([]ControlMessage,_error) {
