Lines 146-159
Link Here
|
146 |
#define NBENCODE(c) (htole16((u_short)(((u_char)(c) >> 4) | \ |
146 |
#define NBENCODE(c) (htole16((u_short)(((u_char)(c) >> 4) | \ |
147 |
(((u_char)(c) & 0xf) << 8)) + 0x4141)) |
147 |
(((u_char)(c) & 0xf) << 8)) + 0x4141)) |
148 |
|
148 |
|
|
|
149 |
#ifdef __arm__ |
149 |
static void |
150 |
static void |
150 |
memsetw(char *dst, int n, u_short word) |
151 |
memsetw(char *dst, int n, u_short word) |
151 |
{ |
152 |
{ |
152 |
while (n--) { |
153 |
while (n--) { |
|
|
154 |
((u_char*)dst)[0] = word & 0xff; |
155 |
((u_char*)dst)[1] = word >> 8; |
156 |
dst += 2; |
157 |
} |
158 |
} |
159 |
#else |
160 |
static void |
161 |
memsetw(char *dst, int n, u_short word) |
162 |
{ |
163 |
while (n--) { |
153 |
*(u_short*)dst = word; |
164 |
*(u_short*)dst = word; |
154 |
dst += 2; |
165 |
dst += 2; |
155 |
} |
166 |
} |
156 |
} |
167 |
} |
|
|
168 |
#endif |
157 |
|
169 |
|
158 |
int |
170 |
int |
159 |
nb_name_encode(struct nb_name *np, u_char *dst) |
171 |
nb_name_encode(struct nb_name *np, u_char *dst) |
Lines 165-182
Link Here
|
165 |
*cp++ = NB_ENCNAMELEN; |
177 |
*cp++ = NB_ENCNAMELEN; |
166 |
name = np->nn_name; |
178 |
name = np->nn_name; |
167 |
if (name[0] == '*' && name[1] == 0) { |
179 |
if (name[0] == '*' && name[1] == 0) { |
|
|
180 |
#ifdef __arm__ |
181 |
memsetw(cp, 1, NBENCODE('*')); |
182 |
#else |
168 |
*(u_short*)cp = NBENCODE('*'); |
183 |
*(u_short*)cp = NBENCODE('*'); |
|
|
184 |
#endif |
169 |
memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' ')); |
185 |
memsetw(cp + 2, NB_NAMELEN - 1, NBENCODE(' ')); |
170 |
cp += NB_ENCNAMELEN; |
186 |
cp += NB_ENCNAMELEN; |
171 |
} else { |
187 |
} else { |
172 |
for (i = 0; *name && i < NB_NAMELEN - 1; i++, cp += 2, name++) |
188 |
for (i = 0; *name && i < NB_NAMELEN - 1; i++, cp += 2, name++) |
|
|
189 |
#ifdef __arm__ |
190 |
memsetw(cp, 1, NBENCODE(toupper(*name))); |
191 |
#else |
173 |
*(u_short*)cp = NBENCODE(toupper(*name)); |
192 |
*(u_short*)cp = NBENCODE(toupper(*name)); |
|
|
193 |
#endif |
174 |
i = NB_NAMELEN - i - 1; |
194 |
i = NB_NAMELEN - i - 1; |
175 |
if (i > 0) { |
195 |
if (i > 0) { |
176 |
memsetw(cp, i, NBENCODE(' ')); |
196 |
memsetw(cp, i, NBENCODE(' ')); |
177 |
cp += i * 2; |
197 |
cp += i * 2; |
178 |
} |
198 |
} |
|
|
199 |
#ifdef __arm__ |
200 |
memsetw(cp, 1, NBENCODE(np->nn_type)); |
201 |
#else |
179 |
*(u_short*)cp = NBENCODE(np->nn_type); |
202 |
*(u_short*)cp = NBENCODE(np->nn_type); |
|
|
203 |
#endif |
180 |
cp += 2; |
204 |
cp += 2; |
181 |
} |
205 |
} |
182 |
*cp = 0; |
206 |
*cp = 0; |