Physical address generation and configuration method and device, equipment and medium

By judging and generating the MAC address when the communication module is powered on, using the information digest algorithm and intercepting characters to form a unique MAC address, the problem of low efficiency in MAC address generation and inability to guarantee uniqueness in the prior art is solved, and automation is achieved. Secure MAC address configuration.

CN119299424APending Publication Date: 2025-01-10FIBOCOM WIRELESS
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411456964.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

In the generation and configuration of MAC addresses, the prior art has problems such as low efficiency and inability to ensure uniqueness and certainty. In particular, random generation of MAC addresses requires a lot of time and regenerates each time they are turned on, so the stability of the MAC addresses cannot be guaranteed.

Method used

After powering on the communication module, determine whether there is a physical address storage file. If it does not exist, a random number is generated and the summary value is calculated using the preset information digest algorithm, appropriate characters are intercepted to form the MAC address, and written to the storage file. Configure the physical address of the network card according to the preset dialing method.

Benefits of technology

It realizes the uniqueness and certainty of automatically generating and configuring MAC addresses, avoids manual intervention, improves generation efficiency, and ensures the security of physical addresses to a certain extent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119299424A_ABST
    Figure CN119299424A_ABST
Patent Text Reader

Abstract

The invention discloses a physical address generation and configuration method and device, equipment and a medium, relates to the technical field of computers, is applied to a communication module, and comprises the steps of judging whether a physical address storage file exists locally or not after power-on startup; if the physical address storage file does not exist locally, generating a random number, and calculating the random number by using a preset information digest algorithm to generate a digest value corresponding to the random number; intercepting the abstract value to generate a first physical address, and writing the first physical address into a newly created physical address storage file; and configuring the first physical address to the target file node according to a preset dialing mode, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card. According to the method, the physical address is automatically generated and configured through the random number and the preset information digest algorithm, the method does not depend on manpower any more, and the uniqueness, certainty and safety of the physical address are guaranteed to a certain extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and medium for generating and configuring a physical address. Background Art

[0002] Communication modules are usually installed on various hosts as network cards to support network communication. Each network card has a corresponding MAC address (Media Access Control Address, also known as LAN address, physical address). Currently, a MAC address usually consists of 6 bytes, expressed as 12 hexadecimal numbers, of which the first three bytes are called the organization unique identifier, which is used to identify the manufacturer of the device; the last three bytes are the device unique identifier assigned by the manufacturer, which is used to identify the specific device. This structure ensures the uniqueness of the MAC address.

[0003] At present, the general practice of generating and configuring MAC addresses is: 1. Burn the MAC address into the storage device, and then read the MAC address through the communication module; 2. Generate a MAC address randomly. In the first solution, the MAC address is mainly written through the serial port, USB flash drive or network port. Among them, the solution of burning the MAC address through the serial port or network port requires the upper computer software, and also requires personnel participation, which increases the process; and the solution of burning the MAC address with a USB flash drive can be completed automatically, but it requires the device to support the USB (Universal Serial Bus) interface, which is not widely applicable and has certain security risks. In addition, the above three methods require the MAC address to be planned in advance to determine the MAC address of each batch of equipment. In the second solution, the generation efficiency of randomly generated MAC addresses is low, and a lot of time is wasted. In addition, the randomly generated MAC address cannot guarantee its uniqueness, and it will be regenerated every time the machine is turned on, and the certainty of the MAC address cannot be guaranteed.

[0004] In summary, how to automatically generate and configure MAC addresses and ensure their uniqueness and certainty is a problem that needs to be solved. Summary of the invention

[0005] In view of this, the purpose of the present invention is to provide a method, device, equipment and medium for generating and configuring a physical address, which can automatically generate and configure a MAC address and ensure its uniqueness and certainty. The specific scheme is as follows:

[0006] In a first aspect, the present application discloses a method for generating and configuring a physical address, which is applied to a communication module, comprising:

[0007] After powering on, determine whether there is a physical address storage file locally;

[0008] If the physical address storage file does not exist locally, a random number is generated, and the random number is calculated using a preset information digest algorithm to generate a digest value corresponding to the random number;

[0009] intercepting the digest value to generate a first physical address, and writing the first physical address into a newly created physical address storage file;

[0010] The first physical address is configured to the target file node according to a preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0011] Optionally, after determining whether a physical address storage file exists locally, the method further includes:

[0012] If a physical address storage file exists locally, read the second physical address in the physical address storage file;

[0013] The second physical address is configured to the target file node according to a preset dialing method, so that the host reads the target file node and uses the second physical address as the physical address of the network card.

[0014] Optionally, intercepting the digest value to generate a first physical address includes:

[0015] According to the preset physical address format requirements, a target separator is added to the summary value to obtain an added result, and a first preset number of characters are intercepted from the added result to generate a first physical address; wherein the first preset number is the sum of the total number of digits and the total number of separators determined according to the physical address format requirements.

[0016] Optionally, adding a target separator to the summary value according to a preset physical address format requirement to obtain an adding result includes:

[0017] For the digest value, add a target separator every two consecutive characters to obtain an addition result;

[0018] Accordingly, the step of extracting a first preset number of characters from the addition result to generate a first physical address includes:

[0019] Taking the first position in the addition result as a starting point, continuously intercepting a first preset number of characters to generate a first physical address;

[0020] Or, starting from the second position in the added result, continuously intercept a third preset number of characters to obtain a first interception result, and starting from the third position in the added result, continuously intercept a fourth preset number of characters to obtain a second interception result, and then the first interception result and the second interception result are spliced ​​to generate a first physical address; wherein the sum of the third preset number and the fourth preset number is the first preset number.

[0021] Optionally, intercepting the digest value to generate a first physical address includes:

[0022] A second preset number of characters is intercepted from the summary value to obtain a target interception result, and a target separator is added to the target interception result according to a preset physical address format requirement to generate a first physical address; wherein the second preset number is a total number of digits determined according to the physical address format requirement.

[0023] Optionally, the extracting a second preset number of characters from the digest value to obtain a target extraction result includes:

[0024] Taking the first position in the digest value as a starting point, continuously intercepting a second preset number of characters to obtain a target interception result;

[0025] Or, starting from the second position in the digest value, continuously intercepting a fifth preset number of characters to obtain a third interception result, and starting from the third position in the digest value, continuously intercepting a sixth preset number of characters to obtain a fourth interception result, and then splicing the third interception result and the fourth interception result to obtain a target interception result;

[0026] Correspondingly, adding a target separator to the target interception result according to a preset physical address format requirement to generate a first physical address includes:

[0027] For the target interception result, a target separator is added every two consecutive characters to generate a first physical address.

[0028] Optionally, after intercepting the digest value to generate the first physical address, the method further includes:

[0029] Determining whether the first physical address is within a preset physical address range to perform a validity check on the first physical address;

[0030] If it is within the preset physical address range, determining that the first physical address is legal, and executing the step of writing the first physical address into the newly created physical address storage file;

[0031] If it is not within the preset physical address range, the first physical address is determined to be illegal, and the process jumps again to the step of generating a random number and calculating the random number using a preset information digest algorithm.

[0032] In a second aspect, the present application discloses a physical address generation and configuration device, which is applied to a communication module, including:

[0033] A judgment module is used to judge whether there is a physical address storage file locally after power-on;

[0034] A summary value generation module, used for generating a random number if the physical address storage file does not exist locally, and calculating the random number using a preset information summary algorithm to generate a summary value corresponding to the random number;

[0035] An interception module, used for intercepting the summary value to generate a first physical address, and writing the first physical address into a newly created physical address storage file;

[0036] The configuration module is used to configure the first physical address to the target file node according to a preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0037] In a third aspect, the present application discloses an electronic device, comprising:

[0038] Memory, used to store computer programs;

[0039] The processor is used to execute the computer program to implement the steps of the aforementioned disclosed method for generating and configuring the physical address.

[0040] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the aforementioned disclosed method for generating and configuring a physical address are implemented.

[0041] It can be seen that after the communication module in the present application is powered on, it determines whether there is a physical address storage file locally; if there is no physical address storage file locally, a random number is generated, and the random number is calculated using a preset information digest algorithm to generate a summary value corresponding to the random number; the summary value is intercepted to generate a first physical address, and the first physical address is written into the newly created physical address storage file; the first physical address is configured to the target file node according to the preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0042] Beneficial effect: After the communication module in the present application is powered on, it is first necessary to determine whether there is a local physical address storage file. If not, a random number is generated, and then the random number is calculated using a preset information digest algorithm to generate a summary value corresponding to the random number. It should be noted that different data can generate a unique summary value after being processed by the preset information digest algorithm. Furthermore, the present application needs to intercept the summary value to generate a first physical address, and write the generated first physical address into the newly created physical address storage file, and then configure the first physical address to the target file node according to the preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card. That is, the present application automatically generates and configures the physical address through random numbers and preset information digest algorithms, no longer relying on manpower, and to a certain extent also guarantees the uniqueness, certainty and security of the physical address. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0044] Figure 1 A flow chart of a method for generating and configuring a physical address disclosed in this application;

[0045] Figure 2 A flow chart of a specific method for generating and configuring a physical address disclosed in this application;

[0046] Figure 3 A flowchart of another specific method for generating and configuring a physical address disclosed in this application;

[0047] Figure 4 A flow chart of MAC address generation and configuration for a communication module disclosed in this application;

[0048] Figure 5 A schematic diagram of the structure of a physical address generation and configuration device disclosed in this application;

[0049] Figure 6 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0051] At present, when generating and configuring MAC addresses, the general practice is: 1. Burn the MAC address into the storage device, and then read the MAC address through the communication module; 2. Randomly generate the MAC address. In the first scheme, the MAC address is mainly written through the serial port, U disk or network port. Among them, the scheme of burning the MAC address through the serial port or network port requires the upper computer software, and also requires the participation of the personnel, which increases the process; and the U disk burning MAC address scheme, although it can be completed automatically, requires the device to support the USB (Universal Serial Bus) interface, the applicability is not wide and there are certain safety hazards, and the above three methods all need to plan the MAC address in advance to determine the MAC address of each batch of equipment. In the second scheme, the generation efficiency of randomly generated MAC addresses is low, and a lot of time is wasted. In addition, the randomly generated MAC address cannot guarantee its uniqueness, and it will be regenerated every time it is turned on, and the MAC address certainty cannot be guaranteed. For this reason, the embodiment of the present application discloses a method, device, equipment and medium for generating and configuring a physical address, which can automatically generate and configure a MAC address and ensure its uniqueness and certainty.

[0052] See also Figure 1 As shown, the embodiment of the present application discloses a method for generating and configuring a physical address, the method comprising:

[0053] Step S11: After powering on, determine whether there is a local physical address storage file.

[0054] In this embodiment, after the communication module is powered on, it is first necessary to determine whether there is a physical address storage file locally. It should be pointed out that each communication module has its own IMEI (International Mobile Equipment Identity) code, which is set by the manufacturer when it comes out, fixed and unique, one machine and one code. IMEI is used to identify each independent mobile communication device in the mobile network, similar to the ID number of each communication device. The IMEI code consists of 15 to 17 digits, of which the first 8 digits are the model approval number, which is used to distinguish the brand and model of the mobile phone; the next 2 digits are the final assembly number, which represents the code of the final assembly; the last 6 digits are the serial number, which represents the production sequence number; the last digit is the check digit, which is used to verify the correctness of the entire IMEI code.

[0055] Step S12: If the physical address storage file does not exist locally, a random number is generated, and the random number is calculated using a preset information digest algorithm to generate a digest value corresponding to the random number.

[0056] In this embodiment, if the physical address storage file does not exist locally, a random number is generated by RANDOM (random number generator), and then the random number is calculated by using a preset information digest algorithm to generate a digest value corresponding to the random number. The preset information digest algorithm may specifically include but is not limited to the MD5 algorithm (Message Digest Algorithm 5), the SHA algorithm (Security Hash Algorithm), etc. It should be noted that different data can generate a unique digest value after being processed by the preset information digest algorithm.

[0057] Furthermore, after the above-mentioned determination of whether a physical address storage file exists locally, it also includes: if a physical address storage file exists locally, reading a second physical address in the physical address storage file; configuring the second physical address to a target file node according to a preset dialing method, so that the host reads the target file node to use the second physical address as the physical address of the network card.

[0058] That is, if there is a physical address storage file locally, the second physical address in the physical address storage file is directly read. At this time, there is no need to generate a new physical address, and the second physical address is configured to the target file node (host_addr) according to the preset dialing method, so that the host reads the target file node to use the second physical address as the physical address of the network card. Specifically, after the communication module enumerates the network card on the host, the host will read the physical address in host_addr and configure it as the physical address of the host-side network card according to the usb_gadget protocol. Among them, the linux usb_gadget framework is a framework that allows user space programs to dynamically configure USB devices. It provides APIs (Application Programming Interfaces) and tools so that users can create and configure the functions of USB devices as needed; it also provides a set of sysfs interfaces so that user space programs can configure USB devices through file operations. Developers can create, modify and delete the configuration, interface and endpoints of USB devices, and set their properties, such as type, address, maximum packet size, etc.

[0059] It should also be pointed out that the communication module is usually loaded on the host as a network card device. The host will load the corresponding network card driver according to the dial-up method of the communication module. Among them, the dial-up method is generally determined according to the communication method between the communication module and the network. For example, some common network card drivers are gobinet (rmnet), cdc_ether (ecm), cdc_mbim (mbim), cdc_rndis (rndis), etc. These drivers identify the communication module through id_table (identifier table) and load it to the corresponding intf (interface), and finally provide the network card for the host enumeration to achieve communication. If a new communication module adopts the dial-up method of cdc_mbim (mbim), when it is connected to the host, the host will confirm that this is the corresponding driver type by looking up the information related to cdc_mbim (mbim) in id_table, and then load the driver to the appropriate intf, so that the host can recognize and use this new network card for communication.

[0060] Step S13: intercepting the summary value to generate a first physical address, and writing the first physical address into a newly created physical address storage file.

[0061] In this embodiment, the summary value needs to be intercepted to generate the first physical address, and the generated first physical address is written into the newly created physical address storage file. That is, the present application automatically generates the physical address through random numbers and a preset information summary algorithm, which no longer relies on manpower, and to a certain extent also ensures the uniqueness, certainty and security of the physical address.

[0062] Furthermore, after the above-mentioned interception of the summary value to generate the first physical address, it also includes: determining whether the first physical address is within a preset physical address range to perform a legitimacy check on the first physical address; if it is within the preset physical address range, determining that the first physical address is legal, and executing the step of writing the first physical address to the newly created physical address storage file; if it is not within the preset physical address range, determining that the first physical address is illegal, and jumping back to the step of generating a random number, and calculating the random number using a preset information summary algorithm.

[0063] That is, after generating the first physical address, the present embodiment needs to perform a legality check on the first physical address to ensure that the generated physical address is legal. In a specific implementation, it is mainly to determine whether the generated first physical address is within the preset physical address range applied in advance. If it is within the preset physical address range, it is considered to be legal. If it is not within the preset physical address range, it is illegal, and then it needs to be regenerated, that is, jump to the step of generating a random number again, and use the preset information digest algorithm to calculate the random number, so as to generate a new first physical address.

[0064] Step S14: configuring the first physical address to the target file node according to a preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0065] In this embodiment, the first physical address is configured to the target file node according to the preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card. The method of configuring the first physical address is similar to the method of configuring the second physical address, which will not be repeated here.

[0066] It can be seen that after the communication module in the present application is powered on, it determines whether there is a physical address storage file locally; if there is no physical address storage file locally, a random number is generated, and the random number is calculated using a preset information digest algorithm to generate a summary value corresponding to the random number; the summary value is intercepted to generate a first physical address, and the first physical address is written into the newly created physical address storage file; the first physical address is configured to the target file node according to the preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0067] Beneficial effect: After the communication module in the present application is powered on, it is first necessary to determine whether there is a local physical address storage file. If not, a random number is generated, and then the random number is calculated using a preset information digest algorithm to generate a summary value corresponding to the random number. It should be noted that different data can generate a unique summary value after being processed by the preset information digest algorithm. Furthermore, the present application needs to intercept the summary value to generate a first physical address, and write the generated first physical address into the newly created physical address storage file, and then configure the first physical address to the target file node according to the preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card. That is, the present application automatically generates and configures the physical address through random numbers and preset information digest algorithms, no longer relying on manpower, and to a certain extent also guarantees the uniqueness, certainty and security of the physical address.

[0068] See also Figure 2 As shown, the embodiment of the present application discloses a specific method for generating and configuring a physical address. Compared with the previous embodiment, this embodiment further illustrates and optimizes the technical solution. Specifically, it includes:

[0069] Step S21: After powering on, determine whether there is a local physical address storage file.

[0070] Step S22: If the physical address storage file does not exist locally, a random number is generated, and the random number is calculated using a preset information digest algorithm to generate a digest value corresponding to the random number.

[0071] Step S23: Add a target separator to the summary value according to the preset physical address format requirements to obtain an added result, and intercept a first preset number of characters from the added result to generate a first physical address, and write the first physical address to a newly created physical address storage file; wherein the first preset number is the sum of the total number of digits and the total number of separators determined according to the physical address format requirements.

[0072] In this embodiment, after the corresponding summary value is generated for the random number using the preset information digest algorithm, a target separator is first added to the summary value according to the preset physical address format requirement. First of all, it should be pointed out that the physical address format requirement usually means that the MAC address consists of 6 bytes, expressed as 12 hexadecimal numbers, and each two hexadecimal numbers are separated by a target separator, where the target separator can specifically be a colon ":" or a hyphen "-"; for example, a specific physical address format is "00:1A:C2:7B:00:47" or "00-1A-C2-7B-00-47". Therefore, in this embodiment, the target separator is first added to the summary value according to the physical address format to obtain the addition result, and the first preset number of characters is intercepted from the addition result to generate the first physical address, where the first preset number refers to the sum of the total number of digits 12 and the total number of separators 5, that is, 17.

[0073] Specifically, the above-mentioned adding a target separator to the summary value according to the preset physical address format requirements to obtain an added result includes: for the summary value, adding a target separator every two consecutive characters to obtain an added result; correspondingly, intercepting a first preset number of characters from the added result to generate a first physical address includes: starting from the first position in the added result, continuously intercepting the first preset number of characters to generate the first physical address; or, starting from the second position in the added result, continuously intercepting a third preset number of characters to obtain a first interception result, and starting from the third position in the added result, continuously intercepting a fourth preset number of characters to obtain a second interception result, and then splicing the first interception result and the second interception result to generate a first physical address; wherein the sum of the third preset number and the fourth preset number is the first preset number.

[0074] Taking the MD5 algorithm as an example, after calculating the random number through the MD5 algorithm, a hash value with a fixed length of 128 bits is obtained. This value is usually expressed in the form of 32 hexadecimal digits. Because each hexadecimal digit can represent a 4-bit binary number, 128 bits can be expressed as a 32-character hexadecimal number. Then, for the digest value, a target separator is added every two consecutive characters to obtain the addition result.

[0075] Furthermore, when a first preset number of characters are intercepted from the addition result to generate a first physical address, the first preset number of characters can be continuously intercepted from the first position in the addition result to generate the first physical address. The first position can be the starting position in the addition result or the middle position in the addition result, and then 17 characters are continuously intercepted from the position as the starting point to generate the first physical address. In addition, it is necessary to ensure that the intercepted 17 characters include 12 hexadecimal digits and 5 target separators. That is, in this embodiment, 17 characters are continuously intercepted from the addition result as the first physical address.

[0076] In addition, when intercepting a first preset number of characters from the addition result to generate a first physical address, two segments of characters can also be intercepted from the addition result respectively, and then the two segments of characters are spliced ​​to generate the first physical address. Specifically, starting from the second position in the addition result, continuously intercepting a third preset number of characters to obtain a first interception result, and starting from the third position in the addition result, continuously intercepting a fourth preset number of characters to obtain a second interception result, and then splicing the two interception results to generate a first physical address. For example, the second position can be the starting position in the addition result, and the third position can be the middle position in the addition result, and then two segments of characters are intercepted respectively and then spliced; wherein, it is necessary to ensure that the sum of the third preset number and the fourth preset number is the first preset number 17, and it is necessary to ensure that the first physical address obtained by the final splicing meets the physical address format requirements and includes 12 hexadecimal digits and 5 target separators. In addition, this embodiment does not limit the specific size of the third preset number and the fourth preset number.

[0077] It should be noted that, in addition to intercepting two segments of characters from the added result and splicing them, three or four segments can also be intercepted and then spliced. However, no matter how many segments are intercepted, it is necessary to ensure that the final first physical address includes 12 hexadecimal digits and 5 target separators and meets the physical address format requirements.

[0078] Step S24: configuring the first physical address to the target file node according to a preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0079] For more specific processing procedures of the above steps S21, S22 and S24, reference may be made to the corresponding contents disclosed in the aforementioned embodiments, which will not be described in detail here.

[0080] It can be seen that the present application automatically generates a physical address through a random number and a preset information digest algorithm. In the specific process, after using the preset information digest algorithm to generate a corresponding digest value for the random number, the target separator is first added to the digest value according to the physical address format to obtain an addition result, and a first preset number of characters are intercepted from the addition result to generate a first physical address. The first preset number here refers to the sum of the total number of digits 12 and the total number of separators 5, that is, 17. When intercepting the first preset number of characters from the addition result to generate the first physical address, 17 characters can be continuously intercepted from the addition result as the first physical address, or several segments of characters can be intercepted from different positions of the addition result and then spliced ​​to generate the first physical address.

[0081] See also Figure 3As shown, the embodiment of the present application discloses a specific method for generating and configuring a physical address. Compared with the previous embodiment, this embodiment further illustrates and optimizes the technical solution. Specifically, it includes:

[0082] Step S31: After powering on, determine whether there is a local physical address storage file.

[0083] Step S32: If the physical address storage file does not exist locally, a random number is generated, and the random number is calculated using a preset information digest algorithm to generate a digest value corresponding to the random number.

[0084] Step S33: intercepting a second preset number of characters from the summary value to obtain a target interception result, and adding a target separator to the target interception result according to the preset physical address format requirements to generate a first physical address, and writing the first physical address to the newly created physical address storage file; wherein the second preset number is the total number of digits determined according to the physical address format requirements.

[0085] In this embodiment, after the random number is generated with the preset information digest algorithm, a second preset number of characters are first intercepted from the digest value to obtain a target interception result, where the second preset number is the total number of digits determined according to the physical address format requirements, i.e., 12. Then, a target separator is added to the target interception result according to the preset physical address format requirements to generate a first physical address.

[0086] Specifically, the above-mentioned intercepting a second preset number of characters from the summary value to obtain the target interception result includes: starting from the first position in the summary value, continuously intercepting the second preset number of characters to obtain the target interception result; or, starting from the second position in the summary value, continuously intercepting a fifth preset number of characters to obtain a third interception result, and starting from the third position in the summary value, continuously intercepting a sixth preset number of characters to obtain a fourth interception result, and then splicing the third interception result and the fourth interception result to obtain the target interception result.

[0087] Taking the MD5 algorithm as an example, after calculating the random number through the MD5 algorithm, a hash value with a fixed length of 128 bits is obtained. This value is usually expressed in the form of 32 hexadecimal digits.

[0088] Then, in a specific implementation, the first position in the digest value can be used as the starting point to continuously intercept 12 characters to obtain the target interception result. The first position can be the starting position in the digest value or the middle position in the digest value. This implementation does not limit it, as long as 12 characters can be continuously intercepted starting from the first position.

[0089] In another specific implementation, the second position in the digest value can be used as a starting point to continuously intercept a fifth preset number of characters to obtain a third interception result, and the third position in the digest value can be used as a starting point to continuously intercept a sixth preset number of characters to obtain a fourth interception result, and then the two interception results are spliced ​​to obtain a target interception result. For example, the second position can be the starting position in the digest value, and the third position can be the middle position in the digest value, and then two segments of characters are intercepted respectively and then spliced; wherein, it is necessary to ensure that the sum of the fifth preset number and the sixth preset number is the second preset number 12, and this embodiment does not limit the specific size of the third preset number and the fourth preset number.

[0090] It should be pointed out that, in addition to the above-mentioned method of cutting off two segments of characters from the digest value and then concatenating them, three or four segments can also be cut off and then concatenated.

[0091] After obtaining the target interception result, adding a target separator to the target interception result according to the preset physical address format requirement to generate the first physical address includes: for the target interception result, adding a target separator every two consecutive characters to generate the first physical address. That is, according to the physical address format requirement, adding a target separator to the target interception result every two consecutive characters to generate the first physical address.

[0092] Step S34: configuring the first physical address to the target file node according to a preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0093] For more specific processing procedures of the above steps S31, S32 and S34, reference may be made to the corresponding contents disclosed in the above embodiments, which will not be described in detail here.

[0094] It can be seen that the present application automatically generates a physical address through a random number and a preset information digest algorithm. In the specific process, after using the preset information digest algorithm to generate a corresponding digest value for the random number, 12 characters are first intercepted from the digest value to obtain the target interception result. Among them, 12 characters can be continuously intercepted from the digest value to obtain the target interception result, and several segments of characters can be intercepted from different positions of the digest value, and then spliced ​​to obtain the target interception result. After obtaining the target interception result, a target separator is added to the target interception result every two consecutive characters according to the physical address format requirements to generate the first physical address.

[0095] Figure 4 This is a flow chart of MAC address generation and configuration of a communication module disclosed in this application. The specific process is as follows:

[0096] (1) The communication module is connected to the host through the USB interface, and the communication module is powered on;

[0097] (2) After the module is turned on, determine whether there is a physical address storage file locally;

[0098] (3) If there is a local physical address storage file, read the second physical address in the physical address storage file and configure it to the target file node (host_addr) according to the dial-up mode rndis, specifically / sys / kernel / config / usb_gadget / g1 / functions / gsi.rndis / host_addr

[0099] (4) If the physical address storage file does not exist locally, a random number is generated through RANDOM, and the random number is calculated using the MD5 algorithm to obtain a digest value;

[0100] (5) For the digest value, search for two consecutive characters and add a colon “:” after them;

[0101] (6) intercepting the first 17 characters in the result of (5) to generate the first physical address. Under specific requirements, the intercepted 17 characters may be specially processed, for example, the second character may be replaced with 0 according to the specific needs of the user;

[0102] (7) Check the legality of the generated first physical address. If it is legal, write it into the newly created physical address storage file, and configure the first physical address to the target file node (host_addr) according to the preset dialing method, such as / sys / kernel / config / usb_gadget / g1 / functions / gsi.rndis / host_addr; if it is illegal, jump to (4) to regenerate a new random number;

[0103] (8) After the communication module enumerates the network card on the host, the host reads the physical address stored in host_addr according to the usb_gadget protocol and configures it as the physical address of the host-side network card.

[0104] This embodiment automatically generates a physical address through a random number + md5 algorithm, and this method of random number + md5 algorithm guarantees the uniqueness, certainty and security of the physical address to a certain extent; in addition, the configuration of the physical address no longer relies on manpower, and does not require personnel participation. As long as the rules are formulated, the network card on the host is automatically configured after the communication module is turned on. That is, this solution is based on this method of random number + md5 algorithm, combined with the characteristics of the usb_gadget framework, to achieve a low-cost, fully automatic, customer-unaware physical address generation and configuration solution, which improves the overall mass production efficiency and reduces costs.

[0105] See also Figure 5 As shown, the embodiment of the present application discloses a method for generating and configuring a physical address, the method comprising:

[0106] A judgment module 11 is used to judge whether there is a local physical address storage file after powering on;

[0107] A digest value generating module 12 is used to generate a random number if the physical address storage file does not exist locally, and calculate the random number using a preset information digest algorithm to generate a digest value corresponding to the random number;

[0108] An interception module 13, configured to intercept the summary value to generate a first physical address, and write the first physical address into a newly created physical address storage file;

[0109] The configuration module 14 is used to configure the first physical address to the target file node according to a preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0110] It can be seen that after the communication module in the present application is powered on, it determines whether there is a physical address storage file locally; if there is no physical address storage file locally, a random number is generated, and the random number is calculated using a preset information digest algorithm to generate a summary value corresponding to the random number; the summary value is intercepted to generate a first physical address, and the first physical address is written into the newly created physical address storage file; the first physical address is configured to the target file node according to the preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

[0111] Beneficial effect: After the communication module in the present application is powered on, it is first necessary to determine whether there is a local physical address storage file. If not, a random number is generated, and then the random number is calculated using a preset information digest algorithm to generate a summary value corresponding to the random number. It should be noted that different data can generate a unique summary value after being processed by the preset information digest algorithm. Furthermore, the present application needs to intercept the summary value to generate a first physical address, and write the generated first physical address into the newly created physical address storage file, and then configure the first physical address to the target file node according to the preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card. That is, the present application automatically generates and configures the physical address through random numbers and preset information digest algorithms, no longer relying on manpower, and to a certain extent also guarantees the uniqueness, certainty and security of the physical address.

[0112] Since the embodiments of the device part correspond to the above embodiments, please refer to the description of the embodiments of the method part for the embodiments of the device part, and will not be repeated here.

[0113] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Specifically, it may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the method for generating and configuring a physical address performed by an electronic device disclosed in any of the aforementioned embodiments.

[0114] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0115] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0116] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222 and data 223, etc. The storage method can be temporary storage or permanent storage.

[0117] Among them, the operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, so as to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, which can be Windows, Unix, Linux, etc. In addition to including a computer program that can be used to complete the physical address generation and configuration method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. In addition to data received by the electronic device and transmitted from an external device, the data 223 can also include data collected by its own input and output interface 25, etc.

[0118] Furthermore, an embodiment of the present application also discloses a computer-readable storage medium, in which a computer program is stored. When the computer program is loaded and executed by a processor, the steps of the method for generating and configuring the physical address disclosed in any of the aforementioned embodiments are implemented.

[0119] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0120] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0121] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a compact disc read-only memory (CD-ROM), or any other form of storage medium known in the art.

[0122] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0123] The above is a detailed introduction to a physical address generation and configuration method, device, equipment and storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for a person skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for generating and configuring a physical address, characterized in that: Applied to communication modules, including: After powering on, determine whether there is a physical address storage file locally; If the physical address storage file does not exist locally, a random number is generated, and the random number is calculated using a preset information digest algorithm to generate a digest value corresponding to the random number; intercepting the digest value to generate a first physical address, and writing the first physical address into a newly created physical address storage file; The first physical address is configured to the target file node according to a preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

2. The method for generating and configuring a physical address according to claim 1, characterized in that: After determining whether there is a local physical address storage file, the method further includes: If a physical address storage file exists locally, read the second physical address in the physical address storage file; The second physical address is configured to the target file node according to a preset dialing method, so that the host reads the target file node and uses the second physical address as the physical address of the network card.

3. The method for generating and configuring a physical address according to claim 1, characterized in that: The intercepting the digest value to generate a first physical address comprises: According to the preset physical address format requirements, a target separator is added to the summary value to obtain an added result, and a first preset number of characters are intercepted from the added result to generate a first physical address; wherein the first preset number is the sum of the total number of digits and the total number of separators determined according to the physical address format requirements.

4. The method for generating and configuring a physical address according to claim 3, characterized in that: The adding of the target separator to the summary value according to the preset physical address format requirement to obtain the adding result includes: For the digest value, add a target separator every two consecutive characters to obtain an added result; Accordingly, the step of extracting a first preset number of characters from the addition result to generate a first physical address includes: Taking the first position in the addition result as a starting point, continuously intercepting a first preset number of characters to generate a first physical address; Or, starting from the second position in the added result, continuously intercept a third preset number of characters to obtain a first interception result, and starting from the third position in the added result, continuously intercept a fourth preset number of characters to obtain a second interception result, and then the first interception result and the second interception result are spliced ​​to generate a first physical address; wherein the sum of the third preset number and the fourth preset number is the first preset number.

5. The method for generating and configuring a physical address according to claim 1, characterized in that: The step of intercepting the digest value to generate a first physical address comprises: A second preset number of characters is intercepted from the summary value to obtain a target interception result, and a target separator is added to the target interception result according to a preset physical address format requirement to generate a first physical address; wherein the second preset number is a total number of digits determined according to the physical address format requirement.

6. The method for generating and configuring a physical address according to claim 5, characterized in that: The step of intercepting a second preset number of characters from the digest value to obtain a target interception result includes: Taking the first position in the digest value as a starting point, continuously intercepting a second preset number of characters to obtain a target interception result; Or, starting from the second position in the digest value, continuously intercepting a fifth preset number of characters to obtain a third interception result, and starting from the third position in the digest value, continuously intercepting a sixth preset number of characters to obtain a fourth interception result, and then splicing the third interception result and the fourth interception result to obtain a target interception result; Correspondingly, adding a target separator to the target interception result according to a preset physical address format requirement to generate a first physical address includes: For the target interception result, a target separator is added every two consecutive characters to generate a first physical address.

7. The method for generating and configuring a physical address according to any one of claims 1 to 6, characterized in that: After intercepting the summary value to generate the first physical address, the method further includes: Determining whether the first physical address is within a preset physical address range to perform a validity check on the first physical address; If it is within the preset physical address range, determining that the first physical address is legal, and executing the step of writing the first physical address into the newly created physical address storage file; If it is not within the preset physical address range, the first physical address is determined to be illegal, and the process jumps again to the step of generating a random number and calculating the random number using a preset information digest algorithm.

8. A device for generating and configuring a physical address, characterized in that: Applied to communication modules, including: A judgment module is used to judge whether there is a physical address storage file locally after power-on; A summary value generation module, used for generating a random number if the physical address storage file does not exist locally, and calculating the random number using a preset information summary algorithm to generate a summary value corresponding to the random number; An interception module, used for intercepting the summary value to generate a first physical address, and writing the first physical address into a newly created physical address storage file; The configuration module is used to configure the first physical address to the target file node according to a preset dialing method, so that after the host reads the target file node, the first physical address is configured as the physical address of the network card.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the method for generating and configuring a physical address as claimed in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program; wherein, when the computer program is executed by a processor, the steps of the method for generating and configuring a physical address as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Radio frequency identification (RFID) privacy authenticating method

    CN101645138A

  • Mac address generation method of GNSS receiver

    CN106341254A

  • Method and device for configuring MAC address of FPGA accelerator card and accelerator card

    CN109451098A

  • Short link generation method, device and equipment and computer readable storage medium

    CN116028734A

  • Chip starting method and device, equipment and medium

    CN116719565A