A DHCPv6-based message processing method, device and medium

By establishing raw sockets in network devices and matching message processing rules, the problem of the Relay process being unable to receive messages when both DHCPv6 Server and DHCPv6 Relay functions are enabled simultaneously is resolved, ensuring the normal operation of the switch and the client.

CN116455872BActive Publication Date: 2026-07-14INSPUR NETWORK TECH (SHANDONG) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
INSPUR NETWORK TECH (SHANDONG) CO LTD
Filing Date
2023-04-18
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

When both DHCPv6 Server and DHCPv6 Relay functions are enabled on a network device, the Relay process cannot receive packets normally, affecting the normal operation of the switch and the client.

Method used

By establishing a raw socket in the network device, the message to be processed is obtained, the corresponding message processing rules are matched according to the port identifier, and the message is parsed and processed to send the processed message to the target port, ensuring that the Relay process can receive messages normally.

Benefits of technology

This ensures that the Relay process can receive packets normally when both DHCPv6 Server and DHCPv6 Relay functions are enabled on the network device, thus guaranteeing the normal operation of the switch and the client.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116455872B_ABST
    Figure CN116455872B_ABST
Patent Text Reader

Abstract

The application provides a message processing method and device based on DHCPV6 and a medium, and belongs to the technical field of communication. The message processing method is applied to a network device in which both DHCPv6 Server function and DHCPv6 Relay function are enabled. The method can establish a raw socket corresponding to a port of a to-be-processed message, acquire the to-be-processed message from the port of the to-be-processed message based on the raw socket, match a corresponding message processing rule according to a port identifier of the port of the to-be-processed message corresponding to the to-be-processed message, wherein the message processing rule at least comprises a message header processing rule corresponding to the port of the to-be-processed message, and perform analysis processing on the to-be-processed message based on the message processing rule to send a processed message to a target port.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of message communication technology, and in particular to a message processing method, device and medium based on DHCPV6. Background Technology

[0002] The Dynamic Host Configuration Protocol for IPv6 (DHCPv6) is designed for the IPv6 addressing scheme, assigning IPv6 addresses / prefixes and other network configuration parameters to hosts. While the IPv6 protocol features a vast address space, the 128-bit length of an IPv6 address necessitates efficient and reasonable automatic address allocation and management strategies.

[0003] Currently, when the switch simultaneously enables DHCPv6 Server and DHCPv6 Relay functions, it does not process packets when the server process receives them, but instead discards them directly. This prevents the relay process from receiving packets normally, affecting the normal operation of the switch and clients. Summary of the Invention

[0004] This application provides a DHCPv6-based message processing method, device, and medium to solve the problem that when network devices simultaneously enable DHCPv6 Server and DHCPv6 Relay functions, the Relay process cannot receive messages normally, affecting the normal operation of switches and clients.

[0005] On one hand, embodiments of this application provide a message processing method based on DHCPv6, which is applied to network devices where both DHCPv6 Server and DHCPv6 Relay functions are enabled. The method includes:

[0006] Establish a raw socket corresponding to the port of the message to be processed;

[0007] Based on the original socket, obtain the message to be processed from the message port to be processed;

[0008] Based on the port identifier of the port corresponding to the message to be processed, a corresponding message processing rule is matched; wherein, the message processing rule includes at least the message header processing rule corresponding to the port of the message to be processed;

[0009] Based on the aforementioned message processing rules, the message to be processed is parsed and processed so that the processed message is sent to the target port.

[0010] In one implementation of this application, the type of the original socket is User Datagram Protocol (UDP); and the port of the message to be processed is a UDP port.

[0011] In one implementation of this application, obtaining the message to be processed from the port to be processed based on the original socket specifically includes:

[0012] Based on the established original socket, a listening socket is established for the port of the message to be processed.

[0013] If the packet address of the port to be processed is detected to match the original socket, the packet to be processed is identified.

[0014] In one implementation of this application, a corresponding message processing rule is matched based on the port identifier of the port corresponding to the message to be processed, specifically including:

[0015] The port identifier of the port of the message to be processed is compared with a preset port list; wherein the port list includes at least the correspondence between the port identifier and the message processing rule;

[0016] Based on the comparison results, the message processing rules are determined.

[0017] In one implementation of this application, the message to be processed is parsed and processed based on the message processing rules, specifically including:

[0018] If the port is identified as a server or a relay, the first message processing rule is determined.

[0019] The UDP header of the message to be processed is removed using the first message processing rule in order to parse the message to be processed.

[0020] If the port is identified as a client, a second message processing rule is determined to parse the message to be processed.

[0021] In one implementation of this application, the message to be processed is parsed and processed based on the message processing rules in order to send the processed message to the target port, specifically including:

[0022] The message to be processed is parsed and processed to respond to the message to be processed, thus obtaining the processed message;

[0023] Based on the port identifier of the target port corresponding to the processed message, a UDP header identifier in a preset UDP header identifier table is determined, and the UDP header identifier is added to the processed message. The processed message with the UDP header identifier added is then sent to the target port.

[0024] In one implementation of this application, the network device first starts the DHCPv6 Server function, and then enables the DHCPv6 Relay function.

[0025] In one implementation of this application, the network device is a switch.

[0026] On the other hand, this application also provides a DHCPv6-based message processing device, which is applied to a network device where both DHCPv6 Server and DHCPv6 Relay functions are enabled; the device includes:

[0027] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0028] Establish a raw socket corresponding to the port of the message to be processed;

[0029] Based on the original socket, obtain the message to be processed from the message port to be processed;

[0030] Based on the port identifier of the port corresponding to the message to be processed, a corresponding message processing rule is matched; wherein, the message processing rule includes at least the message header processing rule corresponding to the port of the message to be processed;

[0031] Based on the aforementioned message processing rules, the message to be processed is parsed and processed so that the processed message is sent to the target port.

[0032] Furthermore, embodiments of this application also provide a non-volatile computer storage medium for message processing based on DHCPv6, storing computer-executable instructions, wherein the computer-executable instructions are configured as follows:

[0033] Establish a raw socket corresponding to the port of the message to be processed;

[0034] Based on the original socket, obtain the message to be processed from the message port to be processed;

[0035] Based on the port identifier of the port corresponding to the message to be processed, a corresponding message processing rule is matched; wherein, the message processing rule includes at least the message header processing rule corresponding to the port of the message to be processed;

[0036] Based on the aforementioned message processing rules, the message to be processed is parsed and processed so that the processed message is sent to the target port.

[0037] The above technical solution, which uses the method of creating a socket based on raw sockets, enables both DHCPv6 Server and DHCPv6 Relay functions. Even when the server process receives and discards packets, the relay process can still receive packets normally, ensuring the normal operation of the switch and the client. Attached Figure Description

[0038] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0039] Figure 1 This is a flowchart illustrating a message processing method based on DHCPv6 in an embodiment of this application.

[0040] Figure 2 This is a schematic diagram of another message processing method based on DHCPv6 in an embodiment of this application;

[0041] Figure 3 This is a schematic diagram of the structure of a message processing device based on DHCPV6 in an embodiment of this application. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0043] DHCPv6 technology solves the problem of having to manually configure IPv6 addresses for devices when deploying IPv6 networks. DHCPv6 offers the following advantages: 1. Better control over IPv6 address allocation; 2. DHCPv6 can not only record addresses assigned to IPv6 hosts but also assign specific addresses to specific IPv6 hosts; 3. DHCPv6 supports assigning IPv6 prefixes to network devices, facilitating automatic configuration and hierarchical network management. In addition to assigning IPv6 addresses / prefixes to IPv6 hosts, it can also assign network configuration parameters such as DNS server IPv6 addresses.

[0044] Because DHCPv6 messages are carried over UDPv6, and both the server and relay processes listen on UDP port 547, if the local device simultaneously enables both DHCPv6 Server and DHCPv6 Relay functions, when the peer server device connected to the Relay interface sends a message, both the Server and Relay processes can receive it. If the server receives the message, it will not process it and will discard it, causing the Relay to fail to receive the message correctly. Consequently, the client connected to the Relay will not receive a response message, and therefore, the client will not be able to be assigned an address.

[0045] The inventors discovered that when a device simultaneously enables both DHCPv6 Server and DHCPv6 Relay functions, if DHCPv6 Server is enabled first, the local device's Server process receives a message sent by the Server connected to the Relay port, but does not process the message and discards it directly. The Relay cannot receive the message and forward it to the Client, resulting in the Client being unable to be assigned an address.

[0046] Based on this, embodiments of this application provide a message processing method, device, and medium based on DHCPv6 to solve the problem that when network devices simultaneously enable DHCPv6 Server and DHCPv6 Relay functions, the Relay process cannot receive messages normally, affecting the normal operation of switches and clients.

[0047] The various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0048] This application provides a DHCPv6-based message processing method. This method is applied to network devices where both DHCPv6 Server and DHCPv6 Relay functions are enabled.Figure 1 As shown, the method may include steps S101-S104:

[0049] S101, the processor establishes a raw socket corresponding to the port of the message to be processed.

[0050] The processor, located within a network device such as a switch, connects to servers and clients, acting as a relay. In this embodiment, the network device first enables the DHCPv6 Server function, then activates the DHCPv6 Relay function. The port for processing packets is a UDP port; the processor can create raw UDP sockets and bind them to the UDP port.

[0051] Using the raw UDP sockets described above, even if the Server interface receives and discards the packet, the Relay interface can still obtain the raw socket packet.

[0052] S102, the processor obtains the message to be processed from the message port based on the raw socket.

[0053] In this embodiment of the application, obtaining the message to be processed from the port of the message to be processed based on the original socket specifically includes:

[0054] The processor can listen on the port of the message to be processed based on the established raw socket. If the address of the data packet on the port of the message to be processed matches the raw socket, the processor determines the message to be processed.

[0055] In other words, the processor listens to the socket, and when it detects a data packet address that matches the original socket, such as an IP address packet sent by the server to the client, both the Server and Relay processes receive the packet. The Server process will discard the packet, while the Relay process can process the packet normally.

[0056] S103, the processor matches the corresponding message processing rules based on the port identifier of the port corresponding to the message to be processed.

[0057] Among them, the message processing rules include at least the message header processing rules corresponding to the port of the message to be processed.

[0058] In this embodiment of the application, the corresponding message processing rules are matched according to the port identifier of the port corresponding to the message to be processed, specifically including:

[0059] The processor compares the port identifier of the packet to be processed with a preset port list. The port list includes at least the correspondence between port identifiers and packet processing rules. Based on the comparison result, the packet processing rules are determined.

[0060] A preset port list can be stored in memory connected to the processor. Upon receiving a message to be processed, the processor can determine the message processing rule that matches the port identifier of the message's port. The message processing rules differ for different messages.

[0061] S104: The processor parses and processes the message to be processed based on the message processing rules, and then sends the processed message to the target port.

[0062] In this embodiment of the application, the message to be processed is parsed and processed based on message processing rules, specifically including:

[0063] If the port is identified as either a server or a relay, the first message processing rule is determined. Based on this rule, the UDP header of the message to be processed is removed to parse the message.

[0064] If the port is identified as a client, determine the second message processing rules to parse the message to be processed.

[0065] For example, when receiving a raw socket message from the Relay / Server, the UDP header needs to be removed before processing; when receiving a message from the Client, it can be processed directly without removing the UDP header.

[0066] In this embodiment of the application, based on message processing rules, the message to be processed is parsed and processed in order to send the processed message to the target port, specifically including:

[0067] The processor parses and processes the unprocessed message to respond to it, obtaining a processed message. Based on the port identifier of the destination port corresponding to the processed message, the processor determines the UDP header identifier from the preset UDP header identifier table, adds the UDP header identifier to the processed message, and sends the processed message with the added UDP header identifier to the destination port.

[0068] After the processor parses the message, it can respond according to the message content and add a UDP header to the message content when sending the processed message. For example, when sending a message to the Client, the UDP header port number is 546, and when sending a message to the Relay, the UDP header port number is 547.

[0069] Specifically, if the target port corresponds to the client, a DHCPv6 address is assigned to the client.

[0070] The above technical solution utilizes raw sockets to create sockets. Packets sent from the server connected to the relay are simultaneously received by both the local device's server and relay. The server process discards the packets without processing them, while the relay process processes and forwards them normally, allowing the client to be assigned an address. In other words, even when the switch simultaneously enables DHCPv6 Server and DHCPv6 Relay functions, the relay process can still receive packets normally, even if the server process receives and discards them, ensuring the normal operation of both the switch and the client.

[0071] Figure 2 This is a flowchart illustrating another message processing method based on DHCPv6, as shown below. Figure 2 As shown, it specifically includes:

[0072] S201, Enable DHCPv6 Server; S202, Create UDP raw socket; S203, Socket listening; S204, Determine if it is a raw socket packet with a UDP header; S205, If yes, remove the UDP header, otherwise proceed to S206; S206, Packet processing; S207, Reply with a response packet; S208, Determine if to send a packet to the Relay / Server; S209, If yes, add a UDP header with port number 547; S2010, Otherwise, add a UDP header with port number 546; S2011, Send the packet.

[0073] Figure 3 This is a schematic diagram of a DHCPv6-based message processing device provided in an embodiment of this application. The message processing device is applied to a network device where both DHCPv6 Server and DHCPv6 Relay functions are enabled. The device includes:

[0074] At least one processor; and a memory communicatively connected to the at least one processor. The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to:

[0075] Establish a raw socket corresponding to the port of the message to be processed. Based on the raw socket, obtain the message to be processed from the port of the message to be processed. Match the corresponding message processing rules according to the port identifier of the port of the message to be processed. The message processing rules must include at least the message header processing rules corresponding to the port of the message to be processed. Based on the message processing rules, parse and process the message to be processed to send the processed message to the target port.

[0076] This application also provides a non-volatile computer storage medium for message processing based on DHCPv6, storing computer-executable instructions, which are configured as follows:

[0077] Establish a raw socket corresponding to the port of the message to be processed. Based on the raw socket, obtain the message to be processed from the port of the message to be processed. Match the corresponding message processing rules according to the port identifier of the port of the message to be processed. The message processing rules must include at least the message header processing rules corresponding to the port of the message to be processed. Based on the message processing rules, parse and process the message to be processed to send the processed message to the target port.

[0078] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0079] The devices and media described in the above embodiments can be implemented by computer chips or physical entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.

[0080] Those skilled in the art will understand that embodiments of this specification can be provided as methods, apparatus, or computer program products. Therefore, embodiments of this specification can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of this specification can take the form of computer program products embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0081] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0082] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0083] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0084] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0085] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0086] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0087] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0088] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0089] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments for devices and non-volatile computer storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0090] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0091] The above description is merely one or more embodiments of this specification and is not intended to limit this specification. Various modifications and variations can be made to the one or more embodiments of this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of one or more embodiments of this specification should be included within the scope of the claims of this specification.

Claims

1. A message processing method based on DHCPv6, characterized in that, The message processing method is applied to network devices where both DHCPv6Server and DHCPv6 Relay functions are enabled; the method includes: Establish a raw socket corresponding to the port of the message to be processed; Based on the original socket, obtain the message to be processed from the message port to be processed; specifically including: according to the established original socket, establish a listening socket for the message port to be processed; if the data packet address of the message port to be processed is found to match the original socket, determine the message to be processed; Based on the port identifier of the port corresponding to the message to be processed, a corresponding message processing rule is matched; wherein, the message processing rule includes at least the message header processing rule corresponding to the port of the message to be processed; Based on the message processing rules, the message to be processed is parsed and processed to send the processed message to the target port; specifically, this includes: when the port is identified as a server or a relay, determining a first message processing rule; removing the UDP header of the message to be processed using the first message processing rule to parse the message; and when the port is identified as a client, determining a second message processing rule to parse the message, wherein messages received from the client are processed directly without removing the UDP header. Specifically, parsing the unprocessed message to send the processed message to the target port includes: The message to be processed is parsed and processed to respond to the message to be processed, thus obtaining the processed message; Based on the port identifier of the target port corresponding to the processed message, a UDP header identifier in a preset UDP header identifier table is determined, and the UDP header identifier is added to the processed message. The processed message with the UDP header identifier added is then sent to the target port.

2. The method according to claim 1, characterized in that, The original socket is of type User Datagram Protocol (UDP); the port of the message to be processed is a UDP port.

3. The method according to claim 1, characterized in that, Based on the port identifier of the port corresponding to the message to be processed, the corresponding message processing rules are matched, specifically including: The port identifier of the port of the message to be processed is compared with a preset port list; wherein the port list includes at least the correspondence between the port identifier and the message processing rule; Based on the comparison results, the message processing rules are determined.

4. The method according to claim 1, characterized in that, The network device first starts the DHCPv6 Server function, and then enables the DHCPv6 Relay function.

5. The method according to claim 1, characterized in that, The network device is a switch.

6. A message processing device based on DHCPv6, characterized in that, The message processing device is used in network devices where both DHCPv6 Server and DHCPv6 Relay functions are enabled; the device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform a DHCPv6-based message processing method as described in any one of claims 1-5.

7. A non-volatile computer storage medium for message processing based on DHCPv6, storing computer-executable instructions, characterized in that, The computer-executable instructions are capable of executing a message processing method based on DHCPv6 as described in any one of claims 1-5.