// Build the Attribute list BUF *SstpBuildAttributeList(LIST *o, USHORT message_type) { UINT i; BUF *b; USHORT us; // Validate arguments if (o == NULL) { return NULL; } b = NewBuf(); us = Endian16(message_type); WriteBuf(b, &us, sizeof(USHORT)); us = Endian16((USHORT)LIST_NUM(o)); WriteBuf(b, &us, sizeof(USHORT)); for (i = 0;i < LIST_NUM(o);i++) { SSTP_ATTRIBUTE *a = LIST_DATA(o, i); BUF *ab = SstpBuildAttribute(a); if (ab != NULL) { WriteBufBuf(b, ab); FreeBuf(ab); } } return b; }
// ICMPv6 近隣要請パケットのビルド BUF *BuildICMPv6NeighborSoliciation(IPV6_ADDR *src_ip, IPV6_ADDR *target_ip, UCHAR *my_mac_address, UINT id) { ICMPV6_OPTION_LIST opt; ICMPV6_OPTION_LINK_LAYER link; ICMPV6_NEIGHBOR_SOLICIATION_HEADER header; BUF *b; BUF *b2; BUF *ret; // 引数チェック if (src_ip == NULL || target_ip == NULL || my_mac_address == NULL) { return NULL; } Zero(&link, sizeof(link)); Copy(link.Address, my_mac_address, 6); Zero(&opt, sizeof(opt)); opt.SourceLinkLayer = &link; b = BuildICMPv6Options(&opt); Zero(&header, sizeof(header)); Copy(&header.TargetAddress, target_ip, sizeof(IPV6_ADDR)); b2 = NewBuf(); WriteBuf(b2, &header, sizeof(header)); WriteBufBuf(b2, b); ret = BuildICMPv6(src_ip, target_ip, 255, ICMPV6_TYPE_NEIGHBOR_SOLICIATION, 0, b2->Buf, b2->Size, id); FreeBuf(b); FreeBuf(b2); return ret; }