Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide the coding method of a kind of OAM protocol stack and system, huge for solving the workload of prior art OAM protocol stack development, code is write the problem that efficiency code low and exploitation is not easy to follow-up maintenance.
For achieving the above object and other relevant objects, the invention provides the coding method of a kind of OAM protocol stack.The coding method of described OAM protocol stack comprises: object definition module is set; According to described object definition template, OAM object is defined to OAM object correlation attribute value; According to the described OAM object correlation attribute value of definition, generate the relevant code of OAM protocol stack.
Alternatively, described object definition template comprises: the definition to the parameter of the global property of object and object; The global property of described object comprises: the title of object, object B ranch value and object Leaf value; The parameter attribute of described object comprises: the length that the title of parameter, the data type of parameter and parameter take in internal memory.
Alternatively, the relevant code of described OAM protocol stack comprises: the public function source code of protocol stack; The public function source code of described protocol stack comprises the structure of protocol stack object; The generation of described structure code is to generate a structure example according to OAM object definition described in each
Alternatively, the relevant code of described OAM protocol stack comprises: the public function source code of protocol stack; The public function source code of described protocol stack comprises the structure array statement of protocol stack object and gets number of objects function; The generation of described structure array statement code is to generate a structure example according to OAM object definition described in each, and all described structure examples form the statement of structure array; The described number of objects function of getting returns to the object number in described structure array.
Alternatively, the described specific implementation according to a structure of OAM object definition generation described in each comprises: according to the title of described object, described object B ranch value, object Leaf value, generate a structure example; Described structure example comprise corresponding object Branch, Leaf, function and value function are set.
Alternatively, the relevant code of described OAM protocol stack comprises: protocol stack object function code is set; The described parameter that function input is set comprises reply message internal memory pointer, message valid data field pointer and object instance number is set; Described object instance number is for determining described OAM object; The global property of described OAM object also comprises: message id is set, message structure body is set, mark and object process ID are manually set; When described OAM object, sign is manually set for default when sign is manually set, the described function code that arranges generating comprises: according to described, the respective attributes value that message valid data field pointer obtains described OAM object is set, and the respective attributes value of described OAM object is filled up to arranging in message structure body of described OAM object; Message id being set, message structure body and object process ID are set generate and message is set sends to target process according to described OAM object; According to arranging of described target process, reply definite setting of message and reply code; The Branch value of described OAM object, Leaf value and the described reply code that arranges are filled up to the definite relevant position of described reply message internal memory pointer.
Alternatively, when the object of described OAM object manually arranges, be designated defaultly when sign is manually set, the described function that arranges generating is do-nothing function, and now the described function that arranges needs artificial treatment.
Alternatively, the relevant code of described OAM protocol stack comprises: the value function code of protocol stack object; The parameter of described value function input comprises replys message internal memory pointer, value message valid data field pointer and object instance number; Described object instance number is for determining described OAM object; The global property of described OAM object also comprises: value message id, value message structure body, manual value mark and object process ID; When the manual value of described OAM object is designated default manual value sign, the described value function code of generation comprises: according to the value message id of described OAM object, value message structure body and object process ID, generate value message and send to target process; According to the value of described target process, reply the respective attributes value that message is obtained described OAM object, and the respective attributes value of described OAM object B ranch value, Leaf value and the described OAM object that obtains is filled into the definite relevant position of described reply message internal memory pointer.
Alternatively, work as described OAM object the manual value of object while being designated default manual value sign, the described value function generating is do-nothing function, now the described function that arranges needs artificial treatment.
The present invention also provides a kind of OAM protocol stack coded system.Described OAM protocol stack coded system comprises: template definition module, for object definition module is set; Object definition module, is connected with described template definition module, for OAM object being defined to OAM object correlation attribute value according to described object definition template; Code generation module, is connected with described object definition module, for the described OAM object correlation attribute value according to definition, generates the relevant code of OAM protocol stack.
Alternatively, the described object definition template in described template definition module comprises: the definition to the parameter of the global property of object and object; The global property of described object comprises: the title of object, object B ranch value and object Leaf value; The parameter attribute of described object comprises: the length that the title of parameter, the data type of parameter and parameter take in internal memory.
Alternatively, the relevant code of described OAM protocol stack in described code generation module comprises: the public function source code of protocol stack; The public function source code of described protocol stack comprises the structure array statement of protocol stack object and gets object function; The generation of described structure array statement code is to generate a structure example according to OAM object definition described in each, and all described structure examples form the statement of structure array; The described object function of getting returns to the object number in described structure array.
Alternatively, the relevant code of described OAM protocol stack in described code generation module comprises: the public function source code of protocol stack; The public function source code of described protocol stack comprises the structure of protocol stack object; The generation of described structure code is to generate a structure example according to OAM object definition described in each.
Alternatively, described structure example comprise corresponding object Branch, Leaf, function and value function are set; The relevant code of described OAM protocol stack in described code generation module comprises: protocol stack object function code is set; The described parameter that function input is set comprises reply message internal memory pointer, message valid data field pointer and object instance number is set; Described object instance number is for determining described OAM object; The global property of described OAM object also comprises: message id is set, message structure body is set, mark and object process ID are manually set; When described OAM object, sign is manually set for default when sign is manually set, the described function code that arranges generating comprises: according to described, the respective attributes value that message valid data field pointer obtains described OAM object is set, and the respective attributes value of described OAM object is filled up to arranging in message structure body of described OAM object; Message id being set, message structure body and object process ID are set generate and message is set sends to target process according to described OAM object; According to arranging of described target process, reply definite setting of message and reply code; The Branch value of described OAM object, Leaf value and the described reply code that arranges are filled up to the definite relevant position of described reply message internal memory pointer.
Alternatively, described structure example comprise corresponding object Branch, Leaf, function and value function are set; The relevant code of described OAM protocol stack in described code generation module comprises: the value function code of protocol stack object; The parameter of described value function input comprises replys message internal memory pointer, value message valid data field pointer and object instance number; Described object instance number is for determining described OAM object; The global property of described OAM object also comprises: value message id, value message structure body, manual value mark and object process ID; When the manual value of described OAM object is designated default manual value sign, the described value function code of generation comprises: according to the value message id of described OAM object, value message structure body and object process ID, generate value message and send to target process; According to the value of described target process, reply the respective attributes value that message is obtained described OAM object, and the respective attributes value of described OAM object B ranch value, Leaf value and the described OAM object that obtains is filled into the definite relevant position of described reply message internal memory pointer.
As mentioned above, a kind of OAM protocol stack of the present invention coding method and system, there is following beneficial effect: can automatically realize the automatic generation of part OAM protocol stack correlative code, the efficiency of writing of code is not only provided greatly, shortened the project development cycle, and accuracy, the clarity of the code automatically generating also obtained enhancing, for secondary development and the maintenance in later stage provides a great convenience.
Embodiment
Below, by specific instantiation explanation embodiments of the present invention, those skilled in the art can understand other advantages of the present invention and effect easily by the disclosed content of this specification.The present invention can also be implemented or be applied by other different embodiment, and the every details in this specification also can be based on different viewpoints and application, carries out various modifications or change not deviating under spirit of the present invention.
It should be noted that, the diagram providing in the present embodiment only illustrates basic conception of the present invention in a schematic way, satisfy and only show with assembly relevant in the present invention in graphic but not component count, shape and size drafting while implementing according to reality, during its actual enforcement, kenel, quantity and the ratio of each assembly can be a kind of random change, and its assembly layout kenel also may be more complicated.
For achieving the above object and other relevant objects, the invention provides the coding method of a kind of OAM protocol stack.As shown in Figure 1, in one embodiment, the coding method of described OAM protocol stack comprises:
Step S1, arranges object definition module.Particularly, described object definition template comprises: the definition to the parameter of the global property of object and object; The global property of described object comprises: the title of object (objectName), object B ranch value (Branch) and object Leaf value (Leaf); The parameter attribute of described object comprises: the data type (dataType) of the title of parameter (varlname), parameter and the length (len) that parameter takies in internal memory.In one embodiment, the global property of described object also comprises: message id (setMsgId) is set, message structure body (setStruct) is set, mark (setspechandler) is manually set, value message id (getMsgId), value message structure body (getStruct), manually value mark (getspechandler) and object process ID (APPL_ID).
In one embodiment, described object definition template specific as follows shown in:
Wherein:
Step S2, defines OAM object correlation attribute value according to described object definition template to OAM object.Particularly, the OAM object of listing according to IEEE802.3 codes and standards, defines described OAM object correlation attribute value in accordance with described object definition template.Particularly, described parameter attribute SET_OBJECT_VARIALBE depends on protocol specification standard to the definition of parameter, can comprise the situation of 1 parameter or a plurality of parameters.Under special circumstances, can be also sky, there is no the situation of parameter.In one embodiment, as OAM protocol operation object aFECmode, it in codes and standards by Branch value and the unique identity of determining it of Leaf value; And having a parameter attribute fecmode, data type is unsigned int.So, shown in described OAM protocol operation object aFECmode object association attributes being defined as follows in accordance with described object definition template:
It should be noted that and according to the system of OAM protocol stack practical application, determine as MSG_ID_EPON_PORT_SET_fecMode (message id is set), do not belong to the content of protocol specification standard.When OAM object properties exist correspondingly when message id is set in the system of our practical application, mean and have system operation-interface, now, we need to use this that message id is set.Otherwise if there is not the corresponding message id that arranges in system, we only need to retain " setMsgId " keyword in template.The processing of other correlation attribute value is also similar, if described property value has corresponding correlation in system, gets its value; Otherwise, retain the keyword in template.In one embodiment, described parameter attribute can be sky, now represents that this OAM object does not exist parametric variable.
Step S3, generates the relevant code of OAM protocol stack according to the described OAM object correlation attribute value of definition.In one embodiment, the relevant code of described OAM protocol stack comprises: the public function source code of protocol stack; The public function source code of described protocol stack comprises the structure of protocol stack object; The generation of described structure code is to generate a structure example according to OAM object definition described in each.In one embodiment, the relevant code of described OAM protocol stack comprises: the public function source code of protocol stack; The public function source code of described protocol stack comprises the structure array statement of protocol stack object and gets number of objects function; The generation of described structure array statement code is to generate a structure example according to OAM object definition described in each, and all described structure examples form the statement of structure array; The described number of objects function of getting returns to the object number in described structure array.In one embodiment, realize the code generation script of the method by the defined described OAM object correlation attribute value of read step 2, and process.OAM object described in each is processed, and described processing comprises: while reading " OBJECT_START ", complete the initialization of some overall script variable.While reading " SET_OBJECT ", by read its after relevant global variable property value remain in corresponding global variable.While reading " SET_OBJECT_VARIABLE ", by read its after relevant parameter variable's attribute value remain in corresponding global variable.While reading " OBJECT_END ", illustrate that a complete object definition is finished, the required global variable assignment of generating code completes.In this way or similarly mode can generate a structure example by OAM object definition described in each simultaneously.In one embodiment, code generation script generates a structure example according to the object oriented of described OAM object, described object B ranch value, object Leaf value; Described structure example comprise corresponding object Branch, Leaf, function and value function are set.The generation that the described OAM object correlation attribute value of each definition is corresponding a structure example, these all structure examples have formed structure volume data.The described number of objects function of getting returns to the structure object number in described structure array, and this can simply add up and generate the realization of structure example number, also can be by the length of described structure array is obtained divided by single structure body length.In one embodiment, described code generation script is realized by TCL script.
In one embodiment, the relevant code of described OAM protocol stack also comprises: protocol stack object function code is set.Particularly, the generation that function code is set can be when reading " OBJECT_END ", when the required global variable assignment of generating code has completed, carried out.The described parameter that function input is set comprises reply message internal memory pointer, replys the displacement of message internal memory, message valid data field pointer and object instance number is set; Wherein, described object instance number is for determining described OAM object.In one embodiment, generate one function code is set for each OAM object, all setting can be kept at after function code generates that object is privately owned to be arranged in function interface source file.
The global property of described OAM object also comprises: message id is set, message structure body is set, mark and object process ID are manually set.Generate protocol stack object function code is set time, code generation script first judge described OAM object manually arrange sign be whether preset sign (preset sign is manually set can be defaulted as this attribute keyword setspechandler) is manually set.If the manual setting of described OAM object is designated the default sign that manually arranges, illustrate that the function that arranges of this OAM object needs artificial treatment, now, the function that arranges of the described OAM object of generation is do-nothing function.When described OAM object, sign is manually set for default when sign is manually set, the described function code that arranges generating comprises: first judge that described whether message id is set effective, if effectively, according to described, the respective attributes value that message valid data field pointer obtains described OAM object is set, and the respective attributes value of described OAM object is filled up to arranging in message structure body of described OAM object.When described property value is while being a plurality of, by described successively, the respective attributes value (obtaining described property value according to object properties order and the described valid data field that message is set of length circulation parsing in message corresponding to attribute) that message valid data field pointer obtains described OAM object is set, and the respective attributes value of described OAM object is filled up to arranging in message structure body of described OAM object.Message id being set, message structure body and object process ID are set generate and message is set sends to target process according to described OAM object; According to arranging of described target process, reply definite setting of message and reply code; The Branch value of described OAM object, Leaf value and the described reply code that arranges are filled up to the definite relevant position of described reply message internal memory pointer.If described, message id is set invalid, does not carry out the operation of getattr, directly the Branch value of described OAM object, Leaf value and invalid return code are filled up to the definite relevant position of described reply message internal memory pointer.The described function that arranges can also comprise transmission described reply message (being generally OAM message).When the described message id that arranges is when invalid, reply the OAM message with invalid return code; When the described message id that arranges is when effective, correctly reply OAM message.In one embodiment, described code generation script is realized by TCL script.
In one embodiment, the relevant code of described OAM protocol stack also comprises: the value function code of protocol stack object.Particularly, the generation of value function code can be when reading " OBJECT_END ", when the required global variable assignment of generating code has completed, carried out.The parameter of described value function input comprises replys message internal memory pointer, the displacement of reply message internal memory, value message valid data field pointer and object instance number.Wherein, described object instance number is for determining described OAM object.In one embodiment, for each OAM object, generate a value function code, all value function code can be kept in the privately owned value function interface of object source file after generating.
The global property of described OAM object also comprises: value message id, value message structure body, manual value mark and object process ID.When generating the value function code of protocol stack object, first code generation script judges whether the manual value sign of described OAM object is the manual value sign (default manual value sign can be defaulted as this attribute keyword getspechandler) of presetting.If the manual value of described OAM object is designated default manual value sign, illustrate that the value function of this OAM object needs artificial treatment, now, the value function of the described OAM object of generation is do-nothing function.When the manual value of described OAM object is designated default manual value sign, the described value function code generating comprises: judge that whether described value message id is effective, if effectively, generate value message according to the value message id of described OAM object, value message structure body and object process ID, send to target process; According to the value of described target process, reply the respective attributes value that message is obtained described OAM object, and the respective attributes value of described OAM object B ranch value, Leaf value and the described OAM object that obtains is filled into the definite relevant position of described reply message internal memory pointer.If described value message id is invalid, do not carry out the operation of getattr, directly the Branch value of described OAM object, Leaf value and invalid return code are filled up to the definite relevant position of described reply message internal memory pointer.Described value function can also comprise transmission described reply message (being generally OAM message).When described value message is replied the OAM message with invalid return code; When described value message id is effective, correct OAM message of replying with content of parameter.In one embodiment, described code generation script is realized by TCL script.
In one embodiment, as shown in Figure 2, the coding method of described OAM protocol stack comprises that generation arranges function code.First, in object definition script according to the OAM object in default object definition template definition agreement.Then, object definition script is imported to function and realize script (being code generation script).In function, realize in script, first according to the sign that manually arranges of described OAM object, judge whether to need manual handle, if answer is YES, need manual handle that function code is set.If answer is No, now, first by message id judgement is set, whether effectively message (whether by judgement, message id is set effectively judges) is set, if answer is YES, to being set, message packet resolves, obtain the respective attributes value of described OAM object, and be filled up to the arranging in message structure body of described OAM object, according to message id is set, message structure body and object process ID are set generate and message is set sends to target process of described OAM object, according to arranging of described target process, reply message and determine to arrange and reply code.According to reply code is set, fills in correct OAM message and reply.If answer is No, reply invalid OAM message.
In one embodiment, as shown in Figure 3, the coding method of described OAM protocol stack comprises generation value function code.First, in object definition script according to the OAM object in default object definition template definition agreement.Then, object definition script is imported to function and realize script (being code generation script).In function, realize in script, first according to the manual value sign of described OAM object, judge whether to need manual handle, if answer is YES, need manual handle value function code, need artificial treatment.If answer is No, now, first by the judgement of value message id, whether effectively message (by judging whether value message id effectively comes to determine) is set, if answer is YES, according to the value message id of described OAM object, value message structure body and object process ID, generates value message and send to target process.According to the value of described target process, reply the respective attributes value that message is obtained described OAM object, and the respective attributes value of described OAM object B ranch value, Leaf value and the described OAM object that obtains is filled on correct OAM message, and reply described correct OAM message.If answer is No, reply invalid OAM message.
The present invention also provides a kind of OAM protocol stack coded system.Described OAM protocol stack coded system can be applied the coding method of foregoing OAM protocol stack.As shown in Figure 4, in one embodiment, described OAM protocol stack coded system 1 comprises: template definition module 11, object definition module 12 and code generation module 13.Wherein:
Template definition module 11, for arranging object definition module.Described object definition template in described template definition module comprises: the definition to the parameter of the global property of object and object; The global property of described object comprises: the title of object, object B ranch value and object Leaf value; The parameter attribute of described object comprises: the length that the title of parameter, the data type of parameter and parameter take in internal memory.
Object definition module 12, is connected with described template definition module 11, for OAM object being defined to OAM object correlation attribute value according to described object definition template.
Code generation module 13, is connected with described object definition module 12, for the described OAM object correlation attribute value according to definition, generates the relevant code of OAM protocol stack.In one embodiment, the relevant code of described OAM protocol stack in described code generation module 13 comprises: the public function source code of protocol stack; The public function source code of described protocol stack comprises the structure of protocol stack object; The generation of described structure code is to generate a structure example according to OAM object definition described in each.In one embodiment, described structure example comprise corresponding object Branch, Leaf, function and value function are set.
In one embodiment, the relevant code of described OAM protocol stack in described code generation module 13 comprises: the public function source code of protocol stack; The public function source code of described protocol stack comprises the structure array statement of protocol stack object and gets object function; The generation of described structure array statement code is to generate a structure example according to OAM object definition described in each, and all described structure examples form the statement of structure array; The described object function of getting returns to the object number in described structure array.In one embodiment, described structure example comprise corresponding object Branch, Leaf, function and value function are set.
In one embodiment, the relevant code of described OAM protocol stack in described code generation module 13 comprises: protocol stack object function code is set; The described parameter that function input is set comprises reply message internal memory pointer, message valid data field pointer and object instance number is set; Described object instance number is for determining described OAM object; The global property of described OAM object also comprises: message id is set, message structure body is set, mark and object process ID are manually set.When the manual setting of described OAM object is designated the default sign that manually arranges, illustrate that the function that arranges of this OAM object needs artificial treatment, now, the value function of the described OAM object of generation is do-nothing function.When described OAM object, sign is manually set for default when sign is manually set, the described function code that arranges generating comprises: judge that described whether message id is set effective, if effectively, according to described, the respective attributes value that message valid data field pointer obtains described OAM object is set, and the respective attributes value of described OAM object is filled up to arranging in message structure body of described OAM object; Message id being set, message structure body and object process ID are set generate and message is set sends to target process according to described OAM object; According to arranging of described target process, reply definite setting of message and reply code; The Branch value of described OAM object, Leaf value and the described reply code that arranges are filled up to the definite relevant position of described reply message internal memory pointer.The described function that arranges can also comprise transmission described reply message (being generally OAM message).When the described message id that arranges is when invalid, reply the OAM message with invalid return code; When the described message id that arranges is when effective, correctly reply OAM message.
In one embodiment, the relevant code of described OAM protocol stack in described code generation module 13 comprises: the value function code of protocol stack object; The parameter of described value function input comprises replys message internal memory pointer, value message valid data field pointer and object instance number.Described object instance number is for determining described OAM object; The global property of described OAM object also comprises: value message id, value message structure body, manual value mark and object process ID.When the manual value of described OAM object is designated default manual value sign, illustrate that the value function of this OAM object needs artificial treatment, now, the value function of the described OAM object of generation is do-nothing function.When the manual value sign of described OAM object does not identify for default manual value, the described value function code generating comprises: judge that whether described value message id is effective, if effectively, generate value message according to the value message id of described OAM object, value message structure body and object process ID, send to target process; According to the value of described target process, reply the respective attributes value that message is obtained described OAM object, and the respective attributes value of described OAM object B ranch value, Leaf value and the described OAM object that obtains is filled into the definite relevant position of described reply message internal memory pointer.Described value function can also comprise transmission described reply message (being generally OAM message).When described value message is replied the OAM message with invalid return code; When described value message id is effective, correct OAM message of replying with content of parameter.
In sum, the present invention's a kind of OAM protocol stack coding method and system, there is following beneficial effect: can automatically realize the automatic generation of part OAM protocol stack correlative code, the efficiency of writing of code is not only provided greatly, shortened the project development cycle, and accuracy, the clarity of the code automatically generating also obtained enhancing, for secondary development and the maintenance in later stage provides a great convenience.So the present invention has effectively overcome various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all can, under spirit of the present invention and category, modify or change above-described embodiment.Therefore, such as in affiliated technical field, have and conventionally know that the knowledgeable, not departing from all equivalence modifications that complete under disclosed spirit and technological thought or changing, must be contained by claim of the present invention.