def serialize(self):
        if self.size == 0:
            self.size = ((len(self.adrs) - 1) * (16 - self.cmpi) +
                         (16 - self.cmpe) + self._pad) // 8
        buf = struct.pack(self._PACK_STR, self.nxt, self.size,
                          self.type_, self.seg, (self.cmpi << 4) | self.cmpe,
                          self._pad << 4)
        buf = bytearray(buf)
        if self.size:
            form_i = "%ds" % (16 - self.cmpi)
            form_e = "%ds" % (16 - self.cmpe)
            slice_i = slice(self.cmpi, 16)
            slice_e = slice(self.cmpe, 16)
            for adr in self.adrs[:-1]:
                buf.extend(
                    struct.pack(
                        form_i, addrconv.ipv6.text_to_bin(adr)[slice_i]))
            buf.extend(struct.pack(
                form_e,
                addrconv.ipv6.text_to_bin(self.adrs[-1])[slice_e]))
        return buf
dataset/ETHPy150Open osrg/ryu/ryu/lib/packet/ipv6.py/routing_type3.serialize/original