[ofw] patch: [ipoib] replace guid with mac on option 160 of dhcp packet.

Tzachi Dar tzachid at mellanox.co.il
Sun Dec 26 07:44:33 PST 2010


[IPoIB_NDIS6_CM] Look for option 160 in a dhcp received packet. If the option exists, look for the guid in the packet. If the guid exists, replace it with the mac of the client.
This is needed in order to have more complicated altiris scenarios working.



Index: B:/users/tzachid/projinf6/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp
===================================================================
--- B:/users/tzachid/projinf6/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp              (revision 7083)
+++ B:/users/tzachid/projinf6/trunk/ulp/ipoib_NDIS6_CM/kernel/ipoib_port.cpp           (revision 7084)
@@ -2862,6 +2862,25 @@
 }


+uint8_t *FindString(uint8_t *src, uint16_t src_len,uint8_t* dst, uint16_t dest_len )
+{
+             int i;
+
+             if (src_len < dest_len) {
+                             ASSERT(FALSE);
+                             IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,("string to look for is too big ...\n"));
+                             return NULL;
+             }
+             for(i=0; i <= src_len - dest_len; i++) {
+                             if (RtlCompareMemory(src+i, dst, dest_len) == dest_len) {
+                                             // string was found
+                                             return src+i;
+                             }
+             }
+             return NULL;
+}
+
+
 static ib_api_status_t
 __recv_dhcp(
                IN                                                           ipoib_port_t* const                                        p_port,
@@ -2874,6 +2893,9 @@
                dhcp_pkt_t                                        *p_dhcp;
                uint8_t                                                 *p_option;
                uint8_t                                                 *p_cid = NULL;
+             uint8_t                                                 *p_opt160 = NULL;
+             uint16_t                                               p_opt160_len = 0;
+             uint8_t                                                 *p_opt160_guid = NULL;
                uint8_t                                                 msg = 0;

                IPOIB_ENTER( IPOIB_DBG_RECV );
@@ -2927,6 +2949,12 @@

                                case DHCP_OPT_CLIENT_ID:
                                                p_cid = p_option;
+                                             p_option += (p_option[1] + 2);
+                                             break;
+
+                             case 160:
+                                             p_opt160 = p_option;
+                                             p_opt160_len = p_option[1];
                                                /* Fall through. */

                                default:
@@ -2970,6 +2998,30 @@
                                                ("Invalide message type.\n") );
                                return IB_INVALID_PARAMETER;
                }
+
+             if (p_opt160) {
+                             // On the altiris system, the system sends a packet with option 160 that has a guid in it. we need to replace it with the mac
+
+                             // I know want to find the guid and replace it
+
+                             // make sure we don't get out of the buffer:
+                             p_opt160_len = (uint16_t)min(p_opt160_len, DHCP_OPTIONS_SIZE - (p_opt160 - &p_dhcp->options[0]));
+
+
+                             p_opt160_guid = FindString(p_opt160, p_opt160_len, p_src->dgid.raw+8, 6);
+                             if (p_opt160_guid != NULL) {
+                                             IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,("option 160 found, guid is replaced with mac\n"));
+                                             RtlCopyMemory( p_opt160_guid, &p_src->mac, sizeof(p_src->mac) );
+
+                             }
+                             else
+                             {
+                                             IPOIB_PRINT_EXIT( TRACE_LEVEL_ERROR, IPOIB_DBG_ERROR,("option 160 found but guid inside it not\n"));
+                             }
+             }
+
+
+
                p_eth->type.ip.prot.udp.hdr.chksum = 0;
                p_dhcp->htype = DHCP_HW_TYPE_ETH;
                p_dhcp->hlen = HW_ADDR_LEN;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/ofw/attachments/20101226/38786b2e/attachment.html>


More information about the ofw mailing list