git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@1164 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2006-09-09 11:26:09 +00:00
parent 9e0ea0a7ea
commit 3ceb3261b3
6 changed files with 4065 additions and 7 deletions

View File

@ -1,7 +1,8 @@
This directory contains a few examples.
1. The ./sample.source.PKIX1 directory contains the X.509 Certificate decoder.
1. The ./sample.source.PKIX1 directory contains the X.509 Certificate decoder,
as specified in rfc3280.txt.
2. The ./sample.source.TAP3 directory contains the GSM TAP3 decoder.
Before trying to compile, read the README file in that directory.
@ -13,11 +14,16 @@ This directory contains a few examples.
3. The ./sample.source.MEGACO directory contains the decoder for
Media Gateway Control Protocol data units as specified in rfc3525.txt.
The crfc2asn1.pl script can be used to extract ASN.1 data from RFC texts.
For instance, it is used to extract X.509 ASN.1 modules from PKIX1 RFC
and MEGACO ASN.1 module from rfc3525.txt.
4. The ./sample.source.LDAP3 directory contains the decoder for
Lightweight Directory Access Protocol version 3 PDU as specified in
rfc4211.txt.
To regenerate the .asn1 files from the original RFC texts, do `rm *.asn1; make`.
The crfc2asn1.pl script can be used to extract ASN.1 data from RFC texts.
For instance, it is used to extract X.509, MEGACO, and LDAPv3 ASN.1 modules
from the corresponding RFC texts (rfc3280.txt, rfc3525.txt, rfc4211.txt).
To regenerate the .asn1 files from the original RFC texts, execute
`make clean; make` in the current directory.
The clyx2asn1.pl script can be used to extract ASN.1 data from LyX editor files.

View File

@ -31,7 +31,7 @@ while(<>) {
if($inasn == 0) {
#
# The least correct way to find the start of ASN
# definition.
# definition. That is, to ask a user.
#
if(/^[ \t]*END[ \t]*(--.*)?$/) {
print STDERR
@ -68,8 +68,19 @@ while(<>) {
}
}
next unless $inasn;
} elsif(/^\s*DEFINITIONS\s*$/
&& $prevLine =~ /^\s*([A-Z][A-Za-z0-9-]*)\s*{[0-9a-z)( -]+}\s*$/) {
$_ = $prevLine . $prevComments . $_;
$modName = $1;
$currentFname = $rfcid . $modName. ".asn1";
$inasn = 1;
} else {
$prevLine = $_;
if(/^[ \t]*--/) {
$prevComments .= $_;
} else {
$prevComments = '';
$prevLine = $_;
}
next;
}

3811
examples/rfc4511.txt Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,200 @@
ASN_MODULE_SOURCES= \
LDAPMessage.c \
MessageID.c \
LDAPString.c \
LDAPOID.c \
LDAPDN.c \
RelativeLDAPDN.c \
AttributeDescription.c \
AttributeValue.c \
AttributeValueAssertion.c \
AssertionValue.c \
PartialAttribute.c \
Attribute.c \
MatchingRuleId.c \
LDAPResult.c \
Referral.c \
URI.c \
Controls.c \
Control.c \
BindRequest.c \
AuthenticationChoice.c \
SaslCredentials.c \
BindResponse.c \
UnbindRequest.c \
SearchRequest.c \
AttributeSelection.c \
Filter.c \
SubstringFilter.c \
MatchingRuleAssertion.c \
SearchResultEntry.c \
PartialAttributeList.c \
SearchResultReference.c \
SearchResultDone.c \
ModifyRequest.c \
ModifyResponse.c \
AddRequest.c \
AttributeList.c \
AddResponse.c \
DelRequest.c \
DelResponse.c \
ModifyDNRequest.c \
ModifyDNResponse.c \
CompareRequest.c \
CompareResponse.c \
AbandonRequest.c \
ExtendedRequest.c \
ExtendedResponse.c \
IntermediateResponse.c
ASN_MODULE_HEADERS= \
LDAPMessage.h \
MessageID.h \
LDAPString.h \
LDAPOID.h \
LDAPDN.h \
RelativeLDAPDN.h \
AttributeDescription.h \
AttributeValue.h \
AttributeValueAssertion.h \
AssertionValue.h \
PartialAttribute.h \
Attribute.h \
MatchingRuleId.h \
LDAPResult.h \
Referral.h \
URI.h \
Controls.h \
Control.h \
BindRequest.h \
AuthenticationChoice.h \
SaslCredentials.h \
BindResponse.h \
UnbindRequest.h \
SearchRequest.h \
AttributeSelection.h \
Filter.h \
SubstringFilter.h \
MatchingRuleAssertion.h \
SearchResultEntry.h \
PartialAttributeList.h \
SearchResultReference.h \
SearchResultDone.h \
ModifyRequest.h \
ModifyResponse.h \
AddRequest.h \
AttributeList.h \
AddResponse.h \
DelRequest.h \
DelResponse.h \
ModifyDNRequest.h \
ModifyDNResponse.h \
CompareRequest.h \
CompareResponse.h \
AbandonRequest.h \
ExtendedRequest.h \
ExtendedResponse.h \
IntermediateResponse.h
ASN_MODULE_HEADERS+=BOOLEAN.h
ASN_MODULE_SOURCES+=BOOLEAN.c
ASN_MODULE_HEADERS+=ENUMERATED.h
ASN_MODULE_SOURCES+=ENUMERATED.c
ASN_MODULE_HEADERS+=INTEGER.h
ASN_MODULE_HEADERS+=NativeEnumerated.h
ASN_MODULE_SOURCES+=INTEGER.c
ASN_MODULE_HEADERS+=NULL.h
ASN_MODULE_SOURCES+=NULL.c
ASN_MODULE_SOURCES+=NativeEnumerated.c
ASN_MODULE_HEADERS+=NativeInteger.h
ASN_MODULE_SOURCES+=NativeInteger.c
ASN_MODULE_HEADERS+=asn_SEQUENCE_OF.h
ASN_MODULE_SOURCES+=asn_SEQUENCE_OF.c
ASN_MODULE_HEADERS+=asn_SET_OF.h
ASN_MODULE_SOURCES+=asn_SET_OF.c
ASN_MODULE_HEADERS+=constr_CHOICE.h
ASN_MODULE_SOURCES+=constr_CHOICE.c
ASN_MODULE_HEADERS+=constr_SEQUENCE.h
ASN_MODULE_SOURCES+=constr_SEQUENCE.c
ASN_MODULE_HEADERS+=constr_SEQUENCE_OF.h
ASN_MODULE_SOURCES+=constr_SEQUENCE_OF.c
ASN_MODULE_HEADERS+=constr_SET_OF.h
ASN_MODULE_SOURCES+=constr_SET_OF.c
ASN_MODULE_HEADERS+=asn_application.h
ASN_MODULE_HEADERS+=asn_system.h
ASN_MODULE_HEADERS+=asn_codecs.h
ASN_MODULE_HEADERS+=asn_internal.h
ASN_MODULE_HEADERS+=OCTET_STRING.h
ASN_MODULE_SOURCES+=OCTET_STRING.c
ASN_MODULE_HEADERS+=BIT_STRING.h
ASN_MODULE_SOURCES+=BIT_STRING.c
ASN_MODULE_SOURCES+=asn_codecs_prim.c
ASN_MODULE_HEADERS+=asn_codecs_prim.h
ASN_MODULE_HEADERS+=ber_tlv_length.h
ASN_MODULE_SOURCES+=ber_tlv_length.c
ASN_MODULE_HEADERS+=ber_tlv_tag.h
ASN_MODULE_SOURCES+=ber_tlv_tag.c
ASN_MODULE_HEADERS+=ber_decoder.h
ASN_MODULE_SOURCES+=ber_decoder.c
ASN_MODULE_HEADERS+=der_encoder.h
ASN_MODULE_SOURCES+=der_encoder.c
ASN_MODULE_HEADERS+=constr_TYPE.h
ASN_MODULE_SOURCES+=constr_TYPE.c
ASN_MODULE_HEADERS+=constraints.h
ASN_MODULE_SOURCES+=constraints.c
ASN_MODULE_HEADERS+=xer_support.h
ASN_MODULE_SOURCES+=xer_support.c
ASN_MODULE_HEADERS+=xer_decoder.h
ASN_MODULE_SOURCES+=xer_decoder.c
ASN_MODULE_HEADERS+=xer_encoder.h
ASN_MODULE_SOURCES+=xer_encoder.c
ASN_MODULE_HEADERS+=per_support.h
ASN_MODULE_SOURCES+=per_support.c
ASN_MODULE_HEADERS+=per_decoder.h
ASN_MODULE_SOURCES+=per_decoder.c
ASN_MODULE_HEADERS+=per_encoder.h
ASN_MODULE_SOURCES+=per_encoder.c
lib_LTLIBRARIES=libsomething.la
libsomething_la_SOURCES=$(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
# This file may be used as an input for make(3)
# Remove the lines below to convert it into a pure .am file
TARGET = ldap3dump
CFLAGS += -I. -DHAVE_CONFIG_H
OBJS=${ASN_MODULE_SOURCES:.c=.o} $(TARGET).o
all: LDAPMessage.c $(TARGET)
$(TARGET): ${OBJS}
$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)
.SUFFIXES:
.SUFFIXES: .c .o
.c.o:
$(CC) $(CFLAGS) -o $@ -c $<
clean:
rm -f $(TARGET)
rm -f $(OBJS)
regen: regenerate-from-asn1-source
regenerate-from-asn1-source:
../../asn1c/asn1c -fcompound-names -S ../../skeletons ../rfc4511-Lightweight-Directory-Access-Protocol-V3.asn1
LDAPMessage.c: regenerate.Makefile
./regenerate.Makefile
@touch LDAPMessage.c
make
ASN_CONVERTER=../../skeletons/converter-sample.c
$(TARGET).o: $(ASN_CONVERTER)
$(CC) $(CFLAGS) -DPDU=LDAPMessage -o $(TARGET).o -c $(ASN_CONVERTER)
distclean: clean
rm -f $(ASN_MODULE_SOURCES) $(ASN_MODULE_HEADERS)
rm -f Makefile.am.sample

View File

@ -0,0 +1,20 @@
GENERAL INFORMATION
===================
The LDAPv3 (Lightweight Directory Access Protocol) PDU decoder.
Invoking `make` will compile the ASN.1 specifications from the rfc4211.txt
in the above directory.
The ../../skeletons/converter-sample.c will supply the missing
"int main()" routine which drives the decoding process.
ldap3dump USAGE
==============
./ldap3dump LDAPMessage.ber # Print as XML (BASIC-XER)
The full list of recognized command line options may be obtained with
> ./ldap3dump -h

View File

@ -0,0 +1,10 @@
extern int opt_debug;
#define ASN_DEBUG(fmt, args...) do { \
if(opt_debug < 2) break; \
fprintf(stderr, fmt, ##args); \
fprintf(stderr, " (%s:%d)\n", \
__FILE__, __LINE__); \
} while(0)